33require_once DOL_DOCUMENT_ROOT.
"/core/class/commonobject.class.php";
34require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/ticket.lib.php';
51 public $element =
'ticket';
56 public $table_element =
'ticket';
61 public $fk_element =
'fk_ticket';
66 public $picto =
'ticket';
96 public $fk_user_create;
101 public $fk_user_assign;
153 public $category_code;
158 public $severity_code;
168 public $category_label;
173 public $severity_label;
183 public $origin_replyto;
188 public $origin_references;
203 public $date_last_msg_sent;
213 public $cache_types_tickets;
218 public $cache_msgs_ticket;
223 public $notify_tiers_at_create;
248 public $regeximgext =
'\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm';
254 const STATUS_READ = 1;
255 const STATUS_ASSIGNED = 2;
256 const STATUS_IN_PROGRESS = 3;
257 const STATUS_NEED_MORE_INFO = 5;
258 const STATUS_WAITING = 7;
259 const STATUS_CLOSED = 8;
260 const STATUS_CANCELED = 9;
291 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'visible' => -2,
'enabled' => 1,
'position' => 1,
'notnull' => 1,
'index' => 1,
'comment' =>
"Id"),
292 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'visible' => 0,
'enabled' => 1,
'position' => 5,
'notnull' => 1,
'index' => 1),
293 '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),
294 'track_id' => array(
'type' =>
'varchar(255)',
'label' =>
'TicketTrackId',
'visible' => -2,
'enabled' => 1,
'position' => 11,
'notnull' => -1,
'searchall' => 1,
'help' =>
"Help text"),
295 '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'),
296 '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'),
297 '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'),
298 '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'),
299 '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),
300 'type_code' => array(
'type' =>
'varchar(32)',
'label' =>
'Type',
'visible' => 1,
'enabled' => 1,
'position' => 20,
'notnull' => -1,
'help' =>
"",
'csslist' =>
'tdoverflowmax100'),
301 'category_code' => array(
'type' =>
'varchar(32)',
'label' =>
'TicketCategory',
'visible' => -1,
'enabled' => 1,
'position' => 21,
'notnull' => -1,
'help' =>
"",
'css' =>
'maxwidth100 tdoverflowmax200'),
302 'severity_code' => array(
'type' =>
'varchar(32)',
'label' =>
'Severity',
'visible' => 1,
'enabled' => 1,
'position' => 22,
'notnull' => -1,
'help' =>
"",
'css' =>
'maxwidth100 tdoverflowmax100'),
303 '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'),
304 'notify_tiers_at_create' => array(
'type' =>
'integer',
'label' =>
'NotifyThirdparty',
'visible' => -1,
'enabled' => 0,
'position' => 51,
'notnull' => 1,
'index' => 1),
305 'fk_project' => array(
'type' =>
'integer:Project:projet/class/project.class.php',
'label' =>
'Project',
'visible' => -1,
'enabled' =>
'isModEnabled("project")',
'position' => 52,
'notnull' => -1,
'index' => 1,
'help' =>
"LinkToProject"),
306 'fk_contract' => array(
'type' =>
'integer:Contrat:contrat/class/contrat.class.php',
'label' =>
'Contract',
'visible' => -1,
'enabled' =>
'isModEnabled("contract")',
'position' => 53,
'notnull' => -1,
'index' => 1,
'help' =>
"LinkToContract"),
308 'datec' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'visible' => 1,
'enabled' => 1,
'position' => 500,
'notnull' => 1,
'csslist' =>
'nowraponall'),
309 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'visible' => -1,
'enabled' => 1,
'position' => 501,
'notnull' => 1),
310 'date_read' => array(
'type' =>
'datetime',
'label' =>
'DateReading',
'visible' => -1,
'enabled' => 1,
'position' => 505,
'notnull' => 1,
'csslist' =>
'nowraponall'),
311 'date_last_msg_sent' => array(
'type' =>
'datetime',
'label' =>
'TicketLastMessageDate',
'visible' => 0,
'enabled' => 1,
'position' => 506,
'notnull' => -1),
312 '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'),
313 'date_close' => array(
'type' =>
'datetime',
'label' =>
'TicketCloseOn',
'visible' => -1,
'enabled' => 1,
'position' => 510,
'notnull' => 1),
314 'message' => array(
'type' =>
'html',
'label' =>
'Message',
'visible' => -2,
'enabled' => 1,
'position' => 540,
'notnull' => -1,),
315 'note_private' => array(
'type' =>
'html',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => 0,
'position' => 110),
316 'note_public' => array(
'type' =>
'html',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => 0,
'position' => 115),
317 'email_msgid' => array(
'type' =>
'varchar(255)',
'label' =>
'EmailMsgID',
'visible' => -2,
'enabled' => 1,
'position' => 540,
'notnull' => -1,
'help' =>
'EmailMsgIDDesc',
'csslist' =>
'tdoverflowmax100'),
318 'email_date' => array(
'type' =>
'datetime',
'label' =>
'EmailDate',
'visible' => -2,
'enabled' => 1,
'position' => 541),
319 'progress' => array(
'type' =>
'integer',
'label' =>
'Progression',
'visible' => -1,
'enabled' => 1,
'position' => 540,
'notnull' => -1,
'css' =>
'right',
'help' =>
"",
'isameasure' => 1,
'csslist' =>
'width50'),
320 'resolution' => array(
'type' =>
'integer',
'label' =>
'Resolution',
'visible' => -1,
'enabled' =>
'getDolGlobalString("TICKET_ENABLE_RESOLUTION")',
'position' => 550,
'notnull' => 1),
321 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'PDFTemplate',
'enabled' => 1,
'visible' => 0,
'position' => 560),
322 'extraparams' => array(
'type' =>
'varchar(255)',
'label' =>
'Extraparams',
'enabled' => 1,
'visible' => 0,
'position' => 570),
323 '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')),
324 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 900),
338 $this->ismultientitymanaged = 1;
339 $this->isextrafieldmanaged = 1;
341 $this->labelStatusShort = array(
342 self::STATUS_NOT_READ =>
'Unread',
343 self::STATUS_READ =>
'Read',
344 self::STATUS_ASSIGNED =>
'Assigned',
345 self::STATUS_IN_PROGRESS =>
'InProgress',
346 self::STATUS_NEED_MORE_INFO =>
'NeedMoreInformationShort',
347 self::STATUS_WAITING =>
'OnHold',
348 self::STATUS_CLOSED =>
'SolvedClosed',
349 self::STATUS_CANCELED =>
'Canceled'
351 $this->labelStatus = array(
352 self::STATUS_NOT_READ =>
'Unread',
353 self::STATUS_READ =>
'Read',
354 self::STATUS_ASSIGNED =>
'Assigned',
355 self::STATUS_IN_PROGRESS =>
'InProgress',
356 self::STATUS_NEED_MORE_INFO =>
'NeedMoreInformation',
357 self::STATUS_WAITING =>
'OnHold',
358 self::STATUS_CLOSED =>
'SolvedClosed',
359 self::STATUS_CANCELED =>
'Canceled'
363 unset($this->fields[
'fk_statut'][
'arrayofkeyval'][self::STATUS_WAITING]);
364 unset($this->labelStatusShort[self::STATUS_WAITING]);
365 unset($this->labelStatus[self::STATUS_WAITING]);
377 $this->errors = array();
382 if (isset($this->
ref)) {
383 $this->
ref = trim($this->
ref);
386 if (isset($this->track_id)) {
387 $this->track_id = trim($this->track_id);
390 if (isset($this->fk_soc)) {
391 $this->fk_soc = (int) $this->fk_soc;
394 if (isset($this->fk_project)) {
395 $this->fk_project = (int) $this->fk_project;
398 if (isset($this->origin_email)) {
399 $this->origin_email = trim($this->origin_email);
402 if (isset($this->fk_user_create)) {
403 $this->fk_user_create = (int) $this->fk_user_create;
406 if (isset($this->fk_user_assign)) {
407 $this->fk_user_assign = (int) $this->fk_user_assign;
410 if (isset($this->subject)) {
411 $this->subject = trim($this->subject);
414 if (isset($this->message)) {
415 $this->message = trim($this->message);
417 if (strlen($this->message) >
getDolGlobalInt(
'TICKET_MAX_LENGTH_FOR_MESSAGE', 16000000)) {
419 $langs->loadLangs(array(
'errors',
'ticket'));
420 $this->errors[] = $langs->trans(
'ErrorFieldTooLong', $langs->transnoentitiesnoconv(
'InitialMessage'));
421 dol_syslog(get_class($this).
'::create error -1 message too long', LOG_ERR);
426 if (isset($this->
status)) {
430 if (isset($this->resolution)) {
431 $this->resolution = (int) $this->resolution;
434 if (isset($this->progress)) {
435 $this->progress = (int) $this->progress;
438 if (isset($this->timing)) {
439 $this->timing = trim($this->timing);
442 if (isset($this->type_code)) {
443 $this->type_code = trim($this->type_code);
446 if (isset($this->category_code)) {
447 $this->category_code = trim($this->category_code);
450 if (isset($this->severity_code)) {
451 $this->severity_code = trim($this->severity_code);
454 if (empty($this->
ref)) {
455 $this->errors[] =
'ErrorTicketRefRequired';
456 dol_syslog(get_class($this).
"::create error -1 ref null", LOG_ERR);
472 $test =
new self($this->db);
474 if ($test->fetch(0, $getRef) > 0) {
475 if (($action ==
'add') || ($action ==
'update' && $this->
ref != $getRef)) {
480 $this->
ref = $getRef;
491 public function create($user, $notrigger = 0)
498 if (empty($this->datec)) {
501 if (empty($this->track_id)) {
507 $result = $this->
verify();
514 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"ticket(";
518 $sql .=
"fk_project,";
519 $sql .=
"fk_contract,";
520 $sql .=
"origin_email,";
521 $sql .=
"origin_replyto,";
522 $sql .=
"origin_references,";
523 $sql .=
"fk_user_create,";
524 $sql .=
"fk_user_assign,";
525 $sql .=
"email_msgid,";
526 $sql .=
"email_date,";
529 $sql .=
"note_private,";
530 $sql .=
"note_public,";
531 $sql .=
"fk_statut,";
532 $sql .=
"resolution,";
535 $sql .=
"type_code,";
536 $sql .=
"category_code,";
537 $sql .=
"severity_code,";
539 $sql .=
"date_read,";
540 $sql .=
"date_close,";
542 $sql .=
"notify_tiers_at_create,";
543 $sql .=
"model_pdf,";
545 $sql .=
") VALUES (";
546 $sql .=
" ".(!isset($this->
ref) ?
'' :
"'".$this->db->escape($this->
ref).
"'").
",";
547 $sql .=
" ".(!isset($this->track_id) ?
'NULL' :
"'".$this->db->escape($this->track_id).
"'").
",";
548 $sql .=
" ".($this->fk_soc > 0 ? ((int) $this->fk_soc) :
"null").
",";
549 $sql .=
" ".($this->fk_project > 0 ? ((int) $this->fk_project) :
"null").
",";
550 $sql .=
" ".($this->fk_contract > 0 ? ((int) $this->fk_contract) :
"null").
",";
551 $sql .=
" ".(!isset($this->origin_email) ?
'NULL' :
"'".$this->db->escape($this->origin_email).
"'").
",";
552 $sql .=
" ".(!isset($this->origin_replyto) ?
'NULL' :
"'".$this->db->escape($this->origin_replyto).
"'").
",";
553 $sql .=
" ".(!isset($this->origin_references) ?
'NULL' :
"'".$this->db->escape($this->origin_references).
"'").
",";
554 $sql .=
" ".(!isset($this->fk_user_create) ? ($user->id > 0 ? ((int) $user->id) :
'NULL') : ($this->fk_user_create > 0 ? ((int) $this->fk_user_create) :
'NULL')).
",";
555 $sql .=
" ".($this->fk_user_assign > 0 ? ((int) $this->fk_user_assign) :
'NULL').
",";
556 $sql .=
" ".(empty($this->email_msgid) ?
'NULL' :
"'".$this->db->escape($this->email_msgid).
"'").
",";
557 $sql .=
" ".(!
isDolTms($this->email_date) ?
'NULL' :
"'".$this->db->idate($this->email_date).
"'").
",";
558 $sql .=
" ".(!isset($this->subject) ?
'NULL' :
"'".$this->db->escape($this->subject).
"'").
",";
559 $sql .=
" ".(!isset($this->message) ?
'NULL' :
"'".$this->db->escape($this->message).
"'").
",";
560 $sql .=
" ".(!isset($this->note_private) ?
'NULL' :
"'".$this->db->escape($this->note_private).
"'").
",";
561 $sql .=
" ".(!isset($this->note_public) ?
'NULL' :
"'".$this->db->escape($this->note_public).
"'").
",";
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 .=
" ".(!
isDolTms($this->datec) ?
'NULL' :
"'".$this->db->idate($this->datec).
"'").
",";
570 $sql .=
" ".(!isset($this->date_read) ||
dol_strlen((
string) $this->date_read) == 0 ?
'NULL' :
"'".$this->db->idate($this->date_read).
"'").
",";
571 $sql .=
" ".(!isset($this->date_close) ||
dol_strlen((
string) $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) {
626 $result = $this->call_trigger(
'TICKET_CREATE', $user);
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 dol_syslog(get_class($this).
"::Create fails verify ".implode(
',', $this->errors), LOG_WARNING);
660 public function fetch(
$id = 0, $ref =
'', $track_id =
'', $email_msgid =
'')
665 if (empty(
$id) && empty($ref) && empty($track_id) && empty($email_msgid)) {
666 $this->error =
'ErrorWrongParameters';
667 dol_print_error(
null, get_class($this).
"::fetch ".$this->error);
673 $sql .=
" t.entity,";
675 $sql .=
" t.track_id,";
676 $sql .=
" t.fk_soc,";
677 $sql .=
" t.fk_project,";
678 $sql .=
" t.fk_contract,";
679 $sql .=
" t.origin_email,";
680 $sql .=
" t.origin_replyto,";
681 $sql .=
" t.origin_references,";
682 $sql .=
" t.fk_user_create,";
683 $sql .=
" t.fk_user_assign,";
684 $sql .=
" t.email_msgid,";
685 $sql .=
" t.email_date,";
686 $sql .=
" t.subject,";
687 $sql .=
" t.message,";
688 $sql .=
" t.note_private,";
689 $sql .=
" t.note_public,";
690 $sql .=
" t.fk_statut as status,";
691 $sql .=
" t.resolution,";
692 $sql .=
" t.progress,";
693 $sql .=
" t.timing,";
694 $sql .=
" t.type_code,";
695 $sql .=
" t.category_code,";
696 $sql .=
" t.severity_code,";
698 $sql .=
" t.date_read,";
699 $sql .=
" t.date_last_msg_sent,";
700 $sql .=
" t.date_close,";
702 $sql .=
" t.model_pdf,";
703 $sql .=
" t.extraparams,";
705 $sql .=
" type.label as type_label, category.label as category_label, severity.label as severity_label";
706 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as t";
707 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_type as type ON type.code=t.type_code";
708 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_category as category ON category.code=t.category_code";
709 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_severity as severity ON severity.code=t.severity_code";
712 $sql .=
" WHERE t.rowid = ".((int)
$id);
714 $sql .=
" WHERE t.entity IN (".getEntity($this->element, 1).
")";
716 $sql .=
" AND t.ref = '".$this->db->escape($ref).
"'";
717 } elseif ($track_id) {
718 $sql .=
" AND t.track_id = '".$this->db->escape($track_id).
"'";
720 $sql .=
" AND t.email_msgid = '".$this->db->escape($email_msgid).
"'";
724 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
725 $resql = $this->db->query($sql);
727 if ($this->db->num_rows($resql)) {
728 $obj = $this->db->fetch_object($resql);
730 $this->
id = $obj->rowid;
731 $this->entity = $obj->entity;
732 $this->
ref = $obj->ref;
733 $this->track_id = $obj->track_id;
734 $this->fk_soc = $obj->fk_soc;
735 $this->socid = $obj->fk_soc;
736 $this->fk_project = $obj->fk_project;
737 $this->fk_contract = $obj->fk_contract;
738 $this->origin_email = $obj->origin_email;
739 $this->origin_replyto = $obj->origin_replyto;
740 $this->origin_references = $obj->origin_references;
741 $this->fk_user_create = $obj->fk_user_create;
742 $this->fk_user_assign = $obj->fk_user_assign;
743 $this->email_msgid = $obj->email_msgid;
744 $this->email_date = $this->db->jdate($obj->email_date);
745 $this->subject = $obj->subject;
746 $this->message = $obj->message;
747 $this->note_private = $obj->note_private;
748 $this->note_public = $obj->note_public;
749 $this->model_pdf = $obj->model_pdf;
750 $this->extraparams = !empty($obj->extraparams) ? (array) json_decode($obj->extraparams,
true) : array();
751 $this->ip = $obj->ip;
753 $this->
status = $obj->status;
754 $this->fk_statut = $this->status;
756 $this->resolution = $obj->resolution;
757 $this->progress = $obj->progress;
758 $this->timing = $obj->timing;
760 $this->type_code = $obj->type_code;
762 $label_type = (is_object($langs) && $langs->trans(
"TicketTypeShort".$obj->type_code) !=
"TicketTypeShort".$obj->type_code ? $langs->trans(
"TicketTypeShort".$obj->type_code) : ($obj->type_label !=
'-' ? $obj->type_label :
''));
763 $this->type_label = $label_type;
765 $this->category_code = $obj->category_code;
766 $label_category = (is_object($langs) && $langs->trans(
"TicketCategoryShort".$obj->category_code) !=
"TicketCategoryShort".$obj->category_code ? $langs->trans(
"TicketCategoryShort".$obj->category_code) : ($obj->category_label !=
'-' ? $obj->category_label :
''));
767 $this->category_label = $label_category;
769 $this->severity_code = $obj->severity_code;
770 $label_severity = (is_object($langs) && $langs->trans(
"TicketSeverityShort".$obj->severity_code) !=
"TicketSeverityShort".$obj->severity_code ? $langs->trans(
"TicketSeverityShort".$obj->severity_code) : ($obj->severity_label !=
'-' ? $obj->severity_label :
''));
771 $this->severity_label = $label_severity;
773 $this->datec = $this->db->jdate($obj->datec);
774 $this->date_creation = $this->db->jdate($obj->datec);
775 $this->date_read = $this->db->jdate($obj->date_read);
776 $this->date_validation = $this->db->jdate($obj->date_read);
777 $this->date_last_msg_sent = $this->db->jdate($obj->date_last_msg_sent);
778 $this->date_close = $this->db->jdate($obj->date_close);
779 $this->tms = $this->db->jdate($obj->tms);
780 $this->date_modification = $this->db->jdate($obj->tms);
784 $this->db->free($resql);
790 $this->error =
"Error ".$this->db->lasterror();
791 dol_syslog(get_class($this).
"::fetch ".$this->error, LOG_ERR);
808 public function fetchAll($user, $sortorder =
'ASC', $sortfield =
't.datec', $limit = 0, $offset = 0, $arch = 0, $filter =
'')
810 global $langs, $extrafields;
813 $extrafields->fetch_name_optionals_label($this->table_element);
818 $sql .=
" t.track_id,";
819 $sql .=
" t.fk_soc,";
820 $sql .=
" t.fk_project,";
821 $sql .=
" t.fk_contract,";
822 $sql .=
" t.origin_email,";
823 $sql .=
" t.origin_replyto,";
824 $sql .=
" t.origin_references,";
825 $sql .=
" t.fk_user_create, uc.lastname as user_create_lastname, uc.firstname as user_create_firstname,";
826 $sql .=
" t.fk_user_assign, ua.lastname as user_assign_lastname, ua.firstname as user_assign_firstname,";
827 $sql .=
" t.subject,";
828 $sql .=
" t.message,";
829 $sql .=
" t.note_private,";
830 $sql .=
" t.note_public,";
831 $sql .=
" t.fk_statut as status,";
832 $sql .=
" t.resolution,";
833 $sql .=
" t.progress,";
834 $sql .=
" t.timing,";
835 $sql .=
" t.type_code,";
836 $sql .=
" t.category_code,";
837 $sql .=
" t.severity_code,";
839 $sql .=
" t.date_read,";
840 $sql .=
" t.date_last_msg_sent,";
841 $sql .=
" t.date_close,";
843 $sql .=
" type.label as type_label, category.label as category_label, severity.label as severity_label";
845 if ($extrafields->attributes[$this->table_element][
'count'] > 0) {
846 foreach ($extrafields->attributes[$this->table_element][
'label'] as $key => $val) {
847 $sql .= ($extrafields->attributes[$this->table_element][
'type'][$key] !=
'separate' ?
",ef.".$key.
" as options_".$key :
'');
850 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as t";
851 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_type as type ON type.code = t.type_code";
852 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_category as category ON category.code = t.category_code";
853 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_severity as severity ON severity.code = t.severity_code";
854 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = t.fk_soc";
855 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as uc ON uc.rowid = t.fk_user_create";
856 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as ua ON ua.rowid = t.fk_user_assign";
857 if ($extrafields->attributes[$this->table_element][
'count'] > 0) {
858 if (is_array($extrafields->attributes[$this->table_element][
'label']) && count($extrafields->attributes[$this->table_element][
'label'])) {
859 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"ticket_extrafields as ef on (t.rowid = ef.fk_object)";
862 $sql .=
" WHERE t.entity IN (".getEntity(
'ticket').
")";
865 if (is_array($filter)) {
866 foreach ($filter as $key => $value) {
867 if (strpos($key,
'date')) {
868 $sql .=
" AND ".$this->db->sanitize($key).
" = '".$this->db->escape((
string) $value).
"'";
869 } elseif (($key ==
't.fk_user_assign') || ($key ==
't.type_code') || ($key ==
't.category_code') || ($key ==
't.severity_code') || ($key ==
't.fk_soc')) {
870 $sql .=
" AND ".$this->db->sanitize($key).
" = '".$this->db->escape((
string) $value).
"'";
871 } elseif ($key ==
't.fk_statut') {
872 if (is_array($value) && count($value) > 0) {
873 $sql .=
" AND ".$this->db->sanitize($key).
" IN (".$this->db->sanitize(implode(
',', $value)).
")";
875 $sql .=
" AND ".$this->db->sanitize($key).
' = '.((int) $value);
877 } elseif ($key ==
't.fk_contract') {
878 $sql .=
" AND ".$this->db->sanitize($key).
' = '.((int) $value);
880 $sql .=
" AND ".$this->db->sanitize($key).
" LIKE '%".$this->db->escape($this->db->escapeforlike((
string) $value)).
"%'";
891 $this->errors[] = $errormessage;
892 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
897 $socid = $user->socid ?: 0;
900 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
901 $search_sale = $user->id;
904 if ($search_sale && $search_sale !=
'-1') {
905 if ($search_sale == -2) {
906 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc)";
907 } elseif ($search_sale > 0) {
908 $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).
")";
913 $sql .=
" AND t.fk_soc = ".((int) $socid);
916 $sql .= $this->db->order($sortfield, $sortorder);
917 if (!empty($limit)) {
918 $sql .= $this->db->plimit($limit + 1, $offset);
921 dol_syslog(get_class($this).
"::fetchAll", LOG_DEBUG);
922 $resql = $this->db->query($sql);
925 $this->lines = array();
927 $num = $this->db->num_rows($resql);
932 $obj = $this->db->fetch_object($resql);
934 $line =
new self($this->db);
936 $line->id = $obj->rowid;
938 $line->ref = $obj->ref;
939 $line->track_id = $obj->track_id;
940 $line->fk_soc = $obj->fk_soc;
941 $line->fk_project = $obj->fk_project;
942 $line->fk_contract = $obj->fk_contract;
943 $line->origin_email = $obj->origin_email;
944 $line->origin_replyto = $obj->origin_replyto;
945 $line->origin_references = $obj->origin_references;
947 $line->fk_user_create = $obj->fk_user_create;
948 $line->fk_user_assign = $obj->fk_user_assign;
950 $line->subject = $obj->subject;
951 $line->message = $obj->message;
952 $line->note_private = $obj->note_private;
953 $line->note_public = $obj->note_public;
954 $line->fk_statut = $obj->status;
955 $line->status = $obj->status;
956 $line->resolution = $obj->resolution;
957 $line->progress = $obj->progress;
958 $line->timing = $obj->timing;
960 $label_type = ($langs->trans(
"TicketTypeShort".$obj->type_code) !=
"TicketTypeShort".$obj->type_code ? $langs->trans(
"TicketTypeShort".$obj->type_code) : ($obj->type_label !=
'-' ? $obj->type_label :
''));
961 $line->type_label = $label_type;
963 $this->category_code = $obj->category_code;
964 $label_category = ($langs->trans(
"TicketCategoryShort".$obj->category_code) !=
"TicketCategoryShort".$obj->category_code ? $langs->trans(
"TicketCategoryShort".$obj->category_code) : ($obj->category_label !=
'-' ? $obj->category_label :
''));
965 $line->category_label = $label_category;
967 $this->severity_code = $obj->severity_code;
968 $label_severity = ($langs->trans(
"TicketSeverityShort".$obj->severity_code) !=
"TicketSeverityShort".$obj->severity_code ? $langs->trans(
"TicketSeverityShort".$obj->severity_code) : ($obj->severity_label !=
'-' ? $obj->severity_label :
''));
969 $line->severity_label = $label_severity;
971 $line->datec = $this->db->jdate($obj->datec);
972 $line->date_read = $this->db->jdate($obj->date_read);
973 $line->date_last_msg_sent = $this->db->jdate($obj->date_last_msg_sent);
974 $line->date_close = $this->db->jdate($obj->date_close);
977 if ($extrafields->attributes[$this->table_element][
'count'] > 0) {
978 if (is_array($extrafields->attributes[$this->table_element][
'label']) && count($extrafields->attributes[$this->table_element][
'label'])) {
979 foreach ($extrafields->attributes[$this->table_element][
'label'] as $key => $val) {
980 $tmpkey =
'options_'.$key;
981 $line->{$tmpkey} = $obj->$tmpkey;
985 $this->lines[$i] = $line;
989 $this->db->free($resql);
992 $this->error =
"Error ".$this->db->lasterror();
993 dol_syslog(get_class($this).
"::fetchAll ".$this->error, LOG_ERR);
1005 public function update($user, $notrigger = 0)
1016 if (isset($this->
ref)) {
1017 $this->
ref = trim($this->
ref);
1020 if (isset($this->track_id)) {
1021 $this->track_id = trim($this->track_id);
1024 if (isset($this->fk_soc)) {
1025 $this->fk_soc = (int) $this->fk_soc;
1028 if (isset($this->fk_project)) {
1029 $this->fk_project = (int) $this->fk_project;
1032 if (isset($this->fk_contract)) {
1033 $this->fk_contract = (int) $this->fk_contract;
1036 if (isset($this->origin_email)) {
1037 $this->origin_email = trim($this->origin_email);
1040 if (isset($this->fk_user_create)) {
1041 $this->fk_user_create = (int) $this->fk_user_create;
1044 if (isset($this->fk_user_assign)) {
1045 $this->fk_user_assign = (int) $this->fk_user_assign;
1048 if (isset($this->subject)) {
1049 $this->subject = trim($this->subject);
1052 if (isset($this->message)) {
1053 $this->message = trim($this->message);
1055 if (strlen($this->message) >
getDolGlobalInt(
'TICKET_MAX_LENGTH_FOR_MESSAGE', 16000000)) {
1057 $langs->loadLangs(array(
'errors',
'ticket'));
1058 $this->errors[] = $langs->trans(
'ErrorFieldTooLong', $langs->transnoentitiesnoconv(
'InitialMessage'));
1059 dol_syslog(get_class($this).
'::update error -1 message too long', LOG_ERR);
1064 if (isset($this->
status)) {
1068 if (isset($this->resolution)) {
1069 $this->resolution = (int) $this->resolution;
1072 if (isset($this->progress)) {
1073 $this->progress = (int) $this->progress;
1076 if (isset($this->timing)) {
1077 $this->timing = trim($this->timing);
1080 if (isset($this->type_code)) {
1081 $this->type_code = trim($this->type_code);
1084 if (isset($this->category_code)) {
1085 $this->category_code = trim($this->category_code);
1088 if (isset($this->severity_code)) {
1089 $this->severity_code = trim($this->severity_code);
1091 if (isset($this->model_pdf)) {
1092 $this->model_pdf = trim($this->model_pdf);
1097 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket SET";
1098 $sql .=
" ref=".(isset($this->
ref) ?
"'".$this->db->escape($this->
ref).
"'" :
"").
",";
1099 $sql .=
" track_id=".(isset($this->track_id) ?
"'".$this->db->escape($this->track_id).
"'" :
"null").
",";
1100 $sql .=
" fk_soc=".(isset($this->fk_soc) ? (int) $this->fk_soc :
"null").
",";
1101 $sql .=
" fk_project=".(isset($this->fk_project) ? (int) $this->fk_project :
"null").
",";
1102 $sql .=
" fk_contract=".(isset($this->fk_contract) ? (int) $this->fk_contract :
"null").
",";
1103 $sql .=
" origin_email=".(isset($this->origin_email) ?
"'".$this->db->escape($this->origin_email).
"'" :
"null").
",";
1104 $sql .=
" origin_replyto=".(isset($this->origin_replyto) ?
"'".$this->db->escape($this->origin_replyto).
"'" :
"null").
",";
1105 $sql .=
" origin_references=".(isset($this->origin_references) ?
"'".$this->db->escape($this->origin_references).
"'" :
"null").
",";
1106 $sql .=
" fk_user_create=".(isset($this->fk_user_create) ? (int) $this->fk_user_create :
"null").
",";
1107 $sql .=
" fk_user_assign=".(isset($this->fk_user_assign) ? (int) $this->fk_user_assign :
"null").
",";
1108 $sql .=
" subject=".(isset($this->subject) ?
"'".$this->db->escape($this->subject).
"'" :
"null").
",";
1109 $sql .=
" message=".(isset($this->message) ?
"'".$this->db->escape($this->message).
"'" :
"null").
",";
1110 $sql .=
" note_private=".(isset($this->note_private) ?
"'".$this->db->escape($this->note_private).
"'" :
"null").
",";
1111 $sql .=
" note_public=".(isset($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null").
",";
1112 $sql .=
" fk_statut=".(isset($this->
status) ? (int) $this->
status :
"0").
",";
1113 $sql .=
" resolution=".(isset($this->resolution) ? (int) $this->resolution :
"null").
",";
1114 $sql .=
" progress=".(isset($this->progress) ?
"'".$this->db->escape((
string) $this->progress).
"'" :
"null").
",";
1115 $sql .=
" timing=".(isset($this->timing) ?
"'".$this->db->escape($this->timing).
"'" :
"null").
",";
1116 $sql .=
" type_code=".(isset($this->type_code) ?
"'".$this->db->escape($this->type_code).
"'" :
"null").
",";
1117 $sql .=
" category_code=".(isset($this->category_code) ?
"'".$this->db->escape($this->category_code).
"'" :
"null").
",";
1118 $sql .=
" severity_code=".(isset($this->severity_code) ?
"'".$this->db->escape($this->severity_code).
"'" :
"null").
",";
1119 $sql .=
" datec=".(isDolTms($this->datec) ?
"'".$this->db->idate($this->datec).
"'" :
'null').
",";
1120 $sql .=
" date_read=".(dol_strlen((
string) $this->date_read) != 0 ?
"'".$this->db->idate($this->date_read).
"'" :
'null').
",";
1121 $sql .=
" date_last_msg_sent=".(dol_strlen((
string) $this->date_last_msg_sent) != 0 ?
"'".$this->db->idate($this->date_last_msg_sent).
"'" :
'null').
",";
1122 $sql .=
" model_pdf=".(isset($this->model_pdf) ?
"'".$this->db->escape($this->model_pdf).
"'" :
"null").
",";
1123 $sql .=
" date_close=".(dol_strlen((
string) $this->date_close) != 0 ?
"'".$this->db->idate($this->date_close).
"'" :
'null');
1124 $sql .=
" WHERE rowid=".((int) $this->
id);
1128 $resql = $this->db->query($sql);
1131 $this->errors[] =
"Error ".$this->db->lasterror();
1136 $result = $this->insertExtraFields();
1142 if (!$error && !$notrigger) {
1144 $result = $this->call_trigger(
'TICKET_MODIFY', $user);
1153 foreach ($this->errors as $errmsg) {
1154 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
1155 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1157 $this->db->rollback();
1160 $this->db->commit();
1172 public function delete($user, $notrigger = 0)
1180 $result = $this->call_trigger(
'TICKET_DELETE', $user);
1189 $res = $this->delete_linked_contact();
1191 dol_syslog(get_class($this).
"::delete error", LOG_ERR);
1198 $res = $this->deleteObjectLinked();
1206 $result = $this->deleteExtraFields();
1209 dol_syslog(get_class($this).
"::delete error -3 ".$this->error, LOG_ERR);
1216 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_ticket";
1217 $sql .=
" WHERE fk_ticket = ".(int) $this->
id;
1219 $result = $this->db->query($sql);
1222 $this->errors[] = $this->db->lasterror();
1227 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"ticket";
1228 $sql .=
" WHERE rowid=".((int) $this->
id);
1230 dol_syslog(get_class($this).
"::delete sql=".$sql);
1231 $resql = $this->db->query($sql);
1234 $this->errors[] =
"Error ".$this->db->lasterror();
1237 $this->deleteEcmFiles(1);
1239 $dir = DOL_DATA_ROOT.
'/'.$this->element.
'/'.$this->ref;
1243 $this->errors[] = $this->error;
1251 foreach ($this->errors as $errmsg) {
1252 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
1253 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1255 $this->db->rollback();
1258 $this->db->commit();
1303 $object->context[
'createfromclone'] =
'createfromclone';
1304 $result =
$object->create($user);
1308 $this->error =
$object->error;
1312 unset(
$object->context[
'createfromclone']);
1316 $this->db->commit();
1319 $this->db->rollback();
1334 $this->
ref =
'TI0501-001';
1335 $this->track_id =
'XXXXaaaa';
1336 $this->origin_email =
'email@email.com';
1337 $this->fk_project = 1;
1338 $this->fk_user_create = 1;
1339 $this->fk_user_assign = 1;
1340 $this->subject =
'Subject of ticket';
1341 $this->message =
'Message of ticket';
1343 $this->resolution = 1;
1344 $this->progress = 10;
1346 $this->type_code =
'TYPECODE';
1347 $this->category_code =
'CATEGORYCODE';
1348 $this->severity_code =
'SEVERITYCODE';
1351 $this->date_last_msg_sent =
dol_now();
1352 $this->date_close =
dol_now();
1366 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 =
'');
1377 global $langs, $hookmanager;
1379 if (!empty($this->cache_types_tickets) && count($this->cache_types_tickets)) {
1386 $sql =
"SELECT rowid, entity, code, label, use_default, pos, description";
1387 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_type";
1388 $sql .=
" WHERE entity IN (".getEntity(
'c_ticket_type').
")";
1389 $sql .=
" AND active > 0";
1390 $sql .=
" ORDER BY pos";
1391 dol_syslog(get_class($this).
"::load_cache_type_tickets", LOG_DEBUG);
1392 $resql = $this->db->query($sql);
1394 $num = $this->db->num_rows($resql);
1397 $obj = $this->db->fetch_object($resql);
1398 $label = ($langs->trans(
"TicketTypeShort".$obj->code) !=
"TicketTypeShort".$obj->code ? $langs->trans(
"TicketTypeShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
1399 $this->cache_types_tickets[$obj->rowid][
'code'] = $obj->code;
1400 $this->cache_types_tickets[$obj->rowid][
'label'] = $label;
1401 $this->cache_types_tickets[$obj->rowid][
'use_default'] = $obj->use_default;
1402 $this->cache_types_tickets[$obj->rowid][
'pos'] = $obj->pos;
1403 $this->cache_types_tickets[$obj->rowid][
'entity'] = (int) $obj->entity;
1407 $parameters = array(
'dictionary' =>
'tickettype');
1408 $reshook = $hookmanager->executeHooks(
'loadDictionaryCache', $parameters, $this);
1409 if (empty($reshook)) {
1410 if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
1411 $this->cache_types_tickets = array_merge($this->cache_types_tickets, $hookmanager->resArray);
1414 $this->cache_types_tickets = $hookmanager->resArray;
1417 return count($this->cache_types_tickets);
1419 dol_print_error($this->db);
1432 global
$conf, $langs, $hookmanager;
1434 if ($publicgroup == -1 && !empty(
$conf->cache[
'category_tickets']) && count(
$conf->cache[
'category_tickets'])) {
1441 $sql =
"SELECT rowid, entity, code, label, use_default, pos, description, public, active, force_severity, fk_parent";
1442 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_category";
1443 $sql .=
" WHERE entity IN (".getEntity(
'c_ticket_category').
")";
1444 $sql .=
" AND active > 0";
1445 if ($publicgroup > -1) {
1446 $sql .=
" AND public = ".((int) $publicgroup);
1448 $sql .=
" ORDER BY pos";
1450 dol_syslog(get_class($this).
"::load_cache_categories_tickets", LOG_DEBUG);
1452 $resql = $this->db->query($sql);
1454 $num = $this->db->num_rows($resql);
1456 $categorytickets = array();
1457 '@phan-var-force array<int,array{code:string,label:string,use_default:int,pos:int,public:int,active:int,force_severity:?string,fk_parent:int}> $categorytickets';
1459 $obj = $this->db->fetch_object($resql);
1460 $categorytickets[$obj->rowid][
'code'] = $obj->code;
1461 $categorytickets[$obj->rowid][
'use_default'] = $obj->use_default;
1462 $categorytickets[$obj->rowid][
'pos'] = $obj->pos;
1463 $categorytickets[$obj->rowid][
'public'] = $obj->public;
1464 $categorytickets[$obj->rowid][
'active'] = $obj->active;
1465 $categorytickets[$obj->rowid][
'force_severity'] = $obj->force_severity;
1466 $categorytickets[$obj->rowid][
'fk_parent'] = $obj->fk_parent;
1470 $label = ($langs->trans(
"TicketCategoryShort".$obj->code) !=
"TicketCategoryShort".$obj->code ? $langs->trans(
"TicketCategoryShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
1471 $categorytickets[$obj->rowid][
'label'] = $label;
1472 $categorytickets[$obj->rowid][
'entity'] = (int) $obj->entity;
1476 $conf->cache[
'category_tickets'] = $categorytickets;
1478 $parameters = array(
'dictionary' =>
'ticketcategory',
'publicgroup' => $publicgroup);
1479 $reshook = $hookmanager->executeHooks(
'loadDictionaryCache', $parameters, $this);
1480 if (empty($reshook)) {
1481 if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
1482 $conf->cache[
'category_tickets'] = array_merge(
$conf->cache[
'category_tickets'], $hookmanager->resArray);
1485 $conf->cache[
'category_tickets'] = $hookmanager->resArray;
1488 return count(
$conf->cache[
'category_tickets']);
1490 dol_print_error($this->db);
1502 global
$conf, $langs, $hookmanager;
1504 if (!empty(
$conf->cache[
'severity_tickets']) && count(
$conf->cache[
'severity_tickets'])) {
1511 $sql =
"SELECT rowid, entity, code, label, use_default, pos, description";
1512 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_severity";
1513 $sql .=
" WHERE entity IN (".getEntity(
'c_ticket_severity').
")";
1514 $sql .=
" AND active > 0";
1515 $sql .=
" ORDER BY pos";
1516 dol_syslog(get_class($this).
"::loadCacheSeveritiesTickets", LOG_DEBUG);
1517 $resql = $this->db->query($sql);
1519 $num = $this->db->num_rows($resql);
1521 $severitytickets = array();
1522 '@phan-var-force array<int,array{code:string,label:string,use_default:int,pos:int}> $severitytickets';
1524 $obj = $this->db->fetch_object($resql);
1526 $severitytickets[$obj->rowid][
'code'] = $obj->code;
1527 $label = ($langs->trans(
"TicketSeverityShort".$obj->code) !=
"TicketSeverityShort".$obj->code ? $langs->trans(
"TicketSeverityShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
1528 $severitytickets[$obj->rowid][
'label'] = $label;
1529 $severitytickets[$obj->rowid][
'use_default'] = $obj->use_default;
1530 $severitytickets[$obj->rowid][
'pos'] = $obj->pos;
1531 $severitytickets[$obj->rowid][
'entity'] = (int) $obj->entity;
1534 $conf->cache[
'severity_tickets'] = $severitytickets;
1536 $parameters = array(
'dictionary' =>
'ticketseverity');
1537 $reshook = $hookmanager->executeHooks(
'loadDictionaryCache', $parameters, $this);
1538 if (empty($reshook)) {
1539 if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
1540 $conf->cache[
'severity_tickets'] = array_merge(
$conf->cache[
'severity_tickets'], $hookmanager->resArray);
1543 $conf->cache[
'severity_tickets'] = $hookmanager->resArray;
1546 return count(
$conf->cache[
'severity_tickets']);
1548 dol_print_error($this->db);
1562 return $this->LibStatut($this->
status, $mode, 0, $this->progress);
1576 public function LibStatut($status, $mode = 0, $notooltip = 0, $progress = 0)
1579 global $langs, $hookmanager;
1581 $labelStatus = (isset($status) && !empty($this->labelStatus[$status])) ? $this->labelStatus[$status] :
'';
1582 $labelStatusShort = (isset($status) && !empty($this->labelStatusShort[$status])) ? $this->labelStatusShort[$status] :
'';
1587 case self::STATUS_NOT_READ:
1588 $statusType =
'status0';
1590 case self::STATUS_READ:
1591 $statusType =
'status1';
1593 case self::STATUS_ASSIGNED:
1594 $statusType =
'status2';
1596 case self::STATUS_IN_PROGRESS:
1597 $statusType =
'status4';
1599 case self::STATUS_WAITING:
1600 $statusType =
'status7';
1602 case self::STATUS_NEED_MORE_INFO:
1603 $statusType =
'status3';
1605 case self::STATUS_CANCELED:
1606 $statusType =
'status9';
1608 case self::STATUS_CLOSED:
1609 $statusType =
'status6';
1616 $parameters = array(
1617 'status' => $status,
1622 $reshook = $hookmanager->executeHooks(
'LibStatut', $parameters, $this);
1625 return $hookmanager->resPrint;
1629 $labelStatus =
'Unknown';
1630 $labelStatusShort =
'Unknown';
1631 $statusType =
'status0';
1637 $params = array(
'tooltip' =>
'no');
1640 $labelStatus = $langs->transnoentitiesnoconv($labelStatus);
1641 $labelStatusShort = $langs->transnoentitiesnoconv($labelStatusShort);
1643 if ($status == self::STATUS_IN_PROGRESS && $progress > 0) {
1644 $labelStatus .=
' ('.round($progress).
'%)';
1645 $labelStatusShort .=
' ('.round($progress).
'%)';
1648 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode,
'', $params);
1661 $langs->load(
'ticket');
1662 $nofetch = !empty($params[
'nofetch']);
1665 $datas[
'picto'] = img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Ticket").
'</u>';
1666 $datas[
'picto'] .=
' '.$this->getLibStatut(4);
1667 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1668 $datas[
'track_id'] =
'<br><b>'.$langs->trans(
'TicketTrackId').
':</b> '.$this->track_id;
1669 $datas[
'subject'] =
'<br><b>'.$langs->trans(
'Subject').
':</b> '.$this->subject;
1670 if ($this->date_creation) {
1671 $datas[
'date_creation'] =
'<br><b>'.$langs->trans(
'DateCreation').
':</b> '.
dol_print_date($this->date_creation,
'dayhour');
1673 if ($this->date_modification) {
1674 $datas[
'date_modification'] =
'<br><b>'.$langs->trans(
'DateModification').
':</b> '.
dol_print_date($this->date_modification,
'dayhour');
1678 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
1679 $form =
new Form($this->db);
1680 $datas[
'categories'] =
'<br>' . $form->showCategories($this->
id, Categorie::TYPE_TICKET, 1);
1696 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1698 global $action,
$conf, $hookmanager, $langs;
1700 if (!empty(
$conf->dol_no_mouse_hover)) {
1708 'objecttype' => $this->element,
1709 'option' => $option,
1712 $classfortooltip =
'classfortooltip';
1715 $classfortooltip =
'classforajaxtooltip';
1716 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1719 $label = implode($this->getTooltipContentArray($params));
1724 if ($option !=
'nolink') {
1726 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1727 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1728 $add_save_lastsearch_values = 1;
1730 if ($add_save_lastsearch_values) {
1731 $query[
'save_lastsearch_values'] = 1;
1734 $url =
dolBuildUrl(DOL_URL_ROOT.
'/ticket/card.php', $query);
1737 if (empty($notooltip)) {
1739 $label = $langs->trans(
"ShowTicket");
1740 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
1742 $linkclose .= ($label ?
' title="'.dolPrintHTMLForAttribute($label).
'"' :
' title="tocomplete"');
1743 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1745 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1748 $linkstart =
'<a href="'.$url.
'"';
1749 $linkstart .= $linkclose.
'>';
1752 $result .= $linkstart;
1754 $result .= img_object(($notooltip ?
'' : $label), ($this->picto ?:
'generic'), (($withpicto != 2) ?
'class="paddingright"' :
''), 0, 0, $notooltip ? 0 : 1);
1756 if ($withpicto != 2) {
1757 $result .= $this->ref;
1759 $result .= $linkend;
1762 $hookmanager->initHooks(array(
'ticketdao'));
1763 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1764 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1766 $result = $hookmanager->resPrint;
1768 $result .= $hookmanager->resPrint;
1788 if ($this->
status != self::STATUS_CANCELED) {
1793 $this->
status = Ticket::STATUS_READ;
1795 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
1796 $sql .=
" SET fk_statut = ".((int) $this->
status) .
", date_read = '".$this->db->idate(
dol_now()).
"'";
1797 $sql .=
" WHERE rowid = ".((int) $this->
id);
1800 $resql = $this->db->query($sql);
1802 $this->context[
'actionmsg'] = $langs->trans(
'TicketLogMesgReadBy', $this->
ref, $user->getFullName($langs));
1803 $this->context[
'actionmsg2'] = $langs->trans(
'TicketLogMesgReadBy', $this->
ref, $user->getFullName($langs));
1807 $result = $this->call_trigger(
'TICKET_MODIFY', $user);
1815 $this->db->commit();
1818 $this->
status = $this->oldcopy->status;
1820 $this->db->rollback();
1822 $this->error = implode(
',', $this->errors);
1824 dol_syslog(get_class($this).
"::markAsRead ".$this->error, LOG_ERR);
1828 $this->
status = $this->oldcopy->status;
1830 $this->db->rollback();
1831 $this->error = $this->db->lasterror();
1832 dol_syslog(get_class($this).
"::markAsRead ".$this->error, LOG_ERR);
1851 if (!empty($this->date_read)) {
1859 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
1860 $sql .=
" SET date_read = '".$this->db->idate(
dol_now()).
"'";
1861 $sql .=
", fk_user_modif = ".((int) $user->id);
1862 $sql .=
" WHERE rowid = ".((int) $this->
id);
1864 dol_syslog(get_class($this).
"::setReadDate");
1866 $resql = $this->db->query($sql);
1869 $this->db->rollback();
1870 $this->date_read = $this->oldcopy->date_read;
1871 $this->error = $this->db->lasterror();
1873 dol_syslog(get_class($this).
"::setReadDate ".$this->error, LOG_ERR);
1878 $result = $this->call_trigger(
'TICKET_MODIFY', $user);
1880 $this->db->rollback();
1881 $this->date_read = $this->oldcopy->date_read;
1882 $this->error = implode(
',', $this->errors);
1884 dol_syslog(get_class($this).
"::setReadDate ".$this->error, LOG_ERR);
1889 $this->db->commit();
1892 $this->fk_user_modif = $user->id;
1893 $this->user_modification_id = $user->id;
1906 public function assignUser($user, $id_assign_user, $notrigger = 0)
1914 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
1915 if ($id_assign_user > 0) {
1916 $newstatus = Ticket::STATUS_ASSIGNED;
1918 $newstatus = Ticket::STATUS_READ;
1920 $sql .=
" SET fk_user_assign=".((int) $id_assign_user).
", fk_statut = ".((int) $newstatus);
1922 $sql .=
" SET fk_user_assign=null, fk_statut = ".Ticket::STATUS_READ;
1924 $sql .=
" WHERE rowid = ".((int) $this->
id);
1926 dol_syslog(get_class($this).
"::assignUser sql=".$sql);
1927 $resql = $this->db->query($sql);
1929 $this->fk_user_assign = $id_assign_user;
1933 $result = $this->call_trigger(
'TICKET_ASSIGNED', $user);
1941 $this->db->commit();
1944 $this->db->rollback();
1945 $this->error = implode(
',', $this->errors);
1946 dol_syslog(get_class($this).
"::assignUser ".$this->error, LOG_ERR);
1950 $this->db->rollback();
1951 $this->error = $this->db->lasterror();
1952 dol_syslog(get_class($this).
"::assignUser ".$this->error, LOG_ERR);
1971 public function createTicketMessage($user, $notrigger = 0, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $send_email =
false, $public_area = 0, $summary =
'', $external_contacts = [])
1973 global
$conf, $langs, $hookmanager;
1979 if (isset($this->track_id)) {
1980 $this->track_id = trim($this->track_id);
1983 if (isset($this->message)) {
1984 $this->message = trim($this->message);
1990 include_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
1992 $actioncomm->type_code =
'AC_OTH_AUTO';
1993 $actioncomm->code =
'TICKET_MSG';
1994 if ($this->
private) {
1995 $actioncomm->code =
'TICKET_MSG_PRIVATE';
1998 $actioncomm->code .=
'_SENTBYMAIL';
2000 if ((empty($user->id) || $user->id == 0) && isset($_SESSION[
'email_customer'])) {
2001 $actioncomm->email_from = $_SESSION[
'email_customer'];
2003 $actioncomm->socid = $this->socid;
2004 $actioncomm->label = $this->subject;
2006 $actioncomm->label = preg_replace(
'/(\[[^\]]*\]).*$/',
'\1', $actioncomm->label);
2007 if ($actioncomm->label) {
2008 $actioncomm->label .=
' ';
2010 $actioncomm->label .= (string) $summary;
2013 $actioncomm->note_private = $this->message;
2014 $actioncomm->userassigned = array($user->id => array(
'id' => $user->id,
'transparency' => 0));
2016 $parameters = array();
2017 $reshook = $hookmanager->executeHooks(
'createTicketMessageExternalContacts', $parameters, $actioncomm);
2019 $actioncomm->socpeopleassigned = $external_contacts;
2020 } elseif ($reshook == 0) {
2021 $actioncomm->socpeopleassigned += $external_contacts;
2024 $actioncomm->userownerid = $user->id;
2025 $actioncomm->datep = $now;
2026 $actioncomm->percentage = -1;
2027 $actioncomm->elementtype =
'ticket';
2030 $actioncomm->elementtype =
'ticket';
2031 $actioncomm->fk_project = $this->fk_project;
2037 if ($public_area && !empty($this->origin_email) &&
getDolGlobalString(
'TICKET_ASSIGN_CONTACT_TO_MESSAGE')) {
2038 $contacts = $this->searchContactByEmail($this->origin_email);
2039 if (!empty($contacts)) {
2041 foreach ($contacts as $contact) {
2042 if ((
int) $contact->status == 1) {
2043 $actioncomm->contact_id = $contact->id;
2050 $attachedfiles = array();
2051 $attachedfiles[
'paths'] = $filename_list;
2052 $attachedfiles[
'names'] = $mimefilename_list;
2053 $attachedfiles[
'mimes'] = $mimetype_list;
2054 if (is_array($attachedfiles) && count($attachedfiles) > 0) {
2055 $actioncomm->attachedfiles = $attachedfiles;
2061 $actionid = $actioncomm->create($user);
2062 if ($actionid <= 0) {
2064 $this->error = $actioncomm->error;
2065 $this->errors = $actioncomm->errors;
2068 if ($actionid > 0) {
2069 if (is_array($attachedfiles) && array_key_exists(
'paths', $attachedfiles) && count($attachedfiles[
'paths']) > 0) {
2071 foreach ($attachedfiles[
'paths'] as $key => $filespath) {
2073 $destdir =
$conf->ticket->dir_output.
'/'.$this->ref;
2078 if (in_array($actioncomm->code, array(
'TICKET_MSG',
'TICKET_MSG_SENTBYMAIL',
'TICKET_MSG_PRIVATE'))) {
2079 $ecmfile =
new EcmFiles($this->db);
2080 $destdir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $destdir);
2081 $destdir = preg_replace(
'/[\\/]$/',
'', $destdir);
2082 $destdir = preg_replace(
'/^[\\/]/',
'', $destdir);
2084 $result = $ecmfile->fetch(0,
'', $destdir.
'/'.$attachedfiles[
'names'][$key]);
2087 $ecmfile->agenda_id = $actionid;
2090 $result = $ecmfile->update($user);
2092 setEventMessages($ecmfile->error, $ecmfile->errors,
'warnings');
2103 $this->db->rollback();
2106 $this->db->commit();
2118 if (!empty($this->cache_msgs_ticket) && is_array($this->cache_msgs_ticket) && count($this->cache_msgs_ticket)) {
2124 $sql =
"SELECT id as rowid, fk_user_author, fk_user_action, email_from, datec, datep, label, note as message, code";
2125 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
2126 $sql .=
" WHERE fk_element = ".(int) $this->
id;
2127 $sql .=
" AND elementtype = 'ticket'";
2128 $sql .=
" ORDER BY datep DESC";
2130 dol_syslog(get_class($this).
"::load_cache_actions_ticket", LOG_DEBUG);
2131 $resql = $this->db->query($sql);
2133 $num = $this->db->num_rows($resql);
2136 $obj = $this->db->fetch_object($resql);
2137 $this->cache_msgs_ticket[$i][
'id'] = $obj->rowid;
2138 $this->cache_msgs_ticket[$i][
'fk_user_author'] = $obj->fk_user_author;
2139 $this->cache_msgs_ticket[$i][
'fk_user_action'] = $obj->fk_user_action;
2140 if (in_array($obj->code, array(
'TICKET_MSG',
'AC_TICKET_CREATE')) && empty($obj->fk_user_author)) {
2141 $this->cache_msgs_ticket[$i][
'fk_contact_author'] = $obj->email_from;
2143 $this->cache_msgs_ticket[$i][
'datec'] = $this->db->jdate($obj->datec);
2144 $this->cache_msgs_ticket[$i][
'datep'] = $this->db->jdate($obj->datep);
2145 $this->cache_msgs_ticket[$i][
'subject'] = $obj->label;
2146 $this->cache_msgs_ticket[$i][
'message'] = $obj->message;
2147 $this->cache_msgs_ticket[$i][
'private'] = (preg_match(
'/^TICKET_MSG_PRIVATE/', $obj->code) ? 1 : 0);
2152 $this->error =
"Error ".$this->db->lasterror();
2153 dol_syslog(get_class($this).
"::load_cache_actions_ticket ".$this->error, LOG_ERR);
2168 if ($this->
status != Ticket::STATUS_CLOSED && $this->
status != Ticket::STATUS_CANCELED) {
2172 $this->
status = ($mode ? Ticket::STATUS_CANCELED : Ticket::STATUS_CLOSED);
2174 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
2175 $sql .=
" SET fk_statut = ".((int) $this->
status).
", progress=100, date_close='".$this->db->idate(
dol_now()).
"'";
2176 $sql .=
" WHERE rowid = ".((int) $this->
id);
2178 dol_syslog(get_class($this).
"::close mode=".$mode);
2179 $resql = $this->db->query($sql);
2185 dol_syslog(
"We have closed the ticket, so we close all linked interventions");
2186 $this->fetchObjectLinked($this->
id, $this->element,
null,
'fichinter');
2187 if ($this->linkedObjectsIds) {
2188 foreach ($this->linkedObjectsIds[
'fichinter'] as $fichinter_id) {
2190 $fichinter->fetch($fichinter_id);
2191 if ($fichinter->statut == 0) {
2192 $result = $fichinter->setValid($user);
2194 $this->errors[] = $fichinter->error;
2198 if ($fichinter->statut < 3) {
2199 $result = $fichinter->setStatut(3);
2201 $this->errors[] = $fichinter->error;
2210 $result = $this->call_trigger(
'TICKET_CLOSE', $user);
2217 $this->db->commit();
2220 $this->db->rollback();
2221 $this->error = implode(
',', $this->errors);
2222 dol_syslog(get_class($this).
"::close ".$this->error, LOG_ERR);
2226 $this->db->rollback();
2227 $this->error = $this->db->lasterror();
2228 dol_syslog(get_class($this).
"::close ".$this->error, LOG_ERR);
2247 $thirdparties = array();
2251 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"societe";
2252 $sql .=
" WHERE entity IN (".getEntity(
'ticket', 1).
")";
2253 if (!empty($type)) {
2254 if ($type == 1 || $type == 2) {
2255 $sql .=
" AND client = ".((int) $type);
2256 } elseif ($type == 3) {
2257 $sql .=
" AND fournisseur = 1";
2260 if (!empty($email)) {
2261 if (empty($exact)) {
2263 if (preg_match(
'/^([\*])?[^*]+([\*])?$/', $email, $regs) && count($regs) > 1) {
2264 $email = str_replace(
'*',
'%', $email);
2266 $email =
'%'.$email.
'%';
2270 if (is_array($filters) && !empty($filters)) {
2274 $sql .=
"email LIKE '".$this->db->escape($email).
"'";
2276 if (is_array($filters) && !empty($filters)) {
2277 foreach ($filters as $field => $value) {
2278 $sql .=
" ".$clause.
" ".$this->db->sanitize($field).
" LIKE '".$this->db->escape($value).
"'";
2280 if (!empty($email)) {
2285 $res = $this->db->query($sql);
2287 while ($rec = $this->db->fetch_array($res)) {
2288 $soc =
new Societe($this->db);
2289 $soc->fetch($rec[
'rowid']);
2290 $thirdparties[] = $soc;
2293 return $thirdparties;
2295 $this->error = $this->db->error().
' sql='.$sql;
2296 dol_syslog(get_class($this).
"::searchSocidByEmail ".$this->error, LOG_ERR);
2311 $contacts = array();
2314 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"socpeople";
2315 $sql .=
" WHERE entity IN (".getEntity(
'contact').
")";
2316 if (!empty($socid)) {
2317 $sql .=
" AND fk_soc = ".((int) $socid);
2319 if (!empty($email)) {
2322 $sql .=
"email = '".$this->db->escape($email).
"'";
2324 $sql .=
"email LIKE BINARY '".$this->db->escape($this->db->escapeforlike($email)).
"'";
2328 $res = $this->db->query($sql);
2330 while ($rec = $this->db->fetch_object($res)) {
2331 include_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
2332 $contactstatic =
new Contact($this->db);
2333 $contactstatic->fetch($rec->rowid);
2334 $contacts[] = $contactstatic;
2339 $this->error = $this->db->error().
' sql='.$sql;
2340 dol_syslog(get_class($this).
"::searchContactByEmail ".$this->error, LOG_ERR);
2356 $sql =
"UPDATE ".$this->db->prefix().
"ticket";
2357 $sql .=
" SET fk_soc = ".($id > 0 ? (int)
$id :
"null");
2358 $sql .=
" WHERE rowid = ".((int) $this->
id);
2359 dol_syslog(get_class($this).
'::setCustomer sql='.$sql);
2360 $resql = $this->db->query($sql);
2362 $this->error = $this->db->lasterror();
2363 dol_syslog(get_class($this).
'::setCustomer '.$this->error, LOG_ERR);
2364 $this->db->rollback();
2371 $sql =
"UPDATE ".$this->db->prefix().
"actioncomm";
2372 $sql .=
" SET fk_soc = ".($id > 0 ? (int)
$id :
"null");
2373 $sql .=
" WHERE elementtype = 'ticket' AND fk_element = ".((int) $this->
id);
2374 dol_syslog(get_class($this).
'::setCustomer sql='.$sql);
2375 $resql = $this->db->query($sql);
2377 $this->error = $this->db->lasterror();
2378 dol_syslog(get_class($this).
'::setCustomer '.$this->error, LOG_ERR);
2379 $this->db->rollback();
2384 $this->db->commit();
2401 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
2402 $sql .=
" SET progress = ".($percent > 0 ? (float) $percent :
"null");
2403 $sql .=
" WHERE rowid = ".((int) $this->
id);
2404 dol_syslog(get_class($this).
'::set_progression sql='.$sql);
2405 $resql = $this->db->query($sql);
2425 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
2426 $sql .=
" SET fk_contract = ".($contractid > 0 ? (int) $contractid :
"null");
2427 $sql .=
" WHERE rowid = ".((int) $this->
id);
2428 dol_syslog(get_class($this).
'::setContract sql='.$sql);
2429 $resql = $this->db->query($sql);
2449 return $this->getIdContact(
'internal',
'SUPPORTTEC');
2460 return $this->listeContact(-1,
'internal', 0,
'', $status);
2470 return $this->getIdContact(
'external',
'SUPPORTCLI');
2481 return $this->listeContact(-1,
'external', 0,
'', $status);
2491 return $this->getIdContact(
'internal',
'CONTRIBUTOR');
2501 return $this->getIdContact(
'external',
'CONTRIBUTOR');
2511 $array_contact = $this->getIdTicketInternalContact();
2513 $array_contact = array_merge($array_contact, $this->getIdTicketCustomerContact());
2515 $array_contact = array_merge($array_contact, $this->getIdTicketInternalInvolvedContact());
2517 $array_contact = array_merge($array_contact, $this->getIdTicketCustomerInvolvedContact());
2519 return $array_contact;
2529 $array_contact = array();
2531 $array_contact = array_merge($array_contact, $this->getIdTicketCustomerContact());
2533 $array_contact = array_merge($array_contact, $this->getIdTicketCustomerInvolvedContact());
2535 return $array_contact;
2550 public function listeContact($statusoflink = -1, $source =
'external', $list = 0, $code =
'', $status = -1)
2556 $sql =
"SELECT ec.rowid, ec.statut as statuslink, ec.fk_socpeople as id, ec.fk_c_type_contact";
2557 if ($source ==
'internal') {
2558 $sql .=
", '-1' as socid, t.statut as statuscontact";
2561 if ($source ==
'external' || $source ==
'thirdparty') {
2562 $sql .=
", t.fk_soc as socid, t.statut as statuscontact";
2565 $sql .=
", t.civility, t.lastname as lastname, t.firstname, t.email";
2566 if ($source ==
'internal') {
2567 $sql .=
", t.office_phone as phone, t.user_mobile as phone_mobile";
2570 if ($source ==
'external' || $source ==
'thirdparty') {
2571 $sql .=
", t.phone as phone, t.phone_mobile as phone_mobile, t.phone_perso as phone_perso";
2574 $sql .=
", tc.source, tc.element, tc.code, tc.libelle as type_contact_label";
2575 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_contact tc";
2576 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact ec";
2577 if ($source ==
'internal') {
2578 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user t on ec.fk_socpeople = t.rowid";
2581 if ($source ==
'external' || $source ==
'thirdparty') {
2582 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople t on ec.fk_socpeople = t.rowid";
2585 $sql .=
" WHERE ec.element_id = ".((int) $this->
id);
2586 $sql .=
" AND ec.fk_c_type_contact=tc.rowid";
2587 $sql .=
" AND tc.element='".$this->db->escape($this->element).
"'";
2588 if ($source ==
'internal') {
2589 $sql .=
" AND tc.source = 'internal'";
2591 $sql .=
" AND t.statut = ".((int) $status);
2595 if ($source ==
'external' || $source ==
'thirdparty') {
2596 $sql .=
" AND tc.source = 'external'";
2598 $sql .=
" AND t.statut = ".((int) $status);
2602 if (!empty($code)) {
2603 $sql .=
" AND tc.code = '".$this->db->escape($code).
"'";
2606 $sql .=
" AND tc.active=1";
2607 if ($statusoflink >= 0) {
2608 $sql .=
" AND ec.statut = ".((int) $statusoflink);
2611 $sql .=
" ORDER BY t.lastname ASC";
2613 $resql = $this->db->query($sql);
2615 $num = $this->db->num_rows($resql);
2618 $obj = $this->db->fetch_object($resql);
2621 $transkey =
"TypeContact_".$obj->element.
"_".$obj->source.
"_".$obj->code;
2622 $labelType = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->type_contact_label);
2624 'source' => $obj->source,
2625 'socid' => (
int) $obj->socid,
2626 'id' => (
int) $obj->id,
2627 'nom' => $obj->lastname,
2628 'civility' => $obj->civility,
2629 'lastname' => $obj->lastname,
2630 'firstname' => $obj->firstname,
2631 'email' => $obj->email,
2632 'rowid' => (
int) $obj->rowid,
2633 'code' => $obj->code,
2634 'libelle' => $labelType,
2635 'labeltype' => $labelType,
2636 'status' => $obj->statuslink,
2637 'statuscontact' => (
int) $obj->statuscontact,
2638 'fk_c_type_contact' => (
int) $obj->fk_c_type_contact,
2639 'phone' => $obj->phone,
2640 'phone_mobile' => $obj->phone_mobile);
2641 if ($source ==
'external') {
2642 $tab[$i][
'phone_perso'] = $obj->phone_perso;
2645 $tab[$i] = $obj->id;
2653 $this->error = $this->db->error();
2654 dol_print_error($this->db);
2676 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
2677 foreach ($dirmodels as $reldir) {
2678 $file =
dol_buildpath($reldir.
"core/modules/ticket/".$modele.
'.php', 0);
2679 if (file_exists($file)) {
2680 $classname = $modele;
2685 if ($classname !==
'') {
2687 $modTicket =
new $classname();
2688 '@phan-var-force ModeleNumRefTicket $modTicket';
2690 $defaultref = $modTicket->getNextValue($thirdparty, $this);
2693 if (is_numeric($defaultref) && $defaultref <= 0) {
2711 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2716 if (file_exists($dir_osencoded)) {
2717 $handle = opendir($dir_osencoded);
2718 if (is_resource($handle)) {
2719 while (($file = readdir($handle)) !==
false) {
2721 $file = mb_convert_encoding($file,
'UTF-8',
'ISO-8859-1');
2746 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
2747 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2748 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
2750 $maxwidthsmall = 270;
2751 $maxheightsmall = 150;
2752 $maxwidthmini = 128;
2753 $maxheightmini = 72;
2755 $formmail =
new FormMail($this->db);
2756 $formmail->trackid = (is_null($forcetrackid) ?
'tic'.$this->id :
'');
2757 $attachedfiles = $formmail->get_attached_files();
2759 $filepath = $attachedfiles[
'paths'];
2760 $filename = $attachedfiles[
'names'];
2761 $mimetype = $attachedfiles[
'mimes'];
2764 $destdir =
$conf->ticket->dir_output.
'/'.$this->ref;
2770 $listofpaths = array();
2771 $listofnames = array();
2772 foreach ($filename as $i => $val) {
2773 $destfile = $destdir.
'/'.$filename[$i];
2775 if (is_file($destfile)) {
2776 $pathinfo = pathinfo($filename[$i]);
2778 $destfile = $destdir.
'/'.$pathinfo[
'filename'].
' - '.
dol_print_date($now,
'dayhourlog').
'.'.$pathinfo[
'extension'];
2782 'description' =>
'File saved by copyFilesForTicket',
2783 'src_object_type' => $this->element,
2784 'src_object_id' => $this->
id,
2785 'gen_or_uploaded' =>
'uploaded'
2788 $res =
dol_move($filepath[$i], $destfile,
'0', 1, 0, 1, $moreinfo);
2792 $this->error =
"Failed to move file ".dirbasename($filepath[$i]).
" into ".
dirbasename($destfile);
2799 $imgThumbSmall =
vignette($destfile, $maxwidthsmall, $maxheightsmall,
'_small', 50,
"thumbs");
2802 $imgThumbMini =
vignette($destfile, $maxwidthmini, $maxheightmini,
'_mini', 50,
"thumbs");
2807 $formmail->remove_attached_files($i);
2810 $listofpaths[$i] = $destfile;
2811 $listofnames[$i] = basename($destfile);
2814 return array(
'listofpaths' => $listofpaths,
'listofnames' => $listofnames,
'listofmimes' => $mimetype);
2830 if (!is_array($categories)) {
2831 $categories = array($categories);
2835 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2837 $existing =
$c->containing($this->
id, Categorie::TYPE_TICKET,
'id');
2840 if (is_array($existing)) {
2841 $to_del = array_diff($existing, $categories);
2842 $to_add = array_diff($categories, $existing);
2845 $to_add = $categories;
2849 foreach ($to_del as $del) {
2850 if (
$c->fetch($del) > 0) {
2851 $c->del_type($this, Categorie::TYPE_TICKET);
2854 foreach ($to_add as $add) {
2855 if (
$c->fetch($add) > 0) {
2856 $c->add_type($this, Categorie::TYPE_TICKET);
2875 public function newMessage($user, &$action, $private = 1, $public_area = 0)
2877 global
$mysoc, $langs, $hookmanager;
2891 array_push($this->errors, $langs->trans(
"ErrorTicketIsNotValid"));
2897 array_push($this->errors, $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Message")));
2898 $action =
'add_message';
2902 $summary = mb_strcut(
GETPOST(
'summary',
'alphanohtml'), 0, 42,
'UTF-8');
2907 $send_email = (bool)
GETPOSTINT(
'send_email');
2910 $resarray =
$object->copyFilesForTicket();
2911 if (is_numeric($resarray) && $resarray == -1) {
2912 $this->setErrorsFromObject(
$object);
2916 $listofpaths = $resarray[
'listofpaths'];
2917 $listofnames = $resarray[
'listofnames'];
2918 $listofmimes = $resarray[
'listofmimes'];
2921 $external_contacts =
$object->getInfosTicketExternalContact(1);
2922 $external_resources = [];
2923 if (!empty($external_contacts)) {
2924 foreach ($external_contacts as $eContact) {
2925 $external_resources[$eContact[
'id']] = $eContact;
2932 $id =
$object->createTicketMessage($user, 0, $listofpaths, $listofmimes, $listofnames, $send_email, $public_area, $summary, $external_resources);
2936 $this->error =
$object->error;
2937 $this->errors =
$object->errors;
2938 $action =
'add_message';
2941 if (!$error &&
$id > 0) {
2942 setEventMessages($langs->trans(
'TicketMessageSuccessfullyAdded'),
null,
'mesgs');
2945 if (!empty($public_area)) {
2953 $internal_contacts =
$object->getInfosTicketInternalContact(1);
2955 $assigned_user_dont_have_email =
'';
2959 if ($this->fk_user_assign > 0) {
2960 $assigned_user =
new User($this->db);
2961 $assigned_user->fetch($this->fk_user_assign);
2962 if (!empty($assigned_user->email)) {
2963 $sendto[$assigned_user->email] = $assigned_user->getFullName($langs).
" <".$assigned_user->email.
">";
2965 $assigned_user_dont_have_email = $assigned_user->getFullName($langs);
2968 $assigned_user =
null;
2972 foreach ($internal_contacts as $key => $info_sendto) {
2974 if ($info_sendto[
'id'] == $user->id) {
2979 if (!empty($info_sendto[
'email']) && ($assigned_user ===
null || $assigned_user->email != $info_sendto[
'email'])) {
2980 $sendto[] =
dolGetFirstLastname($info_sendto[
'firstname'], $info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">";
2984 if (empty($sendto)) {
2999 $parameters = array(
'sendto' => $sendto);
3000 $reshook = $hookmanager->executeHooks(
'updateSendtoTicketMessage', $parameters,
$object, $action);
3001 if (empty($reshook)) {
3002 $sendto = array_merge($sendto, $hookmanager->resArray);
3003 } elseif ($reshook > 0) {
3004 $sendto = $hookmanager->resArray;
3007 if (!empty($sendto)) {
3010 $subject =
'['.$appli.
'- ticket #'.
$object->track_id.
'] '.$this->subject;
3013 $message =
getDolGlobalString(
'TICKET_MESSAGE_MAIL_INTRO', $langs->trans(
'TicketMessageMailIntroText'));
3014 $message .=
'<br><br>';
3015 $messagePost =
GETPOST(
'message',
'restricthtml');
3019 $message .= $messagePost;
3022 $message .=
'<br><br>';
3023 $message .=
"==============================================";
3024 $message .= !empty(
$object->thirdparty->name) ?
'<br>'.$langs->trans(
'ThirdParty').
" : ".
$object->thirdparty->name :
'';
3025 $message .= !empty(
$object->thirdparty->town) ?
'<br>'.$langs->trans(
'Town').
" : ".
$object->thirdparty->town :
'';
3026 $message .= !empty(
$object->thirdparty->phone) ?
'<br>'.$langs->trans(
'Phone').
" : ".
$object->thirdparty->phone :
'';
3029 $message .=
'<br><br>';
3030 if (!empty($assigned_user_dont_have_email)) {
3031 $message .=
'<br>'.$langs->trans(
'NoEMail').
' : '.$assigned_user_dont_have_email;
3033 foreach ($sendto as $val) {
3034 $message .=
'<br>'.$langs->trans(
'TicketNotificationRecipient').
' : '.$val;
3039 $message .=
'<br><br>';
3040 $message .= $langs->trans(
'TicketNotificationEmailBodyInfosTrackUrlinternal').
' : <a href="'.$url_internal_ticket.
'">'.
$object->track_id.
'</a>';
3047 $this->sendTicketMessageByEmail($subject, $message, 0, $sendto, $listofpaths, $listofmimes, $listofnames, array(), $email_from, $replyto);
3056 if ((
int) $send_email > 0) {
3058 $internal_contacts =
$object->getInfosTicketInternalContact(1);
3061 if (is_array($internal_contacts) && count($internal_contacts) > 0) {
3065 $subject =
GETPOST(
'subject',
'alphanohtml') ?
GETPOST(
'subject',
'alphanohtml') :
'['.$appli.
' - '.$langs->trans(
"Ticket").
' #'.
$object->track_id.
'] '.$langs->trans(
'TicketNewMessage');
3067 $message_intro = $langs->trans(
'TicketNotificationEmailBody',
"#".
$object->id);
3070 $message =
getDolGlobalString(
'TICKET_MESSAGE_MAIL_INTRO', $langs->trans(
'TicketMessageMailIntroText'));
3071 $message .=
'<br><br>';
3072 $messagePost =
GETPOST(
'message',
'restricthtml');
3076 $message .= $messagePost;
3079 $message .=
'<br><br>';
3080 $message .=
"==============================================<br>";
3081 $message .= !empty(
$object->thirdparty->name) ? $langs->trans(
'ThirdParty').
" : ".
$object->thirdparty->name :
'';
3082 $message .= !empty(
$object->thirdparty->town) ?
'<br>'.$langs->trans(
'Town').
" : ".
$object->thirdparty->town :
'';
3083 $message .= !empty(
$object->thirdparty->phone) ?
'<br>'.$langs->trans(
'Phone').
" : ".
$object->thirdparty->phone :
'';
3086 foreach ($internal_contacts as $key => $info_sendto) {
3088 if ($info_sendto[
'id'] == $user->id) {
3089 dol_syslog(
"We cancel sending email to internal user ".$info_sendto[
'email'].
" because it is current user", LOG_DEBUG);
3093 if ($info_sendto[
'email'] !=
'') {
3094 $email = $info_sendto[
'email'];
3095 if ($email !=
null) {
3096 $sendto[$email] =
dolGetFirstLastname($info_sendto[
'firstname'], $info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">";
3100 $recipient =
dolGetFirstLastname($info_sendto[
'firstname'], $info_sendto[
'lastname'], -1).
' ('.strtolower((
string) $info_sendto[
'libelle']).
')';
3101 $message .= (!empty($recipient) ?
'<br>'.$langs->trans(
'TicketNotificationRecipient').
' : '.$recipient.
'<br>' :
'');
3109 $message .=
'<br>'.$langs->trans(
'TicketNotificationEmailBodyInfosTrackUrlinternal').
' : <a href="'.$url_internal_ticket.
'">'.
$object->track_id.
'</a><br>';
3118 $parameters = array(
'sendto' => $sendto);
3119 $reshook = $hookmanager->executeHooks(
'updateSendtoTicketMessage', $parameters,
$object, $action);
3120 if (empty($reshook)) {
3121 $sendto = array_merge($sendto, $hookmanager->resArray);
3122 } elseif ($reshook > 0) {
3123 $sendto = $hookmanager->resArray;
3126 $sendtocc = array();
3136 if (!empty($sendto)) {
3137 $this->sendTicketMessageByEmail($subject, $message, 0, $sendto, $listofpaths, $listofmimes, $listofnames, $sendtocc, $email_from, $replyto);
3144 if (empty(
$object->private)) {
3146 if (is_array($external_contacts) && count($external_contacts) === 0) {
3147 if (!empty(
$object->fk_soc)) {
3149 $array_company = array(array(
'id' => -1,
'firstname' =>
'',
'lastname' =>
$object->thirdparty->name,
'email' =>
$object->thirdparty->email,
'libelle' => $langs->transnoentities(
'Customer'),
'socid' =>
$object->thirdparty->id));
3150 $external_contacts = array_merge($external_contacts, $array_company);
3151 } elseif (empty(
$object->fk_soc) && !empty(
$object->origin_replyto)) {
3152 $array_external = array(array(
'id' => -1,
'firstname' =>
'',
'lastname' =>
$object->origin_replyto,
'email' =>
$object->origin_replyto,
'libelle' => $langs->transnoentities(
'Customer'),
'socid' => 0));
3153 $external_contacts = array_merge($external_contacts, $array_external);
3154 } elseif (empty(
$object->fk_soc) && !empty(
$object->origin_email)) {
3155 $array_external = array(array(
'id' => -1,
'firstname' =>
'',
'lastname' =>
$object->origin_email,
'email' =>
$object->origin_email,
'libelle' => $langs->transnoentities(
'Customer'),
'socid' => 0));
3156 $external_contacts = array_merge($external_contacts, $array_external);
3161 if (is_array($external_contacts) && count($external_contacts) > 0) {
3165 $subject =
GETPOST(
'subject') ?
GETPOST(
'subject') :
'['.$appli.
' - '.$langs->trans(
"Ticket").
' #'.
$object->track_id.
'] '.$langs->trans(
'TicketNewMessage');
3170 $message_intro =
dol_nl2br($message_intro);
3173 $message_signature =
dol_nl2br($message_signature);
3177 $messagePost =
GETPOST(
'message',
'restricthtml');
3181 $message = $messagePost;
3182 $message .=
'<br><br>';
3184 foreach ($external_contacts as $key => $info_sendto) {
3186 if ($info_sendto[
'id'] == $user->contact_id) {
3190 if ($info_sendto[
'email'] !=
'' && $info_sendto[
'email'] !=
$object->origin_email) {
3191 $email = $info_sendto[
'email'];
3192 if ($email !=
null) {
3193 $sendto[$email] = trim($info_sendto[
'firstname'].
" ".$info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">";
3196 $recipient =
dolGetFirstLastname($info_sendto[
'firstname'], $info_sendto[
'lastname'], -1).
' ('.strtolower((
string) $info_sendto[
'libelle']).
')';
3197 $message .= (!empty($recipient) ?
'<br>'.$langs->trans(
'TicketNotificationRecipient').
' : '.$recipient.
'<br>' :
'');
3202 $url_public_ticket = (
getDolGlobalInt(
'TICKET_ENABLE_PUBLIC_INTERFACE') ?
3205 if (
getDolGlobalInt(
'TICKET_INCLUDE_LINK_TO_PUBLIC_INTERFACE_IN_MESSAGE')) {
3206 $message .=
'<br>' . $langs->trans(
'TicketNewEmailBodyInfosTrackUrlCustomer') .
' : <a href="' . $url_public_ticket .
'">' .
$object->track_id .
'</a><br>';
3210 $message = $message_intro.
'<br><br>'.$message;
3213 $message .=
'<br>'.$message_signature;
3215 if (!empty(
$object->origin_replyto)) {
3217 } elseif (!empty(
$object->origin_email)) {
3221 if (
$object->fk_soc > 0 && !array_key_exists(
$object->origin_replyto, $sendto) && !array_key_exists(
$object->origin_email, $sendto)) {
3224 if (!empty(
$object->thirdparty->email)) {
3225 $sendto[
$object->thirdparty->email] =
$object->thirdparty->email;
3236 $parameters = array(
'sendto' => $sendto);
3237 $reshook = $hookmanager->executeHooks(
'updateSendtoTicketMessage', $parameters,
$object, $action);
3238 if (empty($reshook)) {
3239 $sendto = array_merge($sendto, $hookmanager->resArray);
3240 } elseif ($reshook > 0) {
3241 $sendto = $hookmanager->resArray;
3246 $sendto_manual = array();
3248 $receiver_selected =
GETPOST(
'receiver',
'array');
3249 if (is_array($receiver_selected)) {
3250 foreach ($receiver_selected as $email) {
3251 $email = trim((
string) $email);
3252 if ($email && filter_var($email, FILTER_VALIDATE_EMAIL)) {
3253 $sendto_manual[$email] = $email;
3259 $sendto_free =
GETPOST(
'sendto',
'alphawithlgt');
3260 if ($sendto_free !==
'') {
3261 foreach (explode(
',', $sendto_free) as $entry) {
3262 $entry = trim($entry);
3263 if ($entry ===
'') {
3266 if (preg_match(
'/.*<\s*([^>]+)\s*>/', $entry, $matches)) {
3267 $email = trim($matches[1]);
3271 if ($email && filter_var($email, FILTER_VALIDATE_EMAIL)) {
3272 $sendto_manual[$email] = $entry;
3277 $sendto = $sendto_manual;
3281 $sendtocc = array();
3282 $sendtocc_emails = array();
3285 $cc_entry = trim($cc_entry);
3290 if (preg_match(
'/<\s*([^>]+)\s*>/', $cc_entry, $m)) {
3291 $cc_email = strtolower(trim($m[1]));
3293 $cc_email = strtolower($cc_entry);
3295 if (!in_array($cc_email, $sendtocc_emails)) {
3296 $sendtocc[] = $cc_entry;
3297 $sendtocc_emails[] = $cc_email;
3303 $receivercc_selected =
GETPOST(
'receivercc',
'array');
3304 if (is_array($receivercc_selected)) {
3305 foreach ($receivercc_selected as $email) {
3306 $email = trim((
string) $email);
3307 if ($email && filter_var($email, FILTER_VALIDATE_EMAIL) && !in_array(strtolower($email), $sendtocc_emails)) {
3308 $sendtocc[] = $email;
3309 $sendtocc_emails[] = strtolower($email);
3315 $sendtocc_free =
GETPOST(
'sendtocc',
'alphawithlgt');
3316 if ($sendtocc_free !==
'') {
3317 foreach (explode(
',', $sendtocc_free) as $entry) {
3318 $entry = trim($entry);
3319 if ($entry ===
'') {
3322 if (preg_match(
'/.*<\s*([^>]+)\s*>/', $entry, $matches)) {
3323 $email = trim($matches[1]);
3327 if ($email && filter_var($email, FILTER_VALIDATE_EMAIL) && !in_array(strtolower($email), $sendtocc_emails)) {
3328 $sendtocc[] = $email;
3329 $sendtocc_emails[] = strtolower($email);
3336 if (!empty($sendto)) {
3341 $result = $this->sendTicketMessageByEmail($subject, $message, 0, $sendto, $listofpaths, $listofmimes, $listofnames, $sendtocc, $email_from, $replyto);
3344 $this->date_last_msg_sent =
dol_now();
3345 $this->update($user, 1);
3349 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"actioncomm";
3350 $sql .=
" SET email_msgid = '".$this->db->escape($this->email_msgid).
"',";
3351 $sql .=
" email_subject = '".$this->db->escape($subject).
"',";
3352 $sql .=
" email_from = '".$this->db->escape($email_from).
"',";
3353 $sql .=
" email_to = '".$this->db->escape(implode(
',', $sendto)).
"',";
3354 $sql .=
" email_tocc = '".$this->db->escape(implode(
',', $sendtocc)).
"',";
3355 $sql .=
" reply_to = '".$this->db->escape($replyto).
"'";
3356 $sql .=
" WHERE id = ".((int)
$id);
3358 $resql = $this->db->query($sql);
3371 && (
$object->status < self::STATUS_IN_PROGRESS && !$user->socid && !$private))
3372 || (
$object->status > self::STATUS_IN_PROGRESS && $public_area)) {
3374 $object->setStatut($object::STATUS_IN_PROGRESS,
null,
'',
'TICKET_MODIFY');
3375 } elseif (
getDolGlobalInt(
'TICKET_SET_STATUS_ON_ANSWER', -1) >= 0 && empty($user->socid) && empty($private)) {
3382 $this->setErrorsFromObject(
$object);
3406 public function sendTicketMessageByEmail($subject, $message, $send_internal_cc = 0, $array_receiver = array(), $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $array_receiver_cc = array(), $email_from =
'', $replyto =
'')
3408 global
$conf, $langs, $user, $hookmanager;
3411 dol_syslog(get_class($this).
'::sendTicketMessageByEmail: Emails are disable into ticket setup by option TICKET_DISABLE_ALL_MAILS', LOG_WARNING);
3415 $langs->load(
"mails");
3417 include_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
3421 if (!is_array($array_receiver) || !count($array_receiver) > 0) {
3422 $array_receiver = $this->getInfosTicketInternalContact(1);
3423 $array_receiver = array_merge($array_receiver, $this->getInfosTicketExternalContact(1));
3426 dol_syslog(
"sendTicketMessageByEmail array_receiver=".json_encode($array_receiver), LOG_DEBUG);
3427 dol_syslog(
"sendTicketMessageByEmail array_receiver_cc=".json_encode($array_receiver_cc), LOG_DEBUG);
3430 if ($send_internal_cc) {
3433 if (!empty($array_receiver_cc) && is_array($array_receiver_cc)) {
3434 $sendtocc .= ($sendtocc ?
',' :
'').implode(
',', $array_receiver_cc);
3437 if (empty($email_from)) {
3441 $parameters = array(
'from' => $email_from);
3443 $reshook = $hookmanager->executeHooks(
'getTicketMessageEmailFrom', $parameters, $this, $action);
3444 if ($reshook && !empty($hookmanager->resArray[
'from'])) {
3445 $email_from = $hookmanager->resArray[
'from'];
3449 $this->email_msgids = array();
3451 if (is_array($array_receiver) && count($array_receiver) > 0) {
3453 $deliveryreceipt = 0;
3454 $filepath = $filename_list;
3455 $filename = $mimefilename_list;
3456 $mimetype = $mimetype_list;
3462 $conf->global->MAIN_MAIL_AUTOCOPY_TO =
'';
3465 $upload_dir_tmp =
$conf->user->dir_output.
"/".$user->id.
'/temp';
3467 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
3468 $trackid =
"tic".$this->id;
3470 $moreinheader =
'X-Dolibarr-Info: sendTicketMessageByEmail'.
"\r\n";
3471 if (!empty($this->email_msgid)) {
3473 $moreinheader .=
'In-Reply-To: <'.$this->email_msgid.
'>'.
"\r\n";
3481 if (!empty($this->origin_references)) {
3482 $references .= (empty($references) ?
'' :
' ').$this->origin_references;
3484 if (!empty($this->email_msgid) && !preg_match(
'/'.preg_quote($this->email_msgid,
'/').
'/', $references)) {
3485 $references .= (empty($references) ?
'' :
' ').
'<'.$this->email_msgid.
'>';
3488 $moreinheader .=
'References: '.$references.
"\r\n";
3492 $receiverstring =
'';
3493 foreach ($array_receiver as $key => $receiver) {
3494 $receiverstring .= ($receiverstring ?
',' :
'').$receiver;
3497 $sendcontext =
'ticket';
3500 $mailfile =
new CMailFile($subject, $receiverstring, $email_from, $message, $filepath, $mimetype, $filename, $sendtocc,
'', $deliveryreceipt, -1,
'',
'', $trackid, $moreinheader, $sendcontext, $replyto, $upload_dir_tmp);
3503 if ($mailfile->error) {
3504 setEventMessages($mailfile->error,
null,
'errors');
3506 $result = $mailfile->sendfile();
3509 setEventMessages($langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($email_from, 2), $mailfile->getValidAddress($receiverstring, 2)),
null,
'mesgs');
3512 $this->email_msgid = $mailfile->msgid;
3514 $langs->load(
"other");
3515 if ($mailfile->error) {
3516 setEventMessages($langs->trans(
'ErrorFailedToSendMail', $email_from, $receiverstring),
null,
'errors');
3517 dol_syslog(
'ErrorFailedToSendMail from='.$email_from.
' to='.$receiverstring.
' : '.$mailfile->error);
3519 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'errors');
3521 setEventMessages($langs->trans(
'ErrorFailedToSendMail', $email_from, $receiverstring),
null,
'errors');
3522 dol_syslog(
'ErrorFailedToSendMail from='.$email_from.
' to='.$receiverstring.
' : (no error details)', LOG_WARNING);
3528 $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
3532 $langs->load(
"other");
3533 setEventMessages($langs->trans(
'ErrorMailRecipientIsEmptyForSendTicketMessage'),
null,
'warnings');
3550 global $user, $langs;
3559 $sql =
"SELECT COUNT(p.rowid) as nb";
3560 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as p";
3561 if (empty($user->socid) &&
isModEnabled(
'societe') && !$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
3562 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON p.fk_soc = sc.fk_soc";
3563 $sql .=
" WHERE sc.fk_user = ".((int) $user->id);
3566 $sql .= $clause.
" p.entity IN (".
getEntity(
'ticket').
")";
3567 if ($mode ==
'opened') {
3568 $sql .=
" AND p.fk_statut NOT IN (".Ticket::STATUS_CLOSED.
", ".Ticket::STATUS_CANCELED.
")";
3571 $sql .=
" AND p.fk_soc = ".((int) $user->socid);
3574 $resql = $this->db->query($sql);
3576 $label = $labelShort =
'';
3578 if ($mode ==
'opened') {
3579 $status =
'openall';
3582 $label = $langs->trans(
"MenuListNonClosed");
3583 $labelShort = $langs->trans(
"MenuListNonClosed");
3588 $response->label = $label;
3589 $response->labelShort = $labelShort;
3590 $response->url = DOL_URL_ROOT.
'/ticket/list.php?search_fk_statut[]='.$status;
3591 $response->img = img_object(
'',
"ticket");
3594 $obj = $this->db->fetch_object($resql);
3596 $response->nbtodo = (int) $obj->nb;
3600 $this->error = $this->db->lasterror();
3614 $this->nb = array();
3617 $sql =
"SELECT count(p.rowid) as nb";
3618 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as p";
3619 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON p.fk_soc = s.rowid";
3620 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
3621 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
3622 $sql .=
" WHERE sc.fk_user = ".((int) $user->id);
3625 $sql .=
" ".$clause.
" p.entity IN (".
getEntity(
'ticket').
")";
3627 $resql = $this->db->query($sql);
3630 while ($obj = $this->db->fetch_object($resql)) {
3631 $this->nb[
"ticket"] = $obj->nb;
3633 $this->db->free($resql);
3636 dol_print_error($this->db);
3637 $this->error = $this->db->lasterror();
3652 $tables = array(
'ticket');
3668 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
3670 $return =
'<div class="box-flex-item box-flex-grow-zero">';
3671 $return .=
'<div class="info-box info-box-sm">';
3672 $return .=
'<span class="info-box-icon bg-infobox-action">';
3673 $return .= img_picto(
'', $this->picto);
3674 $return .=
'</span>';
3675 $return .=
'<div class="info-box-content">';
3676 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->getNomUrl(1) : $this->ref).
'</span>';
3677 if ($selected >= 0) {
3678 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
3680 if (!empty($arraydata[
'user_assignment'])) {
3681 $return .=
'<br><span class="info-box-label" title="'.dol_escape_htmltag($langs->trans(
"AssignedTo")).
'">'.$arraydata[
'user_assignment'].
'</span>';
3683 if (property_exists($this,
'type_code') && !empty($this->type_code)) {
3685 $return .=
'<div class="tdoverflowmax125 inline-block">'.$langs->getLabelFromKey($this->db,
'TicketTypeShort'.$this->type_code,
'c_ticket_type',
'code',
'label', $this->type_code).
'</div>';
3687 if (method_exists($this,
'getLibStatut')) {
3688 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
3690 $return .=
'</div>';
3691 $return .=
'</div>';
3692 $return .=
'</div>';
3708 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
3712 $langs->load(
"ticket");
3713 $outputlangs->load(
"ticket");
3716 $modele =
'generic_ticket_odt';
3718 if (!empty($this->model_pdf)) {
3719 $modele = $this->model_pdf;
3725 $modelpath =
"core/modules/ticket/doc/";
3727 return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
3747 global
$conf, $langs, $user;
3754 $langs->load(
"agenda");
3755 $this->output = $langs->trans(
'ModuleNotEnabled', $langs->transnoentitiesnoconv(
"Ticket"));
3759 $delaybeforefirstresponse =
getDolGlobalInt(
'TICKET_DELAY_BEFORE_FIRST_RESPONSE');
3760 $delaysincelastresponse =
getDolGlobalInt(
'TICKET_DELAY_SINCE_LAST_RESPONSE');
3761 if (empty($delaybeforefirstresponse) && empty($delaysincelastresponse)) {
3762 $this->output =
'Neither TICKET_DELAY_BEFORE_FIRST_RESPONSE nor TICKET_DELAY_SINCE_LAST_RESPONSE is set, nothing to check.';
3766 $langs->loadLangs(array(
'main',
'ticket'));
3772 $listofticketsok = array();
3773 $listofticketsko = array();
3776 $labelreminderok =
'sendReminderForStaleTicketsOK';
3778 $sql =
"SELECT t.rowid FROM ".MAIN_DB_PREFIX.
"ticket as t";
3779 $sql .=
" WHERE t.entity IN (".getEntity(
'ticket').
")";
3780 $sql .=
" AND t.fk_statut NOT IN (".self::STATUS_CLOSED.
", ".self::STATUS_CANCELED.
")";
3781 $sql .=
" AND t.fk_user_assign > 0";
3782 $sql .=
" AND NOT EXISTS (SELECT a.id FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
3783 $sql .=
" WHERE a.elementtype = 'ticket' AND a.fk_element = t.rowid AND a.code = 'AC_EMAIL'";
3784 $sql .=
" AND a.label = '".$this->db->escape($labelreminderok).
"'";
3787 $resql = $this->db->query($sql);
3789 $num_rows = $this->db->num_rows($resql);
3791 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
3792 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
3793 $formmail =
new FormMail($this->db);
3796 while ($i < $num_rows) {
3797 $obj = $this->db->fetch_object($resql);
3799 $ticketstatic =
new Ticket($this->db);
3800 $ticketstatic->fetch($obj->rowid);
3805 $datelastmsgsent = (int) $ticketstatic->date_last_msg_sent;
3806 if ($delaybeforefirstresponse && $datelastmsgsent == 0) {
3807 $hourdiffcreation = ($now - (int) $ticketstatic->datec) / 3600;
3808 $islate = ($hourdiffcreation > $delaybeforefirstresponse);
3809 } elseif ($delaysincelastresponse) {
3810 $hourdiff = ($now - $datelastmsgsent) / 3600;
3811 $islate = ($hourdiff > $delaysincelastresponse);
3818 $recipient =
new User($this->db);
3819 $recipientres = $recipient->fetch($ticketstatic->fk_user_assign);
3821 if ($recipientres <= 0 || empty($recipient->email)) {
3823 $listofticketsko[$ticketstatic->id] = $ticketstatic->id;
3825 $ticketstatic->fetch_thirdparty();
3827 $arraydefaultmessage =
null;
3830 if (!empty($labeltouse)) {
3831 $arraydefaultmessage = $formmail->getEMailTemplate($this->db,
'ticket', $user, $langs, 0, 1, $labeltouse);
3834 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
3835 $substitutionarray = getCommonSubstitutionArray($langs, 0,
null, $ticketstatic);
3837 $substitutionarray[
'__TICKET_STALE_SINCE_HOURS__'] = ($datelastmsgsent == 0)
3838 ? (
string) round(($now - (
int) $ticketstatic->datec) / 3600)
3839 : (string) round(($now - $datelastmsgsent) / 3600);
3841 $subject =
make_substitutions($arraydefaultmessage->topic, $substitutionarray, $langs);
3842 $msg =
make_substitutions($arraydefaultmessage->content, $substitutionarray, $langs);
3844 $to = (string) $recipient->email;
3846 $trackid =
'tic'.$ticketstatic->id;
3847 $moreinheader =
'X-Dolibarr-Info: sendReminderForStaleTickets'.
"\r\n";
3849 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
3850 $cmail =
new CMailFile($subject, $to, $email_from, $msg, array(), array(), array(),
'',
'', 0, 1,
'',
'', $trackid, $moreinheader);
3851 $result = $cmail->sendfile();
3854 $this->error .= $cmail->error.
' ';
3855 if (!is_null($cmail->errors)) {
3856 $this->errors = array_merge($this->errors, $cmail->errors);
3859 $listofticketsko[$ticketstatic->id] = $ticketstatic->id;
3862 $listofticketsok[$ticketstatic->id] = $ticketstatic->id;
3865 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
3868 $actioncomm->type_code =
'AC_OTH_AUTO';
3869 $actioncomm->code =
'AC_EMAIL';
3870 $actioncomm->label = $labelreminderok;
3871 $actioncomm->note_private = $msg;
3872 $actioncomm->fk_project = 0;
3873 $actioncomm->datep = $now;
3874 $actioncomm->datef = $now;
3875 $actioncomm->percentage = -1;
3876 $actioncomm->socid = (is_object($ticketstatic->thirdparty) ? $ticketstatic->thirdparty->id : 0);
3877 $actioncomm->contact_id = 0;
3878 $actioncomm->authorid = $user->id;
3879 $actioncomm->userownerid = $user->id;
3880 $actioncomm->email_msgid = $cmail->msgid;
3881 $actioncomm->email_from = $email_from;
3882 $actioncomm->email_sender =
'';
3883 $actioncomm->email_to = $to;
3884 $actioncomm->email_subject = $subject;
3886 $actioncomm->fk_element = $ticketstatic->id;
3887 $actioncomm->elementid = $ticketstatic->id;
3888 $actioncomm->elementtype = $ticketstatic->element;
3890 $actioncomm->create($user);
3894 $this->error .=
"Can't find email template with label=".$labeltouse.
", to use for the reminding email ";
3897 $listofticketsko[$ticketstatic->id] = $ticketstatic->id;
3907 $this->error = $this->db->lasterror();
3911 $this->output =
'Found '.($nbok + $nbko).
' late tickets to send reminder for.';
3912 $this->output .=
' Sent email successfully for '.$nbok.
' tickets';
3914 $this->output .=
' - Canceled for '.$nbko.
' ticket(s) (no email for the assigned user, missing template, or send error)';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage agenda events (actions)
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage categories.
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.
add_contact($fk_socpeople, $type_contact, $source='external', $notrigger=0)
Add a link between element $this->element and a contact.
Class to manage Dolibarr database access.
Class to manage ECM files.
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.
static replaceThirdparty($db, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
createTicketMessage($user, $notrigger=0, $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array(), $send_email=false, $public_area=0, $summary='', $external_contacts=[])
Add message into database.
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()
Load into cache the list of ticket severities (configurable in the dictionary)
$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.
setReadDate($user, $notrigger=0)
Set read date if not already set.
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 clickable 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.
const STATUS_NOT_READ
Status.
sendTicketMessageByEmail($subject, $message, $send_internal_cc=0, $array_receiver=array(), $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array(), $array_receiver_cc=array(), $email_from='', $replyto='')
Send ticket by email to linked contacts.
getTicketAllCustomerContacts()
Return id of all contacts for ticket.
sendReminderForStaleTickets()
Send an email to the assigned user when a non-closed ticket has gone too long without a reply.
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).
getIdTicketCustomerContact()
Return id des contacts clients pour le suivi ticket.
checkExistingRef(string $action, string $getRef)
Check if ref exists or not.
__construct(DoliDB $db)
Constructor.
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.
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.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
dol_get_first_hour($date, $gm='tzserver')
Return GMT time for first hour of a given GMT date (it removes hours, min and second part)
dirbasename($pathfile)
Return the relative dirname (relative to DOL_DATA_ROOT) of a full path string.
dol_move($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=1, $moreinfo=array(), $entity=null)
Move a file into another name.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0, $level=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_is_file($pathoffile)
Return if path is a file.
dol_is_dir($folder)
Test if filename is a directory.
dol_now($mode='gmt')
Return date for now.
setEntity($currentobject)
Set entity id to use when to create an object.
dol_strlen($string, $stringencoding='UTF-8', $binarycount=0)
Make a strlen call.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
isDolTms($timestamp)
isDolTms check if a timestamp is valid.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0, $forbiddenfields=array())
forgeSQLFromUniversalSearchCriteria
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.