32require_once DOL_DOCUMENT_ROOT.
"/core/class/commonobject.class.php";
33require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/ticket.lib.php';
50 public $element =
'ticket';
55 public $table_element =
'ticket';
60 public $fk_element =
'fk_ticket';
65 public $picto =
'ticket';
96 public $fk_user_create;
101 public $fk_user_assign;
153 public $category_code;
158 public $severity_code;
203 public $date_last_msg_sent;
213 public $cache_types_tickets;
218 public $cache_category_tickets;
223 public $cache_msgs_ticket;
228 public $notify_tiers_at_create;
259 public $regeximgext =
'\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm';
265 const STATUS_READ = 1;
266 const STATUS_ASSIGNED = 2;
267 const STATUS_IN_PROGRESS = 3;
268 const STATUS_NEED_MORE_INFO = 5;
269 const STATUS_WAITING = 7;
270 const STATUS_CLOSED = 8;
271 const STATUS_CANCELED = 9;
302 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'visible' => -2,
'enabled' => 1,
'position' => 1,
'notnull' => 1,
'index' => 1,
'comment' =>
"Id"),
303 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'visible' => 0,
'enabled' => 1,
'position' => 5,
'notnull' => 1,
'index' => 1),
304 'ref' => array(
'type' =>
'varchar(128)',
'label' =>
'Ref',
'visible' => 1,
'enabled' => 1,
'position' => 10,
'notnull' => 1,
'index' => 1,
'searchall' => 1,
'comment' =>
"Reference of object",
'css' =>
'',
'showoncombobox' => 1),
305 'track_id' => array(
'type' =>
'varchar(255)',
'label' =>
'TicketTrackId',
'visible' => -2,
'enabled' => 1,
'position' => 11,
'notnull' => -1,
'searchall' => 1,
'help' =>
"Help text"),
306 'fk_user_create' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Author',
'visible' => 1,
'enabled' => 1,
'position' => 15,
'notnull' => 1,
'csslist' =>
'tdoverflowmax100 maxwidth150onsmartphone'),
307 'origin_email' => array(
'type' =>
'mail',
'label' =>
'OriginEmail',
'visible' => -2,
'enabled' => 1,
'position' => 16,
'notnull' => 1,
'index' => 1,
'searchall' => 1,
'comment' =>
"Reference of object",
'csslist' =>
'tdoverflowmax150'),
308 'origin_replyto' => array(
'type' =>
'mail',
'label' =>
'EmailReplyto',
'visible' => -2,
'enabled' => 1,
'position' => 17,
'notnull' => 1,
'index' => 1,
'searchall' => 1,
'comment' =>
"Email to reply to",
'csslist' =>
'tdoverflowmax150'),
309 'origin_references' => array(
'type' =>
'text',
'label' =>
'EmailReferences',
'visible' => -2,
'enabled' => 1,
'position' => 18,
'notnull' => 1,
'index' => 1,
'searchall' => 1,
'comment' =>
"References from origin email",
'csslist' =>
'tdoverflowmax150'),
310 'subject' => array(
'type' =>
'varchar(255)',
'label' =>
'Subject',
'visible' => 1,
'enabled' => 1,
'position' => 19,
'notnull' => -1,
'searchall' => 1,
'help' =>
"",
'css' =>
'maxwidth200 tdoverflowmax200',
'csslist'=>
'tdoverflowmax250',
'autofocusoncreate' => 1),
311 'type_code' => array(
'type' =>
'varchar(32)',
'label' =>
'Type',
'visible' => 1,
'enabled' => 1,
'position' => 20,
'notnull' => -1,
'help' =>
"",
'csslist' =>
'tdoverflowmax100'),
312 'category_code' => array(
'type' =>
'varchar(32)',
'label' =>
'TicketCategory',
'visible' => -1,
'enabled' => 1,
'position' => 21,
'notnull' => -1,
'help' =>
"",
'css' =>
'maxwidth100 tdoverflowmax200'),
313 'severity_code' => array(
'type' =>
'varchar(32)',
'label' =>
'Severity',
'visible' => 1,
'enabled' => 1,
'position' => 22,
'notnull' => -1,
'help' =>
"",
'css' =>
'maxwidth100'),
314 'fk_soc' => array(
'type' =>
'integer:Societe:societe/class/societe.class.php',
'label' =>
'ThirdParty',
'visible' => 1,
'enabled' =>
'isModEnabled("societe")',
'position' => 50,
'notnull' => -1,
'index' => 1,
'searchall' => 1,
'help' =>
"OrganizationEventLinkToThirdParty",
'css' =>
'tdoverflowmax150 maxwidth150onsmartphone'),
315 'notify_tiers_at_create' => array(
'type' =>
'integer',
'label' =>
'NotifyThirdparty',
'visible' => -1,
'enabled' => 0,
'position' => 51,
'notnull' => 1,
'index' => 1),
316 'fk_project' => array(
'type' =>
'integer:Project:projet/class/project.class.php',
'label' =>
'Project',
'visible' => -1,
'enabled' =>
'$conf->project->enabled',
'position' => 52,
'notnull' => -1,
'index' => 1,
'help' =>
"LinkToProject"),
317 'fk_contract' => array(
'type' =>
'integer:Contrat:contrat/class/contrat.class.php',
'label' =>
'Contract',
'visible' => -1,
'enabled' =>
'$conf->contract->enabled',
'position' => 53,
'notnull' => -1,
'index' => 1,
'help' =>
"LinkToContract"),
319 'datec' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'visible' => 1,
'enabled' => 1,
'position' => 500,
'notnull' => 1,
'csslist' =>
'nowraponall'),
320 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'visible' => -1,
'enabled' => 1,
'position' => 501,
'notnull' => 1),
321 'date_read' => array(
'type' =>
'datetime',
'label' =>
'DateReading',
'visible' => -1,
'enabled' => 1,
'position' => 505,
'notnull' => 1,
'csslist' =>
'nowraponall'),
322 'date_last_msg_sent' => array(
'type' =>
'datetime',
'label' =>
'TicketLastMessageDate',
'visible' => 0,
'enabled' => 1,
'position' => 506,
'notnull' => -1),
323 'fk_user_assign' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'AssignedTo',
'visible' => 1,
'enabled' => 1,
'position' => 507,
'notnull' => 1,
'csslist' =>
'tdoverflowmax100 maxwidth150onsmartphone'),
324 'date_close' => array(
'type' =>
'datetime',
'label' =>
'TicketCloseOn',
'visible' => -1,
'enabled' => 1,
'position' => 510,
'notnull' => 1),
325 'message' => array(
'type' =>
'html',
'label' =>
'Message',
'visible' => -2,
'enabled' => 1,
'position' => 540,
'notnull' => -1,),
326 'email_msgid' => array(
'type' =>
'varchar(255)',
'label' =>
'EmailMsgID',
'visible' => -2,
'enabled' => 1,
'position' => 540,
'notnull' => -1,
'help' =>
'EmailMsgIDDesc',
'csslist' =>
'tdoverflowmax100'),
327 'email_date' => array(
'type' =>
'datetime',
'label' =>
'EmailDate',
'visible' => -2,
'enabled' => 1,
'position' => 541),
328 'progress' => array(
'type' =>
'integer',
'label' =>
'Progression',
'visible' => -1,
'enabled' => 1,
'position' => 540,
'notnull' => -1,
'css' =>
'right',
'help' =>
"",
'isameasure' => 2,
'csslist' =>
'width50'),
329 'resolution' => array(
'type' =>
'integer',
'label' =>
'Resolution',
'visible' => -1,
'enabled' =>
'getDolGlobalString("TICKET_ENABLE_RESOLUTION")',
'position' => 550,
'notnull' => 1),
330 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'PDFTemplate',
'enabled' => 1,
'visible' => 0,
'position' => 560),
331 'extraparams' => array(
'type' =>
'varchar(255)',
'label' =>
'Extraparams',
'enabled' => 1,
'visible' => -1,
'position' => 570),
332 'fk_statut' => array(
'type' =>
'integer',
'label' =>
'Status',
'visible' => 1,
'enabled' => 1,
'position' => 600,
'notnull' => 1,
'index' => 1,
'arrayofkeyval' => array(0 =>
'Unread', 1 =>
'Read', 2 =>
'Assigned', 3 =>
'InProgress', 5 =>
'NeedMoreInformation', 7 =>
'OnHold', 8 =>
'SolvedClosed', 9 =>
'Deleted')),
333 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 900),
347 $this->ismultientitymanaged = 1;
348 $this->isextrafieldmanaged = 1;
350 $this->labelStatusShort = array(
351 self::STATUS_NOT_READ =>
'Unread',
352 self::STATUS_READ =>
'Read',
353 self::STATUS_ASSIGNED =>
'Assigned',
354 self::STATUS_IN_PROGRESS =>
'InProgress',
355 self::STATUS_NEED_MORE_INFO =>
'NeedMoreInformationShort',
356 self::STATUS_WAITING =>
'OnHold',
357 self::STATUS_CLOSED =>
'SolvedClosed',
358 self::STATUS_CANCELED =>
'Canceled'
360 $this->labelStatus = array(
361 self::STATUS_NOT_READ =>
'Unread',
362 self::STATUS_READ =>
'Read',
363 self::STATUS_ASSIGNED =>
'Assigned',
364 self::STATUS_IN_PROGRESS =>
'InProgress',
365 self::STATUS_NEED_MORE_INFO =>
'NeedMoreInformation',
366 self::STATUS_WAITING =>
'OnHold',
367 self::STATUS_CLOSED =>
'SolvedClosed',
368 self::STATUS_CANCELED =>
'Canceled'
372 unset($this->fields[
'fk_statut'][
'arrayofkeyval'][self::STATUS_WAITING]);
373 unset($this->labelStatusShort[self::STATUS_WAITING]);
374 unset($this->labelStatus[self::STATUS_WAITING]);
386 $this->errors = array();
391 if (isset($this->
ref)) {
392 $this->
ref = trim($this->
ref);
395 if (isset($this->track_id)) {
396 $this->track_id = trim($this->track_id);
399 if (isset($this->fk_soc)) {
400 $this->fk_soc = (int) $this->fk_soc;
403 if (isset($this->fk_project)) {
404 $this->fk_project = (int) $this->fk_project;
407 if (isset($this->origin_email)) {
408 $this->origin_email = trim($this->origin_email);
411 if (isset($this->fk_user_create)) {
412 $this->fk_user_create = (int) $this->fk_user_create;
415 if (isset($this->fk_user_assign)) {
416 $this->fk_user_assign = (int) $this->fk_user_assign;
419 if (isset($this->subject)) {
420 $this->subject = trim($this->subject);
423 if (isset($this->message)) {
424 $this->message = trim($this->message);
426 $this->errors[] =
'ErrorFieldTooLong';
427 dol_syslog(get_class($this).
'::create error -1 message too long', LOG_ERR);
432 if (isset($this->fk_statut)) {
433 $this->fk_statut = (int) $this->fk_statut;
436 if (isset($this->resolution)) {
437 $this->resolution = trim($this->resolution);
440 if (isset($this->progress)) {
441 $this->progress = (int) $this->progress;
444 if (isset($this->timing)) {
445 $this->timing = trim($this->timing);
448 if (isset($this->type_code)) {
449 $this->type_code = trim($this->type_code);
452 if (isset($this->category_code)) {
453 $this->category_code = trim($this->category_code);
456 if (isset($this->severity_code)) {
457 $this->severity_code = trim($this->severity_code);
460 if (empty($this->
ref)) {
461 $this->errors[] =
'ErrorTicketRefRequired';
462 dol_syslog(get_class($this).
"::create error -1 ref null", LOG_ERR);
479 $test =
new self($this->db);
481 if ($test->fetch(
'', $getRef) > 0) {
482 if (($action ==
'add') || ($action ==
'update' && $this->
ref != $getRef)) {
487 $this->
ref = $getRef;
498 public function create($user, $notrigger = 0)
506 if (empty($this->track_id)) {
512 $result = $this->
verify();
515 $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);
518 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"ticket(";
522 $sql .=
"fk_project,";
523 $sql .=
"fk_contract,";
524 $sql .=
"origin_email,";
525 $sql .=
"origin_replyto,";
526 $sql .=
"origin_references,";
527 $sql .=
"fk_user_create,";
528 $sql .=
"fk_user_assign,";
529 $sql .=
"email_msgid,";
530 $sql .=
"email_date,";
533 $sql .=
"fk_statut,";
534 $sql .=
"resolution,";
537 $sql .=
"type_code,";
538 $sql .=
"category_code,";
539 $sql .=
"severity_code,";
541 $sql .=
"date_read,";
542 $sql .=
"date_close,";
544 $sql .=
"notify_tiers_at_create,";
545 $sql .=
"model_pdf,";
547 $sql .=
") VALUES (";
548 $sql .=
" ".(!isset($this->
ref) ?
'' :
"'".$this->db->escape($this->
ref).
"'").
",";
549 $sql .=
" ".(!isset($this->track_id) ?
'NULL' :
"'".$this->db->escape($this->track_id).
"'").
",";
550 $sql .=
" ".($this->fk_soc > 0 ? ((int) $this->fk_soc) :
"null").
",";
551 $sql .=
" ".($this->fk_project > 0 ? ((int) $this->fk_project) :
"null").
",";
552 $sql .=
" ".($this->fk_contract > 0 ? ((int) $this->fk_contract) :
"null").
",";
553 $sql .=
" ".(!isset($this->origin_email) ?
'NULL' :
"'".$this->db->escape($this->origin_email).
"'").
",";
554 $sql .=
" ".(!isset($this->origin_replyto) ?
'NULL' :
"'".$this->db->escape($this->origin_replyto).
"'").
",";
555 $sql .=
" ".(!isset($this->origin_references) ?
'NULL' :
"'".$this->db->escape($this->origin_references).
"'").
",";
556 $sql .=
" ".(!isset($this->fk_user_create) ? ($user->id > 0 ? ((int) $user->id) :
'NULL') : ($this->fk_user_create > 0 ? ((int) $this->fk_user_create) :
'NULL')).
",";
557 $sql .=
" ".($this->fk_user_assign > 0 ? ((int) $this->fk_user_assign) :
'NULL').
",";
558 $sql .=
" ".(empty($this->email_msgid) ?
'NULL' :
"'".$this->db->escape($this->email_msgid).
"'").
",";
559 $sql .=
" ".(empty($this->email_date) ?
'NULL' :
"'".$this->db->idate($this->email_date).
"'").
",";
560 $sql .=
" ".(!isset($this->subject) ?
'NULL' :
"'".$this->db->escape($this->subject).
"'").
",";
561 $sql .=
" ".(!isset($this->message) ?
'NULL' :
"'".$this->db->escape($this->message).
"'").
",";
562 $sql .=
" ".(!isset($this->
status) ?
'0' : ((int) $this->
status)).
",";
563 $sql .=
" ".(!isset($this->resolution) ?
'NULL' : ((int) $this->resolution)).
",";
564 $sql .=
" ".(!isset($this->progress) ?
'0' : ((int) $this->progress)).
",";
565 $sql .=
" ".(!isset($this->timing) ?
'NULL' :
"'".$this->db->escape($this->timing).
"'").
",";
566 $sql .=
" ".(!isset($this->type_code) ?
'NULL' :
"'".$this->db->escape($this->type_code).
"'").
",";
567 $sql .=
" ".(empty($this->category_code) || $this->category_code ==
'-1' ?
'NULL' :
"'".$this->db->escape($this->category_code).
"'").
",";
568 $sql .=
" ".(!isset($this->severity_code) ?
'NULL' :
"'".$this->db->escape($this->severity_code).
"'").
",";
569 $sql .=
" ".(!isset($this->datec) ||
dol_strlen($this->datec) == 0 ?
'NULL' :
"'".$this->db->idate($this->datec).
"'").
",";
570 $sql .=
" ".(!isset($this->date_read) ||
dol_strlen($this->date_read) == 0 ?
'NULL' :
"'".$this->db->idate($this->date_read).
"'").
",";
571 $sql .=
" ".(!isset($this->date_close) ||
dol_strlen($this->date_close) == 0 ?
'NULL' :
"'".$this->db->idate($this->date_close).
"'");
572 $sql .=
", ".((int) $this->entity);
573 $sql .=
", ".(!isset($this->notify_tiers_at_create) ? 1 : ((int) $this->notify_tiers_at_create));
574 $sql .=
", '".$this->db->escape($this->model_pdf).
"'";
575 $sql .=
", ".(!isset($this->ip) ?
'NULL' :
"'".$this->db->escape($this->ip).
"'");
580 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
581 $resql = $this->db->query($sql);
584 $this->errors[] =
"Error ".$this->db->lasterror();
588 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"ticket");
591 if (!$error &&
getDolGlobalString(
'TICKET_ADD_AUTHOR_AS_CONTACT') && empty($this->context[
"createdfrompublicinterface"])) {
595 if (!empty($user->socid) && !empty($user->contact_id) &&
getDolGlobalInt(
'TICKET_ADD_AUTHOR_AS_CONTACT') == 2) {
596 $contact_type =
'external';
597 $contributor_id = $user->contact_id;
599 $contact_type =
'internal';
600 $contributor_id = $user->id;
604 if ($this->
add_contact($contributor_id,
'CONTRIBUTOR', $contact_type) < 0) {
609 if (!$error && $this->fk_user_assign > 0) {
610 if ($this->
add_contact($this->fk_user_assign,
'SUPPORTTEC',
'internal') < 0) {
624 if (!$error && !$notrigger) {
635 foreach ($this->errors as $errmsg) {
636 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
637 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
639 $this->db->rollback();
646 $this->db->rollback();
647 dol_syslog(get_class($this).
"::Create fails verify ".implode(
',', $this->errors), LOG_WARNING);
661 public function fetch($id = 0, $ref =
'', $track_id =
'', $email_msgid =
'')
666 if (empty($id) && empty($ref) && empty($track_id) && empty($email_msgid)) {
667 $this->error =
'ErrorWrongParameters';
674 $sql .=
" t.entity,";
676 $sql .=
" t.track_id,";
677 $sql .=
" t.fk_soc,";
678 $sql .=
" t.fk_project,";
679 $sql .=
" t.fk_contract,";
680 $sql .=
" t.origin_email,";
681 $sql .=
" t.origin_replyto,";
682 $sql .=
" t.origin_references,";
683 $sql .=
" t.fk_user_create,";
684 $sql .=
" t.fk_user_assign,";
685 $sql .=
" t.email_msgid,";
686 $sql .=
" t.email_date,";
687 $sql .=
" t.subject,";
688 $sql .=
" t.message,";
689 $sql .=
" t.fk_statut as status,";
690 $sql .=
" t.resolution,";
691 $sql .=
" t.progress,";
692 $sql .=
" t.timing,";
693 $sql .=
" t.type_code,";
694 $sql .=
" t.category_code,";
695 $sql .=
" t.severity_code,";
697 $sql .=
" t.date_read,";
698 $sql .=
" t.date_last_msg_sent,";
699 $sql .=
" t.date_close,";
701 $sql .=
" t.model_pdf,";
702 $sql .=
" t.extraparams,";
704 $sql .=
" type.label as type_label, category.label as category_label, severity.label as severity_label";
705 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as t";
706 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_type as type ON type.code=t.type_code";
707 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_category as category ON category.code=t.category_code";
708 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_severity as severity ON severity.code=t.severity_code";
711 $sql .=
" WHERE t.rowid = ".((int) $id);
713 $sql .=
" WHERE t.entity IN (".getEntity($this->element, 1).
")";
715 $sql .=
" AND t.ref = '".$this->db->escape($ref).
"'";
716 } elseif ($track_id) {
717 $sql .=
" AND t.track_id = '".$this->db->escape($track_id).
"'";
719 $sql .=
" AND t.email_msgid = '".$this->db->escape($email_msgid).
"'";
723 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
724 $resql = $this->db->query($sql);
726 if ($this->db->num_rows($resql)) {
727 $obj = $this->db->fetch_object($resql);
729 $this->
id = $obj->rowid;
730 $this->entity = $obj->entity;
731 $this->
ref = $obj->ref;
732 $this->track_id = $obj->track_id;
733 $this->fk_soc = $obj->fk_soc;
734 $this->socid = $obj->fk_soc;
735 $this->fk_project = $obj->fk_project;
736 $this->fk_contract = $obj->fk_contract;
737 $this->origin_email = $obj->origin_email;
738 $this->origin_replyto = $obj->origin_replyto;
739 $this->origin_references = $obj->origin_references;
740 $this->fk_user_create = $obj->fk_user_create;
741 $this->fk_user_assign = $obj->fk_user_assign;
742 $this->email_msgid = $obj->email_msgid;
743 $this->email_date = $this->db->jdate($obj->email_date);
744 $this->subject = $obj->subject;
745 $this->message = $obj->message;
746 $this->model_pdf = $obj->model_pdf;
747 $this->extraparams = !empty($obj->extraparams) ? (array) json_decode($obj->extraparams,
true) : array();
748 $this->ip = $obj->ip;
750 $this->
status = $obj->status;
751 $this->fk_statut = $this->status;
753 $this->resolution = $obj->resolution;
754 $this->progress = $obj->progress;
755 $this->timing = $obj->timing;
757 $this->type_code = $obj->type_code;
758 $label_type = ($langs->trans(
"TicketTypeShort".$obj->type_code) !=
"TicketTypeShort".$obj->type_code ? $langs->trans(
"TicketTypeShort".$obj->type_code) : ($obj->type_label !=
'-' ? $obj->type_label :
''));
759 $this->type_label = $label_type;
761 $this->category_code = $obj->category_code;
762 $label_category = ($langs->trans(
"TicketCategoryShort".$obj->category_code) !=
"TicketCategoryShort".$obj->category_code ? $langs->trans(
"TicketCategoryShort".$obj->category_code) : ($obj->category_label !=
'-' ? $obj->category_label :
''));
763 $this->category_label = $label_category;
765 $this->severity_code = $obj->severity_code;
766 $label_severity = ($langs->trans(
"TicketSeverityShort".$obj->severity_code) !=
"TicketSeverityShort".$obj->severity_code ? $langs->trans(
"TicketSeverityShort".$obj->severity_code) : ($obj->severity_label !=
'-' ? $obj->severity_label :
''));
767 $this->severity_label = $label_severity;
769 $this->datec = $this->db->jdate($obj->datec);
770 $this->date_creation = $this->db->jdate($obj->datec);
771 $this->date_read = $this->db->jdate($obj->date_read);
772 $this->date_validation = $this->db->jdate($obj->date_read);
773 $this->date_last_msg_sent = $this->db->jdate($obj->date_last_msg_sent);
774 $this->date_close = $this->db->jdate($obj->date_close);
775 $this->tms = $this->db->jdate($obj->tms);
776 $this->date_modification = $this->db->jdate($obj->tms);
780 $this->db->free($resql);
786 $this->error =
"Error ".$this->db->lasterror();
787 dol_syslog(get_class($this).
"::fetch ".$this->error, LOG_ERR);
804 public function fetchAll($user, $sortorder =
'ASC', $sortfield =
't.datec', $limit = 0, $offset = 0, $arch = 0, $filter =
'')
806 global $langs, $extrafields;
809 $extrafields->fetch_name_optionals_label($this->table_element);
814 $sql .=
" t.track_id,";
815 $sql .=
" t.fk_soc,";
816 $sql .=
" t.fk_project,";
817 $sql .=
" t.fk_contract,";
818 $sql .=
" t.origin_email,";
819 $sql .=
" t.origin_replyto,";
820 $sql .=
" t.origin_references,";
821 $sql .=
" t.fk_user_create, uc.lastname as user_create_lastname, uc.firstname as user_create_firstname,";
822 $sql .=
" t.fk_user_assign, ua.lastname as user_assign_lastname, ua.firstname as user_assign_firstname,";
823 $sql .=
" t.subject,";
824 $sql .=
" t.message,";
825 $sql .=
" t.fk_statut as status,";
826 $sql .=
" t.resolution,";
827 $sql .=
" t.progress,";
828 $sql .=
" t.timing,";
829 $sql .=
" t.type_code,";
830 $sql .=
" t.category_code,";
831 $sql .=
" t.severity_code,";
833 $sql .=
" t.date_read,";
834 $sql .=
" t.date_last_msg_sent,";
835 $sql .=
" t.date_close,";
837 $sql .=
" type.label as type_label, category.label as category_label, severity.label as severity_label";
839 if ($extrafields->attributes[$this->table_element][
'count'] > 0) {
840 foreach ($extrafields->attributes[$this->table_element][
'label'] as $key => $val) {
841 $sql .= ($extrafields->attributes[$this->table_element][
'type'][$key] !=
'separate' ?
",ef.".$key.
" as options_".$key :
'');
844 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as t";
845 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_type as type ON type.code = t.type_code";
846 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_category as category ON category.code = t.category_code";
847 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_severity as severity ON severity.code = t.severity_code";
848 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = t.fk_soc";
849 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as uc ON uc.rowid = t.fk_user_create";
850 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as ua ON ua.rowid = t.fk_user_assign";
851 if ($extrafields->attributes[$this->table_element][
'count'] > 0) {
852 if (is_array($extrafields->attributes[$this->table_element][
'label']) && count($extrafields->attributes[$this->table_element][
'label'])) {
853 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"ticket_extrafields as ef on (t.rowid = ef.fk_object)";
856 $sql .=
" WHERE t.entity IN (".getEntity(
'ticket').
")";
859 if (is_array($filter)) {
860 foreach ($filter as $key => $value) {
861 if (strpos($key,
'date')) {
862 $sql .=
" AND ".$this->db->sanitize($key).
" = '".$this->db->escape($value).
"'";
863 } elseif (($key ==
't.fk_user_assign') || ($key ==
't.type_code') || ($key ==
't.category_code') || ($key ==
't.severity_code') || ($key ==
't.fk_soc')) {
864 $sql .=
" AND ".$this->db->sanitize($key).
" = '".$this->db->escape($value).
"'";
865 } elseif ($key ==
't.fk_statut') {
866 if (is_array($value) && count($value) > 0) {
867 $sql .=
" AND ".$this->db->sanitize($key).
" IN (".$this->db->sanitize(implode(
',', $value)).
")";
869 $sql .=
" AND ".$this->db->sanitize($key).
' = '.((int) $value);
871 } elseif ($key ==
't.fk_contract') {
872 $sql .=
" AND ".$this->db->sanitize($key).
' = '.((int) $value);
874 $sql .=
" AND ".$this->db->sanitize($key).
" LIKE '%".$this->db->escape($this->db->escapeforlike($value)).
"%'";
885 $this->errors[] = $errormessage;
886 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
891 $socid = $user->socid ? $user->socid : 0;
894 if (!$user->hasRight(
'societe',
'client',
'voir')) {
895 $search_sale = $user->id;
898 if ($search_sale && $search_sale !=
'-1') {
899 if ($search_sale == -2) {
900 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc)";
901 } elseif ($search_sale > 0) {
902 $sql .=
" AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc AND sc.fk_user = ".((int) $search_sale).
")";
907 $sql .=
" AND t.fk_soc = ".((int) $socid);
910 $sql .= $this->db->order($sortfield, $sortorder);
911 if (!empty($limit)) {
912 $sql .= $this->db->plimit($limit + 1, $offset);
915 dol_syslog(get_class($this).
"::fetchAll", LOG_DEBUG);
916 $resql = $this->db->query($sql);
919 $this->lines = array();
921 $num = $this->db->num_rows($resql);
926 $obj = $this->db->fetch_object($resql);
928 $line =
new self($this->db);
930 $line->id = $obj->rowid;
932 $line->ref = $obj->ref;
933 $line->track_id = $obj->track_id;
934 $line->fk_soc = $obj->fk_soc;
935 $line->fk_project = $obj->fk_project;
936 $line->fk_contract = $obj->fk_contract;
937 $line->origin_email = $obj->origin_email;
938 $line->origin_replyto = $obj->origin_replyto;
939 $line->origin_references = $obj->origin_references;
941 $line->fk_user_create = $obj->fk_user_create;
942 $line->fk_user_assign = $obj->fk_user_assign;
944 $line->subject = $obj->subject;
945 $line->message = $obj->message;
946 $line->fk_statut = $obj->status;
947 $line->status = $obj->status;
948 $line->resolution = $obj->resolution;
949 $line->progress = $obj->progress;
950 $line->timing = $obj->timing;
952 $label_type = ($langs->trans(
"TicketTypeShort".$obj->type_code) !=
"TicketTypeShort".$obj->type_code ? $langs->trans(
"TicketTypeShort".$obj->type_code) : ($obj->type_label !=
'-' ? $obj->type_label :
''));
953 $line->type_label = $label_type;
955 $this->category_code = $obj->category_code;
956 $label_category = ($langs->trans(
"TicketCategoryShort".$obj->category_code) !=
"TicketCategoryShort".$obj->category_code ? $langs->trans(
"TicketCategoryShort".$obj->category_code) : ($obj->category_label !=
'-' ? $obj->category_label :
''));
957 $line->category_label = $label_category;
959 $this->severity_code = $obj->severity_code;
960 $label_severity = ($langs->trans(
"TicketSeverityShort".$obj->severity_code) !=
"TicketSeverityShort".$obj->severity_code ? $langs->trans(
"TicketSeverityShort".$obj->severity_code) : ($obj->severity_label !=
'-' ? $obj->severity_label :
''));
961 $line->severity_label = $label_severity;
963 $line->datec = $this->db->jdate($obj->datec);
964 $line->date_read = $this->db->jdate($obj->date_read);
965 $line->date_last_msg_sent = $this->db->jdate($obj->date_last_msg_sent);
966 $line->date_close = $this->db->jdate($obj->date_close);
969 if ($extrafields->attributes[$this->table_element][
'count'] > 0) {
970 if (is_array($extrafields->attributes[$this->table_element][
'label']) && count($extrafields->attributes[$this->table_element][
'label'])) {
971 foreach ($extrafields->attributes[$this->table_element][
'label'] as $key => $val) {
972 $tmpkey =
'options_'.$key;
973 $line->{$tmpkey} = $obj->$tmpkey;
977 $this->lines[$i] = $line;
981 $this->db->free($resql);
984 $this->error =
"Error ".$this->db->lasterror();
985 dol_syslog(get_class($this).
"::fetchAll ".$this->error, LOG_ERR);
997 public function update($user, $notrigger = 0)
1008 if (isset($this->
ref)) {
1009 $this->
ref = trim($this->
ref);
1012 if (isset($this->track_id)) {
1013 $this->track_id = trim($this->track_id);
1016 if (isset($this->fk_soc)) {
1017 $this->fk_soc = (int) $this->fk_soc;
1020 if (isset($this->fk_project)) {
1021 $this->fk_project = (int) $this->fk_project;
1024 if (isset($this->fk_contract)) {
1025 $this->fk_contract = (int) $this->fk_contract;
1028 if (isset($this->origin_email)) {
1029 $this->origin_email = trim($this->origin_email);
1032 if (isset($this->fk_user_create)) {
1033 $this->fk_user_create = (int) $this->fk_user_create;
1036 if (isset($this->fk_user_assign)) {
1037 $this->fk_user_assign = (int) $this->fk_user_assign;
1040 if (isset($this->subject)) {
1041 $this->subject = trim($this->subject);
1044 if (isset($this->message)) {
1045 $this->message = trim($this->message);
1047 $this->errors[] =
'ErrorFieldTooLong';
1048 dol_syslog(get_class($this).
'::update error -1 message too long', LOG_ERR);
1053 if (isset($this->fk_statut)) {
1054 $this->fk_statut = (int) $this->fk_statut;
1057 if (isset($this->resolution)) {
1058 $this->resolution = trim($this->resolution);
1061 if (isset($this->progress)) {
1062 $this->progress = (int) $this->progress;
1065 if (isset($this->timing)) {
1066 $this->timing = trim($this->timing);
1069 if (isset($this->type_code)) {
1070 $this->timing = trim($this->type_code);
1073 if (isset($this->category_code)) {
1074 $this->timing = trim($this->category_code);
1077 if (isset($this->severity_code)) {
1078 $this->timing = trim($this->severity_code);
1080 if (isset($this->model_pdf)) {
1081 $this->model_pdf = trim($this->model_pdf);
1086 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket SET";
1087 $sql .=
" ref=".(isset($this->
ref) ?
"'".$this->db->escape($this->
ref).
"'" :
"").
",";
1088 $sql .=
" track_id=".(isset($this->track_id) ?
"'".$this->db->escape($this->track_id).
"'" :
"null").
",";
1089 $sql .=
" fk_soc=".(isset($this->fk_soc) ? (int) $this->fk_soc :
"null").
",";
1090 $sql .=
" fk_project=".(isset($this->fk_project) ? (int) $this->fk_project :
"null").
",";
1091 $sql .=
" fk_contract=".(isset($this->fk_contract) ? (int) $this->fk_contract :
"null").
",";
1092 $sql .=
" origin_email=".(isset($this->origin_email) ?
"'".$this->db->escape($this->origin_email).
"'" :
"null").
",";
1093 $sql .=
" origin_replyto=".(isset($this->origin_replyto) ?
"'".$this->db->escape($this->origin_replyto).
"'" :
"null").
",";
1094 $sql .=
" origin_references=".(isset($this->origin_references) ?
"'".$this->db->escape($this->origin_references).
"'" :
"null").
",";
1095 $sql .=
" fk_user_create=".(isset($this->fk_user_create) ? (int) $this->fk_user_create :
"null").
",";
1096 $sql .=
" fk_user_assign=".(isset($this->fk_user_assign) ? (int) $this->fk_user_assign :
"null").
",";
1097 $sql .=
" subject=".(isset($this->subject) ?
"'".$this->db->escape($this->subject).
"'" :
"null").
",";
1098 $sql .=
" message=".(isset($this->message) ?
"'".$this->db->escape($this->message).
"'" :
"null").
",";
1099 $sql .=
" fk_statut=".(isset($this->fk_statut) ? (int) $this->fk_statut :
"0").
",";
1100 $sql .=
" resolution=".(isset($this->resolution) ? (int) $this->resolution :
"null").
",";
1101 $sql .=
" progress=".(isset($this->progress) ?
"'".$this->db->escape($this->progress).
"'" :
"null").
",";
1102 $sql .=
" timing=".(isset($this->timing) ?
"'".$this->db->escape($this->timing).
"'" :
"null").
",";
1103 $sql .=
" type_code=".(isset($this->type_code) ?
"'".$this->db->escape($this->type_code).
"'" :
"null").
",";
1104 $sql .=
" category_code=".(isset($this->category_code) ?
"'".$this->db->escape($this->category_code).
"'" :
"null").
",";
1105 $sql .=
" severity_code=".(isset($this->severity_code) ?
"'".$this->db->escape($this->severity_code).
"'" :
"null").
",";
1106 $sql .=
" datec=".(dol_strlen($this->datec) != 0 ?
"'".$this->db->idate($this->datec).
"'" :
'null').
",";
1107 $sql .=
" date_read=".(dol_strlen($this->date_read) != 0 ?
"'".$this->db->idate($this->date_read).
"'" :
'null').
",";
1108 $sql .=
" date_last_msg_sent=".(dol_strlen($this->date_last_msg_sent) != 0 ?
"'".$this->db->idate($this->date_last_msg_sent).
"'" :
'null').
",";
1109 $sql .=
" model_pdf=".(isset($this->model_pdf) ?
"'".$this->db->escape($this->model_pdf).
"'" :
"null").
",";
1110 $sql .=
" date_close=".(dol_strlen($this->date_close) != 0 ?
"'".$this->db->idate($this->date_close).
"'" :
'null');
1111 $sql .=
" WHERE rowid=".((int) $this->
id);
1115 $resql = $this->db->query($sql);
1118 $this->errors[] =
"Error ".$this->db->lasterror();
1123 $result = $this->insertExtraFields();
1129 if (!$error && !$notrigger) {
1131 $result = $this->call_trigger(
'TICKET_MODIFY', $user);
1140 foreach ($this->errors as $errmsg) {
1141 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
1142 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1144 $this->db->rollback();
1147 $this->db->commit();
1159 public function delete($user, $notrigger = 0)
1168 $result = $this->call_trigger(
'TICKET_DELETE', $user);
1178 $res = $this->delete_linked_contact();
1180 dol_syslog(get_class($this).
"::delete error", LOG_ERR);
1187 $res = $this->deleteObjectLinked();
1195 $result = $this->deleteExtraFields();
1198 dol_syslog(get_class($this).
"::delete error -3 ".$this->error, LOG_ERR);
1205 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_ticket";
1206 $sql .=
" WHERE fk_ticket = ".(int) $this->
id;
1208 $result = $this->db->query($sql);
1211 $this->errors[] = $this->db->lasterror();
1216 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"ticket";
1217 $sql .=
" WHERE rowid=".((int) $this->
id);
1219 dol_syslog(get_class($this).
"::delete sql=".$sql);
1220 $resql = $this->db->query($sql);
1223 $this->errors[] =
"Error ".$this->db->lasterror();
1226 $this->deleteEcmFiles(1);
1228 $dir = DOL_DATA_ROOT.
'/'.$this->element.
'/'.$this->ref;
1232 $this->errors[] = $this->error;
1240 foreach ($this->errors as $errmsg) {
1241 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
1242 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1244 $this->db->rollback();
1247 $this->db->commit();
1276 $object->context[
'createfromclone'] =
'createfromclone';
1277 $result =
$object->create($user);
1281 $this->error =
$object->error;
1288 unset(
$object->context[
'createfromclone']);
1292 $this->db->commit();
1295 $this->db->rollback();
1310 $this->
ref =
'TI0501-001';
1311 $this->track_id =
'XXXXaaaa';
1312 $this->origin_email =
'email@email.com';
1313 $this->fk_project = 1;
1314 $this->fk_user_create = 1;
1315 $this->fk_user_assign = 1;
1316 $this->subject =
'Subject of ticket';
1317 $this->message =
'Message of ticket';
1319 $this->resolution =
'1';
1320 $this->progress = 10;
1322 $this->type_code =
'TYPECODE';
1323 $this->category_code =
'CATEGORYCODE';
1324 $this->severity_code =
'SEVERITYCODE';
1327 $this->date_last_msg_sent =
dol_now();
1328 $this->date_close =
dol_now();
1342 print
Form::selectarray(
'search_fk_statut', $this->labelStatusShort, $selected, $show_empty = 1, $key_in_label = 0, $value_as_key = 0, $option =
'', $translate = 1, $maxlen = 0, $disabled = 0, $sort =
'', $morecss =
'');
1355 if (!empty($this->cache_types_tickets) && count($this->cache_types_tickets)) {
1360 $sql =
"SELECT rowid, code, label, use_default, pos, description";
1361 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_type";
1362 $sql .=
" WHERE entity IN (".getEntity(
'c_ticket_type').
")";
1363 $sql .=
" AND active > 0";
1364 $sql .=
" ORDER BY pos";
1365 dol_syslog(get_class($this).
"::load_cache_type_tickets", LOG_DEBUG);
1366 $resql = $this->db->query($sql);
1368 $num = $this->db->num_rows($resql);
1371 $obj = $this->db->fetch_object($resql);
1372 $label = ($langs->trans(
"TicketTypeShort".$obj->code) !=
"TicketTypeShort".$obj->code ? $langs->trans(
"TicketTypeShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
1373 $this->cache_types_tickets[$obj->rowid][
'code'] = $obj->code;
1374 $this->cache_types_tickets[$obj->rowid][
'label'] = $label;
1375 $this->cache_types_tickets[$obj->rowid][
'use_default'] = $obj->use_default;
1376 $this->cache_types_tickets[$obj->rowid][
'pos'] = $obj->pos;
1394 global $conf, $langs;
1396 if ($publicgroup == -1 && !empty($this->cache_category_ticket) && count($this->cache_category_tickets)) {
1401 $sql =
"SELECT rowid, code, label, use_default, pos, description, public, active, force_severity, fk_parent";
1402 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_category";
1403 $sql .=
" WHERE entity IN (".getEntity(
'c_ticket_category').
")";
1404 $sql .=
" AND active > 0";
1405 if ($publicgroup > -1) {
1406 $sql .=
" AND public = ".((int) $publicgroup);
1408 $sql .=
" ORDER BY pos";
1410 dol_syslog(get_class($this).
"::load_cache_categories_tickets", LOG_DEBUG);
1412 $resql = $this->db->query($sql);
1414 $num = $this->db->num_rows($resql);
1417 $obj = $this->db->fetch_object($resql);
1418 $this->cache_category_tickets[$obj->rowid][
'code'] = $obj->code;
1419 $this->cache_category_tickets[$obj->rowid][
'use_default'] = $obj->use_default;
1420 $this->cache_category_tickets[$obj->rowid][
'pos'] = $obj->pos;
1421 $this->cache_category_tickets[$obj->rowid][
'public'] = $obj->public;
1422 $this->cache_category_tickets[$obj->rowid][
'active'] = $obj->active;
1423 $this->cache_category_tickets[$obj->rowid][
'force_severity'] = $obj->force_severity;
1424 $this->cache_category_tickets[$obj->rowid][
'fk_parent'] = $obj->fk_parent;
1428 $label = ($langs->trans(
"TicketCategoryShort".$obj->code) !=
"TicketCategoryShort".$obj->code ? $langs->trans(
"TicketCategoryShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
1429 $this->cache_category_tickets[$obj->rowid][
'label'] = $label;
1447 global $conf, $langs;
1449 if (!empty($conf->cache[
'severity_tickets']) && count($conf->cache[
'severity_tickets'])) {
1454 $sql =
"SELECT rowid, code, label, use_default, pos, description";
1455 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_severity";
1456 $sql .=
" WHERE entity IN (".getEntity(
'c_ticket_severity').
")";
1457 $sql .=
" AND active > 0";
1458 $sql .=
" ORDER BY pos";
1459 dol_syslog(get_class($this).
"::loadCacheSeveritiesTickets", LOG_DEBUG);
1460 $resql = $this->db->query($sql);
1462 $num = $this->db->num_rows($resql);
1465 $obj = $this->db->fetch_object($resql);
1467 $conf->cache[
'severity_tickets'][$obj->rowid][
'code'] = $obj->code;
1468 $label = ($langs->trans(
"TicketSeverityShort".$obj->code) !=
"TicketSeverityShort".$obj->code ? $langs->trans(
"TicketSeverityShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
1469 $conf->cache[
'severity_tickets'][$obj->rowid][
'label'] = $label;
1470 $conf->cache[
'severity_tickets'][$obj->rowid][
'use_default'] = $obj->use_default;
1471 $conf->cache[
'severity_tickets'][$obj->rowid][
'pos'] = $obj->pos;
1490 return $this->LibStatut($this->
status, $mode, 0, $this->progress);
1504 public function LibStatut($status, $mode = 0, $notooltip = 0, $progress = 0)
1507 global $langs, $hookmanager;
1509 $labelStatus = (isset($status) && !empty($this->labelStatus[$status])) ? $this->labelStatus[$status] :
'';
1510 $labelStatusShort = (isset($status) && !empty($this->labelStatusShort[$status])) ? $this->labelStatusShort[$status] :
'';
1513 case self::STATUS_NOT_READ:
1514 $statusType =
'status0';
1516 case self::STATUS_READ:
1517 $statusType =
'status1';
1519 case self::STATUS_ASSIGNED:
1520 $statusType =
'status2';
1522 case self::STATUS_IN_PROGRESS:
1523 $statusType =
'status4';
1525 case self::STATUS_WAITING:
1526 $statusType =
'status7';
1528 case self::STATUS_NEED_MORE_INFO:
1529 $statusType =
'status3';
1531 case self::STATUS_CANCELED:
1532 $statusType =
'status9';
1534 case self::STATUS_CLOSED:
1535 $statusType =
'status6';
1538 $labelStatus =
'Unknown';
1539 $labelStatusShort =
'Unknown';
1540 $statusType =
'status0';
1544 $parameters = array(
1545 'status' => $status,
1550 $reshook = $hookmanager->executeHooks(
'LibStatut', $parameters, $this);
1553 return $hookmanager->resPrint;
1558 $params = array(
'tooltip' =>
'no');
1561 $labelStatus = $langs->transnoentitiesnoconv($labelStatus);
1562 $labelStatusShort = $langs->transnoentitiesnoconv($labelStatusShort);
1564 if ($status == self::STATUS_IN_PROGRESS && $progress > 0) {
1565 $labelStatus .=
' ('.round($progress).
'%)';
1566 $labelStatusShort .=
' ('.round($progress).
'%)';
1569 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode,
'', $params);
1583 $langs->load(
'ticket');
1584 $nofetch = !empty($params[
'nofetch']);
1587 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Ticket").
'</u>';
1588 $datas[
'picto'] .=
' '.$this->getLibStatut(4);
1589 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1590 $datas[
'track_id'] =
'<br><b>'.$langs->trans(
'TicketTrackId').
':</b> '.$this->track_id;
1591 $datas[
'subject'] =
'<br><b>'.$langs->trans(
'Subject').
':</b> '.$this->subject;
1592 if ($this->date_creation) {
1593 $datas[
'date_creation'] =
'<br><b>'.$langs->trans(
'DateCreation').
':</b> '.
dol_print_date($this->date_creation,
'dayhour');
1595 if ($this->date_modification) {
1596 $datas[
'date_modification'] =
'<br><b>'.$langs->trans(
'DateModification').
':</b> '.
dol_print_date($this->date_modification,
'dayhour');
1599 if (isModEnabled(
'category') && !$nofetch) {
1600 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
1601 $form =
new Form($this->db);
1602 $datas[
'categories'] =
'<br>' . $form->showCategories($this->
id, Categorie::TYPE_TICKET, 1);
1618 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1620 global $action, $conf, $hookmanager, $langs;
1622 if (!empty($conf->dol_no_mouse_hover)) {
1630 'objecttype' => $this->element,
1631 'option' => $option,
1634 $classfortooltip =
'classfortooltip';
1637 $classfortooltip =
'classforajaxtooltip';
1638 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1641 $label = implode($this->getTooltipContentArray($params));
1644 $url = DOL_URL_ROOT.
'/ticket/card.php?id='.$this->id;
1646 if ($option !=
'nolink') {
1648 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1649 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1650 $add_save_lastsearch_values = 1;
1652 if ($add_save_lastsearch_values) {
1653 $url .=
'&save_lastsearch_values=1';
1658 if (empty($notooltip)) {
1660 $label = $langs->trans(
"ShowTicket");
1661 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1663 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
1664 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1666 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1669 $linkstart =
'<a href="'.$url.
'"';
1670 $linkstart .= $linkclose.
'>';
1673 $result .= $linkstart;
1675 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), (($withpicto != 2) ?
'class="paddingright"' :
''), 0, 0, $notooltip ? 0 : 1);
1677 if ($withpicto != 2) {
1678 $result .= $this->ref;
1680 $result .= $linkend;
1683 $hookmanager->initHooks(array(
'ticketdao'));
1684 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1685 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1687 $result = $hookmanager->resPrint;
1689 $result .= $hookmanager->resPrint;
1709 if ($this->
status != self::STATUS_CANCELED) {
1714 $this->
status = Ticket::STATUS_READ;
1716 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
1717 $sql .=
" SET fk_statut = ".Ticket::STATUS_READ.
", date_read = '".$this->db->idate(
dol_now()).
"'";
1718 $sql .=
" WHERE rowid = ".((int) $this->
id);
1721 $resql = $this->db->query($sql);
1723 $this->context[
'actionmsg'] = $langs->trans(
'TicketLogMesgReadBy', $this->
ref, $user->getFullName($langs));
1724 $this->context[
'actionmsg2'] = $langs->trans(
'TicketLogMesgReadBy', $this->
ref, $user->getFullName($langs));
1728 $result = $this->call_trigger(
'TICKET_MODIFY', $user);
1736 $this->db->commit();
1739 $this->
status = $this->oldcopy->status;
1741 $this->db->rollback();
1742 $this->error = implode(
',', $this->errors);
1743 dol_syslog(get_class($this).
"::markAsRead ".$this->error, LOG_ERR);
1747 $this->
status = $this->oldcopy->status;
1749 $this->db->rollback();
1750 $this->error = $this->db->lasterror();
1751 dol_syslog(get_class($this).
"::markAsRead ".$this->error, LOG_ERR);
1767 public function assignUser($user, $id_assign_user, $notrigger = 0)
1775 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
1776 if ($id_assign_user > 0) {
1777 $sql .=
" SET fk_user_assign=".((int) $id_assign_user).
", fk_statut = ".Ticket::STATUS_ASSIGNED;
1779 $sql .=
" SET fk_user_assign=null, fk_statut = ".Ticket::STATUS_READ;
1781 $sql .=
" WHERE rowid = ".((int) $this->
id);
1783 dol_syslog(get_class($this).
"::assignUser sql=".$sql);
1784 $resql = $this->db->query($sql);
1786 $this->fk_user_assign = $id_assign_user;
1790 $result = $this->call_trigger(
'TICKET_ASSIGNED', $user);
1798 $this->db->commit();
1801 $this->db->rollback();
1802 $this->error = implode(
',', $this->errors);
1803 dol_syslog(get_class($this).
"::assignUser ".$this->error, LOG_ERR);
1807 $this->db->rollback();
1808 $this->error = $this->db->lasterror();
1809 dol_syslog(get_class($this).
"::assignUser ".$this->error, LOG_ERR);
1826 public function createTicketMessage($user, $notrigger = 0, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $send_email =
false, $public_area = 0)
1828 global $conf, $langs;
1834 if (isset($this->fk_track_id)) {
1835 $this->fk_track_id = trim($this->fk_track_id);
1838 if (isset($this->message)) {
1839 $this->message = trim($this->message);
1845 include_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
1847 $actioncomm->type_code =
'AC_OTH_AUTO';
1848 $actioncomm->code =
'TICKET_MSG';
1849 if ($this->
private) {
1850 $actioncomm->code =
'TICKET_MSG_PRIVATE';
1853 $actioncomm->code .=
'_SENTBYMAIL';
1855 if ((empty($user->id) || $user->id == 0) && isset($_SESSION[
'email_customer'])) {
1856 $actioncomm->email_from = $_SESSION[
'email_customer'];
1858 $actioncomm->socid = $this->socid;
1859 $actioncomm->label = $this->subject;
1860 $actioncomm->note_private = $this->message;
1861 $actioncomm->userassigned = array($user->id => array(
'id' => $user->id,
'transparency' => 0));
1862 $actioncomm->userownerid = $user->id;
1863 $actioncomm->datep = $now;
1864 $actioncomm->percentage = -1;
1865 $actioncomm->elementtype =
'ticket';
1866 $actioncomm->fk_element = $this->id;
1867 $actioncomm->fk_project = $this->fk_project;
1870 if ($public_area && !empty($this->origin_email) &&
getDolGlobalString(
'TICKET_ASSIGN_CONTACT_TO_MESSAGE')) {
1871 $contacts = $this->searchContactByEmail($this->origin_email);
1872 if (!empty($contacts)) {
1874 foreach ($contacts as $contact) {
1875 if ((
int) $contact->statut == 1) {
1876 $actioncomm->contact_id = $contact->id;
1883 $attachedfiles = array();
1884 $attachedfiles[
'paths'] = $filename_list;
1885 $attachedfiles[
'names'] = $mimefilename_list;
1886 $attachedfiles[
'mimes'] = $mimetype_list;
1887 if (is_array($attachedfiles) && count($attachedfiles) > 0) {
1888 $actioncomm->attachedfiles = $attachedfiles;
1894 $actionid = $actioncomm->create($user);
1895 if ($actionid <= 0) {
1897 $this->error = $actioncomm->error;
1898 $this->errors = $actioncomm->errors;
1901 if ($actionid > 0) {
1902 if (is_array($attachedfiles) && array_key_exists(
'paths', $attachedfiles) && count($attachedfiles[
'paths']) > 0) {
1904 foreach ($attachedfiles[
'paths'] as $key => $filespath) {
1906 $destdir = $conf->ticket->dir_output.
'/'.$this->ref;
1909 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1911 if (in_array($actioncomm->code, array(
'TICKET_MSG',
'TICKET_MSG_SENTBYMAIL'))) {
1912 $ecmfile =
new EcmFiles($this->db);
1913 $destdir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $destdir);
1914 $destdir = preg_replace(
'/[\\/]$/',
'', $destdir);
1915 $destdir = preg_replace(
'/^[\\/]/',
'', $destdir);
1917 $result = $ecmfile->fetch(0,
'', $destdir.
'/'.$attachedfiles[
'names'][$key]);
1927 $result = $ecmfile->update($user);
1940 $this->db->rollback();
1943 $this->db->commit();
1955 if (!empty($this->cache_msgs_ticket) && is_array($this->cache_msgs_ticket) && count($this->cache_msgs_ticket)) {
1961 $sql =
"SELECT id as rowid, fk_user_author, email_from, datec, datep, label, note as message, code";
1962 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
1963 $sql .=
" WHERE fk_element = ".(int) $this->
id;
1964 $sql .=
" AND elementtype = 'ticket'";
1965 $sql .=
" ORDER BY datep DESC";
1967 dol_syslog(get_class($this).
"::load_cache_actions_ticket", LOG_DEBUG);
1968 $resql = $this->db->query($sql);
1970 $num = $this->db->num_rows($resql);
1973 $obj = $this->db->fetch_object($resql);
1974 $this->cache_msgs_ticket[$i][
'id'] = $obj->rowid;
1975 $this->cache_msgs_ticket[$i][
'fk_user_author'] = $obj->fk_user_author;
1976 if (in_array($obj->code, array(
'TICKET_MSG',
'AC_TICKET_CREATE')) && empty($obj->fk_user_author)) {
1977 $this->cache_msgs_ticket[$i][
'fk_contact_author'] = $obj->email_from;
1979 $this->cache_msgs_ticket[$i][
'datec'] = $this->db->jdate($obj->datec);
1980 $this->cache_msgs_ticket[$i][
'datep'] = $this->db->jdate($obj->datep);
1981 $this->cache_msgs_ticket[$i][
'subject'] = $obj->label;
1982 $this->cache_msgs_ticket[$i][
'message'] = $obj->message;
1983 $this->cache_msgs_ticket[$i][
'private'] = (preg_match(
'/^TICKET_MSG_PRIVATE/', $obj->code) ? 1 : 0);
1988 $this->error =
"Error ".$this->db->lasterror();
1989 dol_syslog(get_class($this).
"::load_cache_actions_ticket ".$this->error, LOG_ERR);
2005 if ($this->
status != Ticket::STATUS_CLOSED && $this->
status != Ticket::STATUS_CANCELED) {
2008 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
2009 $sql .=
" SET fk_statut=".($mode ? Ticket::STATUS_CANCELED : Ticket::STATUS_CLOSED).
", progress=100, date_close='".$this->db->idate(
dol_now()).
"'";
2010 $sql .=
" WHERE rowid = ".((int) $this->
id);
2012 dol_syslog(get_class($this).
"::close mode=".$mode);
2013 $resql = $this->db->query($sql);
2018 if (isModEnabled(
'intervention') &&
getDolGlobalString(
'WORKFLOW_TICKET_CLOSE_INTERVENTION')) {
2019 dol_syslog(
"We have closed the ticket, so we close all linked interventions");
2020 $this->fetchObjectLinked($this->
id, $this->element,
null,
'fichinter');
2021 if ($this->linkedObjectsIds) {
2022 foreach ($this->linkedObjectsIds[
'fichinter'] as $fichinter_id) {
2024 $fichinter->fetch($fichinter_id);
2025 if ($fichinter->statut == 0) {
2026 $result = $fichinter->setValid($user);
2028 $this->errors[] = $fichinter->error;
2032 if ($fichinter->statut < 3) {
2033 $result = $fichinter->setStatut(3);
2035 $this->errors[] = $fichinter->error;
2044 $result = $this->call_trigger(
'TICKET_CLOSE', $user);
2051 $this->db->commit();
2054 $this->db->rollback();
2055 $this->error = implode(
',', $this->errors);
2056 dol_syslog(get_class($this).
"::close ".$this->error, LOG_ERR);
2060 $this->db->rollback();
2061 $this->error = $this->db->lasterror();
2062 dol_syslog(get_class($this).
"::close ".$this->error, LOG_ERR);
2081 $thirdparties = array();
2085 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"societe";
2086 $sql .=
" WHERE entity IN (".getEntity(
'ticket', 1).
")";
2087 if (!empty($type)) {
2088 if ($type == 1 || $type == 2) {
2089 $sql .=
" AND client = ".((int) $type);
2090 } elseif ($type == 3) {
2091 $sql .=
" AND fournisseur = 1";
2094 if (!empty($email)) {
2095 if (empty($exact)) {
2097 if (preg_match(
'/^([\*])?[^*]+([\*])?$/', $email, $regs) && count($regs) > 1) {
2098 $email = str_replace(
'*',
'%', $email);
2100 $email =
'%'.$email.
'%';
2104 if (is_array($filters) && !empty($filters)) {
2108 $sql .=
"email LIKE '".$this->db->escape($email).
"'";
2110 if (is_array($filters) && !empty($filters)) {
2111 foreach ($filters as $field => $value) {
2112 $sql .=
" ".$clause.
" ".$field.
" LIKE '".$this->db->escape($value).
"'";
2114 if (!empty($email)) {
2119 $res = $this->db->query($sql);
2121 while ($rec = $this->db->fetch_array($res)) {
2122 $soc =
new Societe($this->db);
2123 $soc->fetch($rec[
'rowid']);
2124 $thirdparties[] = $soc;
2127 return $thirdparties;
2129 $this->error = $this->db->error().
' sql='.$sql;
2130 dol_syslog(get_class($this).
"::searchSocidByEmail ".$this->error, LOG_ERR);
2145 $contacts = array();
2148 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"socpeople";
2149 $sql .=
" WHERE entity IN (".getEntity(
'contact').
")";
2150 if (!empty($socid)) {
2151 $sql .=
" AND fk_soc = ".((int) $socid);
2153 if (!empty($email)) {
2156 $sql .=
"email = '".$this->db->escape($email).
"'";
2158 $sql .=
"email LIKE BINARY '".$this->db->escape($this->db->escapeforlike($email)).
"'";
2162 $res = $this->db->query($sql);
2164 while ($rec = $this->db->fetch_object($res)) {
2165 include_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
2166 $contactstatic =
new Contact($this->db);
2167 $contactstatic->fetch($rec->rowid);
2168 $contacts[] = $contactstatic;
2173 $this->error = $this->db->error().
' sql='.$sql;
2174 dol_syslog(get_class($this).
"::searchContactByEmail ".$this->error, LOG_ERR);
2188 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
2189 $sql .=
" SET fk_soc = ".($id > 0 ? $id :
"null");
2190 $sql .=
" WHERE rowid = ".((int) $this->
id);
2191 dol_syslog(get_class($this).
'::setCustomer sql='.$sql);
2192 $resql = $this->db->query($sql);
2212 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
2213 $sql .=
" SET progress = ".($percent > 0 ? $percent :
"null");
2214 $sql .=
" WHERE rowid = ".((int) $this->
id);
2215 dol_syslog(get_class($this).
'::set_progression sql='.$sql);
2216 $resql = $this->db->query($sql);
2236 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
2237 $sql .=
" SET fk_contract = ".($contractid > 0 ? $contractid :
"null");
2238 $sql .=
" WHERE rowid = ".((int) $this->
id);
2239 dol_syslog(get_class($this).
'::setContract sql='.$sql);
2240 $resql = $this->db->query($sql);
2260 return $this->getIdContact(
'internal',
'SUPPORTTEC');
2271 return $this->listeContact(-1,
'internal', 0,
'', $status);
2281 return $this->getIdContact(
'external',
'SUPPORTCLI');
2292 return $this->listeContact(-1,
'external', 0,
'', $status);
2302 return $this->getIdContact(
'internal',
'CONTRIBUTOR');
2312 return $this->getIdContact(
'external',
'CONTRIBUTOR');
2322 $array_contact = array();
2324 $array_contact = $this->getIdTicketInternalContact();
2326 $array_contact = array_merge($array_contact, $this->getIdTicketCustomerContact());
2328 $array_contact = array_merge($array_contact, $this->getIdTicketInternalInvolvedContact());
2330 $array_contact = array_merge($array_contact, $this->getIdTicketCustomerInvolvedContact());
2332 return $array_contact;
2342 $array_contact = array();
2344 $array_contact = array_merge($array_contact, $this->getIdTicketCustomerContact());
2346 $array_contact = array_merge($array_contact, $this->getIdTicketCustomerInvolvedContact());
2348 return $array_contact;
2363 public function listeContact($statusoflink = -1, $source =
'external', $list = 0, $code =
'', $status = -1)
2369 $sql =
"SELECT ec.rowid, ec.statut as statuslink, ec.fk_socpeople as id, ec.fk_c_type_contact";
2370 if ($source ==
'internal') {
2371 $sql .=
", '-1' as socid, t.statut as statuscontact";
2374 if ($source ==
'external' || $source ==
'thirdparty') {
2375 $sql .=
", t.fk_soc as socid, t.statut as statuscontact";
2378 $sql .=
", t.civility, t.lastname as lastname, t.firstname, t.email";
2379 if ($source ==
'internal') {
2380 $sql .=
", t.office_phone as phone, t.user_mobile as phone_mobile";
2383 if ($source ==
'external') {
2384 $sql .=
", t.phone as phone, t.phone_mobile as phone_mobile, t.phone_perso as phone_perso";
2387 $sql .=
", tc.source, tc.element, tc.code, tc.libelle as type_contact_label";
2388 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_contact tc";
2389 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact ec";
2390 if ($source ==
'internal') {
2391 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user t on ec.fk_socpeople = t.rowid";
2394 if ($source ==
'external' || $source ==
'thirdparty') {
2395 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople t on ec.fk_socpeople = t.rowid";
2398 $sql .=
" WHERE ec.element_id = ".((int) $this->
id);
2399 $sql .=
" AND ec.fk_c_type_contact=tc.rowid";
2400 $sql .=
" AND tc.element='".$this->db->escape($this->element).
"'";
2401 if ($source ==
'internal') {
2402 $sql .=
" AND tc.source = 'internal'";
2404 $sql .=
" AND t.statut = ".((int) $status);
2408 if ($source ==
'external' || $source ==
'thirdparty') {
2409 $sql .=
" AND tc.source = 'external'";
2411 $sql .=
" AND t.statut = ".((int) $status);
2415 if (!empty($code)) {
2416 $sql .=
" AND tc.code = '".$this->db->escape($code).
"'";
2419 $sql .=
" AND tc.active=1";
2420 if ($statusoflink >= 0) {
2421 $sql .=
" AND ec.statut = ".((int) $statusoflink);
2424 $sql .=
" ORDER BY t.lastname ASC";
2426 $resql = $this->db->query($sql);
2428 $num = $this->db->num_rows($resql);
2431 $obj = $this->db->fetch_object($resql);
2434 $transkey =
"TypeContact_".$obj->element.
"_".$obj->source.
"_".$obj->code;
2435 $labelType = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->type_contact_label);
2437 'source' => $obj->source,
2438 'socid' => $obj->socid,
2440 'nom' => $obj->lastname,
2441 'civility' => $obj->civility,
2442 'lastname' => $obj->lastname,
2443 'firstname' => $obj->firstname,
2444 'email' => $obj->email,
2445 'rowid' => $obj->rowid,
2446 'code' => $obj->code,
2447 'libelle' => $labelType,
2448 'labeltype' => $labelType,
2449 'status' => $obj->statuslink,
2450 'statuscontact' => $obj->statuscontact,
2451 'fk_c_type_contact' => $obj->fk_c_type_contact,
2452 'phone' => $obj->phone,
2453 'phone_mobile' => $obj->phone_mobile);
2455 $tab[$i] = $obj->id;
2463 $this->error = $this->db->error();
2485 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
2486 foreach ($dirmodels as $reldir) {
2487 $file =
dol_buildpath($reldir.
"core/modules/ticket/".$modele.
'.php', 0);
2488 if (file_exists($file)) {
2489 $classname = $modele;
2494 if ($classname !==
'') {
2496 $modTicket =
new $classname();
2498 $defaultref = $modTicket->getNextValue($thirdparty, $this);
2501 if (is_numeric($defaultref) && $defaultref <= 0) {
2519 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2527 if (file_exists($dir_osencoded)) {
2528 $handle = opendir($dir_osencoded);
2529 if (is_resource($handle)) {
2530 while (($file = readdir($handle)) !==
false) {
2532 $file = mb_convert_encoding($file,
'UTF-8',
'ISO-8859-1');
2557 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
2558 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2559 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
2561 $maxwidthsmall = 270;
2562 $maxheightsmall = 150;
2563 $maxwidthmini = 128;
2564 $maxheightmini = 72;
2566 $formmail =
new FormMail($this->db);
2567 $formmail->trackid = (is_null($forcetrackid) ?
'tic'.$this->id :
'');
2568 $attachedfiles = $formmail->get_attached_files();
2570 $filepath = $attachedfiles[
'paths'];
2571 $filename = $attachedfiles[
'names'];
2572 $mimetype = $attachedfiles[
'mimes'];
2575 $destdir = $conf->ticket->dir_output.
'/'.$this->ref;
2581 $listofpaths = array();
2582 $listofnames = array();
2583 foreach ($filename as $i => $val) {
2584 $destfile = $destdir.
'/'.$filename[$i];
2586 if (is_file($destfile)) {
2587 $pathinfo = pathinfo($filename[$i]);
2589 $destfile = $destdir.
'/'.$pathinfo[
'filename'].
' - '.
dol_print_date($now,
'dayhourlog').
'.'.$pathinfo[
'extension'];
2592 $moreinfo = array(
'description' =>
'File saved by copyFilesForTicket',
'src_object_type' => $this->element,
'src_object_id' => $this->
id);
2594 $res =
dol_move($filepath[$i], $destfile, 0, 1, 0, 1, $moreinfo);
2598 $this->error =
"Failed to move file ".dirbasename($filepath[$i]).
" into ".
dirbasename($destfile);
2605 $imgThumbSmall =
vignette($destfile, $maxwidthsmall, $maxheightsmall,
'_small', 50,
"thumbs");
2608 $imgThumbMini =
vignette($destfile, $maxwidthmini, $maxheightmini,
'_mini', 50,
"thumbs");
2613 $formmail->remove_attached_files($i);
2616 $listofpaths[$i] = $destfile;
2617 $listofnames[$i] = basename($destfile);
2620 return array(
'listofpaths' => $listofpaths,
'listofnames' => $listofnames,
'listofmimes' => $mimetype);
2636 if (!is_array($categories)) {
2637 $categories = array($categories);
2641 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2643 $existing = $c->containing($this->
id, Categorie::TYPE_TICKET,
'id');
2646 if (is_array($existing)) {
2647 $to_del = array_diff($existing, $categories);
2648 $to_add = array_diff($categories, $existing);
2651 $to_add = $categories;
2655 foreach ($to_del as $del) {
2656 if ($c->fetch($del) > 0) {
2657 $c->del_type($this, Categorie::TYPE_TICKET);
2660 foreach ($to_add as $add) {
2661 if ($c->fetch($add) > 0) {
2662 $c->add_type($this, Categorie::TYPE_TICKET);
2681 public function newMessage($user, &$action, $private = 1, $public_area = 0)
2683 global $mysoc, $conf, $langs;
2697 array_push($this->errors, $langs->trans(
"ErrorTicketIsNotValid"));
2703 array_push($this->errors, $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Message")));
2704 $action =
'add_message';
2715 $resarray =
$object->copyFilesForTicket();
2716 if (is_numeric($resarray) && $resarray == -1) {
2721 $listofpaths = $resarray[
'listofpaths'];
2722 $listofnames = $resarray[
'listofnames'];
2723 $listofmimes = $resarray[
'listofmimes'];
2725 $id =
$object->createTicketMessage($user, 0, $listofpaths, $listofmimes, $listofnames, $send_email, $public_area);
2728 $this->error =
$object->error;
2729 $this->errors =
$object->errors;
2730 $action =
'add_message';
2733 if (!$error && $id > 0) {
2734 setEventMessages($langs->trans(
'TicketMessageSuccessfullyAdded'),
null,
'mesgs');
2736 if (!empty($public_area)) {
2744 $internal_contacts =
$object->getInfosTicketInternalContact(1);
2746 $assigned_user_dont_have_email =
'';
2750 if ($this->fk_user_assign > 0) {
2751 $assigned_user =
new User($this->db);
2752 $assigned_user->fetch($this->fk_user_assign);
2753 if (!empty($assigned_user->email)) {
2754 $sendto[$assigned_user->email] = $assigned_user->getFullName($langs).
" <".$assigned_user->email.
">";
2756 $assigned_user_dont_have_email = $assigned_user->getFullName($langs);
2761 foreach ($internal_contacts as $key => $info_sendto) {
2763 if ($info_sendto[
'id'] == $user->id) {
2768 if (!empty($info_sendto[
'email']) && $assigned_user->email != $info_sendto[
'email']) {
2769 $sendto[] =
dolGetFirstLastname($info_sendto[
'firstname'], $info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">";
2773 if (empty($sendto)) {
2788 if (!empty($sendto)) {
2791 $subject =
'['.$appli.
'- ticket #'.
$object->track_id.
'] '.$this->subject;
2794 $message =
getDolGlobalString(
'TICKET_MESSAGE_MAIL_INTRO', $langs->trans(
'TicketMessageMailIntroText'));
2795 $message .=
'<br><br>';
2796 $messagePost =
GETPOST(
'message',
'restricthtml');
2800 $message .= $messagePost;
2803 $message .=
'<br><br>';
2804 $message .=
"==============================================";
2805 $message .= !empty(
$object->thirdparty->name) ?
'<br>'.$langs->trans(
'Thirdparty').
" : ".
$object->thirdparty->name :
'';
2806 $message .= !empty(
$object->thirdparty->town) ?
'<br>'.$langs->trans(
'Town').
" : ".
$object->thirdparty->town :
'';
2807 $message .= !empty(
$object->thirdparty->phone) ?
'<br>'.$langs->trans(
'Phone').
" : ".
$object->thirdparty->phone :
'';
2810 $message .=
'<br><br>';
2811 if (!empty($assigned_user_dont_have_email)) {
2812 $message .=
'<br>'.$langs->trans(
'NoEMail').
' : '.$assigned_user_dont_have_email;
2814 foreach ($sendto as $val) {
2815 $message .=
'<br>'.$langs->trans(
'TicketNotificationRecipient').
' : '.$val;
2820 $message .=
'<br><br>';
2821 $message .= $langs->trans(
'TicketNotificationEmailBodyInfosTrackUrlinternal').
' : <a href="'.$url_internal_ticket.
'">'.
$object->track_id.
'</a>';
2823 $this->sendTicketMessageByEmail($subject, $message,
'', $sendto, $listofpaths, $listofmimes, $listofnames);
2832 if ($send_email > 0) {
2834 $internal_contacts =
$object->getInfosTicketInternalContact(1);
2837 if (is_array($internal_contacts) && count($internal_contacts) > 0) {
2841 $subject =
GETPOST(
'subject',
'alphanohtml') ?
GETPOST(
'subject',
'alphanohtml') :
'['.$appli.
' - '.$langs->trans(
"Ticket").
' #'.
$object->track_id.
'] '.$langs->trans(
'TicketNewMessage');
2843 $message_intro = $langs->trans(
'TicketNotificationEmailBody',
"#".
$object->id);
2846 $message =
getDolGlobalString(
'TICKET_MESSAGE_MAIL_INTRO', $langs->trans(
'TicketMessageMailIntroText'));
2847 $message .=
'<br><br>';
2848 $messagePost =
GETPOST(
'message',
'restricthtml');
2852 $message .= $messagePost;
2855 $message .=
'<br><br>';
2856 $message .=
"==============================================<br>";
2857 $message .= !empty(
$object->thirdparty->name) ? $langs->trans(
'Thirdparty').
" : ".
$object->thirdparty->name :
'';
2858 $message .= !empty(
$object->thirdparty->town) ?
'<br>'.$langs->trans(
'Town').
" : ".
$object->thirdparty->town :
'';
2859 $message .= !empty(
$object->thirdparty->phone) ?
'<br>'.$langs->trans(
'Phone').
" : ".
$object->thirdparty->phone :
'';
2862 foreach ($internal_contacts as $key => $info_sendto) {
2864 if ($info_sendto[
'id'] == $user->id) {
2868 if ($info_sendto[
'email'] !=
'') {
2869 if (!empty($info_sendto[
'email'])) {
2870 $sendto[$info_sendto[
'email']] =
dolGetFirstLastname($info_sendto[
'firstname'], $info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">";
2874 $recipient =
dolGetFirstLastname($info_sendto[
'firstname'], $info_sendto[
'lastname'],
'-1').
' ('.strtolower($info_sendto[
'libelle']).
')';
2875 $message .= (!empty($recipient) ? $langs->trans(
'TicketNotificationRecipient').
' : '.$recipient.
'<br>' :
'');
2883 $message .=
'<br>'.$langs->trans(
'TicketNotificationEmailBodyInfosTrackUrlinternal').
' : <a href="'.$url_internal_ticket.
'">'.
$object->track_id.
'</a><br>';
2893 if (!empty($sendto)) {
2894 $this->sendTicketMessageByEmail($subject, $message,
'', $sendto, $listofpaths, $listofmimes, $listofnames);
2901 if (empty(
$object->private)) {
2903 $external_contacts =
$object->getInfosTicketExternalContact(1);
2906 if (is_array($external_contacts) && count($external_contacts) === 0) {
2907 if (!empty(
$object->fk_soc)) {
2909 $array_company = array(array(
'firstname' =>
'',
'lastname' =>
$object->thirdparty->name,
'email' =>
$object->thirdparty->email,
'libelle' => $langs->transnoentities(
'Customer'),
'socid' =>
$object->thirdparty->id));
2910 $external_contacts = array_merge($external_contacts, $array_company);
2911 } elseif (empty(
$object->fk_soc) && !empty(
$object->origin_replyto)) {
2912 $array_external = array(array(
'firstname' =>
'',
'lastname' =>
$object->origin_replyto,
'email' =>
$object->origin_replyto,
'libelle' => $langs->transnoentities(
'Customer'),
'socid' => 0));
2913 $external_contacts = array_merge($external_contacts, $array_external);
2914 } elseif (empty(
$object->fk_soc) && !empty(
$object->origin_email)) {
2915 $array_external = array(array(
'firstname' =>
'',
'lastname' =>
$object->origin_email,
'email' =>
$object->thirdparty->email,
'libelle' => $langs->transnoentities(
'Customer'),
'socid' =>
$object->thirdparty->id));
2916 $external_contacts = array_merge($external_contacts, $array_external);
2921 if (is_array($external_contacts) && count($external_contacts) > 0) {
2925 $subject =
GETPOST(
'subject') ?
GETPOST(
'subject') :
'['.$appli.
' - '.$langs->trans(
"Ticket").
' #'.
$object->track_id.
'] '.$langs->trans(
'TicketNewMessage');
2930 $message_intro =
dol_nl2br($message_intro);
2933 $message_signature =
dol_nl2br($message_signature);
2937 $messagePost =
GETPOST(
'message',
'restricthtml');
2941 $message = $messagePost;
2942 $message .=
'<br><br>';
2944 foreach ($external_contacts as $key => $info_sendto) {
2946 if ($info_sendto[
'id'] == $user->contact_id) {
2950 if ($info_sendto[
'email'] !=
'' && $info_sendto[
'email'] !=
$object->origin_email) {
2951 if (!empty($info_sendto[
'email'])) {
2952 $sendto[$info_sendto[
'email']] = trim($info_sendto[
'firstname'].
" ".$info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">";
2955 $recipient =
dolGetFirstLastname($info_sendto[
'firstname'], $info_sendto[
'lastname'],
'-1').
' ('.strtolower($info_sendto[
'libelle']).
')';
2956 $message .= (!empty($recipient) ? $langs->trans(
'TicketNotificationRecipient').
' : '.$recipient.
'<br>' :
'');
2961 $url_public_ticket = (
getDolGlobalInt(
'TICKET_ENABLE_PUBLIC_INTERFACE') ?
2964 $message .=
'<br>'.$langs->trans(
'TicketNewEmailBodyInfosTrackUrlCustomer').
' : <a href="'.$url_public_ticket.
'">'.
$object->track_id.
'</a><br>';
2967 $message = $message_intro.
'<br><br>'.$message;
2970 $message .=
'<br>'.$message_signature;
2972 if (!empty(
$object->origin_replyto)) {
2974 } elseif (!empty(
$object->origin_email)) {
2978 if (
$object->fk_soc > 0 && !array_key_exists(
$object->origin_replyto, $sendto) && !array_key_exists(
$object->origin_email, $sendto)) {
2981 if (!empty(
$object->thirdparty->email)) {
2982 $sendto[
$object->thirdparty->email] =
$object->thirdparty->email;
2994 if (!empty($sendto)) {
2995 $result = $this->sendTicketMessageByEmail($subject, $message,
'', $sendto, $listofpaths, $listofmimes, $listofnames);
2998 $this->date_last_msg_sent =
dol_now();
2999 $this->update($user, 1);
3010 if ((
$object->status < self::STATUS_IN_PROGRESS && !$user->socid && !$private) ||
3011 (
$object->status > self::STATUS_IN_PROGRESS && $public_area)
3013 $object->setStatut($object::STATUS_IN_PROGRESS);
3039 public function sendTicketMessageByEmail($subject, $message, $send_internal_cc = 0, $array_receiver = array(), $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array())
3041 global $conf, $langs, $user;
3044 dol_syslog(get_class($this).
'::sendTicketMessageByEmail: Emails are disable into ticket setup by option TICKET_DISABLE_ALL_MAILS', LOG_WARNING);
3048 $langs->load(
"mails");
3050 include_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
3054 if (!is_array($array_receiver) || !count($array_receiver) > 0) {
3055 $array_receiver = $this->getInfosTicketInternalContact(1);
3056 $array_receiver = array_merge($array_receiver, $this->getInfosTicketExternalContact(1));
3060 if ($send_internal_cc) {
3066 if (is_array($array_receiver) && count($array_receiver) > 0) {
3067 foreach ($array_receiver as $key => $receiver) {
3068 $deliveryreceipt = 0;
3069 $filepath = $filename_list;
3070 $filename = $mimefilename_list;
3071 $mimetype = $mimetype_list;
3077 $conf->global->MAIN_MAIL_AUTOCOPY_TO =
'';
3080 $upload_dir_tmp = $conf->user->dir_output.
"/".$user->id.
'/temp';
3082 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
3083 $trackid =
"tic".$this->id;
3085 $moreinheader =
'X-Dolibarr-Info: sendTicketMessageByEmail'.
"\r\n";
3086 if (!empty($this->email_msgid)) {
3088 $moreinheader .=
'In-Reply-To: <'.$this->email_msgid.
'>'.
"\r\n";
3096 if (!empty($this->origin_references)) {
3097 $references .= (empty($references) ?
'' :
' ').$this->origin_references;
3099 if (!empty($this->email_msgid) && !preg_match(
'/'.preg_quote($this->email_msgid,
'/').
'/', $references)) {
3100 $references .= (empty($references) ?
'' :
' ').
'<'.$this->email_msgid.
'>';
3103 $moreinheader .=
'References: '.$references.
"\r\n";
3107 $mailfile =
new CMailFile($subject, $receiver, $from, $message, $filepath, $mimetype, $filename, $sendtocc,
'', $deliveryreceipt, -1,
'',
'', $trackid, $moreinheader,
'ticket',
'', $upload_dir_tmp);
3109 if ($mailfile->error) {
3112 $result = $mailfile->sendfile();
3114 setEventMessages($langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($receiver, 2)),
null,
'mesgs');
3117 $langs->load(
"other");
3118 if ($mailfile->error) {
3119 setEventMessages($langs->trans(
'ErrorFailedToSendMail', $from, $receiver),
null,
'errors');
3120 dol_syslog($langs->trans(
'ErrorFailedToSendMail', $from, $receiver).
' : '.$mailfile->error);
3122 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'errors');
3128 $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
3132 $langs->load(
"other");
3133 setEventMessages($langs->trans(
'ErrorMailRecipientIsEmptyForSendTicketMessage'),
null,
'warnings');
3150 global $user, $langs;
3157 $sql =
"SELECT p.rowid, p.ref, p.datec as datec";
3158 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as p";
3159 if (isModEnabled(
'societe') && !$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
3160 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON p.fk_soc = sc.fk_soc";
3161 $sql .=
" WHERE sc.fk_user = ".((int) $user->id);
3164 $sql .= $clause.
" p.entity IN (".
getEntity(
'ticket').
")";
3165 if ($mode ==
'opened') {
3166 $sql .=
" AND p.fk_statut NOT IN (".Ticket::STATUS_CLOSED.
", ".Ticket::STATUS_CANCELED.
")";
3169 $sql .=
" AND p.fk_soc = ".((int) $user->socid);
3172 $resql = $this->db->query($sql);
3174 $label = $labelShort =
'';
3176 if ($mode ==
'opened') {
3177 $status =
'openall';
3180 $label = $langs->trans(
"MenuListNonClosed");
3181 $labelShort = $langs->trans(
"MenuListNonClosed");
3186 $response->label = $label;
3187 $response->labelShort = $labelShort;
3188 $response->url = DOL_URL_ROOT.
'/ticket/list.php?search_fk_statut[]='.$status;
3192 while ($obj = $this->db->fetch_object($resql)) {
3193 $response->nbtodo++;
3194 if ($mode ==
'opened') {
3195 $datelimit = $this->db->jdate($obj->datec) + $delay_warning;
3196 if ($datelimit < $now) {
3203 $this->error = $this->db->lasterror();
3217 $this->nb = array();
3220 $sql =
"SELECT count(p.rowid) as nb";
3221 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as p";
3222 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON p.fk_soc = s.rowid";
3223 if (!$user->hasRight(
'societe',
'client',
'voir')) {
3224 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
3225 $sql .=
" WHERE sc.fk_user = ".((int) $user->id);
3228 $sql .=
" ".$clause.
" p.entity IN (".
getEntity(
'ticket').
")";
3230 $resql = $this->db->query($sql);
3233 while ($obj = $this->db->fetch_object($resql)) {
3234 $this->nb[
"ticket"] = $obj->nb;
3236 $this->db->free($resql);
3240 $this->error = $this->db->lasterror();
3255 $tables = array(
'ticket');
3271 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
3273 $return =
'<div class="box-flex-item box-flex-grow-zero">';
3274 $return .=
'<div class="info-box info-box-sm">';
3275 $return .=
'<span class="info-box-icon bg-infobox-action">';
3277 $return .=
'</span>';
3278 $return .=
'<div class="info-box-content">';
3279 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->getNomUrl(1) : $this->ref).
'</span>';
3280 if ($selected >= 0) {
3281 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
3283 if (!empty($arraydata[
'user_assignment'])) {
3284 $return .=
'<br><span class="info-box-label" title="'.dol_escape_htmltag($langs->trans(
"AssignedTo")).
'">'.$arraydata[
'user_assignment'].
'</span>';
3286 if (property_exists($this,
'type_code') && !empty($this->type_code)) {
3288 $return .=
'<div class="tdoverflowmax125 inline-block">'.$langs->getLabelFromKey($this->db,
'TicketTypeShort'.$this->type_code,
'c_ticket_type',
'code',
'label', $this->type_code).
'</div>';
3290 if (method_exists($this,
'getLibStatut')) {
3291 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
3293 $return .=
'</div>';
3294 $return .=
'</div>';
3295 $return .=
'</div>';
3311 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
3315 $langs->load(
"ticket");
3316 $outputlangs->load(
"ticket");
3319 $modele =
'generic_ticket_odt';
3321 if (!empty($this->model_pdf)) {
3322 $modele = $this->model_pdf;
3328 $modelpath =
"core/modules/ticket/doc/";
3330 return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Class to manage agenda events (actions)
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage categories.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
call_trigger($triggerName, $user)
Call trigger based on this instance.
add_contact($fk_socpeople, $type_contact, $source='external', $notrigger=0)
Add a link between element $this->element and a contact.
Class to manage ECM files.
Class to manage interventions.
Class to manage third parties objects (customers, suppliers, prospects...)
fetch($id=0, $ref='', $track_id='', $email_msgid='')
Load object in memory from the database.
fetchAll($user, $sortorder='ASC', $sortfield='t.datec', $limit=0, $offset=0, $arch=0, $filter='')
Load all objects in memory from database.
$email_from
Email from user.
static replaceThirdparty($db, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
listeContact($statusoflink=-1, $source='external', $list=0, $code='', $status=-1)
Get array of all contacts for a ticket Override method of file commonobject.class....
loadCacheMsgsTicket()
Load the list of event on ticket into ->cache_msgs_ticket.
setProgression($percent)
Define progression of current ticket.
searchSocidByEmail($email, $type=0, $filters=array(), $clause='AND')
Search and fetch thirparties by email.
loadCacheSeveritiesTickets()
Charge dans cache la liste des sévérité de tickets (paramétrable dans dictionnaire)
$fields
'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]',...
getInfosTicketExternalContact($status=-1)
Retrieve information about external contacts.
searchContactByEmail($email, $socid=0, $case='')
Search and fetch contacts by email.
getIdTicketCustomerInvolvedContact()
Return id des contacts clients des intervenants.
LibStatut($status, $mode=0, $notooltip=0, $progress=0)
Return status label of object.
setContract($contractid)
Link element with a contract.
getTicketAllContacts()
Return id of all contacts for ticket.
createFromClone(User $user, $fromid)
Load an object from its id and create a new one in database.
assignUser($user, $id_assign_user, $notrigger=0)
Set an assigned user to a ticket.
loadStateBoard()
Load indicator this->nb of global stats widget.
getTooltipContentArray($params)
getTooltipContentArray
getKanbanView($option='', $arraydata=null)
Return clicable link of object (with eventually picto)
printSelectStatus($selected="")
Print selected status.
is_photo_available($sdir)
Return if at least one photo is available.
getIdTicketInternalContact()
Return id des contacts interne de suivi.
update($user, $notrigger=0)
Update object into database.
loadCacheCategoriesTickets($publicgroup=-1)
Load into a cache array, the list of ticket categories (setup done into dictionary)
setCustomer($id)
Define parent commany of current ticket.
markAsRead($user, $notrigger=0)
Mark a message as read.
getDefaultRef($thirdparty=null)
Get a default reference.
sendTicketMessageByEmail($subject, $message, $send_internal_cc=0, $array_receiver=array(), $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array())
Send ticket by email to linked contacts.
const STATUS_NOT_READ
Status.
__construct($db)
Constructor.
getTicketAllCustomerContacts()
Return id of all contacts for ticket.
$category_label
Category label.
$origin_references
References from origin email.
$severity_label
Severity label.
createTicketMessage($user, $notrigger=0, $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array(), $send_email=false, $public_area=0)
Add message into database.
verify()
Check properties of ticket are ok (like ref, track_id, ...).
setCategories($categories)
Sets object to supplied categories.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
newMessage($user, &$action, $private=1, $public_area=0)
Add new message on a ticket (private/public area).
$subject
var string Ticket subject
getIdTicketCustomerContact()
Return id des contacts clients pour le suivi ticket.
checkExistingRef(string $action, string $getRef)
Check if ref exists or not.
loadCacheTypesTickets()
Load into a cache the types of tickets (setup done into dictionaries)
getLibStatut($mode=0)
Return status label of object.
close(User $user, $mode=0)
Close a ticket.
$origin_replyto
Email to reply to.
getIdTicketInternalInvolvedContact()
Return id des contacts clients des intervenants.
copyFilesForTicket($forcetrackid=null)
Copy files defined into $_SESSION array into the ticket directory of attached files.
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
load_board($user, $mode)
Load indicators for dashboard (this->nbtodo and this->nbtodolate)
getInfosTicketInternalContact($status=-1)
Retrieve information about internal contacts.
create($user, $notrigger=0)
Create object into database.
Class to manage Dolibarr users.
dirbasename($pathfile)
Return the relative dirname (relative to DOL_DATA_ROOT) of a full path string.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_move($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=1, $moreinfo=array())
Move a file into another name.
dol_is_file($pathoffile)
Return if path is a file.
dol_is_dir($folder)
Test if filename is a directory.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
utf8_check($str)
Check if a string is in UTF8.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
vignette($file, $maxWidth=160, $maxHeight=120, $extName='_small', $quality=50, $outdir='thumbs', $targetformat=0)
Create a thumbnail from an image file (Supported extensions are gif, jpg, png and bmp).
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
Class to generate the form for creating a new ticket.
generate_random_id($car=16)
Generate a random id.