32require_once DOL_DOCUMENT_ROOT.
"/core/class/commonobject.class.php";
33require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/ticket.lib.php';
50 public $element =
'ticket';
55 public $table_element =
'ticket';
60 public $fk_element =
'fk_ticket';
65 public $picto =
'ticket';
100 public $fk_user_create;
105 public $fk_user_assign;
157 public $category_code;
162 public $severity_code;
172 public $category_label;
177 public $severity_label;
187 public $origin_replyto;
192 public $origin_references;
207 public $date_last_msg_sent;
217 public $cache_types_tickets;
222 public $cache_category_tickets;
227 public $cache_msgs_ticket;
232 public $notify_tiers_at_create;
263 public $regeximgext =
'\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm';
269 const STATUS_READ = 1;
270 const STATUS_ASSIGNED = 2;
271 const STATUS_IN_PROGRESS = 3;
272 const STATUS_NEED_MORE_INFO = 5;
273 const STATUS_WAITING = 7;
274 const STATUS_CLOSED = 8;
275 const STATUS_CANCELED = 9;
306 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'visible' => -2,
'enabled' => 1,
'position' => 1,
'notnull' => 1,
'index' => 1,
'comment' =>
"Id"),
307 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'visible' => 0,
'enabled' => 1,
'position' => 5,
'notnull' => 1,
'index' => 1),
308 '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),
309 'track_id' => array(
'type' =>
'varchar(255)',
'label' =>
'TicketTrackId',
'visible' => -2,
'enabled' => 1,
'position' => 11,
'notnull' => -1,
'searchall' => 1,
'help' =>
"Help text"),
310 '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'),
311 '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'),
312 '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'),
313 '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'),
314 '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),
315 'type_code' => array(
'type' =>
'varchar(32)',
'label' =>
'Type',
'visible' => 1,
'enabled' => 1,
'position' => 20,
'notnull' => -1,
'help' =>
"",
'csslist' =>
'tdoverflowmax100'),
316 'category_code' => array(
'type' =>
'varchar(32)',
'label' =>
'TicketCategory',
'visible' => -1,
'enabled' => 1,
'position' => 21,
'notnull' => -1,
'help' =>
"",
'css' =>
'maxwidth100 tdoverflowmax200'),
317 'severity_code' => array(
'type' =>
'varchar(32)',
'label' =>
'Severity',
'visible' => 1,
'enabled' => 1,
'position' => 22,
'notnull' => -1,
'help' =>
"",
'css' =>
'maxwidth100'),
318 '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'),
319 'notify_tiers_at_create' => array(
'type' =>
'integer',
'label' =>
'NotifyThirdparty',
'visible' => -1,
'enabled' => 0,
'position' => 51,
'notnull' => 1,
'index' => 1),
320 'fk_project' => array(
'type' =>
'integer:Project:projet/class/project.class.php',
'label' =>
'Project',
'visible' => -1,
'enabled' =>
'$conf->project->enabled',
'position' => 52,
'notnull' => -1,
'index' => 1,
'help' =>
"LinkToProject"),
321 'fk_contract' => array(
'type' =>
'integer:Contrat:contrat/class/contrat.class.php',
'label' =>
'Contract',
'visible' => -1,
'enabled' =>
'$conf->contract->enabled',
'position' => 53,
'notnull' => -1,
'index' => 1,
'help' =>
"LinkToContract"),
323 'datec' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'visible' => 1,
'enabled' => 1,
'position' => 500,
'notnull' => 1,
'csslist' =>
'nowraponall'),
324 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'visible' => -1,
'enabled' => 1,
'position' => 501,
'notnull' => 1),
325 'date_read' => array(
'type' =>
'datetime',
'label' =>
'DateReading',
'visible' => -1,
'enabled' => 1,
'position' => 505,
'notnull' => 1,
'csslist' =>
'nowraponall'),
326 'date_last_msg_sent' => array(
'type' =>
'datetime',
'label' =>
'TicketLastMessageDate',
'visible' => 0,
'enabled' => 1,
'position' => 506,
'notnull' => -1),
327 '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'),
328 'date_close' => array(
'type' =>
'datetime',
'label' =>
'TicketCloseOn',
'visible' => -1,
'enabled' => 1,
'position' => 510,
'notnull' => 1),
329 'message' => array(
'type' =>
'html',
'label' =>
'Message',
'visible' => -2,
'enabled' => 1,
'position' => 540,
'notnull' => -1,),
330 'email_msgid' => array(
'type' =>
'varchar(255)',
'label' =>
'EmailMsgID',
'visible' => -2,
'enabled' => 1,
'position' => 540,
'notnull' => -1,
'help' =>
'EmailMsgIDDesc',
'csslist' =>
'tdoverflowmax100'),
331 'email_date' => array(
'type' =>
'datetime',
'label' =>
'EmailDate',
'visible' => -2,
'enabled' => 1,
'position' => 541),
332 'progress' => array(
'type' =>
'integer',
'label' =>
'Progression',
'visible' => -1,
'enabled' => 1,
'position' => 540,
'notnull' => -1,
'css' =>
'right',
'help' =>
"",
'isameasure' => 1,
'csslist' =>
'width50'),
333 'resolution' => array(
'type' =>
'integer',
'label' =>
'Resolution',
'visible' => -1,
'enabled' =>
'getDolGlobalString("TICKET_ENABLE_RESOLUTION")',
'position' => 550,
'notnull' => 1),
334 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'PDFTemplate',
'enabled' => 1,
'visible' => 0,
'position' => 560),
335 'extraparams' => array(
'type' =>
'varchar(255)',
'label' =>
'Extraparams',
'enabled' => 1,
'visible' => -1,
'position' => 570),
336 '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')),
337 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 900),
351 $this->ismultientitymanaged = 1;
352 $this->isextrafieldmanaged = 1;
354 $this->labelStatusShort = array(
355 self::STATUS_NOT_READ =>
'Unread',
356 self::STATUS_READ =>
'Read',
357 self::STATUS_ASSIGNED =>
'Assigned',
358 self::STATUS_IN_PROGRESS =>
'InProgress',
359 self::STATUS_NEED_MORE_INFO =>
'NeedMoreInformationShort',
360 self::STATUS_WAITING =>
'OnHold',
361 self::STATUS_CLOSED =>
'SolvedClosed',
362 self::STATUS_CANCELED =>
'Canceled'
364 $this->labelStatus = array(
365 self::STATUS_NOT_READ =>
'Unread',
366 self::STATUS_READ =>
'Read',
367 self::STATUS_ASSIGNED =>
'Assigned',
368 self::STATUS_IN_PROGRESS =>
'InProgress',
369 self::STATUS_NEED_MORE_INFO =>
'NeedMoreInformation',
370 self::STATUS_WAITING =>
'OnHold',
371 self::STATUS_CLOSED =>
'SolvedClosed',
372 self::STATUS_CANCELED =>
'Canceled'
376 unset($this->fields[
'fk_statut'][
'arrayofkeyval'][self::STATUS_WAITING]);
377 unset($this->labelStatusShort[self::STATUS_WAITING]);
378 unset($this->labelStatus[self::STATUS_WAITING]);
390 $this->errors = array();
395 if (isset($this->
ref)) {
396 $this->
ref = trim($this->
ref);
399 if (isset($this->track_id)) {
400 $this->track_id = trim($this->track_id);
403 if (isset($this->fk_soc)) {
404 $this->fk_soc = (int) $this->fk_soc;
407 if (isset($this->fk_project)) {
408 $this->fk_project = (int) $this->fk_project;
411 if (isset($this->origin_email)) {
412 $this->origin_email = trim($this->origin_email);
415 if (isset($this->fk_user_create)) {
416 $this->fk_user_create = (int) $this->fk_user_create;
419 if (isset($this->fk_user_assign)) {
420 $this->fk_user_assign = (int) $this->fk_user_assign;
423 if (isset($this->subject)) {
424 $this->subject = trim($this->subject);
427 if (isset($this->message)) {
428 $this->message = trim($this->message);
430 $this->errors[] =
'ErrorFieldTooLong';
431 dol_syslog(get_class($this).
'::create error -1 message too long', LOG_ERR);
436 if (isset($this->
status)) {
440 if (isset($this->resolution)) {
441 $this->resolution = (int) $this->resolution;
444 if (isset($this->progress)) {
445 $this->progress = (int) $this->progress;
448 if (isset($this->timing)) {
449 $this->timing = trim($this->timing);
452 if (isset($this->type_code)) {
453 $this->type_code = trim($this->type_code);
456 if (isset($this->category_code)) {
457 $this->category_code = trim($this->category_code);
460 if (isset($this->severity_code)) {
461 $this->severity_code = trim($this->severity_code);
464 if (empty($this->
ref)) {
465 $this->errors[] =
'ErrorTicketRefRequired';
466 dol_syslog(get_class($this).
"::create error -1 ref null", LOG_ERR);
483 $test =
new self($this->db);
485 if ($test->fetch(0, $getRef) > 0) {
486 if (($action ==
'add') || ($action ==
'update' && $this->
ref != $getRef)) {
491 $this->
ref = $getRef;
502 public function create($user, $notrigger = 0)
510 if (empty($this->track_id)) {
516 $result = $this->
verify();
519 $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);
522 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"ticket(";
526 $sql .=
"fk_project,";
527 $sql .=
"fk_contract,";
528 $sql .=
"origin_email,";
529 $sql .=
"origin_replyto,";
530 $sql .=
"origin_references,";
531 $sql .=
"fk_user_create,";
532 $sql .=
"fk_user_assign,";
533 $sql .=
"email_msgid,";
534 $sql .=
"email_date,";
537 $sql .=
"fk_statut,";
538 $sql .=
"resolution,";
541 $sql .=
"type_code,";
542 $sql .=
"category_code,";
543 $sql .=
"severity_code,";
545 $sql .=
"date_read,";
546 $sql .=
"date_close,";
548 $sql .=
"notify_tiers_at_create,";
549 $sql .=
"model_pdf,";
551 $sql .=
") VALUES (";
552 $sql .=
" ".(!isset($this->
ref) ?
'' :
"'".$this->db->escape($this->
ref).
"'").
",";
553 $sql .=
" ".(!isset($this->track_id) ?
'NULL' :
"'".$this->db->escape($this->track_id).
"'").
",";
554 $sql .=
" ".($this->fk_soc > 0 ? ((int) $this->fk_soc) :
"null").
",";
555 $sql .=
" ".($this->fk_project > 0 ? ((int) $this->fk_project) :
"null").
",";
556 $sql .=
" ".($this->fk_contract > 0 ? ((int) $this->fk_contract) :
"null").
",";
557 $sql .=
" ".(!isset($this->origin_email) ?
'NULL' :
"'".$this->db->escape($this->origin_email).
"'").
",";
558 $sql .=
" ".(!isset($this->origin_replyto) ?
'NULL' :
"'".$this->db->escape($this->origin_replyto).
"'").
",";
559 $sql .=
" ".(!isset($this->origin_references) ?
'NULL' :
"'".$this->db->escape($this->origin_references).
"'").
",";
560 $sql .=
" ".(!isset($this->fk_user_create) ? ($user->id > 0 ? ((int) $user->id) :
'NULL') : ($this->fk_user_create > 0 ? ((int) $this->fk_user_create) :
'NULL')).
",";
561 $sql .=
" ".($this->fk_user_assign > 0 ? ((int) $this->fk_user_assign) :
'NULL').
",";
562 $sql .=
" ".(empty($this->email_msgid) ?
'NULL' :
"'".$this->db->escape($this->email_msgid).
"'").
",";
563 $sql .=
" ".(!
isDolTms($this->email_date) ?
'NULL' :
"'".$this->db->idate($this->email_date).
"'").
",";
564 $sql .=
" ".(!isset($this->subject) ?
'NULL' :
"'".$this->db->escape($this->subject).
"'").
",";
565 $sql .=
" ".(!isset($this->message) ?
'NULL' :
"'".$this->db->escape($this->message).
"'").
",";
566 $sql .=
" ".(!isset($this->
status) ?
'0' : ((int) $this->
status)).
",";
567 $sql .=
" ".(!isset($this->resolution) ?
'NULL' : ((int) $this->resolution)).
",";
568 $sql .=
" ".(!isset($this->progress) ?
'0' : ((int) $this->progress)).
",";
569 $sql .=
" ".(!isset($this->timing) ?
'NULL' :
"'".$this->db->escape($this->timing).
"'").
",";
570 $sql .=
" ".(!isset($this->type_code) ?
'NULL' :
"'".$this->db->escape($this->type_code).
"'").
",";
571 $sql .=
" ".(empty($this->category_code) || $this->category_code ==
'-1' ?
'NULL' :
"'".$this->db->escape($this->category_code).
"'").
",";
572 $sql .=
" ".(!isset($this->severity_code) ?
'NULL' :
"'".$this->db->escape($this->severity_code).
"'").
",";
573 $sql .=
" ".(!
isDolTms($this->datec) ?
'NULL' :
"'".$this->db->idate($this->datec).
"'").
",";
574 $sql .=
" ".(!isset($this->date_read) ||
dol_strlen((
string) $this->date_read) == 0 ?
'NULL' :
"'".$this->db->idate($this->date_read).
"'").
",";
575 $sql .=
" ".(!isset($this->date_close) ||
dol_strlen((
string) $this->date_close) == 0 ?
'NULL' :
"'".$this->db->idate($this->date_close).
"'");
576 $sql .=
", ".((int) $this->entity);
577 $sql .=
", ".(!isset($this->notify_tiers_at_create) ? 1 : ((int) $this->notify_tiers_at_create));
578 $sql .=
", '".$this->db->escape($this->model_pdf).
"'";
579 $sql .=
", ".(!isset($this->ip) ?
'NULL' :
"'".$this->db->escape($this->ip).
"'");
584 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
585 $resql = $this->db->query($sql);
588 $this->errors[] =
"Error ".$this->db->lasterror();
592 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"ticket");
595 if (!$error &&
getDolGlobalString(
'TICKET_ADD_AUTHOR_AS_CONTACT') && empty($this->context[
"createdfrompublicinterface"])) {
599 if (!empty($user->socid) && !empty($user->contact_id) &&
getDolGlobalInt(
'TICKET_ADD_AUTHOR_AS_CONTACT') == 2) {
600 $contact_type =
'external';
601 $contributor_id = $user->contact_id;
603 $contact_type =
'internal';
604 $contributor_id = $user->id;
608 if ($this->
add_contact($contributor_id,
'CONTRIBUTOR', $contact_type) < 0) {
613 if (!$error && $this->fk_user_assign > 0) {
614 if ($this->
add_contact($this->fk_user_assign,
'SUPPORTTEC',
'internal') < 0) {
628 if (!$error && !$notrigger) {
639 foreach ($this->errors as $errmsg) {
640 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
641 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
643 $this->db->rollback();
650 $this->db->rollback();
651 dol_syslog(get_class($this).
"::Create fails verify ".implode(
',', $this->errors), LOG_WARNING);
665 public function fetch(
$id = 0, $ref =
'', $track_id =
'', $email_msgid =
'')
670 if (empty(
$id) && empty($ref) && empty($track_id) && empty($email_msgid)) {
671 $this->error =
'ErrorWrongParameters';
678 $sql .=
" t.entity,";
680 $sql .=
" t.track_id,";
681 $sql .=
" t.fk_soc,";
682 $sql .=
" t.fk_project,";
683 $sql .=
" t.fk_contract,";
684 $sql .=
" t.origin_email,";
685 $sql .=
" t.origin_replyto,";
686 $sql .=
" t.origin_references,";
687 $sql .=
" t.fk_user_create,";
688 $sql .=
" t.fk_user_assign,";
689 $sql .=
" t.email_msgid,";
690 $sql .=
" t.email_date,";
691 $sql .=
" t.subject,";
692 $sql .=
" t.message,";
693 $sql .=
" t.fk_statut as status,";
694 $sql .=
" t.resolution,";
695 $sql .=
" t.progress,";
696 $sql .=
" t.timing,";
697 $sql .=
" t.type_code,";
698 $sql .=
" t.category_code,";
699 $sql .=
" t.severity_code,";
701 $sql .=
" t.date_read,";
702 $sql .=
" t.date_last_msg_sent,";
703 $sql .=
" t.date_close,";
705 $sql .=
" t.model_pdf,";
706 $sql .=
" t.extraparams,";
708 $sql .=
" type.label as type_label, category.label as category_label, severity.label as severity_label";
709 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as t";
710 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_type as type ON type.code=t.type_code";
711 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_category as category ON category.code=t.category_code";
712 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_severity as severity ON severity.code=t.severity_code";
715 $sql .=
" WHERE t.rowid = ".((int)
$id);
717 $sql .=
" WHERE t.entity IN (".getEntity($this->element, 1).
")";
719 $sql .=
" AND t.ref = '".$this->db->escape($ref).
"'";
720 } elseif ($track_id) {
721 $sql .=
" AND t.track_id = '".$this->db->escape($track_id).
"'";
723 $sql .=
" AND t.email_msgid = '".$this->db->escape($email_msgid).
"'";
727 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
728 $resql = $this->db->query($sql);
730 if ($this->db->num_rows($resql)) {
731 $obj = $this->db->fetch_object($resql);
733 $this->
id = $obj->rowid;
734 $this->entity = $obj->entity;
735 $this->
ref = $obj->ref;
736 $this->track_id = $obj->track_id;
737 $this->fk_soc = $obj->fk_soc;
738 $this->socid = $obj->fk_soc;
739 $this->fk_project = $obj->fk_project;
740 $this->fk_contract = $obj->fk_contract;
741 $this->origin_email = $obj->origin_email;
742 $this->origin_replyto = $obj->origin_replyto;
743 $this->origin_references = $obj->origin_references;
744 $this->fk_user_create = $obj->fk_user_create;
745 $this->fk_user_assign = $obj->fk_user_assign;
746 $this->email_msgid = $obj->email_msgid;
747 $this->email_date = $this->db->jdate($obj->email_date);
748 $this->subject = $obj->subject;
749 $this->message = $obj->message;
750 $this->model_pdf = $obj->model_pdf;
751 $this->extraparams = !empty($obj->extraparams) ? (array) json_decode($obj->extraparams,
true) : array();
752 $this->ip = $obj->ip;
754 $this->
status = $obj->status;
755 $this->fk_statut = $this->status;
757 $this->resolution = $obj->resolution;
758 $this->progress = $obj->progress;
759 $this->timing = $obj->timing;
761 $this->type_code = $obj->type_code;
762 $label_type = ($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 = ($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 = ($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.fk_statut as status,";
830 $sql .=
" t.resolution,";
831 $sql .=
" t.progress,";
832 $sql .=
" t.timing,";
833 $sql .=
" t.type_code,";
834 $sql .=
" t.category_code,";
835 $sql .=
" t.severity_code,";
837 $sql .=
" t.date_read,";
838 $sql .=
" t.date_last_msg_sent,";
839 $sql .=
" t.date_close,";
841 $sql .=
" type.label as type_label, category.label as category_label, severity.label as severity_label";
843 if ($extrafields->attributes[$this->table_element][
'count'] > 0) {
844 foreach ($extrafields->attributes[$this->table_element][
'label'] as $key => $val) {
845 $sql .= ($extrafields->attributes[$this->table_element][
'type'][$key] !=
'separate' ?
",ef.".$key.
" as options_".$key :
'');
848 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as t";
849 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_type as type ON type.code = t.type_code";
850 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_category as category ON category.code = t.category_code";
851 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_severity as severity ON severity.code = t.severity_code";
852 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = t.fk_soc";
853 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as uc ON uc.rowid = t.fk_user_create";
854 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as ua ON ua.rowid = t.fk_user_assign";
855 if ($extrafields->attributes[$this->table_element][
'count'] > 0) {
856 if (is_array($extrafields->attributes[$this->table_element][
'label']) && count($extrafields->attributes[$this->table_element][
'label'])) {
857 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"ticket_extrafields as ef on (t.rowid = ef.fk_object)";
860 $sql .=
" WHERE t.entity IN (".getEntity(
'ticket').
")";
863 if (is_array($filter)) {
864 foreach ($filter as $key => $value) {
865 if (strpos($key,
'date')) {
866 $sql .=
" AND ".$this->db->sanitize($key).
" = '".$this->db->escape($value).
"'";
867 } elseif (($key ==
't.fk_user_assign') || ($key ==
't.type_code') || ($key ==
't.category_code') || ($key ==
't.severity_code') || ($key ==
't.fk_soc')) {
868 $sql .=
" AND ".$this->db->sanitize($key).
" = '".$this->db->escape($value).
"'";
869 } elseif ($key ==
't.fk_statut') {
870 if (is_array($value) && count($value) > 0) {
871 $sql .=
" AND ".$this->db->sanitize($key).
" IN (".$this->db->sanitize(implode(
',', $value)).
")";
873 $sql .=
" AND ".$this->db->sanitize($key).
' = '.((int) $value);
875 } elseif ($key ==
't.fk_contract') {
876 $sql .=
" AND ".$this->db->sanitize($key).
' = '.((int) $value);
878 $sql .=
" AND ".$this->db->sanitize($key).
" LIKE '%".$this->db->escape($this->db->escapeforlike($value)).
"%'";
889 $this->errors[] = $errormessage;
890 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
895 $socid = $user->socid ?: 0;
898 if (!$user->hasRight(
'societe',
'client',
'voir')) {
899 $search_sale = $user->id;
902 if ($search_sale && $search_sale !=
'-1') {
903 if ($search_sale == -2) {
904 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc)";
905 } elseif ($search_sale > 0) {
906 $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).
")";
911 $sql .=
" AND t.fk_soc = ".((int) $socid);
914 $sql .= $this->db->order($sortfield, $sortorder);
915 if (!empty($limit)) {
916 $sql .= $this->db->plimit($limit + 1, $offset);
919 dol_syslog(get_class($this).
"::fetchAll", LOG_DEBUG);
920 $resql = $this->db->query($sql);
923 $this->lines = array();
925 $num = $this->db->num_rows($resql);
930 $obj = $this->db->fetch_object($resql);
932 $line =
new self($this->db);
934 $line->id = $obj->rowid;
936 $line->ref = $obj->ref;
937 $line->track_id = $obj->track_id;
938 $line->fk_soc = $obj->fk_soc;
939 $line->fk_project = $obj->fk_project;
940 $line->fk_contract = $obj->fk_contract;
941 $line->origin_email = $obj->origin_email;
942 $line->origin_replyto = $obj->origin_replyto;
943 $line->origin_references = $obj->origin_references;
945 $line->fk_user_create = $obj->fk_user_create;
946 $line->fk_user_assign = $obj->fk_user_assign;
948 $line->subject = $obj->subject;
949 $line->message = $obj->message;
950 $line->fk_statut = $obj->status;
951 $line->status = $obj->status;
952 $line->resolution = $obj->resolution;
953 $line->progress = $obj->progress;
954 $line->timing = $obj->timing;
956 $label_type = ($langs->trans(
"TicketTypeShort".$obj->type_code) !=
"TicketTypeShort".$obj->type_code ? $langs->trans(
"TicketTypeShort".$obj->type_code) : ($obj->type_label !=
'-' ? $obj->type_label :
''));
957 $line->type_label = $label_type;
959 $this->category_code = $obj->category_code;
960 $label_category = ($langs->trans(
"TicketCategoryShort".$obj->category_code) !=
"TicketCategoryShort".$obj->category_code ? $langs->trans(
"TicketCategoryShort".$obj->category_code) : ($obj->category_label !=
'-' ? $obj->category_label :
''));
961 $line->category_label = $label_category;
963 $this->severity_code = $obj->severity_code;
964 $label_severity = ($langs->trans(
"TicketSeverityShort".$obj->severity_code) !=
"TicketSeverityShort".$obj->severity_code ? $langs->trans(
"TicketSeverityShort".$obj->severity_code) : ($obj->severity_label !=
'-' ? $obj->severity_label :
''));
965 $line->severity_label = $label_severity;
967 $line->datec = $this->db->jdate($obj->datec);
968 $line->date_read = $this->db->jdate($obj->date_read);
969 $line->date_last_msg_sent = $this->db->jdate($obj->date_last_msg_sent);
970 $line->date_close = $this->db->jdate($obj->date_close);
973 if ($extrafields->attributes[$this->table_element][
'count'] > 0) {
974 if (is_array($extrafields->attributes[$this->table_element][
'label']) && count($extrafields->attributes[$this->table_element][
'label'])) {
975 foreach ($extrafields->attributes[$this->table_element][
'label'] as $key => $val) {
976 $tmpkey =
'options_'.$key;
977 $line->{$tmpkey} = $obj->$tmpkey;
981 $this->lines[$i] = $line;
985 $this->db->free($resql);
988 $this->error =
"Error ".$this->db->lasterror();
989 dol_syslog(get_class($this).
"::fetchAll ".$this->error, LOG_ERR);
1001 public function update($user, $notrigger = 0)
1012 if (isset($this->
ref)) {
1013 $this->
ref = trim($this->
ref);
1016 if (isset($this->track_id)) {
1017 $this->track_id = trim($this->track_id);
1020 if (isset($this->fk_soc)) {
1021 $this->fk_soc = (int) $this->fk_soc;
1024 if (isset($this->fk_project)) {
1025 $this->fk_project = (int) $this->fk_project;
1028 if (isset($this->fk_contract)) {
1029 $this->fk_contract = (int) $this->fk_contract;
1032 if (isset($this->origin_email)) {
1033 $this->origin_email = trim($this->origin_email);
1036 if (isset($this->fk_user_create)) {
1037 $this->fk_user_create = (int) $this->fk_user_create;
1040 if (isset($this->fk_user_assign)) {
1041 $this->fk_user_assign = (int) $this->fk_user_assign;
1044 if (isset($this->subject)) {
1045 $this->subject = trim($this->subject);
1048 if (isset($this->message)) {
1049 $this->message = trim($this->message);
1051 $this->errors[] =
'ErrorFieldTooLong';
1052 dol_syslog(get_class($this).
'::update error -1 message too long', LOG_ERR);
1057 if (isset($this->
status)) {
1061 if (isset($this->resolution)) {
1062 $this->resolution = (int) $this->resolution;
1065 if (isset($this->progress)) {
1066 $this->progress = (int) $this->progress;
1069 if (isset($this->timing)) {
1070 $this->timing = trim($this->timing);
1073 if (isset($this->type_code)) {
1074 $this->timing = trim($this->type_code);
1077 if (isset($this->category_code)) {
1078 $this->timing = trim($this->category_code);
1081 if (isset($this->severity_code)) {
1082 $this->timing = trim($this->severity_code);
1084 if (isset($this->model_pdf)) {
1085 $this->model_pdf = trim($this->model_pdf);
1090 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket SET";
1091 $sql .=
" ref=".(isset($this->
ref) ?
"'".$this->db->escape($this->
ref).
"'" :
"").
",";
1092 $sql .=
" track_id=".(isset($this->track_id) ?
"'".$this->db->escape($this->track_id).
"'" :
"null").
",";
1093 $sql .=
" fk_soc=".(isset($this->fk_soc) ? (int) $this->fk_soc :
"null").
",";
1094 $sql .=
" fk_project=".(isset($this->fk_project) ? (int) $this->fk_project :
"null").
",";
1095 $sql .=
" fk_contract=".(isset($this->fk_contract) ? (int) $this->fk_contract :
"null").
",";
1096 $sql .=
" origin_email=".(isset($this->origin_email) ?
"'".$this->db->escape($this->origin_email).
"'" :
"null").
",";
1097 $sql .=
" origin_replyto=".(isset($this->origin_replyto) ?
"'".$this->db->escape($this->origin_replyto).
"'" :
"null").
",";
1098 $sql .=
" origin_references=".(isset($this->origin_references) ?
"'".$this->db->escape($this->origin_references).
"'" :
"null").
",";
1099 $sql .=
" fk_user_create=".(isset($this->fk_user_create) ? (int) $this->fk_user_create :
"null").
",";
1100 $sql .=
" fk_user_assign=".(isset($this->fk_user_assign) ? (int) $this->fk_user_assign :
"null").
",";
1101 $sql .=
" subject=".(isset($this->subject) ?
"'".$this->db->escape($this->subject).
"'" :
"null").
",";
1102 $sql .=
" message=".(isset($this->message) ?
"'".$this->db->escape($this->message).
"'" :
"null").
",";
1103 $sql .=
" fk_statut=".(isset($this->
status) ? (int) $this->
status :
"0").
",";
1104 $sql .=
" resolution=".(isset($this->resolution) ? (int) $this->resolution :
"null").
",";
1105 $sql .=
" progress=".(isset($this->progress) ?
"'".$this->db->escape($this->progress).
"'" :
"null").
",";
1106 $sql .=
" timing=".(isset($this->timing) ?
"'".$this->db->escape($this->timing).
"'" :
"null").
",";
1107 $sql .=
" type_code=".(isset($this->type_code) ?
"'".$this->db->escape($this->type_code).
"'" :
"null").
",";
1108 $sql .=
" category_code=".(isset($this->category_code) ?
"'".$this->db->escape($this->category_code).
"'" :
"null").
",";
1109 $sql .=
" severity_code=".(isset($this->severity_code) ?
"'".$this->db->escape($this->severity_code).
"'" :
"null").
",";
1110 $sql .=
" datec=".(isDolTms($this->datec) ?
"'".$this->db->idate($this->datec).
"'" :
'null').
",";
1111 $sql .=
" date_read=".(dol_strlen((
string) $this->date_read) != 0 ?
"'".$this->db->idate($this->date_read).
"'" :
'null').
",";
1112 $sql .=
" date_last_msg_sent=".(dol_strlen((
string) $this->date_last_msg_sent) != 0 ?
"'".$this->db->idate($this->date_last_msg_sent).
"'" :
'null').
",";
1113 $sql .=
" model_pdf=".(isset($this->model_pdf) ?
"'".$this->db->escape($this->model_pdf).
"'" :
"null").
",";
1114 $sql .=
" date_close=".(dol_strlen((
string) $this->date_close) != 0 ?
"'".$this->db->idate($this->date_close).
"'" :
'null');
1115 $sql .=
" WHERE rowid=".((int) $this->
id);
1119 $resql = $this->db->query($sql);
1122 $this->errors[] =
"Error ".$this->db->lasterror();
1127 $result = $this->insertExtraFields();
1133 if (!$error && !$notrigger) {
1135 $result = $this->call_trigger(
'TICKET_MODIFY', $user);
1144 foreach ($this->errors as $errmsg) {
1145 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
1146 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1148 $this->db->rollback();
1151 $this->db->commit();
1163 public function delete($user, $notrigger = 0)
1171 $result = $this->call_trigger(
'TICKET_DELETE', $user);
1180 $res = $this->delete_linked_contact();
1182 dol_syslog(get_class($this).
"::delete error", LOG_ERR);
1189 $res = $this->deleteObjectLinked();
1197 $result = $this->deleteExtraFields();
1200 dol_syslog(get_class($this).
"::delete error -3 ".$this->error, LOG_ERR);
1207 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_ticket";
1208 $sql .=
" WHERE fk_ticket = ".(int) $this->
id;
1210 $result = $this->db->query($sql);
1213 $this->errors[] = $this->db->lasterror();
1218 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"ticket";
1219 $sql .=
" WHERE rowid=".((int) $this->
id);
1221 dol_syslog(get_class($this).
"::delete sql=".$sql);
1222 $resql = $this->db->query($sql);
1225 $this->errors[] =
"Error ".$this->db->lasterror();
1228 $this->deleteEcmFiles(1);
1230 $dir = DOL_DATA_ROOT.
'/'.$this->element.
'/'.$this->ref;
1234 $this->errors[] = $this->error;
1242 foreach ($this->errors as $errmsg) {
1243 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
1244 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1246 $this->db->rollback();
1249 $this->db->commit();
1278 $object->context[
'createfromclone'] =
'createfromclone';
1279 $result =
$object->create($user);
1283 $this->error =
$object->error;
1287 unset(
$object->context[
'createfromclone']);
1291 $this->db->commit();
1294 $this->db->rollback();
1309 $this->
ref =
'TI0501-001';
1310 $this->track_id =
'XXXXaaaa';
1311 $this->origin_email =
'email@email.com';
1312 $this->fk_project = 1;
1313 $this->fk_user_create = 1;
1314 $this->fk_user_assign = 1;
1315 $this->subject =
'Subject of ticket';
1316 $this->message =
'Message of ticket';
1318 $this->resolution = 1;
1319 $this->progress = 10;
1321 $this->type_code =
'TYPECODE';
1322 $this->category_code =
'CATEGORYCODE';
1323 $this->severity_code =
'SEVERITYCODE';
1326 $this->date_last_msg_sent =
dol_now();
1327 $this->date_close =
dol_now();
1341 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 =
'');
1354 if (!empty($this->cache_types_tickets) && count($this->cache_types_tickets)) {
1359 $sql =
"SELECT rowid, code, label, use_default, pos, description";
1360 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_type";
1361 $sql .=
" WHERE entity IN (".getEntity(
'c_ticket_type').
")";
1362 $sql .=
" AND active > 0";
1363 $sql .=
" ORDER BY pos";
1364 dol_syslog(get_class($this).
"::load_cache_type_tickets", LOG_DEBUG);
1365 $resql = $this->db->query($sql);
1367 $num = $this->db->num_rows($resql);
1370 $obj = $this->db->fetch_object($resql);
1371 $label = ($langs->trans(
"TicketTypeShort".$obj->code) !=
"TicketTypeShort".$obj->code ? $langs->trans(
"TicketTypeShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
1372 $this->cache_types_tickets[$obj->rowid][
'code'] = $obj->code;
1373 $this->cache_types_tickets[$obj->rowid][
'label'] = $label;
1374 $this->cache_types_tickets[$obj->rowid][
'use_default'] = $obj->use_default;
1375 $this->cache_types_tickets[$obj->rowid][
'pos'] = $obj->pos;
1395 if ($publicgroup == -1 && !empty($this->cache_category_tickets) && count($this->cache_category_tickets)) {
1400 $sql =
"SELECT rowid, code, label, use_default, pos, description, public, active, force_severity, fk_parent";
1401 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_category";
1402 $sql .=
" WHERE entity IN (".getEntity(
'c_ticket_category').
")";
1403 $sql .=
" AND active > 0";
1404 if ($publicgroup > -1) {
1405 $sql .=
" AND public = ".((int) $publicgroup);
1407 $sql .=
" ORDER BY pos";
1409 dol_syslog(get_class($this).
"::load_cache_categories_tickets", LOG_DEBUG);
1411 $resql = $this->db->query($sql);
1413 $num = $this->db->num_rows($resql);
1416 $obj = $this->db->fetch_object($resql);
1417 $this->cache_category_tickets[$obj->rowid][
'code'] = $obj->code;
1418 $this->cache_category_tickets[$obj->rowid][
'use_default'] = $obj->use_default;
1419 $this->cache_category_tickets[$obj->rowid][
'pos'] = $obj->pos;
1420 $this->cache_category_tickets[$obj->rowid][
'public'] = $obj->public;
1421 $this->cache_category_tickets[$obj->rowid][
'active'] = $obj->active;
1422 $this->cache_category_tickets[$obj->rowid][
'force_severity'] = $obj->force_severity;
1423 $this->cache_category_tickets[$obj->rowid][
'fk_parent'] = $obj->fk_parent;
1427 $label = ($langs->trans(
"TicketCategoryShort".$obj->code) !=
"TicketCategoryShort".$obj->code ? $langs->trans(
"TicketCategoryShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
1428 $this->cache_category_tickets[$obj->rowid][
'label'] = $label;
1446 global $conf, $langs;
1448 if (!empty($conf->cache[
'severity_tickets']) && count($conf->cache[
'severity_tickets'])) {
1453 $sql =
"SELECT rowid, code, label, use_default, pos, description";
1454 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_severity";
1455 $sql .=
" WHERE entity IN (".getEntity(
'c_ticket_severity').
")";
1456 $sql .=
" AND active > 0";
1457 $sql .=
" ORDER BY pos";
1458 dol_syslog(get_class($this).
"::loadCacheSeveritiesTickets", LOG_DEBUG);
1459 $resql = $this->db->query($sql);
1461 $num = $this->db->num_rows($resql);
1464 $obj = $this->db->fetch_object($resql);
1466 $conf->cache[
'severity_tickets'][$obj->rowid][
'code'] = $obj->code;
1467 $label = ($langs->trans(
"TicketSeverityShort".$obj->code) !=
"TicketSeverityShort".$obj->code ? $langs->trans(
"TicketSeverityShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
1468 $conf->cache[
'severity_tickets'][$obj->rowid][
'label'] = $label;
1469 $conf->cache[
'severity_tickets'][$obj->rowid][
'use_default'] = $obj->use_default;
1470 $conf->cache[
'severity_tickets'][$obj->rowid][
'pos'] = $obj->pos;
1489 return $this->LibStatut($this->
status, $mode, 0, $this->progress);
1503 public function LibStatut($status, $mode = 0, $notooltip = 0, $progress = 0)
1506 global $langs, $hookmanager;
1508 $labelStatus = (isset($status) && !empty($this->labelStatus[$status])) ? $this->labelStatus[$status] :
'';
1509 $labelStatusShort = (isset($status) && !empty($this->labelStatusShort[$status])) ? $this->labelStatusShort[$status] :
'';
1512 case self::STATUS_NOT_READ:
1513 $statusType =
'status0';
1515 case self::STATUS_READ:
1516 $statusType =
'status1';
1518 case self::STATUS_ASSIGNED:
1519 $statusType =
'status2';
1521 case self::STATUS_IN_PROGRESS:
1522 $statusType =
'status4';
1524 case self::STATUS_WAITING:
1525 $statusType =
'status7';
1527 case self::STATUS_NEED_MORE_INFO:
1528 $statusType =
'status3';
1530 case self::STATUS_CANCELED:
1531 $statusType =
'status9';
1533 case self::STATUS_CLOSED:
1534 $statusType =
'status6';
1537 $labelStatus =
'Unknown';
1538 $labelStatusShort =
'Unknown';
1539 $statusType =
'status0';
1543 $parameters = array(
1544 'status' => $status,
1549 $reshook = $hookmanager->executeHooks(
'LibStatut', $parameters, $this);
1552 return $hookmanager->resPrint;
1557 $params = array(
'tooltip' =>
'no');
1560 $labelStatus = $langs->transnoentitiesnoconv($labelStatus);
1561 $labelStatusShort = $langs->transnoentitiesnoconv($labelStatusShort);
1563 if ($status == self::STATUS_IN_PROGRESS && $progress > 0) {
1564 $labelStatus .=
' ('.round($progress).
'%)';
1565 $labelStatusShort .=
' ('.round($progress).
'%)';
1568 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode,
'', $params);
1581 $langs->load(
'ticket');
1582 $nofetch = !empty($params[
'nofetch']);
1585 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Ticket").
'</u>';
1586 $datas[
'picto'] .=
' '.$this->getLibStatut(4);
1587 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1588 $datas[
'track_id'] =
'<br><b>'.$langs->trans(
'TicketTrackId').
':</b> '.$this->track_id;
1589 $datas[
'subject'] =
'<br><b>'.$langs->trans(
'Subject').
':</b> '.$this->subject;
1590 if ($this->date_creation) {
1591 $datas[
'date_creation'] =
'<br><b>'.$langs->trans(
'DateCreation').
':</b> '.
dol_print_date($this->date_creation,
'dayhour');
1593 if ($this->date_modification) {
1594 $datas[
'date_modification'] =
'<br><b>'.$langs->trans(
'DateModification').
':</b> '.
dol_print_date($this->date_modification,
'dayhour');
1597 if (isModEnabled(
'category') && !$nofetch) {
1598 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
1599 $form =
new Form($this->db);
1600 $datas[
'categories'] =
'<br>' . $form->showCategories($this->
id, Categorie::TYPE_TICKET, 1);
1616 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1618 global $action, $conf, $hookmanager, $langs;
1620 if (!empty($conf->dol_no_mouse_hover)) {
1628 'objecttype' => $this->element,
1629 'option' => $option,
1632 $classfortooltip =
'classfortooltip';
1635 $classfortooltip =
'classforajaxtooltip';
1636 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1639 $label = implode($this->getTooltipContentArray($params));
1642 $url = DOL_URL_ROOT.
'/ticket/card.php?id='.
$this->id;
1644 if ($option !=
'nolink') {
1646 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1647 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1648 $add_save_lastsearch_values = 1;
1650 if ($add_save_lastsearch_values) {
1651 $url .=
'&save_lastsearch_values=1';
1656 if (empty($notooltip)) {
1658 $label = $langs->trans(
"ShowTicket");
1659 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1661 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
1662 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1664 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1667 $linkstart =
'<a href="'.$url.
'"';
1668 $linkstart .= $linkclose.
'>';
1671 $result .= $linkstart;
1673 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ?:
'generic'), (($withpicto != 2) ?
'class="paddingright"' :
''), 0, 0, $notooltip ? 0 : 1);
1675 if ($withpicto != 2) {
1676 $result .= $this->ref;
1678 $result .= $linkend;
1681 $hookmanager->initHooks(array(
'ticketdao'));
1682 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1683 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1685 $result = $hookmanager->resPrint;
1687 $result .= $hookmanager->resPrint;
1707 if ($this->
status != self::STATUS_CANCELED) {
1712 $this->
status = Ticket::STATUS_READ;
1714 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
1715 $sql .=
" SET fk_statut = ".Ticket::STATUS_READ.
", date_read = '".$this->db->idate(
dol_now()).
"'";
1716 $sql .=
" WHERE rowid = ".((int) $this->
id);
1719 $resql = $this->db->query($sql);
1721 $this->context[
'actionmsg'] = $langs->trans(
'TicketLogMesgReadBy', $this->
ref, $user->getFullName($langs));
1722 $this->context[
'actionmsg2'] = $langs->trans(
'TicketLogMesgReadBy', $this->
ref, $user->getFullName($langs));
1726 $result = $this->call_trigger(
'TICKET_MODIFY', $user);
1734 $this->db->commit();
1737 $this->
status = $this->oldcopy->status;
1739 $this->db->rollback();
1740 $this->error = implode(
',', $this->errors);
1741 dol_syslog(get_class($this).
"::markAsRead ".$this->error, LOG_ERR);
1745 $this->
status = $this->oldcopy->status;
1747 $this->db->rollback();
1748 $this->error = $this->db->lasterror();
1749 dol_syslog(get_class($this).
"::markAsRead ".$this->error, LOG_ERR);
1765 public function assignUser($user, $id_assign_user, $notrigger = 0)
1773 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
1774 if ($id_assign_user > 0) {
1775 $sql .=
" SET fk_user_assign=".((int) $id_assign_user).
", fk_statut = ".Ticket::STATUS_ASSIGNED;
1777 $sql .=
" SET fk_user_assign=null, fk_statut = ".Ticket::STATUS_READ;
1779 $sql .=
" WHERE rowid = ".((int) $this->
id);
1781 dol_syslog(get_class($this).
"::assignUser sql=".$sql);
1782 $resql = $this->db->query($sql);
1784 $this->fk_user_assign = $id_assign_user;
1788 $result = $this->call_trigger(
'TICKET_ASSIGNED', $user);
1796 $this->db->commit();
1799 $this->db->rollback();
1800 $this->error = implode(
',', $this->errors);
1801 dol_syslog(get_class($this).
"::assignUser ".$this->error, LOG_ERR);
1805 $this->db->rollback();
1806 $this->error = $this->db->lasterror();
1807 dol_syslog(get_class($this).
"::assignUser ".$this->error, LOG_ERR);
1824 public function createTicketMessage($user, $notrigger = 0, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $send_email =
false, $public_area = 0)
1832 if (isset($this->fk_track_id)) {
1833 $this->fk_track_id = trim($this->fk_track_id);
1836 if (isset($this->message)) {
1837 $this->message = trim($this->message);
1843 include_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
1845 $actioncomm->type_code =
'AC_OTH_AUTO';
1846 $actioncomm->code =
'TICKET_MSG';
1847 if ($this->
private) {
1848 $actioncomm->code =
'TICKET_MSG_PRIVATE';
1851 $actioncomm->code .=
'_SENTBYMAIL';
1853 if ((empty($user->id) || $user->id == 0) && isset($_SESSION[
'email_customer'])) {
1854 $actioncomm->email_from = $_SESSION[
'email_customer'];
1856 $actioncomm->socid = $this->socid;
1857 $actioncomm->label = $this->subject;
1858 $actioncomm->note_private = $this->message;
1859 $actioncomm->userassigned = array($user->id => array(
'id' => $user->id,
'transparency' => 0));
1860 $actioncomm->userownerid = $user->id;
1861 $actioncomm->datep = $now;
1862 $actioncomm->percentage = -1;
1863 $actioncomm->elementtype =
'ticket';
1865 $actioncomm->fk_project = $this->fk_project;
1871 if ($public_area && !empty($this->origin_email) &&
getDolGlobalString(
'TICKET_ASSIGN_CONTACT_TO_MESSAGE')) {
1872 $contacts = $this->searchContactByEmail($this->origin_email);
1873 if (!empty($contacts)) {
1875 foreach ($contacts as $contact) {
1876 if ((
int) $contact->statut == 1) {
1877 $actioncomm->contact_id = $contact->id;
1884 $attachedfiles = array();
1885 $attachedfiles[
'paths'] = $filename_list;
1886 $attachedfiles[
'names'] = $mimefilename_list;
1887 $attachedfiles[
'mimes'] = $mimetype_list;
1888 if (is_array($attachedfiles) && count($attachedfiles) > 0) {
1889 $actioncomm->attachedfiles = $attachedfiles;
1895 $actionid = $actioncomm->create($user);
1896 if ($actionid <= 0) {
1898 $this->error = $actioncomm->error;
1899 $this->errors = $actioncomm->errors;
1902 if ($actionid > 0) {
1903 if (is_array($attachedfiles) && array_key_exists(
'paths', $attachedfiles) && count($attachedfiles[
'paths']) > 0) {
1905 foreach ($attachedfiles[
'paths'] as $key => $filespath) {
1907 $destdir = $conf->ticket->dir_output.
'/'.$this->ref;
1912 if (in_array($actioncomm->code, array(
'TICKET_MSG',
'TICKET_MSG_SENTBYMAIL'))) {
1913 $ecmfile =
new EcmFiles($this->db);
1914 $destdir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $destdir);
1915 $destdir = preg_replace(
'/[\\/]$/',
'', $destdir);
1916 $destdir = preg_replace(
'/^[\\/]/',
'', $destdir);
1918 $result = $ecmfile->fetch(0,
'', $destdir.
'/'.$attachedfiles[
'names'][$key]);
1928 $result = $ecmfile->update($user);
1941 $this->db->rollback();
1944 $this->db->commit();
1956 if (!empty($this->cache_msgs_ticket) && is_array($this->cache_msgs_ticket) && count($this->cache_msgs_ticket)) {
1962 $sql =
"SELECT id as rowid, fk_user_author, email_from, datec, datep, label, note as message, code";
1963 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
1964 $sql .=
" WHERE fk_element = ".(int) $this->
id;
1965 $sql .=
" AND elementtype = 'ticket'";
1966 $sql .=
" ORDER BY datep DESC";
1968 dol_syslog(get_class($this).
"::load_cache_actions_ticket", LOG_DEBUG);
1969 $resql = $this->db->query($sql);
1971 $num = $this->db->num_rows($resql);
1974 $obj = $this->db->fetch_object($resql);
1975 $this->cache_msgs_ticket[$i][
'id'] = $obj->rowid;
1976 $this->cache_msgs_ticket[$i][
'fk_user_author'] = $obj->fk_user_author;
1977 if (in_array($obj->code, array(
'TICKET_MSG',
'AC_TICKET_CREATE')) && empty($obj->fk_user_author)) {
1978 $this->cache_msgs_ticket[$i][
'fk_contact_author'] = $obj->email_from;
1980 $this->cache_msgs_ticket[$i][
'datec'] = $this->db->jdate($obj->datec);
1981 $this->cache_msgs_ticket[$i][
'datep'] = $this->db->jdate($obj->datep);
1982 $this->cache_msgs_ticket[$i][
'subject'] = $obj->label;
1983 $this->cache_msgs_ticket[$i][
'message'] = $obj->message;
1984 $this->cache_msgs_ticket[$i][
'private'] = (preg_match(
'/^TICKET_MSG_PRIVATE/', $obj->code) ? 1 : 0);
1989 $this->error =
"Error ".$this->db->lasterror();
1990 dol_syslog(get_class($this).
"::load_cache_actions_ticket ".$this->error, LOG_ERR);
2005 if ($this->
status != Ticket::STATUS_CLOSED && $this->
status != Ticket::STATUS_CANCELED) {
2008 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
2009 $sql .=
" SET fk_statut=".($mode ? Ticket::STATUS_CANCELED : Ticket::STATUS_CLOSED).
", progress=100, date_close='".$this->db->idate(
dol_now()).
"'";
2010 $sql .=
" WHERE rowid = ".((int) $this->
id);
2012 dol_syslog(get_class($this).
"::close mode=".$mode);
2013 $resql = $this->db->query($sql);
2018 if (isModEnabled(
'intervention') &&
getDolGlobalString(
'WORKFLOW_TICKET_CLOSE_INTERVENTION')) {
2019 dol_syslog(
"We have closed the ticket, so we close all linked interventions");
2020 $this->fetchObjectLinked($this->
id, $this->element,
null,
'fichinter');
2021 if ($this->linkedObjectsIds) {
2022 foreach ($this->linkedObjectsIds[
'fichinter'] as $fichinter_id) {
2024 $fichinter->fetch($fichinter_id);
2025 if ($fichinter->statut == 0) {
2026 $result = $fichinter->setValid($user);
2028 $this->errors[] = $fichinter->error;
2032 if ($fichinter->statut < 3) {
2033 $result = $fichinter->setStatut(3);
2035 $this->errors[] = $fichinter->error;
2044 $result = $this->call_trigger(
'TICKET_CLOSE', $user);
2051 $this->db->commit();
2054 $this->db->rollback();
2055 $this->error = implode(
',', $this->errors);
2056 dol_syslog(get_class($this).
"::close ".$this->error, LOG_ERR);
2060 $this->db->rollback();
2061 $this->error = $this->db->lasterror();
2062 dol_syslog(get_class($this).
"::close ".$this->error, LOG_ERR);
2081 $thirdparties = array();
2085 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"societe";
2086 $sql .=
" WHERE entity IN (".getEntity(
'ticket', 1).
")";
2087 if (!empty($type)) {
2088 if ($type == 1 || $type == 2) {
2089 $sql .=
" AND client = ".((int) $type);
2090 } elseif ($type == 3) {
2091 $sql .=
" AND fournisseur = 1";
2094 if (!empty($email)) {
2095 if (empty($exact)) {
2097 if (preg_match(
'/^([\*])?[^*]+([\*])?$/', $email, $regs) && count($regs) > 1) {
2098 $email = str_replace(
'*',
'%', $email);
2100 $email =
'%'.$email.
'%';
2104 if (is_array($filters) && !empty($filters)) {
2108 $sql .=
"email LIKE '".$this->db->escape($email).
"'";
2110 if (is_array($filters) && !empty($filters)) {
2111 foreach ($filters as $field => $value) {
2112 $sql .=
" ".$clause.
" ".$field.
" LIKE '".$this->db->escape($value).
"'";
2114 if (!empty($email)) {
2119 $res = $this->db->query($sql);
2121 while ($rec = $this->db->fetch_array($res)) {
2122 $soc =
new Societe($this->db);
2123 $soc->fetch($rec[
'rowid']);
2124 $thirdparties[] = $soc;
2127 return $thirdparties;
2129 $this->error = $this->db->error().
' sql='.$sql;
2130 dol_syslog(get_class($this).
"::searchSocidByEmail ".$this->error, LOG_ERR);
2145 $contacts = array();
2148 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"socpeople";
2149 $sql .=
" WHERE entity IN (".getEntity(
'contact').
")";
2150 if (!empty($socid)) {
2151 $sql .=
" AND fk_soc = ".((int) $socid);
2153 if (!empty($email)) {
2156 $sql .=
"email = '".$this->db->escape($email).
"'";
2158 $sql .=
"email LIKE BINARY '".$this->db->escape($this->db->escapeforlike($email)).
"'";
2162 $res = $this->db->query($sql);
2164 while ($rec = $this->db->fetch_object($res)) {
2165 include_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
2166 $contactstatic =
new Contact($this->db);
2167 $contactstatic->fetch($rec->rowid);
2168 $contacts[] = $contactstatic;
2173 $this->error = $this->db->error().
' sql='.$sql;
2174 dol_syslog(get_class($this).
"::searchContactByEmail ".$this->error, LOG_ERR);
2188 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
2189 $sql .=
" SET fk_soc = ".($id > 0 ?
$id :
"null");
2190 $sql .=
" WHERE rowid = ".((int) $this->
id);
2191 dol_syslog(get_class($this).
'::setCustomer sql='.$sql);
2192 $resql = $this->db->query($sql);
2212 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
2213 $sql .=
" SET progress = ".($percent > 0 ? $percent :
"null");
2214 $sql .=
" WHERE rowid = ".((int) $this->
id);
2215 dol_syslog(get_class($this).
'::set_progression sql='.$sql);
2216 $resql = $this->db->query($sql);
2236 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
2237 $sql .=
" SET fk_contract = ".($contractid > 0 ? $contractid :
"null");
2238 $sql .=
" WHERE rowid = ".((int) $this->
id);
2239 dol_syslog(get_class($this).
'::setContract sql='.$sql);
2240 $resql = $this->db->query($sql);
2260 return $this->getIdContact(
'internal',
'SUPPORTTEC');
2271 return $this->listeContact(-1,
'internal', 0,
'', $status);
2281 return $this->getIdContact(
'external',
'SUPPORTCLI');
2292 return $this->listeContact(-1,
'external', 0,
'', $status);
2302 return $this->getIdContact(
'internal',
'CONTRIBUTOR');
2312 return $this->getIdContact(
'external',
'CONTRIBUTOR');
2322 $array_contact = $this->getIdTicketInternalContact();
2324 $array_contact = array_merge($array_contact, $this->getIdTicketCustomerContact());
2326 $array_contact = array_merge($array_contact, $this->getIdTicketInternalInvolvedContact());
2328 $array_contact = array_merge($array_contact, $this->getIdTicketCustomerInvolvedContact());
2330 return $array_contact;
2340 $array_contact = array();
2342 $array_contact = array_merge($array_contact, $this->getIdTicketCustomerContact());
2344 $array_contact = array_merge($array_contact, $this->getIdTicketCustomerInvolvedContact());
2346 return $array_contact;
2361 public function listeContact($statusoflink = -1, $source =
'external', $list = 0, $code =
'', $status = -1)
2367 $sql =
"SELECT ec.rowid, ec.statut as statuslink, ec.fk_socpeople as id, ec.fk_c_type_contact";
2368 if ($source ==
'internal') {
2369 $sql .=
", '-1' as socid, t.statut as statuscontact";
2372 if ($source ==
'external' || $source ==
'thirdparty') {
2373 $sql .=
", t.fk_soc as socid, t.statut as statuscontact";
2376 $sql .=
", t.civility, t.lastname as lastname, t.firstname, t.email";
2377 if ($source ==
'internal') {
2378 $sql .=
", t.office_phone as phone, t.user_mobile as phone_mobile";
2381 if ($source ==
'external') {
2382 $sql .=
", t.phone as phone, t.phone_mobile as phone_mobile, t.phone_perso as phone_perso";
2385 $sql .=
", tc.source, tc.element, tc.code, tc.libelle as type_contact_label";
2386 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_contact tc";
2387 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact ec";
2388 if ($source ==
'internal') {
2389 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user t on ec.fk_socpeople = t.rowid";
2392 if ($source ==
'external' || $source ==
'thirdparty') {
2393 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople t on ec.fk_socpeople = t.rowid";
2396 $sql .=
" WHERE ec.element_id = ".((int) $this->
id);
2397 $sql .=
" AND ec.fk_c_type_contact=tc.rowid";
2398 $sql .=
" AND tc.element='".$this->db->escape($this->element).
"'";
2399 if ($source ==
'internal') {
2400 $sql .=
" AND tc.source = 'internal'";
2402 $sql .=
" AND t.statut = ".((int) $status);
2406 if ($source ==
'external' || $source ==
'thirdparty') {
2407 $sql .=
" AND tc.source = 'external'";
2409 $sql .=
" AND t.statut = ".((int) $status);
2413 if (!empty($code)) {
2414 $sql .=
" AND tc.code = '".$this->db->escape($code).
"'";
2417 $sql .=
" AND tc.active=1";
2418 if ($statusoflink >= 0) {
2419 $sql .=
" AND ec.statut = ".((int) $statusoflink);
2422 $sql .=
" ORDER BY t.lastname ASC";
2424 $resql = $this->db->query($sql);
2426 $num = $this->db->num_rows($resql);
2429 $obj = $this->db->fetch_object($resql);
2432 $transkey =
"TypeContact_".$obj->element.
"_".$obj->source.
"_".$obj->code;
2433 $labelType = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->type_contact_label);
2435 'source' => $obj->source,
2436 'socid' => $obj->socid,
2438 'nom' => $obj->lastname,
2439 'civility' => $obj->civility,
2440 'lastname' => $obj->lastname,
2441 'firstname' => $obj->firstname,
2442 'email' => $obj->email,
2443 'rowid' => $obj->rowid,
2444 'code' => $obj->code,
2445 'libelle' => $labelType,
2446 'labeltype' => $labelType,
2447 'status' => $obj->statuslink,
2448 'statuscontact' => $obj->statuscontact,
2449 'fk_c_type_contact' => $obj->fk_c_type_contact,
2450 'phone' => $obj->phone,
2451 'phone_mobile' => $obj->phone_mobile);
2453 $tab[$i] = $obj->id;
2461 $this->error = $this->db->error();
2484 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
2485 foreach ($dirmodels as $reldir) {
2486 $file =
dol_buildpath($reldir.
"core/modules/ticket/".$modele.
'.php', 0);
2487 if (file_exists($file)) {
2488 $classname = $modele;
2493 if ($classname !==
'') {
2495 $modTicket =
new $classname();
2496 '@phan-var-force ModeleNumRefTicket $modTicket';
2498 $defaultref = $modTicket->getNextValue($thirdparty, $this);
2501 if (is_numeric($defaultref) && $defaultref <= 0) {
2519 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2524 if (file_exists($dir_osencoded)) {
2525 $handle = opendir($dir_osencoded);
2526 if (is_resource($handle)) {
2527 while (($file = readdir($handle)) !==
false) {
2529 $file = mb_convert_encoding($file,
'UTF-8',
'ISO-8859-1');
2554 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
2555 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2556 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
2558 $maxwidthsmall = 270;
2559 $maxheightsmall = 150;
2560 $maxwidthmini = 128;
2561 $maxheightmini = 72;
2563 $formmail =
new FormMail($this->db);
2564 $formmail->trackid = (is_null($forcetrackid) ?
'tic'.$this->id :
'');
2565 $attachedfiles = $formmail->get_attached_files();
2567 $filepath = $attachedfiles[
'paths'];
2568 $filename = $attachedfiles[
'names'];
2569 $mimetype = $attachedfiles[
'mimes'];
2572 $destdir = $conf->ticket->dir_output.
'/'.$this->ref;
2578 $listofpaths = array();
2579 $listofnames = array();
2580 foreach ($filename as $i => $val) {
2581 $destfile = $destdir.
'/'.$filename[$i];
2583 if (is_file($destfile)) {
2584 $pathinfo = pathinfo($filename[$i]);
2586 $destfile = $destdir.
'/'.$pathinfo[
'filename'].
' - '.
dol_print_date($now,
'dayhourlog').
'.'.$pathinfo[
'extension'];
2589 $moreinfo = array(
'description' =>
'File saved by copyFilesForTicket',
'src_object_type' => $this->element,
'src_object_id' => $this->
id);
2591 $res =
dol_move($filepath[$i], $destfile,
'0', 1, 0, 1, $moreinfo);
2595 $this->error =
"Failed to move file ".dirbasename($filepath[$i]).
" into ".
dirbasename($destfile);
2602 $imgThumbSmall =
vignette($destfile, $maxwidthsmall, $maxheightsmall,
'_small', 50,
"thumbs");
2605 $imgThumbMini =
vignette($destfile, $maxwidthmini, $maxheightmini,
'_mini', 50,
"thumbs");
2610 $formmail->remove_attached_files($i);
2613 $listofpaths[$i] = $destfile;
2614 $listofnames[$i] = basename($destfile);
2617 return array(
'listofpaths' => $listofpaths,
'listofnames' => $listofnames,
'listofmimes' => $mimetype);
2633 if (!is_array($categories)) {
2634 $categories = array($categories);
2638 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2640 $existing = $c->containing($this->
id, Categorie::TYPE_TICKET,
'id');
2643 if (is_array($existing)) {
2644 $to_del = array_diff($existing, $categories);
2645 $to_add = array_diff($categories, $existing);
2648 $to_add = $categories;
2652 foreach ($to_del as $del) {
2653 if ($c->fetch($del) > 0) {
2654 $c->del_type($this, Categorie::TYPE_TICKET);
2657 foreach ($to_add as $add) {
2658 if ($c->fetch($add) > 0) {
2659 $c->add_type($this, Categorie::TYPE_TICKET);
2678 public function newMessage($user, &$action, $private = 1, $public_area = 0)
2680 global $mysoc, $langs;
2694 array_push($this->errors, $langs->trans(
"ErrorTicketIsNotValid"));
2700 array_push($this->errors, $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Message")));
2701 $action =
'add_message';
2712 $resarray =
$object->copyFilesForTicket();
2713 if (is_numeric($resarray) && $resarray == -1) {
2718 $listofpaths = $resarray[
'listofpaths'];
2719 $listofnames = $resarray[
'listofnames'];
2720 $listofmimes = $resarray[
'listofmimes'];
2722 $id =
$object->createTicketMessage($user, 0, $listofpaths, $listofmimes, $listofnames, $send_email, $public_area);
2725 $this->error =
$object->error;
2726 $this->errors =
$object->errors;
2727 $action =
'add_message';
2730 if (!$error &&
$id > 0) {
2731 setEventMessages($langs->trans(
'TicketMessageSuccessfullyAdded'),
null,
'mesgs');
2733 if (!empty($public_area)) {
2741 $internal_contacts =
$object->getInfosTicketInternalContact(1);
2743 $assigned_user_dont_have_email =
'';
2747 if ($this->fk_user_assign > 0) {
2748 $assigned_user =
new User($this->db);
2749 $assigned_user->fetch($this->fk_user_assign);
2750 if (!empty($assigned_user->email)) {
2751 $sendto[$assigned_user->email] = $assigned_user->getFullName($langs).
" <".$assigned_user->email.
">";
2753 $assigned_user_dont_have_email = $assigned_user->getFullName($langs);
2756 $assigned_user =
null;
2760 foreach ($internal_contacts as $key => $info_sendto) {
2762 if ($info_sendto[
'id'] == $user->id) {
2767 if (!empty($info_sendto[
'email']) && ($assigned_user ===
null || $assigned_user->email != $info_sendto[
'email'])) {
2768 $sendto[] =
dolGetFirstLastname($info_sendto[
'firstname'], $info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">";
2772 if (empty($sendto)) {
2787 if (!empty($sendto)) {
2790 $subject =
'['.$appli.
'- ticket #'.
$object->track_id.
'] '.$this->subject;
2793 $message =
getDolGlobalString(
'TICKET_MESSAGE_MAIL_INTRO', $langs->trans(
'TicketMessageMailIntroText'));
2794 $message .=
'<br><br>';
2795 $messagePost =
GETPOST(
'message',
'restricthtml');
2799 $message .= $messagePost;
2802 $message .=
'<br><br>';
2803 $message .=
"==============================================";
2804 $message .= !empty(
$object->thirdparty->name) ?
'<br>'.$langs->trans(
'Thirdparty').
" : ".
$object->thirdparty->name :
'';
2805 $message .= !empty(
$object->thirdparty->town) ?
'<br>'.$langs->trans(
'Town').
" : ".
$object->thirdparty->town :
'';
2806 $message .= !empty(
$object->thirdparty->phone) ?
'<br>'.$langs->trans(
'Phone').
" : ".
$object->thirdparty->phone :
'';
2809 $message .=
'<br><br>';
2810 if (!empty($assigned_user_dont_have_email)) {
2811 $message .=
'<br>'.$langs->trans(
'NoEMail').
' : '.$assigned_user_dont_have_email;
2813 foreach ($sendto as $val) {
2814 $message .=
'<br>'.$langs->trans(
'TicketNotificationRecipient').
' : '.$val;
2819 $message .=
'<br><br>';
2820 $message .= $langs->trans(
'TicketNotificationEmailBodyInfosTrackUrlinternal').
' : <a href="'.$url_internal_ticket.
'">'.
$object->track_id.
'</a>';
2822 $this->sendTicketMessageByEmail($subject, $message, 0, $sendto, $listofpaths, $listofmimes, $listofnames);
2831 if ($send_email > 0) {
2833 $internal_contacts =
$object->getInfosTicketInternalContact(1);
2836 if (is_array($internal_contacts) && count($internal_contacts) > 0) {
2840 $subject =
GETPOST(
'subject',
'alphanohtml') ?
GETPOST(
'subject',
'alphanohtml') :
'['.$appli.
' - '.$langs->trans(
"Ticket").
' #'.
$object->track_id.
'] '.$langs->trans(
'TicketNewMessage');
2842 $message_intro = $langs->trans(
'TicketNotificationEmailBody',
"#".
$object->id);
2845 $message =
getDolGlobalString(
'TICKET_MESSAGE_MAIL_INTRO', $langs->trans(
'TicketMessageMailIntroText'));
2846 $message .=
'<br><br>';
2847 $messagePost =
GETPOST(
'message',
'restricthtml');
2851 $message .= $messagePost;
2854 $message .=
'<br><br>';
2855 $message .=
"==============================================<br>";
2856 $message .= !empty(
$object->thirdparty->name) ? $langs->trans(
'Thirdparty').
" : ".
$object->thirdparty->name :
'';
2857 $message .= !empty(
$object->thirdparty->town) ?
'<br>'.$langs->trans(
'Town').
" : ".
$object->thirdparty->town :
'';
2858 $message .= !empty(
$object->thirdparty->phone) ?
'<br>'.$langs->trans(
'Phone').
" : ".
$object->thirdparty->phone :
'';
2861 foreach ($internal_contacts as $key => $info_sendto) {
2863 if ($info_sendto[
'id'] == $user->id) {
2867 if ($info_sendto[
'email'] !=
'') {
2868 $email = $info_sendto[
'email'];
2869 if ($email !=
null) {
2870 $sendto[$email] =
dolGetFirstLastname($info_sendto[
'firstname'], $info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">";
2874 $recipient =
dolGetFirstLastname($info_sendto[
'firstname'], $info_sendto[
'lastname'], -1).
' ('.strtolower((
string) $info_sendto[
'libelle']).
')';
2875 $message .= (!empty($recipient) ? $langs->trans(
'TicketNotificationRecipient').
' : '.$recipient.
'<br>' :
'');
2883 $message .=
'<br>'.$langs->trans(
'TicketNotificationEmailBodyInfosTrackUrlinternal').
' : <a href="'.$url_internal_ticket.
'">'.
$object->track_id.
'</a><br>';
2893 if (!empty($sendto)) {
2894 $this->sendTicketMessageByEmail($subject, $message, 0, $sendto, $listofpaths, $listofmimes, $listofnames);
2901 if (empty(
$object->private)) {
2903 $external_contacts =
$object->getInfosTicketExternalContact(1);
2906 if (is_array($external_contacts) && count($external_contacts) === 0) {
2907 if (!empty(
$object->fk_soc)) {
2909 $array_company = array(array(
'firstname' =>
'',
'lastname' =>
$object->thirdparty->name,
'email' =>
$object->thirdparty->email,
'libelle' => $langs->transnoentities(
'Customer'),
'socid' =>
$object->thirdparty->id));
2910 $external_contacts = array_merge($external_contacts, $array_company);
2911 } elseif (empty(
$object->fk_soc) && !empty(
$object->origin_replyto)) {
2912 $array_external = array(array(
'firstname' =>
'',
'lastname' =>
$object->origin_replyto,
'email' =>
$object->origin_replyto,
'libelle' => $langs->transnoentities(
'Customer'),
'socid' => 0));
2913 $external_contacts = array_merge($external_contacts, $array_external);
2914 } elseif (empty(
$object->fk_soc) && !empty(
$object->origin_email)) {
2915 $array_external = array(array(
'firstname' =>
'',
'lastname' =>
$object->origin_email,
'email' =>
$object->thirdparty->email,
'libelle' => $langs->transnoentities(
'Customer'),
'socid' =>
$object->thirdparty->id));
2916 $external_contacts = array_merge($external_contacts, $array_external);
2921 if (is_array($external_contacts) && count($external_contacts) > 0) {
2925 $subject =
GETPOST(
'subject') ?
GETPOST(
'subject') :
'['.$appli.
' - '.$langs->trans(
"Ticket").
' #'.
$object->track_id.
'] '.$langs->trans(
'TicketNewMessage');
2930 $message_intro =
dol_nl2br($message_intro);
2933 $message_signature =
dol_nl2br($message_signature);
2937 $messagePost =
GETPOST(
'message',
'restricthtml');
2941 $message = $messagePost;
2942 $message .=
'<br><br>';
2944 foreach ($external_contacts as $key => $info_sendto) {
2946 if ($info_sendto[
'id'] == $user->contact_id) {
2950 if ($info_sendto[
'email'] !=
'' && $info_sendto[
'email'] !=
$object->origin_email) {
2951 $email = $info_sendto[
'email'];
2952 if ($email !=
null) {
2953 $sendto[$email] = trim($info_sendto[
'firstname'].
" ".$info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">";
2956 $recipient =
dolGetFirstLastname($info_sendto[
'firstname'], $info_sendto[
'lastname'], -1).
' ('.strtolower((
string) $info_sendto[
'libelle']).
')';
2957 $message .= (!empty($recipient) ? $langs->trans(
'TicketNotificationRecipient').
' : '.$recipient.
'<br>' :
'');
2962 $url_public_ticket = (
getDolGlobalInt(
'TICKET_ENABLE_PUBLIC_INTERFACE') ?
2965 $message .=
'<br>'.$langs->trans(
'TicketNewEmailBodyInfosTrackUrlCustomer').
' : <a href="'.$url_public_ticket.
'">'.
$object->track_id.
'</a><br>';
2968 $message = $message_intro.
'<br><br>'.$message;
2971 $message .=
'<br>'.$message_signature;
2973 if (!empty(
$object->origin_replyto)) {
2975 } elseif (!empty(
$object->origin_email)) {
2979 if (
$object->fk_soc > 0 && !array_key_exists(
$object->origin_replyto, $sendto) && !array_key_exists(
$object->origin_email, $sendto)) {
2982 if (!empty(
$object->thirdparty->email)) {
2983 $sendto[
$object->thirdparty->email] =
$object->thirdparty->email;
2995 if (!empty($sendto)) {
2996 $result = $this->sendTicketMessageByEmail($subject, $message, 0, $sendto, $listofpaths, $listofmimes, $listofnames);
2999 $this->date_last_msg_sent =
dol_now();
3000 $this->update($user, 1);
3013 && (
$object->status < self::STATUS_IN_PROGRESS && !$user->socid && !$private))
3014 || (
$object->status > self::STATUS_IN_PROGRESS && $public_area)) {
3015 $object->setStatut($object::STATUS_IN_PROGRESS);
3016 } elseif (
getDolGlobalInt(
'TICKET_SET_STATUS_ON_ANSWER', -1) >= 0 && empty($user->socid) && empty($private)) {
3044 public function sendTicketMessageByEmail($subject, $message, $send_internal_cc = 0, $array_receiver = array(), $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array())
3046 global $conf, $langs, $user;
3049 dol_syslog(get_class($this).
'::sendTicketMessageByEmail: Emails are disable into ticket setup by option TICKET_DISABLE_ALL_MAILS', LOG_WARNING);
3053 $langs->load(
"mails");
3055 include_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
3059 if (!is_array($array_receiver) || !count($array_receiver) > 0) {
3060 $array_receiver = $this->getInfosTicketInternalContact(1);
3061 $array_receiver = array_merge($array_receiver, $this->getInfosTicketExternalContact(1));
3065 if ($send_internal_cc) {
3071 if (is_array($array_receiver) && count($array_receiver) > 0) {
3072 foreach ($array_receiver as $key => $receiver) {
3073 $deliveryreceipt = 0;
3074 $filepath = $filename_list;
3075 $filename = $mimefilename_list;
3076 $mimetype = $mimetype_list;
3082 $conf->global->MAIN_MAIL_AUTOCOPY_TO =
'';
3085 $upload_dir_tmp = $conf->user->dir_output.
"/".$user->id.
'/temp';
3087 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
3088 $trackid =
"tic".$this->id;
3090 $moreinheader =
'X-Dolibarr-Info: sendTicketMessageByEmail'.
"\r\n";
3091 if (!empty($this->email_msgid)) {
3093 $moreinheader .=
'In-Reply-To: <'.$this->email_msgid.
'>'.
"\r\n";
3101 if (!empty($this->origin_references)) {
3102 $references .= (empty($references) ?
'' :
' ').$this->origin_references;
3104 if (!empty($this->email_msgid) && !preg_match(
'/'.preg_quote($this->email_msgid,
'/').
'/', $references)) {
3105 $references .= (empty($references) ?
'' :
' ').
'<'.$this->email_msgid.
'>';
3108 $moreinheader .=
'References: '.$references.
"\r\n";
3112 $mailfile =
new CMailFile($subject, $receiver, $from, $message, $filepath, $mimetype, $filename, $sendtocc,
'', $deliveryreceipt, -1,
'',
'', $trackid, $moreinheader,
'ticket',
'', $upload_dir_tmp);
3114 if ($mailfile->error) {
3117 $result = $mailfile->sendfile();
3119 setEventMessages($langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($receiver, 2)),
null,
'mesgs');
3122 $langs->load(
"other");
3123 if ($mailfile->error) {
3124 setEventMessages($langs->trans(
'ErrorFailedToSendMail', $from, $receiver),
null,
'errors');
3125 dol_syslog($langs->trans(
'ErrorFailedToSendMail', $from, $receiver).
' : '.$mailfile->error);
3127 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'errors');
3133 $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
3137 $langs->load(
"other");
3138 setEventMessages($langs->trans(
'ErrorMailRecipientIsEmptyForSendTicketMessage'),
null,
'warnings');
3155 global $user, $langs;
3162 $sql =
"SELECT p.rowid, p.ref, p.datec as datec";
3163 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as p";
3164 if (isModEnabled(
'societe') && !$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
3165 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON p.fk_soc = sc.fk_soc";
3166 $sql .=
" WHERE sc.fk_user = ".((int) $user->id);
3169 $sql .= $clause.
" p.entity IN (".
getEntity(
'ticket').
")";
3170 if ($mode ==
'opened') {
3171 $sql .=
" AND p.fk_statut NOT IN (".Ticket::STATUS_CLOSED.
", ".Ticket::STATUS_CANCELED.
")";
3174 $sql .=
" AND p.fk_soc = ".((int) $user->socid);
3177 $resql = $this->db->query($sql);
3179 $label = $labelShort =
'';
3181 if ($mode ==
'opened') {
3182 $status =
'openall';
3185 $label = $langs->trans(
"MenuListNonClosed");
3186 $labelShort = $langs->trans(
"MenuListNonClosed");
3191 $response->label = $label;
3192 $response->labelShort = $labelShort;
3193 $response->url = DOL_URL_ROOT.
'/ticket/list.php?search_fk_statut[]='.$status;
3197 while ($obj = $this->db->fetch_object($resql)) {
3198 $response->nbtodo++;
3199 if ($mode ==
'opened') {
3200 $datelimit = $this->db->jdate($obj->datec) + $delay_warning;
3201 if ($datelimit < $now) {
3208 $this->error = $this->db->lasterror();
3222 $this->nb = array();
3225 $sql =
"SELECT count(p.rowid) as nb";
3226 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as p";
3227 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON p.fk_soc = s.rowid";
3228 if (!$user->hasRight(
'societe',
'client',
'voir')) {
3229 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
3230 $sql .=
" WHERE sc.fk_user = ".((int) $user->id);
3233 $sql .=
" ".$clause.
" p.entity IN (".
getEntity(
'ticket').
")";
3235 $resql = $this->db->query($sql);
3238 while ($obj = $this->db->fetch_object($resql)) {
3239 $this->nb[
"ticket"] = $obj->nb;
3241 $this->db->free($resql);
3245 $this->error = $this->db->lasterror();
3260 $tables = array(
'ticket');
3276 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
3278 $return =
'<div class="box-flex-item box-flex-grow-zero">';
3279 $return .=
'<div class="info-box info-box-sm">';
3280 $return .=
'<span class="info-box-icon bg-infobox-action">';
3282 $return .=
'</span>';
3283 $return .=
'<div class="info-box-content">';
3284 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->getNomUrl(1) : $this->ref).
'</span>';
3285 if ($selected >= 0) {
3286 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
3288 if (!empty($arraydata[
'user_assignment'])) {
3289 $return .=
'<br><span class="info-box-label" title="'.dol_escape_htmltag($langs->trans(
"AssignedTo")).
'">'.$arraydata[
'user_assignment'].
'</span>';
3291 if (property_exists($this,
'type_code') && !empty($this->type_code)) {
3293 $return .=
'<div class="tdoverflowmax125 inline-block">'.$langs->getLabelFromKey($this->db,
'TicketTypeShort'.$this->type_code,
'c_ticket_type',
'code',
'label', $this->type_code).
'</div>';
3295 if (method_exists($this,
'getLibStatut')) {
3296 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
3298 $return .=
'</div>';
3299 $return .=
'</div>';
3300 $return .=
'</div>';
3316 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
3320 $langs->load(
"ticket");
3321 $outputlangs->load(
"ticket");
3324 $modele =
'generic_ticket_odt';
3326 if (!empty($this->model_pdf)) {
3327 $modele = $this->model_pdf;
3333 $modelpath =
"core/modules/ticket/doc/";
3335 return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage agenda events (actions)
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage categories.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
call_trigger($triggerName, $user)
Call trigger based on this instance.
add_contact($fk_socpeople, $type_contact, $source='external', $notrigger=0)
Add a link between element $this->element and a contact.
Class to manage 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.
listeContact($statusoflink=-1, $source='external', $list=0, $code='', $status=-1)
Get array of all contacts for a ticket Override method of file commonobject.class....
loadCacheMsgsTicket()
Load the list of event on ticket into ->cache_msgs_ticket.
setProgression($percent)
Define progression of current ticket.
searchSocidByEmail($email, $type=0, $filters=array(), $clause='AND')
Search and fetch thirparties by email.
loadCacheSeveritiesTickets()
Charge dans cache la liste des sévérité de tickets (paramétrable dans dictionnaire)
$fields
'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]',...
getInfosTicketExternalContact($status=-1)
Retrieve information about external contacts.
searchContactByEmail($email, $socid=0, $case='')
Search and fetch contacts by email.
getIdTicketCustomerInvolvedContact()
Return id des contacts clients des intervenants.
LibStatut($status, $mode=0, $notooltip=0, $progress=0)
Return status label of object.
setContract($contractid)
Link element with a contract.
getTicketAllContacts()
Return id of all contacts for ticket.
createFromClone(User $user, $fromid)
Load an object from its id and create a new one in database.
assignUser($user, $id_assign_user, $notrigger=0)
Set an assigned user to a ticket.
loadStateBoard()
Load indicator this->nb of global stats widget.
getTooltipContentArray($params)
getTooltipContentArray
getKanbanView($option='', $arraydata=null)
Return 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.
sendTicketMessageByEmail($subject, $message, $send_internal_cc=0, $array_receiver=array(), $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array())
Send ticket by email to linked contacts.
const STATUS_NOT_READ
Status.
getTicketAllCustomerContacts()
Return id of all contacts for ticket.
createTicketMessage($user, $notrigger=0, $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array(), $send_email=false, $public_area=0)
Add message into database.
verify()
Check properties of ticket are ok (like ref, track_id, ...).
setCategories($categories)
Sets object to supplied categories.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
newMessage($user, &$action, $private=1, $public_area=0)
Add new message on a ticket (private/public area).
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...
dirbasename($pathfile)
Return the relative dirname (relative to DOL_DATA_ROOT) of a full path string.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_move($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=1, $moreinfo=array())
Move a file into another name.
dol_is_file($pathoffile)
Return if path is a file.
dol_is_dir($folder)
Test if filename is a directory.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
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.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
utf8_check($str)
Check if a string is in UTF8.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
vignette($file, $maxWidth=160, $maxHeight=120, $extName='_small', $quality=50, $outdir='thumbs', $targetformat=0)
Create a thumbnail from an image file (Supported extensions are gif, jpg, png and bmp).
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
Class to generate the form for creating a new ticket.
generate_random_id($car=16)
Generate a random id.