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;
257 public $regeximgext =
'\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm';
263 const STATUS_READ = 1;
264 const STATUS_ASSIGNED = 2;
265 const STATUS_IN_PROGRESS = 3;
266 const STATUS_NEED_MORE_INFO = 5;
267 const STATUS_WAITING = 7;
268 const STATUS_CLOSED = 8;
269 const STATUS_CANCELED = 9;
300 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'visible' => -2,
'enabled' => 1,
'position' => 1,
'notnull' => 1,
'index' => 1,
'comment' =>
"Id"),
301 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'visible' => 0,
'enabled' => 1,
'position' => 5,
'notnull' => 1,
'index' => 1),
302 '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),
303 'track_id' => array(
'type' =>
'varchar(255)',
'label' =>
'TicketTrackId',
'visible' => -2,
'enabled' => 1,
'position' => 11,
'notnull' => -1,
'searchall' => 1,
'help' =>
"Help text"),
304 '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'),
305 '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'),
306 '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'),
307 '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'),
308 '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),
309 'type_code' => array(
'type' =>
'varchar(32)',
'label' =>
'Type',
'visible' => 1,
'enabled' => 1,
'position' => 20,
'notnull' => -1,
'help' =>
"",
'csslist' =>
'tdoverflowmax100'),
310 'category_code' => array(
'type' =>
'varchar(32)',
'label' =>
'TicketCategory',
'visible' => -1,
'enabled' => 1,
'position' => 21,
'notnull' => -1,
'help' =>
"",
'css' =>
'maxwidth100 tdoverflowmax200'),
311 'severity_code' => array(
'type' =>
'varchar(32)',
'label' =>
'Severity',
'visible' => 1,
'enabled' => 1,
'position' => 22,
'notnull' => -1,
'help' =>
"",
'css' =>
'maxwidth100'),
312 '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'),
313 'notify_tiers_at_create' => array(
'type' =>
'integer',
'label' =>
'NotifyThirdparty',
'visible' => -1,
'enabled' => 0,
'position' => 51,
'notnull' => 1,
'index' => 1),
314 '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"),
315 '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"),
317 'datec' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'visible' => 1,
'enabled' => 1,
'position' => 500,
'notnull' => 1,
'csslist' =>
'nowraponall'),
318 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'visible' => -1,
'enabled' => 1,
'position' => 501,
'notnull' => 1),
319 'date_read' => array(
'type' =>
'datetime',
'label' =>
'DateReading',
'visible' => -1,
'enabled' => 1,
'position' => 505,
'notnull' => 1,
'csslist' =>
'nowraponall'),
320 'date_last_msg_sent' => array(
'type' =>
'datetime',
'label' =>
'TicketLastMessageDate',
'visible' => 0,
'enabled' => 1,
'position' => 506,
'notnull' => -1),
321 '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'),
322 'date_close' => array(
'type' =>
'datetime',
'label' =>
'TicketCloseOn',
'visible' => -1,
'enabled' => 1,
'position' => 510,
'notnull' => 1),
323 'message' => array(
'type' =>
'html',
'label' =>
'Message',
'visible' => -2,
'enabled' => 1,
'position' => 540,
'notnull' => -1,),
324 'email_msgid' => array(
'type' =>
'varchar(255)',
'label' =>
'EmailMsgID',
'visible' => -2,
'enabled' => 1,
'position' => 540,
'notnull' => -1,
'help' =>
'EmailMsgIDDesc',
'csslist' =>
'tdoverflowmax100'),
325 'email_date' => array(
'type' =>
'datetime',
'label' =>
'EmailDate',
'visible' => -2,
'enabled' => 1,
'position' => 541),
326 'progress' => array(
'type' =>
'integer',
'label' =>
'Progression',
'visible' => -1,
'enabled' => 1,
'position' => 540,
'notnull' => -1,
'css' =>
'right',
'help' =>
"",
'isameasure' => 1,
'csslist' =>
'width50'),
327 'resolution' => array(
'type' =>
'integer',
'label' =>
'Resolution',
'visible' => -1,
'enabled' =>
'getDolGlobalString("TICKET_ENABLE_RESOLUTION")',
'position' => 550,
'notnull' => 1),
328 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'PDFTemplate',
'enabled' => 1,
'visible' => 0,
'position' => 560),
329 'extraparams' => array(
'type' =>
'varchar(255)',
'label' =>
'Extraparams',
'enabled' => 1,
'visible' => 0,
'position' => 570),
330 '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')),
331 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 900),
345 $this->ismultientitymanaged = 1;
346 $this->isextrafieldmanaged = 1;
348 $this->labelStatusShort = array(
349 self::STATUS_NOT_READ =>
'Unread',
350 self::STATUS_READ =>
'Read',
351 self::STATUS_ASSIGNED =>
'Assigned',
352 self::STATUS_IN_PROGRESS =>
'InProgress',
353 self::STATUS_NEED_MORE_INFO =>
'NeedMoreInformationShort',
354 self::STATUS_WAITING =>
'OnHold',
355 self::STATUS_CLOSED =>
'SolvedClosed',
356 self::STATUS_CANCELED =>
'Canceled'
358 $this->labelStatus = array(
359 self::STATUS_NOT_READ =>
'Unread',
360 self::STATUS_READ =>
'Read',
361 self::STATUS_ASSIGNED =>
'Assigned',
362 self::STATUS_IN_PROGRESS =>
'InProgress',
363 self::STATUS_NEED_MORE_INFO =>
'NeedMoreInformation',
364 self::STATUS_WAITING =>
'OnHold',
365 self::STATUS_CLOSED =>
'SolvedClosed',
366 self::STATUS_CANCELED =>
'Canceled'
370 unset($this->fields[
'fk_statut'][
'arrayofkeyval'][self::STATUS_WAITING]);
371 unset($this->labelStatusShort[self::STATUS_WAITING]);
372 unset($this->labelStatus[self::STATUS_WAITING]);
384 $this->errors = array();
389 if (isset($this->
ref)) {
390 $this->
ref = trim($this->
ref);
393 if (isset($this->track_id)) {
394 $this->track_id = trim($this->track_id);
397 if (isset($this->fk_soc)) {
398 $this->fk_soc = (int) $this->fk_soc;
401 if (isset($this->fk_project)) {
402 $this->fk_project = (int) $this->fk_project;
405 if (isset($this->origin_email)) {
406 $this->origin_email = trim($this->origin_email);
409 if (isset($this->fk_user_create)) {
410 $this->fk_user_create = (int) $this->fk_user_create;
413 if (isset($this->fk_user_assign)) {
414 $this->fk_user_assign = (int) $this->fk_user_assign;
417 if (isset($this->subject)) {
418 $this->subject = trim($this->subject);
421 if (isset($this->message)) {
422 $this->message = trim($this->message);
424 $this->errors[] =
'ErrorFieldTooLong';
425 dol_syslog(get_class($this).
'::create error -1 message too long', LOG_ERR);
430 if (isset($this->
status)) {
434 if (isset($this->resolution)) {
435 $this->resolution = (int) $this->resolution;
438 if (isset($this->progress)) {
439 $this->progress = (int) $this->progress;
442 if (isset($this->timing)) {
443 $this->timing = trim($this->timing);
446 if (isset($this->type_code)) {
447 $this->type_code = trim($this->type_code);
450 if (isset($this->category_code)) {
451 $this->category_code = trim($this->category_code);
454 if (isset($this->severity_code)) {
455 $this->severity_code = trim($this->severity_code);
458 if (empty($this->
ref)) {
459 $this->errors[] =
'ErrorTicketRefRequired';
460 dol_syslog(get_class($this).
"::create error -1 ref null", LOG_ERR);
477 $test =
new self($this->db);
479 if ($test->fetch(0, $getRef) > 0) {
480 if (($action ==
'add') || ($action ==
'update' && $this->
ref != $getRef)) {
485 $this->
ref = $getRef;
496 public function create($user, $notrigger = 0)
504 if (empty($this->track_id)) {
510 $result = $this->
verify();
517 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"ticket(";
521 $sql .=
"fk_project,";
522 $sql .=
"fk_contract,";
523 $sql .=
"origin_email,";
524 $sql .=
"origin_replyto,";
525 $sql .=
"origin_references,";
526 $sql .=
"fk_user_create,";
527 $sql .=
"fk_user_assign,";
528 $sql .=
"email_msgid,";
529 $sql .=
"email_date,";
532 $sql .=
"fk_statut,";
533 $sql .=
"resolution,";
536 $sql .=
"type_code,";
537 $sql .=
"category_code,";
538 $sql .=
"severity_code,";
540 $sql .=
"date_read,";
541 $sql .=
"date_close,";
543 $sql .=
"notify_tiers_at_create,";
544 $sql .=
"model_pdf,";
546 $sql .=
") VALUES (";
547 $sql .=
" ".(!isset($this->
ref) ?
'' :
"'".$this->db->escape($this->
ref).
"'").
",";
548 $sql .=
" ".(!isset($this->track_id) ?
'NULL' :
"'".$this->db->escape($this->track_id).
"'").
",";
549 $sql .=
" ".($this->fk_soc > 0 ? ((int) $this->fk_soc) :
"null").
",";
550 $sql .=
" ".($this->fk_project > 0 ? ((int) $this->fk_project) :
"null").
",";
551 $sql .=
" ".($this->fk_contract > 0 ? ((int) $this->fk_contract) :
"null").
",";
552 $sql .=
" ".(!isset($this->origin_email) ?
'NULL' :
"'".$this->db->escape($this->origin_email).
"'").
",";
553 $sql .=
" ".(!isset($this->origin_replyto) ?
'NULL' :
"'".$this->db->escape($this->origin_replyto).
"'").
",";
554 $sql .=
" ".(!isset($this->origin_references) ?
'NULL' :
"'".$this->db->escape($this->origin_references).
"'").
",";
555 $sql .=
" ".(!isset($this->fk_user_create) ? ($user->id > 0 ? ((int) $user->id) :
'NULL') : ($this->fk_user_create > 0 ? ((int) $this->fk_user_create) :
'NULL')).
",";
556 $sql .=
" ".($this->fk_user_assign > 0 ? ((int) $this->fk_user_assign) :
'NULL').
",";
557 $sql .=
" ".(empty($this->email_msgid) ?
'NULL' :
"'".$this->db->escape($this->email_msgid).
"'").
",";
558 $sql .=
" ".(!
isDolTms($this->email_date) ?
'NULL' :
"'".$this->db->idate($this->email_date).
"'").
",";
559 $sql .=
" ".(!isset($this->subject) ?
'NULL' :
"'".$this->db->escape($this->subject).
"'").
",";
560 $sql .=
" ".(!isset($this->message) ?
'NULL' :
"'".$this->db->escape($this->message).
"'").
",";
561 $sql .=
" ".(!isset($this->
status) ?
'0' : ((int) $this->
status)).
",";
562 $sql .=
" ".(!isset($this->resolution) ?
'NULL' : ((int) $this->resolution)).
",";
563 $sql .=
" ".(!isset($this->progress) ?
'0' : ((int) $this->progress)).
",";
564 $sql .=
" ".(!isset($this->timing) ?
'NULL' :
"'".$this->db->escape($this->timing).
"'").
",";
565 $sql .=
" ".(!isset($this->type_code) ?
'NULL' :
"'".$this->db->escape($this->type_code).
"'").
",";
566 $sql .=
" ".(empty($this->category_code) || $this->category_code ==
'-1' ?
'NULL' :
"'".$this->db->escape($this->category_code).
"'").
",";
567 $sql .=
" ".(!isset($this->severity_code) ?
'NULL' :
"'".$this->db->escape($this->severity_code).
"'").
",";
568 $sql .=
" ".(!
isDolTms($this->datec) ?
'NULL' :
"'".$this->db->idate($this->datec).
"'").
",";
569 $sql .=
" ".(!isset($this->date_read) ||
dol_strlen((
string) $this->date_read) == 0 ?
'NULL' :
"'".$this->db->idate($this->date_read).
"'").
",";
570 $sql .=
" ".(!isset($this->date_close) ||
dol_strlen((
string) $this->date_close) == 0 ?
'NULL' :
"'".$this->db->idate($this->date_close).
"'");
571 $sql .=
", ".((int) $this->entity);
572 $sql .=
", ".(!isset($this->notify_tiers_at_create) ? 1 : ((int) $this->notify_tiers_at_create));
573 $sql .=
", '".$this->db->escape($this->model_pdf).
"'";
574 $sql .=
", ".(!isset($this->ip) ?
'NULL' :
"'".$this->db->escape($this->ip).
"'");
579 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
580 $resql = $this->db->query($sql);
583 $this->errors[] =
"Error ".$this->db->lasterror();
587 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"ticket");
590 if (!$error &&
getDolGlobalString(
'TICKET_ADD_AUTHOR_AS_CONTACT') && empty($this->context[
"createdfrompublicinterface"])) {
594 if (!empty($user->socid) && !empty($user->contact_id) &&
getDolGlobalInt(
'TICKET_ADD_AUTHOR_AS_CONTACT') == 2) {
595 $contact_type =
'external';
596 $contributor_id = $user->contact_id;
598 $contact_type =
'internal';
599 $contributor_id = $user->id;
603 if ($this->
add_contact($contributor_id,
'CONTRIBUTOR', $contact_type) < 0) {
608 if (!$error && $this->fk_user_assign > 0) {
609 if ($this->
add_contact($this->fk_user_assign,
'SUPPORTTEC',
'internal') < 0) {
623 if (!$error && !$notrigger) {
634 foreach ($this->errors as $errmsg) {
635 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
636 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
638 $this->db->rollback();
645 $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';
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.fk_statut as status,";
689 $sql .=
" t.resolution,";
690 $sql .=
" t.progress,";
691 $sql .=
" t.timing,";
692 $sql .=
" t.type_code,";
693 $sql .=
" t.category_code,";
694 $sql .=
" t.severity_code,";
696 $sql .=
" t.date_read,";
697 $sql .=
" t.date_last_msg_sent,";
698 $sql .=
" t.date_close,";
700 $sql .=
" t.model_pdf,";
701 $sql .=
" t.extraparams,";
703 $sql .=
" type.label as type_label, category.label as category_label, severity.label as severity_label";
704 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as t";
705 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_type as type ON type.code=t.type_code";
706 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_category as category ON category.code=t.category_code";
707 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_severity as severity ON severity.code=t.severity_code";
710 $sql .=
" WHERE t.rowid = ".((int)
$id);
712 $sql .=
" WHERE t.entity IN (".getEntity($this->element, 1).
")";
714 $sql .=
" AND t.ref = '".$this->db->escape($ref).
"'";
715 } elseif ($track_id) {
716 $sql .=
" AND t.track_id = '".$this->db->escape($track_id).
"'";
718 $sql .=
" AND t.email_msgid = '".$this->db->escape($email_msgid).
"'";
722 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
723 $resql = $this->db->query($sql);
725 if ($this->db->num_rows($resql)) {
726 $obj = $this->db->fetch_object($resql);
728 $this->
id = $obj->rowid;
729 $this->entity = $obj->entity;
730 $this->
ref = $obj->ref;
731 $this->track_id = $obj->track_id;
732 $this->fk_soc = $obj->fk_soc;
733 $this->socid = $obj->fk_soc;
734 $this->fk_project = $obj->fk_project;
735 $this->fk_contract = $obj->fk_contract;
736 $this->origin_email = $obj->origin_email;
737 $this->origin_replyto = $obj->origin_replyto;
738 $this->origin_references = $obj->origin_references;
739 $this->fk_user_create = $obj->fk_user_create;
740 $this->fk_user_assign = $obj->fk_user_assign;
741 $this->email_msgid = $obj->email_msgid;
742 $this->email_date = $this->db->jdate($obj->email_date);
743 $this->subject = $obj->subject;
744 $this->message = $obj->message;
745 $this->model_pdf = $obj->model_pdf;
746 $this->extraparams = !empty($obj->extraparams) ? (array) json_decode($obj->extraparams,
true) : array();
747 $this->ip = $obj->ip;
749 $this->
status = $obj->status;
750 $this->fk_statut = $this->status;
752 $this->resolution = $obj->resolution;
753 $this->progress = $obj->progress;
754 $this->timing = $obj->timing;
756 $this->type_code = $obj->type_code;
757 $label_type = ($langs->trans(
"TicketTypeShort".$obj->type_code) !=
"TicketTypeShort".$obj->type_code ? $langs->trans(
"TicketTypeShort".$obj->type_code) : ($obj->type_label !=
'-' ? $obj->type_label :
''));
758 $this->type_label = $label_type;
760 $this->category_code = $obj->category_code;
761 $label_category = ($langs->trans(
"TicketCategoryShort".$obj->category_code) !=
"TicketCategoryShort".$obj->category_code ? $langs->trans(
"TicketCategoryShort".$obj->category_code) : ($obj->category_label !=
'-' ? $obj->category_label :
''));
762 $this->category_label = $label_category;
764 $this->severity_code = $obj->severity_code;
765 $label_severity = ($langs->trans(
"TicketSeverityShort".$obj->severity_code) !=
"TicketSeverityShort".$obj->severity_code ? $langs->trans(
"TicketSeverityShort".$obj->severity_code) : ($obj->severity_label !=
'-' ? $obj->severity_label :
''));
766 $this->severity_label = $label_severity;
768 $this->datec = $this->db->jdate($obj->datec);
769 $this->date_creation = $this->db->jdate($obj->datec);
770 $this->date_read = $this->db->jdate($obj->date_read);
771 $this->date_validation = $this->db->jdate($obj->date_read);
772 $this->date_last_msg_sent = $this->db->jdate($obj->date_last_msg_sent);
773 $this->date_close = $this->db->jdate($obj->date_close);
774 $this->tms = $this->db->jdate($obj->tms);
775 $this->date_modification = $this->db->jdate($obj->tms);
779 $this->db->free($resql);
785 $this->error =
"Error ".$this->db->lasterror();
786 dol_syslog(get_class($this).
"::fetch ".$this->error, LOG_ERR);
803 public function fetchAll($user, $sortorder =
'ASC', $sortfield =
't.datec', $limit = 0, $offset = 0, $arch = 0, $filter =
'')
805 global $langs, $extrafields;
808 $extrafields->fetch_name_optionals_label($this->table_element);
813 $sql .=
" t.track_id,";
814 $sql .=
" t.fk_soc,";
815 $sql .=
" t.fk_project,";
816 $sql .=
" t.fk_contract,";
817 $sql .=
" t.origin_email,";
818 $sql .=
" t.origin_replyto,";
819 $sql .=
" t.origin_references,";
820 $sql .=
" t.fk_user_create, uc.lastname as user_create_lastname, uc.firstname as user_create_firstname,";
821 $sql .=
" t.fk_user_assign, ua.lastname as user_assign_lastname, ua.firstname as user_assign_firstname,";
822 $sql .=
" t.subject,";
823 $sql .=
" t.message,";
824 $sql .=
" t.fk_statut as status,";
825 $sql .=
" t.resolution,";
826 $sql .=
" t.progress,";
827 $sql .=
" t.timing,";
828 $sql .=
" t.type_code,";
829 $sql .=
" t.category_code,";
830 $sql .=
" t.severity_code,";
832 $sql .=
" t.date_read,";
833 $sql .=
" t.date_last_msg_sent,";
834 $sql .=
" t.date_close,";
836 $sql .=
" type.label as type_label, category.label as category_label, severity.label as severity_label";
838 if ($extrafields->attributes[$this->table_element][
'count'] > 0) {
839 foreach ($extrafields->attributes[$this->table_element][
'label'] as $key => $val) {
840 $sql .= ($extrafields->attributes[$this->table_element][
'type'][$key] !=
'separate' ?
",ef.".$key.
" as options_".$key :
'');
843 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as t";
844 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_type as type ON type.code = t.type_code";
845 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_category as category ON category.code = t.category_code";
846 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_severity as severity ON severity.code = t.severity_code";
847 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = t.fk_soc";
848 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as uc ON uc.rowid = t.fk_user_create";
849 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as ua ON ua.rowid = t.fk_user_assign";
850 if ($extrafields->attributes[$this->table_element][
'count'] > 0) {
851 if (is_array($extrafields->attributes[$this->table_element][
'label']) && count($extrafields->attributes[$this->table_element][
'label'])) {
852 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"ticket_extrafields as ef on (t.rowid = ef.fk_object)";
855 $sql .=
" WHERE t.entity IN (".getEntity(
'ticket').
")";
858 if (is_array($filter)) {
859 foreach ($filter as $key => $value) {
860 if (strpos($key,
'date')) {
861 $sql .=
" AND ".$this->db->sanitize($key).
" = '".$this->db->escape($value).
"'";
862 } elseif (($key ==
't.fk_user_assign') || ($key ==
't.type_code') || ($key ==
't.category_code') || ($key ==
't.severity_code') || ($key ==
't.fk_soc')) {
863 $sql .=
" AND ".$this->db->sanitize($key).
" = '".$this->db->escape($value).
"'";
864 } elseif ($key ==
't.fk_statut') {
865 if (is_array($value) && count($value) > 0) {
866 $sql .=
" AND ".$this->db->sanitize($key).
" IN (".$this->db->sanitize(implode(
',', $value)).
")";
868 $sql .=
" AND ".$this->db->sanitize($key).
' = '.((int) $value);
870 } elseif ($key ==
't.fk_contract') {
871 $sql .=
" AND ".$this->db->sanitize($key).
' = '.((int) $value);
873 $sql .=
" AND ".$this->db->sanitize($key).
" LIKE '%".$this->db->escape($this->db->escapeforlike($value)).
"%'";
884 $this->errors[] = $errormessage;
885 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
890 $socid = $user->socid ?: 0;
893 if (!$user->hasRight(
'societe',
'client',
'voir')) {
894 $search_sale = $user->id;
897 if ($search_sale && $search_sale !=
'-1') {
898 if ($search_sale == -2) {
899 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc)";
900 } elseif ($search_sale > 0) {
901 $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).
")";
906 $sql .=
" AND t.fk_soc = ".((int) $socid);
909 $sql .= $this->db->order($sortfield, $sortorder);
910 if (!empty($limit)) {
911 $sql .= $this->db->plimit($limit + 1, $offset);
914 dol_syslog(get_class($this).
"::fetchAll", LOG_DEBUG);
915 $resql = $this->db->query($sql);
918 $this->lines = array();
920 $num = $this->db->num_rows($resql);
925 $obj = $this->db->fetch_object($resql);
927 $line =
new self($this->db);
929 $line->id = $obj->rowid;
931 $line->ref = $obj->ref;
932 $line->track_id = $obj->track_id;
933 $line->fk_soc = $obj->fk_soc;
934 $line->fk_project = $obj->fk_project;
935 $line->fk_contract = $obj->fk_contract;
936 $line->origin_email = $obj->origin_email;
937 $line->origin_replyto = $obj->origin_replyto;
938 $line->origin_references = $obj->origin_references;
940 $line->fk_user_create = $obj->fk_user_create;
941 $line->fk_user_assign = $obj->fk_user_assign;
943 $line->subject = $obj->subject;
944 $line->message = $obj->message;
945 $line->fk_statut = $obj->status;
946 $line->status = $obj->status;
947 $line->resolution = $obj->resolution;
948 $line->progress = $obj->progress;
949 $line->timing = $obj->timing;
951 $label_type = ($langs->trans(
"TicketTypeShort".$obj->type_code) !=
"TicketTypeShort".$obj->type_code ? $langs->trans(
"TicketTypeShort".$obj->type_code) : ($obj->type_label !=
'-' ? $obj->type_label :
''));
952 $line->type_label = $label_type;
954 $this->category_code = $obj->category_code;
955 $label_category = ($langs->trans(
"TicketCategoryShort".$obj->category_code) !=
"TicketCategoryShort".$obj->category_code ? $langs->trans(
"TicketCategoryShort".$obj->category_code) : ($obj->category_label !=
'-' ? $obj->category_label :
''));
956 $line->category_label = $label_category;
958 $this->severity_code = $obj->severity_code;
959 $label_severity = ($langs->trans(
"TicketSeverityShort".$obj->severity_code) !=
"TicketSeverityShort".$obj->severity_code ? $langs->trans(
"TicketSeverityShort".$obj->severity_code) : ($obj->severity_label !=
'-' ? $obj->severity_label :
''));
960 $line->severity_label = $label_severity;
962 $line->datec = $this->db->jdate($obj->datec);
963 $line->date_read = $this->db->jdate($obj->date_read);
964 $line->date_last_msg_sent = $this->db->jdate($obj->date_last_msg_sent);
965 $line->date_close = $this->db->jdate($obj->date_close);
968 if ($extrafields->attributes[$this->table_element][
'count'] > 0) {
969 if (is_array($extrafields->attributes[$this->table_element][
'label']) && count($extrafields->attributes[$this->table_element][
'label'])) {
970 foreach ($extrafields->attributes[$this->table_element][
'label'] as $key => $val) {
971 $tmpkey =
'options_'.$key;
972 $line->{$tmpkey} = $obj->$tmpkey;
976 $this->lines[$i] = $line;
980 $this->db->free($resql);
983 $this->error =
"Error ".$this->db->lasterror();
984 dol_syslog(get_class($this).
"::fetchAll ".$this->error, LOG_ERR);
996 public function update($user, $notrigger = 0)
1007 if (isset($this->
ref)) {
1008 $this->
ref = trim($this->
ref);
1011 if (isset($this->track_id)) {
1012 $this->track_id = trim($this->track_id);
1015 if (isset($this->fk_soc)) {
1016 $this->fk_soc = (int) $this->fk_soc;
1019 if (isset($this->fk_project)) {
1020 $this->fk_project = (int) $this->fk_project;
1023 if (isset($this->fk_contract)) {
1024 $this->fk_contract = (int) $this->fk_contract;
1027 if (isset($this->origin_email)) {
1028 $this->origin_email = trim($this->origin_email);
1031 if (isset($this->fk_user_create)) {
1032 $this->fk_user_create = (int) $this->fk_user_create;
1035 if (isset($this->fk_user_assign)) {
1036 $this->fk_user_assign = (int) $this->fk_user_assign;
1039 if (isset($this->subject)) {
1040 $this->subject = trim($this->subject);
1043 if (isset($this->message)) {
1044 $this->message = trim($this->message);
1046 $this->errors[] =
'ErrorFieldTooLong';
1047 dol_syslog(get_class($this).
'::update error -1 message too long', LOG_ERR);
1052 if (isset($this->
status)) {
1056 if (isset($this->resolution)) {
1057 $this->resolution = (int) $this->resolution;
1060 if (isset($this->progress)) {
1061 $this->progress = (int) $this->progress;
1064 if (isset($this->timing)) {
1065 $this->timing = trim($this->timing);
1068 if (isset($this->type_code)) {
1069 $this->timing = trim($this->type_code);
1072 if (isset($this->category_code)) {
1073 $this->timing = trim($this->category_code);
1076 if (isset($this->severity_code)) {
1077 $this->timing = trim($this->severity_code);
1079 if (isset($this->model_pdf)) {
1080 $this->model_pdf = trim($this->model_pdf);
1085 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket SET";
1086 $sql .=
" ref=".(isset($this->
ref) ?
"'".$this->db->escape($this->
ref).
"'" :
"").
",";
1087 $sql .=
" track_id=".(isset($this->track_id) ?
"'".$this->db->escape($this->track_id).
"'" :
"null").
",";
1088 $sql .=
" fk_soc=".(isset($this->fk_soc) ? (int) $this->fk_soc :
"null").
",";
1089 $sql .=
" fk_project=".(isset($this->fk_project) ? (int) $this->fk_project :
"null").
",";
1090 $sql .=
" fk_contract=".(isset($this->fk_contract) ? (int) $this->fk_contract :
"null").
",";
1091 $sql .=
" origin_email=".(isset($this->origin_email) ?
"'".$this->db->escape($this->origin_email).
"'" :
"null").
",";
1092 $sql .=
" origin_replyto=".(isset($this->origin_replyto) ?
"'".$this->db->escape($this->origin_replyto).
"'" :
"null").
",";
1093 $sql .=
" origin_references=".(isset($this->origin_references) ?
"'".$this->db->escape($this->origin_references).
"'" :
"null").
",";
1094 $sql .=
" fk_user_create=".(isset($this->fk_user_create) ? (int) $this->fk_user_create :
"null").
",";
1095 $sql .=
" fk_user_assign=".(isset($this->fk_user_assign) ? (int) $this->fk_user_assign :
"null").
",";
1096 $sql .=
" subject=".(isset($this->subject) ?
"'".$this->db->escape($this->subject).
"'" :
"null").
",";
1097 $sql .=
" message=".(isset($this->message) ?
"'".$this->db->escape($this->message).
"'" :
"null").
",";
1098 $sql .=
" fk_statut=".(isset($this->
status) ? (int) $this->
status :
"0").
",";
1099 $sql .=
" resolution=".(isset($this->resolution) ? (int) $this->resolution :
"null").
",";
1100 $sql .=
" progress=".(isset($this->progress) ?
"'".$this->db->escape($this->progress).
"'" :
"null").
",";
1101 $sql .=
" timing=".(isset($this->timing) ?
"'".$this->db->escape($this->timing).
"'" :
"null").
",";
1102 $sql .=
" type_code=".(isset($this->type_code) ?
"'".$this->db->escape($this->type_code).
"'" :
"null").
",";
1103 $sql .=
" category_code=".(isset($this->category_code) ?
"'".$this->db->escape($this->category_code).
"'" :
"null").
",";
1104 $sql .=
" severity_code=".(isset($this->severity_code) ?
"'".$this->db->escape($this->severity_code).
"'" :
"null").
",";
1105 $sql .=
" datec=".(isDolTms($this->datec) ?
"'".$this->db->idate($this->datec).
"'" :
'null').
",";
1106 $sql .=
" date_read=".(dol_strlen((
string) $this->date_read) != 0 ?
"'".$this->db->idate($this->date_read).
"'" :
'null').
",";
1107 $sql .=
" date_last_msg_sent=".(dol_strlen((
string) $this->date_last_msg_sent) != 0 ?
"'".$this->db->idate($this->date_last_msg_sent).
"'" :
'null').
",";
1108 $sql .=
" model_pdf=".(isset($this->model_pdf) ?
"'".$this->db->escape($this->model_pdf).
"'" :
"null").
",";
1109 $sql .=
" date_close=".(dol_strlen((
string) $this->date_close) != 0 ?
"'".$this->db->idate($this->date_close).
"'" :
'null');
1110 $sql .=
" WHERE rowid=".((int) $this->
id);
1114 $resql = $this->db->query($sql);
1117 $this->errors[] =
"Error ".$this->db->lasterror();
1122 $result = $this->insertExtraFields();
1128 if (!$error && !$notrigger) {
1130 $result = $this->call_trigger(
'TICKET_MODIFY', $user);
1139 foreach ($this->errors as $errmsg) {
1140 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
1141 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1143 $this->db->rollback();
1146 $this->db->commit();
1158 public function delete($user, $notrigger = 0)
1166 $result = $this->call_trigger(
'TICKET_DELETE', $user);
1175 $res = $this->delete_linked_contact();
1177 dol_syslog(get_class($this).
"::delete error", LOG_ERR);
1184 $res = $this->deleteObjectLinked();
1192 $result = $this->deleteExtraFields();
1195 dol_syslog(get_class($this).
"::delete error -3 ".$this->error, LOG_ERR);
1202 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_ticket";
1203 $sql .=
" WHERE fk_ticket = ".(int) $this->
id;
1205 $result = $this->db->query($sql);
1208 $this->errors[] = $this->db->lasterror();
1213 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"ticket";
1214 $sql .=
" WHERE rowid=".((int) $this->
id);
1216 dol_syslog(get_class($this).
"::delete sql=".$sql);
1217 $resql = $this->db->query($sql);
1220 $this->errors[] =
"Error ".$this->db->lasterror();
1223 $this->deleteEcmFiles(1);
1225 $dir = DOL_DATA_ROOT.
'/'.$this->element.
'/'.$this->ref;
1229 $this->errors[] = $this->error;
1237 foreach ($this->errors as $errmsg) {
1238 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
1239 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
1241 $this->db->rollback();
1244 $this->db->commit();
1273 $object->context[
'createfromclone'] =
'createfromclone';
1274 $result =
$object->create($user);
1278 $this->error =
$object->error;
1282 unset(
$object->context[
'createfromclone']);
1286 $this->db->commit();
1289 $this->db->rollback();
1304 $this->
ref =
'TI0501-001';
1305 $this->track_id =
'XXXXaaaa';
1306 $this->origin_email =
'email@email.com';
1307 $this->fk_project = 1;
1308 $this->fk_user_create = 1;
1309 $this->fk_user_assign = 1;
1310 $this->subject =
'Subject of ticket';
1311 $this->message =
'Message of ticket';
1313 $this->resolution = 1;
1314 $this->progress = 10;
1316 $this->type_code =
'TYPECODE';
1317 $this->category_code =
'CATEGORYCODE';
1318 $this->severity_code =
'SEVERITYCODE';
1321 $this->date_last_msg_sent =
dol_now();
1322 $this->date_close =
dol_now();
1336 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 =
'');
1349 if (!empty($this->cache_types_tickets) && count($this->cache_types_tickets)) {
1354 $sql =
"SELECT rowid, code, label, use_default, pos, description";
1355 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_type";
1356 $sql .=
" WHERE entity IN (".getEntity(
'c_ticket_type').
")";
1357 $sql .=
" AND active > 0";
1358 $sql .=
" ORDER BY pos";
1359 dol_syslog(get_class($this).
"::load_cache_type_tickets", LOG_DEBUG);
1360 $resql = $this->db->query($sql);
1362 $num = $this->db->num_rows($resql);
1365 $obj = $this->db->fetch_object($resql);
1366 $label = ($langs->trans(
"TicketTypeShort".$obj->code) !=
"TicketTypeShort".$obj->code ? $langs->trans(
"TicketTypeShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
1367 $this->cache_types_tickets[$obj->rowid][
'code'] = $obj->code;
1368 $this->cache_types_tickets[$obj->rowid][
'label'] = $label;
1369 $this->cache_types_tickets[$obj->rowid][
'use_default'] = $obj->use_default;
1370 $this->cache_types_tickets[$obj->rowid][
'pos'] = $obj->pos;
1390 if ($publicgroup == -1 && !empty($this->cache_category_tickets) && count($this->cache_category_tickets)) {
1395 $sql =
"SELECT rowid, code, label, use_default, pos, description, public, active, force_severity, fk_parent";
1396 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_category";
1397 $sql .=
" WHERE entity IN (".getEntity(
'c_ticket_category').
")";
1398 $sql .=
" AND active > 0";
1399 if ($publicgroup > -1) {
1400 $sql .=
" AND public = ".((int) $publicgroup);
1402 $sql .=
" ORDER BY pos";
1404 dol_syslog(get_class($this).
"::load_cache_categories_tickets", LOG_DEBUG);
1406 $resql = $this->db->query($sql);
1408 $num = $this->db->num_rows($resql);
1411 $obj = $this->db->fetch_object($resql);
1412 $this->cache_category_tickets[$obj->rowid][
'code'] = $obj->code;
1413 $this->cache_category_tickets[$obj->rowid][
'use_default'] = $obj->use_default;
1414 $this->cache_category_tickets[$obj->rowid][
'pos'] = $obj->pos;
1415 $this->cache_category_tickets[$obj->rowid][
'public'] = $obj->public;
1416 $this->cache_category_tickets[$obj->rowid][
'active'] = $obj->active;
1417 $this->cache_category_tickets[$obj->rowid][
'force_severity'] = $obj->force_severity;
1418 $this->cache_category_tickets[$obj->rowid][
'fk_parent'] = $obj->fk_parent;
1422 $label = ($langs->trans(
"TicketCategoryShort".$obj->code) !=
"TicketCategoryShort".$obj->code ? $langs->trans(
"TicketCategoryShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
1423 $this->cache_category_tickets[$obj->rowid][
'label'] = $label;
1441 global
$conf, $langs;
1443 if (!empty(
$conf->cache[
'severity_tickets']) && count(
$conf->cache[
'severity_tickets'])) {
1448 $sql =
"SELECT rowid, code, label, use_default, pos, description";
1449 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_severity";
1450 $sql .=
" WHERE entity IN (".getEntity(
'c_ticket_severity').
")";
1451 $sql .=
" AND active > 0";
1452 $sql .=
" ORDER BY pos";
1453 dol_syslog(get_class($this).
"::loadCacheSeveritiesTickets", LOG_DEBUG);
1454 $resql = $this->db->query($sql);
1456 $num = $this->db->num_rows($resql);
1459 $obj = $this->db->fetch_object($resql);
1461 $conf->cache[
'severity_tickets'][$obj->rowid][
'code'] = $obj->code;
1462 $label = ($langs->trans(
"TicketSeverityShort".$obj->code) !=
"TicketSeverityShort".$obj->code ? $langs->trans(
"TicketSeverityShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
1463 $conf->cache[
'severity_tickets'][$obj->rowid][
'label'] = $label;
1464 $conf->cache[
'severity_tickets'][$obj->rowid][
'use_default'] = $obj->use_default;
1465 $conf->cache[
'severity_tickets'][$obj->rowid][
'pos'] = $obj->pos;
1484 return $this->LibStatut($this->
status, $mode, 0, $this->progress);
1498 public function LibStatut($status, $mode = 0, $notooltip = 0, $progress = 0)
1501 global $langs, $hookmanager;
1503 $labelStatus = (isset($status) && !empty($this->labelStatus[$status])) ? $this->labelStatus[$status] :
'';
1504 $labelStatusShort = (isset($status) && !empty($this->labelStatusShort[$status])) ? $this->labelStatusShort[$status] :
'';
1507 case self::STATUS_NOT_READ:
1508 $statusType =
'status0';
1510 case self::STATUS_READ:
1511 $statusType =
'status1';
1513 case self::STATUS_ASSIGNED:
1514 $statusType =
'status2';
1516 case self::STATUS_IN_PROGRESS:
1517 $statusType =
'status4';
1519 case self::STATUS_WAITING:
1520 $statusType =
'status7';
1522 case self::STATUS_NEED_MORE_INFO:
1523 $statusType =
'status3';
1525 case self::STATUS_CANCELED:
1526 $statusType =
'status9';
1528 case self::STATUS_CLOSED:
1529 $statusType =
'status6';
1532 $labelStatus =
'Unknown';
1533 $labelStatusShort =
'Unknown';
1534 $statusType =
'status0';
1538 $parameters = array(
1539 'status' => $status,
1544 $reshook = $hookmanager->executeHooks(
'LibStatut', $parameters, $this);
1547 return $hookmanager->resPrint;
1552 $params = array(
'tooltip' =>
'no');
1555 $labelStatus = $langs->transnoentitiesnoconv($labelStatus);
1556 $labelStatusShort = $langs->transnoentitiesnoconv($labelStatusShort);
1558 if ($status == self::STATUS_IN_PROGRESS && $progress > 0) {
1559 $labelStatus .=
' ('.round($progress).
'%)';
1560 $labelStatusShort .=
' ('.round($progress).
'%)';
1563 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode,
'', $params);
1576 $langs->load(
'ticket');
1577 $nofetch = !empty($params[
'nofetch']);
1580 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Ticket").
'</u>';
1581 $datas[
'picto'] .=
' '.$this->getLibStatut(4);
1582 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1583 $datas[
'track_id'] =
'<br><b>'.$langs->trans(
'TicketTrackId').
':</b> '.$this->track_id;
1584 $datas[
'subject'] =
'<br><b>'.$langs->trans(
'Subject').
':</b> '.$this->subject;
1585 if ($this->date_creation) {
1586 $datas[
'date_creation'] =
'<br><b>'.$langs->trans(
'DateCreation').
':</b> '.
dol_print_date($this->date_creation,
'dayhour');
1588 if ($this->date_modification) {
1589 $datas[
'date_modification'] =
'<br><b>'.$langs->trans(
'DateModification').
':</b> '.
dol_print_date($this->date_modification,
'dayhour');
1592 if (isModEnabled(
'category') && !$nofetch) {
1593 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
1594 $form =
new Form($this->db);
1595 $datas[
'categories'] =
'<br>' . $form->showCategories($this->
id, Categorie::TYPE_TICKET, 1);
1611 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1613 global $action,
$conf, $hookmanager, $langs;
1615 if (!empty(
$conf->dol_no_mouse_hover)) {
1623 'objecttype' => $this->element,
1624 'option' => $option,
1627 $classfortooltip =
'classfortooltip';
1630 $classfortooltip =
'classforajaxtooltip';
1631 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1634 $label = implode($this->getTooltipContentArray($params));
1637 $url = DOL_URL_ROOT.
'/ticket/card.php?id='.
$this->id;
1639 if ($option !=
'nolink') {
1641 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1642 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1643 $add_save_lastsearch_values = 1;
1645 if ($add_save_lastsearch_values) {
1646 $url .=
'&save_lastsearch_values=1';
1651 if (empty($notooltip)) {
1653 $label = $langs->trans(
"ShowTicket");
1654 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1656 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
1657 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1659 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1662 $linkstart =
'<a href="'.$url.
'"';
1663 $linkstart .= $linkclose.
'>';
1666 $result .= $linkstart;
1668 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ?:
'generic'), (($withpicto != 2) ?
'class="paddingright"' :
''), 0, 0, $notooltip ? 0 : 1);
1670 if ($withpicto != 2) {
1671 $result .= $this->ref;
1673 $result .= $linkend;
1676 $hookmanager->initHooks(array(
'ticketdao'));
1677 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1678 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1680 $result = $hookmanager->resPrint;
1682 $result .= $hookmanager->resPrint;
1702 if ($this->
status != self::STATUS_CANCELED) {
1707 $this->
status = Ticket::STATUS_READ;
1709 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
1710 $sql .=
" SET fk_statut = ".Ticket::STATUS_READ.
", date_read = '".$this->db->idate(
dol_now()).
"'";
1711 $sql .=
" WHERE rowid = ".((int) $this->
id);
1714 $resql = $this->db->query($sql);
1716 $this->context[
'actionmsg'] = $langs->trans(
'TicketLogMesgReadBy', $this->
ref, $user->getFullName($langs));
1717 $this->context[
'actionmsg2'] = $langs->trans(
'TicketLogMesgReadBy', $this->
ref, $user->getFullName($langs));
1721 $result = $this->call_trigger(
'TICKET_MODIFY', $user);
1729 $this->db->commit();
1732 $this->
status = $this->oldcopy->status;
1734 $this->db->rollback();
1735 $this->error = implode(
',', $this->errors);
1736 dol_syslog(get_class($this).
"::markAsRead ".$this->error, LOG_ERR);
1740 $this->
status = $this->oldcopy->status;
1742 $this->db->rollback();
1743 $this->error = $this->db->lasterror();
1744 dol_syslog(get_class($this).
"::markAsRead ".$this->error, LOG_ERR);
1760 public function assignUser($user, $id_assign_user, $notrigger = 0)
1768 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
1769 if ($id_assign_user > 0) {
1770 $sql .=
" SET fk_user_assign=".((int) $id_assign_user).
", fk_statut = ".Ticket::STATUS_ASSIGNED;
1772 $sql .=
" SET fk_user_assign=null, fk_statut = ".Ticket::STATUS_READ;
1774 $sql .=
" WHERE rowid = ".((int) $this->
id);
1776 dol_syslog(get_class($this).
"::assignUser sql=".$sql);
1777 $resql = $this->db->query($sql);
1779 $this->fk_user_assign = $id_assign_user;
1783 $result = $this->call_trigger(
'TICKET_ASSIGNED', $user);
1791 $this->db->commit();
1794 $this->db->rollback();
1795 $this->error = implode(
',', $this->errors);
1796 dol_syslog(get_class($this).
"::assignUser ".$this->error, LOG_ERR);
1800 $this->db->rollback();
1801 $this->error = $this->db->lasterror();
1802 dol_syslog(get_class($this).
"::assignUser ".$this->error, LOG_ERR);
1819 public function createTicketMessage($user, $notrigger = 0, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $send_email =
false, $public_area = 0)
1827 if (isset($this->fk_track_id)) {
1828 $this->fk_track_id = trim($this->fk_track_id);
1831 if (isset($this->message)) {
1832 $this->message = trim($this->message);
1838 include_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
1840 $actioncomm->type_code =
'AC_OTH_AUTO';
1841 $actioncomm->code =
'TICKET_MSG';
1842 if ($this->
private) {
1843 $actioncomm->code =
'TICKET_MSG_PRIVATE';
1846 $actioncomm->code .=
'_SENTBYMAIL';
1848 if ((empty($user->id) || $user->id == 0) && isset($_SESSION[
'email_customer'])) {
1849 $actioncomm->email_from = $_SESSION[
'email_customer'];
1851 $actioncomm->socid = $this->socid;
1852 $actioncomm->label = $this->subject;
1853 $actioncomm->note_private = $this->message;
1854 $actioncomm->userassigned = array($user->id => array(
'id' => $user->id,
'transparency' => 0));
1855 $actioncomm->userownerid = $user->id;
1856 $actioncomm->datep = $now;
1857 $actioncomm->percentage = -1;
1858 $actioncomm->elementtype =
'ticket';
1860 $actioncomm->fk_project = $this->fk_project;
1866 if ($public_area && !empty($this->origin_email) &&
getDolGlobalString(
'TICKET_ASSIGN_CONTACT_TO_MESSAGE')) {
1867 $contacts = $this->searchContactByEmail($this->origin_email);
1868 if (!empty($contacts)) {
1870 foreach ($contacts as $contact) {
1871 if ((
int) $contact->statut == 1) {
1872 $actioncomm->contact_id = $contact->id;
1879 $attachedfiles = array();
1880 $attachedfiles[
'paths'] = $filename_list;
1881 $attachedfiles[
'names'] = $mimefilename_list;
1882 $attachedfiles[
'mimes'] = $mimetype_list;
1883 if (is_array($attachedfiles) && count($attachedfiles) > 0) {
1884 $actioncomm->attachedfiles = $attachedfiles;
1890 $actionid = $actioncomm->create($user);
1891 if ($actionid <= 0) {
1893 $this->error = $actioncomm->error;
1894 $this->errors = $actioncomm->errors;
1897 if ($actionid > 0) {
1898 if (is_array($attachedfiles) && array_key_exists(
'paths', $attachedfiles) && count($attachedfiles[
'paths']) > 0) {
1900 foreach ($attachedfiles[
'paths'] as $key => $filespath) {
1902 $destdir =
$conf->ticket->dir_output.
'/'.$this->ref;
1907 if (in_array($actioncomm->code, array(
'TICKET_MSG',
'TICKET_MSG_SENTBYMAIL'))) {
1908 $ecmfile =
new EcmFiles($this->db);
1909 $destdir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $destdir);
1910 $destdir = preg_replace(
'/[\\/]$/',
'', $destdir);
1911 $destdir = preg_replace(
'/^[\\/]/',
'', $destdir);
1913 $result = $ecmfile->fetch(0,
'', $destdir.
'/'.$attachedfiles[
'names'][$key]);
1923 $result = $ecmfile->update($user);
1936 $this->db->rollback();
1939 $this->db->commit();
1951 if (!empty($this->cache_msgs_ticket) && is_array($this->cache_msgs_ticket) && count($this->cache_msgs_ticket)) {
1957 $sql =
"SELECT id as rowid, fk_user_author, email_from, datec, datep, label, note as message, code";
1958 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
1959 $sql .=
" WHERE fk_element = ".(int) $this->
id;
1960 $sql .=
" AND elementtype = 'ticket'";
1961 $sql .=
" ORDER BY datep DESC";
1963 dol_syslog(get_class($this).
"::load_cache_actions_ticket", LOG_DEBUG);
1964 $resql = $this->db->query($sql);
1966 $num = $this->db->num_rows($resql);
1969 $obj = $this->db->fetch_object($resql);
1970 $this->cache_msgs_ticket[$i][
'id'] = $obj->rowid;
1971 $this->cache_msgs_ticket[$i][
'fk_user_author'] = $obj->fk_user_author;
1972 if (in_array($obj->code, array(
'TICKET_MSG',
'AC_TICKET_CREATE')) && empty($obj->fk_user_author)) {
1973 $this->cache_msgs_ticket[$i][
'fk_contact_author'] = $obj->email_from;
1975 $this->cache_msgs_ticket[$i][
'datec'] = $this->db->jdate($obj->datec);
1976 $this->cache_msgs_ticket[$i][
'datep'] = $this->db->jdate($obj->datep);
1977 $this->cache_msgs_ticket[$i][
'subject'] = $obj->label;
1978 $this->cache_msgs_ticket[$i][
'message'] = $obj->message;
1979 $this->cache_msgs_ticket[$i][
'private'] = (preg_match(
'/^TICKET_MSG_PRIVATE/', $obj->code) ? 1 : 0);
1984 $this->error =
"Error ".$this->db->lasterror();
1985 dol_syslog(get_class($this).
"::load_cache_actions_ticket ".$this->error, LOG_ERR);
2000 if ($this->
status != Ticket::STATUS_CLOSED && $this->
status != Ticket::STATUS_CANCELED) {
2003 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
2004 $sql .=
" SET fk_statut=".($mode ? Ticket::STATUS_CANCELED : Ticket::STATUS_CLOSED).
", progress=100, date_close='".$this->db->idate(
dol_now()).
"'";
2005 $sql .=
" WHERE rowid = ".((int) $this->
id);
2007 dol_syslog(get_class($this).
"::close mode=".$mode);
2008 $resql = $this->db->query($sql);
2013 if (isModEnabled(
'intervention') &&
getDolGlobalString(
'WORKFLOW_TICKET_CLOSE_INTERVENTION')) {
2014 dol_syslog(
"We have closed the ticket, so we close all linked interventions");
2015 $this->fetchObjectLinked($this->
id, $this->element,
null,
'fichinter');
2016 if ($this->linkedObjectsIds) {
2017 foreach ($this->linkedObjectsIds[
'fichinter'] as $fichinter_id) {
2019 $fichinter->fetch($fichinter_id);
2020 if ($fichinter->statut == 0) {
2021 $result = $fichinter->setValid($user);
2023 $this->errors[] = $fichinter->error;
2027 if ($fichinter->statut < 3) {
2028 $result = $fichinter->setStatut(3);
2030 $this->errors[] = $fichinter->error;
2039 $result = $this->call_trigger(
'TICKET_CLOSE', $user);
2046 $this->db->commit();
2049 $this->db->rollback();
2050 $this->error = implode(
',', $this->errors);
2051 dol_syslog(get_class($this).
"::close ".$this->error, LOG_ERR);
2055 $this->db->rollback();
2056 $this->error = $this->db->lasterror();
2057 dol_syslog(get_class($this).
"::close ".$this->error, LOG_ERR);
2076 $thirdparties = array();
2080 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"societe";
2081 $sql .=
" WHERE entity IN (".getEntity(
'ticket', 1).
")";
2082 if (!empty($type)) {
2083 if ($type == 1 || $type == 2) {
2084 $sql .=
" AND client = ".((int) $type);
2085 } elseif ($type == 3) {
2086 $sql .=
" AND fournisseur = 1";
2089 if (!empty($email)) {
2090 if (empty($exact)) {
2092 if (preg_match(
'/^([\*])?[^*]+([\*])?$/', $email, $regs) && count($regs) > 1) {
2093 $email = str_replace(
'*',
'%', $email);
2095 $email =
'%'.$email.
'%';
2099 if (is_array($filters) && !empty($filters)) {
2103 $sql .=
"email LIKE '".$this->db->escape($email).
"'";
2105 if (is_array($filters) && !empty($filters)) {
2106 foreach ($filters as $field => $value) {
2107 $sql .=
" ".$clause.
" ".$field.
" LIKE '".$this->db->escape($value).
"'";
2109 if (!empty($email)) {
2114 $res = $this->db->query($sql);
2116 while ($rec = $this->db->fetch_array($res)) {
2117 $soc =
new Societe($this->db);
2118 $soc->fetch($rec[
'rowid']);
2119 $thirdparties[] = $soc;
2122 return $thirdparties;
2124 $this->error = $this->db->error().
' sql='.$sql;
2125 dol_syslog(get_class($this).
"::searchSocidByEmail ".$this->error, LOG_ERR);
2140 $contacts = array();
2143 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"socpeople";
2144 $sql .=
" WHERE entity IN (".getEntity(
'contact').
")";
2145 if (!empty($socid)) {
2146 $sql .=
" AND fk_soc = ".((int) $socid);
2148 if (!empty($email)) {
2151 $sql .=
"email = '".$this->db->escape($email).
"'";
2153 $sql .=
"email LIKE BINARY '".$this->db->escape($this->db->escapeforlike($email)).
"'";
2157 $res = $this->db->query($sql);
2159 while ($rec = $this->db->fetch_object($res)) {
2160 include_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
2161 $contactstatic =
new Contact($this->db);
2162 $contactstatic->fetch($rec->rowid);
2163 $contacts[] = $contactstatic;
2168 $this->error = $this->db->error().
' sql='.$sql;
2169 dol_syslog(get_class($this).
"::searchContactByEmail ".$this->error, LOG_ERR);
2183 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
2184 $sql .=
" SET fk_soc = ".($id > 0 ? (int)
$id :
"null");
2185 $sql .=
" WHERE rowid = ".((int) $this->
id);
2186 dol_syslog(get_class($this).
'::setCustomer sql='.$sql);
2187 $resql = $this->db->query($sql);
2207 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
2208 $sql .=
" SET progress = ".($percent > 0 ? (float) $percent :
"null");
2209 $sql .=
" WHERE rowid = ".((int) $this->
id);
2210 dol_syslog(get_class($this).
'::set_progression sql='.$sql);
2211 $resql = $this->db->query($sql);
2231 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ticket";
2232 $sql .=
" SET fk_contract = ".($contractid > 0 ? (int) $contractid :
"null");
2233 $sql .=
" WHERE rowid = ".((int) $this->
id);
2234 dol_syslog(get_class($this).
'::setContract sql='.$sql);
2235 $resql = $this->db->query($sql);
2255 return $this->getIdContact(
'internal',
'SUPPORTTEC');
2266 return $this->listeContact(-1,
'internal', 0,
'', $status);
2276 return $this->getIdContact(
'external',
'SUPPORTCLI');
2287 return $this->listeContact(-1,
'external', 0,
'', $status);
2297 return $this->getIdContact(
'internal',
'CONTRIBUTOR');
2307 return $this->getIdContact(
'external',
'CONTRIBUTOR');
2317 $array_contact = $this->getIdTicketInternalContact();
2319 $array_contact = array_merge($array_contact, $this->getIdTicketCustomerContact());
2321 $array_contact = array_merge($array_contact, $this->getIdTicketInternalInvolvedContact());
2323 $array_contact = array_merge($array_contact, $this->getIdTicketCustomerInvolvedContact());
2325 return $array_contact;
2335 $array_contact = array();
2337 $array_contact = array_merge($array_contact, $this->getIdTicketCustomerContact());
2339 $array_contact = array_merge($array_contact, $this->getIdTicketCustomerInvolvedContact());
2341 return $array_contact;
2356 public function listeContact($statusoflink = -1, $source =
'external', $list = 0, $code =
'', $status = -1)
2362 $sql =
"SELECT ec.rowid, ec.statut as statuslink, ec.fk_socpeople as id, ec.fk_c_type_contact";
2363 if ($source ==
'internal') {
2364 $sql .=
", '-1' as socid, t.statut as statuscontact";
2367 if ($source ==
'external' || $source ==
'thirdparty') {
2368 $sql .=
", t.fk_soc as socid, t.statut as statuscontact";
2371 $sql .=
", t.civility, t.lastname as lastname, t.firstname, t.email";
2372 if ($source ==
'internal') {
2373 $sql .=
", t.office_phone as phone, t.user_mobile as phone_mobile";
2376 if ($source ==
'external') {
2377 $sql .=
", t.phone as phone, t.phone_mobile as phone_mobile, t.phone_perso as phone_perso";
2380 $sql .=
", tc.source, tc.element, tc.code, tc.libelle as type_contact_label";
2381 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_contact tc";
2382 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact ec";
2383 if ($source ==
'internal') {
2384 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user t on ec.fk_socpeople = t.rowid";
2387 if ($source ==
'external' || $source ==
'thirdparty') {
2388 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople t on ec.fk_socpeople = t.rowid";
2391 $sql .=
" WHERE ec.element_id = ".((int) $this->
id);
2392 $sql .=
" AND ec.fk_c_type_contact=tc.rowid";
2393 $sql .=
" AND tc.element='".$this->db->escape($this->element).
"'";
2394 if ($source ==
'internal') {
2395 $sql .=
" AND tc.source = 'internal'";
2397 $sql .=
" AND t.statut = ".((int) $status);
2401 if ($source ==
'external' || $source ==
'thirdparty') {
2402 $sql .=
" AND tc.source = 'external'";
2404 $sql .=
" AND t.statut = ".((int) $status);
2408 if (!empty($code)) {
2409 $sql .=
" AND tc.code = '".$this->db->escape($code).
"'";
2412 $sql .=
" AND tc.active=1";
2413 if ($statusoflink >= 0) {
2414 $sql .=
" AND ec.statut = ".((int) $statusoflink);
2417 $sql .=
" ORDER BY t.lastname ASC";
2419 $resql = $this->db->query($sql);
2421 $num = $this->db->num_rows($resql);
2424 $obj = $this->db->fetch_object($resql);
2427 $transkey =
"TypeContact_".$obj->element.
"_".$obj->source.
"_".$obj->code;
2428 $labelType = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->type_contact_label);
2430 'source' => $obj->source,
2431 'socid' => $obj->socid,
2433 'nom' => $obj->lastname,
2434 'civility' => $obj->civility,
2435 'lastname' => $obj->lastname,
2436 'firstname' => $obj->firstname,
2437 'email' => $obj->email,
2438 'rowid' => $obj->rowid,
2439 'code' => $obj->code,
2440 'libelle' => $labelType,
2441 'labeltype' => $labelType,
2442 'status' => $obj->statuslink,
2443 'statuscontact' => $obj->statuscontact,
2444 'fk_c_type_contact' => $obj->fk_c_type_contact,
2445 'phone' => $obj->phone,
2446 'phone_mobile' => $obj->phone_mobile);
2448 $tab[$i] = $obj->id;
2456 $this->error = $this->db->error();
2479 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
2480 foreach ($dirmodels as $reldir) {
2481 $file =
dol_buildpath($reldir.
"core/modules/ticket/".$modele.
'.php', 0);
2482 if (file_exists($file)) {
2483 $classname = $modele;
2488 if ($classname !==
'') {
2490 $modTicket =
new $classname();
2491 '@phan-var-force ModeleNumRefTicket $modTicket';
2493 $defaultref = $modTicket->getNextValue($thirdparty, $this);
2496 if (is_numeric($defaultref) && $defaultref <= 0) {
2514 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2519 if (file_exists($dir_osencoded)) {
2520 $handle = opendir($dir_osencoded);
2521 if (is_resource($handle)) {
2522 while (($file = readdir($handle)) !==
false) {
2524 $file = mb_convert_encoding($file,
'UTF-8',
'ISO-8859-1');
2549 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
2550 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2551 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
2553 $maxwidthsmall = 270;
2554 $maxheightsmall = 150;
2555 $maxwidthmini = 128;
2556 $maxheightmini = 72;
2558 $formmail =
new FormMail($this->db);
2559 $formmail->trackid = (is_null($forcetrackid) ?
'tic'.$this->id :
'');
2560 $attachedfiles = $formmail->get_attached_files();
2562 $filepath = $attachedfiles[
'paths'];
2563 $filename = $attachedfiles[
'names'];
2564 $mimetype = $attachedfiles[
'mimes'];
2567 $destdir =
$conf->ticket->dir_output.
'/'.$this->ref;
2573 $listofpaths = array();
2574 $listofnames = array();
2575 foreach ($filename as $i => $val) {
2576 $destfile = $destdir.
'/'.$filename[$i];
2578 if (is_file($destfile)) {
2579 $pathinfo = pathinfo($filename[$i]);
2581 $destfile = $destdir.
'/'.$pathinfo[
'filename'].
' - '.
dol_print_date($now,
'dayhourlog').
'.'.$pathinfo[
'extension'];
2584 $moreinfo = array(
'description' =>
'File saved by copyFilesForTicket',
'src_object_type' => $this->element,
'src_object_id' => $this->
id);
2586 $res =
dol_move($filepath[$i], $destfile,
'0', 1, 0, 1, $moreinfo);
2590 $this->error =
"Failed to move file ".dirbasename($filepath[$i]).
" into ".
dirbasename($destfile);
2597 $imgThumbSmall =
vignette($destfile, $maxwidthsmall, $maxheightsmall,
'_small', 50,
"thumbs");
2600 $imgThumbMini =
vignette($destfile, $maxwidthmini, $maxheightmini,
'_mini', 50,
"thumbs");
2605 $formmail->remove_attached_files($i);
2608 $listofpaths[$i] = $destfile;
2609 $listofnames[$i] = basename($destfile);
2612 return array(
'listofpaths' => $listofpaths,
'listofnames' => $listofnames,
'listofmimes' => $mimetype);
2628 if (!is_array($categories)) {
2629 $categories = array($categories);
2633 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2635 $existing = $c->containing($this->
id, Categorie::TYPE_TICKET,
'id');
2638 if (is_array($existing)) {
2639 $to_del = array_diff($existing, $categories);
2640 $to_add = array_diff($categories, $existing);
2643 $to_add = $categories;
2647 foreach ($to_del as $del) {
2648 if ($c->fetch($del) > 0) {
2649 $c->del_type($this, Categorie::TYPE_TICKET);
2652 foreach ($to_add as $add) {
2653 if ($c->fetch($add) > 0) {
2654 $c->add_type($this, Categorie::TYPE_TICKET);
2673 public function newMessage($user, &$action, $private = 1, $public_area = 0)
2675 global $mysoc, $langs;
2689 array_push($this->errors, $langs->trans(
"ErrorTicketIsNotValid"));
2695 array_push($this->errors, $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Message")));
2696 $action =
'add_message';
2707 $resarray =
$object->copyFilesForTicket();
2708 if (is_numeric($resarray) && $resarray == -1) {
2713 $listofpaths = $resarray[
'listofpaths'];
2714 $listofnames = $resarray[
'listofnames'];
2715 $listofmimes = $resarray[
'listofmimes'];
2717 $id =
$object->createTicketMessage($user, 0, $listofpaths, $listofmimes, $listofnames, $send_email, $public_area);
2720 $this->error =
$object->error;
2721 $this->errors =
$object->errors;
2722 $action =
'add_message';
2725 if (!$error &&
$id > 0) {
2726 setEventMessages($langs->trans(
'TicketMessageSuccessfullyAdded'),
null,
'mesgs');
2728 if (!empty($public_area)) {
2736 $internal_contacts =
$object->getInfosTicketInternalContact(1);
2738 $assigned_user_dont_have_email =
'';
2742 if ($this->fk_user_assign > 0) {
2743 $assigned_user =
new User($this->db);
2744 $assigned_user->fetch($this->fk_user_assign);
2745 if (!empty($assigned_user->email)) {
2746 $sendto[$assigned_user->email] = $assigned_user->getFullName($langs).
" <".$assigned_user->email.
">";
2748 $assigned_user_dont_have_email = $assigned_user->getFullName($langs);
2751 $assigned_user =
null;
2755 foreach ($internal_contacts as $key => $info_sendto) {
2757 if ($info_sendto[
'id'] == $user->id) {
2762 if (!empty($info_sendto[
'email']) && ($assigned_user ===
null || $assigned_user->email != $info_sendto[
'email'])) {
2763 $sendto[] =
dolGetFirstLastname($info_sendto[
'firstname'], $info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">";
2767 if (empty($sendto)) {
2782 if (!empty($sendto)) {
2785 $subject =
'['.$appli.
'- ticket #'.
$object->track_id.
'] '.$this->subject;
2788 $message =
getDolGlobalString(
'TICKET_MESSAGE_MAIL_INTRO', $langs->trans(
'TicketMessageMailIntroText'));
2789 $message .=
'<br><br>';
2790 $messagePost =
GETPOST(
'message',
'restricthtml');
2794 $message .= $messagePost;
2797 $message .=
'<br><br>';
2798 $message .=
"==============================================";
2799 $message .= !empty(
$object->thirdparty->name) ?
'<br>'.$langs->trans(
'Thirdparty').
" : ".
$object->thirdparty->name :
'';
2800 $message .= !empty(
$object->thirdparty->town) ?
'<br>'.$langs->trans(
'Town').
" : ".
$object->thirdparty->town :
'';
2801 $message .= !empty(
$object->thirdparty->phone) ?
'<br>'.$langs->trans(
'Phone').
" : ".
$object->thirdparty->phone :
'';
2804 $message .=
'<br><br>';
2805 if (!empty($assigned_user_dont_have_email)) {
2806 $message .=
'<br>'.$langs->trans(
'NoEMail').
' : '.$assigned_user_dont_have_email;
2808 foreach ($sendto as $val) {
2809 $message .=
'<br>'.$langs->trans(
'TicketNotificationRecipient').
' : '.$val;
2814 $message .=
'<br><br>';
2815 $message .= $langs->trans(
'TicketNotificationEmailBodyInfosTrackUrlinternal').
' : <a href="'.$url_internal_ticket.
'">'.
$object->track_id.
'</a>';
2817 $this->sendTicketMessageByEmail($subject, $message, 0, $sendto, $listofpaths, $listofmimes, $listofnames);
2826 if ($send_email > 0) {
2828 $internal_contacts =
$object->getInfosTicketInternalContact(1);
2831 if (is_array($internal_contacts) && count($internal_contacts) > 0) {
2835 $subject =
GETPOST(
'subject',
'alphanohtml') ?
GETPOST(
'subject',
'alphanohtml') :
'['.$appli.
' - '.$langs->trans(
"Ticket").
' #'.
$object->track_id.
'] '.$langs->trans(
'TicketNewMessage');
2837 $message_intro = $langs->trans(
'TicketNotificationEmailBody',
"#".
$object->id);
2840 $message =
getDolGlobalString(
'TICKET_MESSAGE_MAIL_INTRO', $langs->trans(
'TicketMessageMailIntroText'));
2841 $message .=
'<br><br>';
2842 $messagePost =
GETPOST(
'message',
'restricthtml');
2846 $message .= $messagePost;
2849 $message .=
'<br><br>';
2850 $message .=
"==============================================<br>";
2851 $message .= !empty(
$object->thirdparty->name) ? $langs->trans(
'Thirdparty').
" : ".
$object->thirdparty->name :
'';
2852 $message .= !empty(
$object->thirdparty->town) ?
'<br>'.$langs->trans(
'Town').
" : ".
$object->thirdparty->town :
'';
2853 $message .= !empty(
$object->thirdparty->phone) ?
'<br>'.$langs->trans(
'Phone').
" : ".
$object->thirdparty->phone :
'';
2856 foreach ($internal_contacts as $key => $info_sendto) {
2858 if ($info_sendto[
'id'] == $user->id) {
2862 if ($info_sendto[
'email'] !=
'') {
2863 $email = $info_sendto[
'email'];
2864 if ($email !=
null) {
2865 $sendto[$email] =
dolGetFirstLastname($info_sendto[
'firstname'], $info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">";
2869 $recipient =
dolGetFirstLastname($info_sendto[
'firstname'], $info_sendto[
'lastname'], -1).
' ('.strtolower((
string) $info_sendto[
'libelle']).
')';
2870 $message .= (!empty($recipient) ? $langs->trans(
'TicketNotificationRecipient').
' : '.$recipient.
'<br>' :
'');
2878 $message .=
'<br>'.$langs->trans(
'TicketNotificationEmailBodyInfosTrackUrlinternal').
' : <a href="'.$url_internal_ticket.
'">'.
$object->track_id.
'</a><br>';
2888 if (!empty($sendto)) {
2889 $this->sendTicketMessageByEmail($subject, $message, 0, $sendto, $listofpaths, $listofmimes, $listofnames);
2896 if (empty(
$object->private)) {
2898 $external_contacts =
$object->getInfosTicketExternalContact(1);
2901 if (is_array($external_contacts) && count($external_contacts) === 0) {
2902 if (!empty(
$object->fk_soc)) {
2904 $array_company = array(array(
'firstname' =>
'',
'lastname' =>
$object->thirdparty->name,
'email' =>
$object->thirdparty->email,
'libelle' => $langs->transnoentities(
'Customer'),
'socid' =>
$object->thirdparty->id));
2905 $external_contacts = array_merge($external_contacts, $array_company);
2906 } elseif (empty(
$object->fk_soc) && !empty(
$object->origin_replyto)) {
2907 $array_external = array(array(
'firstname' =>
'',
'lastname' =>
$object->origin_replyto,
'email' =>
$object->origin_replyto,
'libelle' => $langs->transnoentities(
'Customer'),
'socid' => 0));
2908 $external_contacts = array_merge($external_contacts, $array_external);
2909 } elseif (empty(
$object->fk_soc) && !empty(
$object->origin_email)) {
2910 $array_external = array(array(
'firstname' =>
'',
'lastname' =>
$object->origin_email,
'email' =>
$object->thirdparty->email,
'libelle' => $langs->transnoentities(
'Customer'),
'socid' =>
$object->thirdparty->id));
2911 $external_contacts = array_merge($external_contacts, $array_external);
2916 if (is_array($external_contacts) && count($external_contacts) > 0) {
2920 $subject =
GETPOST(
'subject') ?
GETPOST(
'subject') :
'['.$appli.
' - '.$langs->trans(
"Ticket").
' #'.
$object->track_id.
'] '.$langs->trans(
'TicketNewMessage');
2925 $message_intro =
dol_nl2br($message_intro);
2928 $message_signature =
dol_nl2br($message_signature);
2932 $messagePost =
GETPOST(
'message',
'restricthtml');
2936 $message = $messagePost;
2937 $message .=
'<br><br>';
2939 foreach ($external_contacts as $key => $info_sendto) {
2941 if ($info_sendto[
'id'] == $user->contact_id) {
2945 if ($info_sendto[
'email'] !=
'' && $info_sendto[
'email'] !=
$object->origin_email) {
2946 $email = $info_sendto[
'email'];
2947 if ($email !=
null) {
2948 $sendto[$email] = trim($info_sendto[
'firstname'].
" ".$info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">";
2951 $recipient =
dolGetFirstLastname($info_sendto[
'firstname'], $info_sendto[
'lastname'], -1).
' ('.strtolower((
string) $info_sendto[
'libelle']).
')';
2952 $message .= (!empty($recipient) ? $langs->trans(
'TicketNotificationRecipient').
' : '.$recipient.
'<br>' :
'');
2957 $url_public_ticket = (
getDolGlobalInt(
'TICKET_ENABLE_PUBLIC_INTERFACE') ?
2960 $message .=
'<br>'.$langs->trans(
'TicketNewEmailBodyInfosTrackUrlCustomer').
' : <a href="'.$url_public_ticket.
'">'.
$object->track_id.
'</a><br>';
2963 $message = $message_intro.
'<br><br>'.$message;
2966 $message .=
'<br>'.$message_signature;
2968 if (!empty(
$object->origin_replyto)) {
2970 } elseif (!empty(
$object->origin_email)) {
2974 if (
$object->fk_soc > 0 && !array_key_exists(
$object->origin_replyto, $sendto) && !array_key_exists(
$object->origin_email, $sendto)) {
2977 if (!empty(
$object->thirdparty->email)) {
2978 $sendto[
$object->thirdparty->email] =
$object->thirdparty->email;
2990 if (!empty($sendto)) {
2991 $result = $this->sendTicketMessageByEmail($subject, $message, 0, $sendto, $listofpaths, $listofmimes, $listofnames);
2994 $this->date_last_msg_sent =
dol_now();
2995 $this->update($user, 1);
3008 && (
$object->status < self::STATUS_IN_PROGRESS && !$user->socid && !$private))
3009 || (
$object->status > self::STATUS_IN_PROGRESS && $public_area)) {
3010 $object->setStatut($object::STATUS_IN_PROGRESS);
3011 } elseif (
getDolGlobalInt(
'TICKET_SET_STATUS_ON_ANSWER', -1) >= 0 && empty($user->socid) && empty($private)) {
3039 public function sendTicketMessageByEmail($subject, $message, $send_internal_cc = 0, $array_receiver = array(), $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array())
3041 global
$conf, $langs, $user;
3044 dol_syslog(get_class($this).
'::sendTicketMessageByEmail: Emails are disable into ticket setup by option TICKET_DISABLE_ALL_MAILS', LOG_WARNING);
3048 $langs->load(
"mails");
3050 include_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
3054 if (!is_array($array_receiver) || !count($array_receiver) > 0) {
3055 $array_receiver = $this->getInfosTicketInternalContact(1);
3056 $array_receiver = array_merge($array_receiver, $this->getInfosTicketExternalContact(1));
3060 if ($send_internal_cc) {
3066 if (is_array($array_receiver) && count($array_receiver) > 0) {
3067 foreach ($array_receiver as $key => $receiver) {
3068 $deliveryreceipt = 0;
3069 $filepath = $filename_list;
3070 $filename = $mimefilename_list;
3071 $mimetype = $mimetype_list;
3077 $conf->global->MAIN_MAIL_AUTOCOPY_TO =
'';
3080 $upload_dir_tmp =
$conf->user->dir_output.
"/".$user->id.
'/temp';
3082 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
3083 $trackid =
"tic".$this->id;
3085 $moreinheader =
'X-Dolibarr-Info: sendTicketMessageByEmail'.
"\r\n";
3086 if (!empty($this->email_msgid)) {
3088 $moreinheader .=
'In-Reply-To: <'.$this->email_msgid.
'>'.
"\r\n";
3096 if (!empty($this->origin_references)) {
3097 $references .= (empty($references) ?
'' :
' ').$this->origin_references;
3099 if (!empty($this->email_msgid) && !preg_match(
'/'.preg_quote($this->email_msgid,
'/').
'/', $references)) {
3100 $references .= (empty($references) ?
'' :
' ').
'<'.$this->email_msgid.
'>';
3103 $moreinheader .=
'References: '.$references.
"\r\n";
3107 $mailfile =
new CMailFile($subject, $receiver, $from, $message, $filepath, $mimetype, $filename, $sendtocc,
'', $deliveryreceipt, -1,
'',
'', $trackid, $moreinheader,
'ticket',
'', $upload_dir_tmp);
3109 if ($mailfile->error) {
3112 $result = $mailfile->sendfile();
3114 setEventMessages($langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($receiver, 2)),
null,
'mesgs');
3117 $langs->load(
"other");
3118 if ($mailfile->error) {
3119 setEventMessages($langs->trans(
'ErrorFailedToSendMail', $from, $receiver),
null,
'errors');
3120 dol_syslog($langs->trans(
'ErrorFailedToSendMail', $from, $receiver).
' : '.$mailfile->error);
3122 setEventMessages(
'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS',
null,
'errors');
3128 $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
3132 $langs->load(
"other");
3133 setEventMessages($langs->trans(
'ErrorMailRecipientIsEmptyForSendTicketMessage'),
null,
'warnings');
3150 global $user, $langs;
3157 $sql =
"SELECT p.rowid, p.ref, p.datec as datec";
3158 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as p";
3159 if (isModEnabled(
'societe') && !$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
3160 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON p.fk_soc = sc.fk_soc";
3161 $sql .=
" WHERE sc.fk_user = ".((int) $user->id);
3164 $sql .= $clause.
" p.entity IN (".
getEntity(
'ticket').
")";
3165 if ($mode ==
'opened') {
3166 $sql .=
" AND p.fk_statut NOT IN (".Ticket::STATUS_CLOSED.
", ".Ticket::STATUS_CANCELED.
")";
3169 $sql .=
" AND p.fk_soc = ".((int) $user->socid);
3172 $resql = $this->db->query($sql);
3174 $label = $labelShort =
'';
3176 if ($mode ==
'opened') {
3177 $status =
'openall';
3180 $label = $langs->trans(
"MenuListNonClosed");
3181 $labelShort = $langs->trans(
"MenuListNonClosed");
3186 $response->label = $label;
3187 $response->labelShort = $labelShort;
3188 $response->url = DOL_URL_ROOT.
'/ticket/list.php?search_fk_statut[]='.$status;
3192 while ($obj = $this->db->fetch_object($resql)) {
3193 $response->nbtodo++;
3194 if ($mode ==
'opened') {
3195 $datelimit = $this->db->jdate($obj->datec) + $delay_warning;
3196 if ($datelimit < $now) {
3203 $this->error = $this->db->lasterror();
3217 $this->nb = array();
3220 $sql =
"SELECT count(p.rowid) as nb";
3221 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as p";
3222 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON p.fk_soc = s.rowid";
3223 if (!$user->hasRight(
'societe',
'client',
'voir')) {
3224 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
3225 $sql .=
" WHERE sc.fk_user = ".((int) $user->id);
3228 $sql .=
" ".$clause.
" p.entity IN (".
getEntity(
'ticket').
")";
3230 $resql = $this->db->query($sql);
3233 while ($obj = $this->db->fetch_object($resql)) {
3234 $this->nb[
"ticket"] = $obj->nb;
3236 $this->db->free($resql);
3240 $this->error = $this->db->lasterror();
3255 $tables = array(
'ticket');
3271 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
3273 $return =
'<div class="box-flex-item box-flex-grow-zero">';
3274 $return .=
'<div class="info-box info-box-sm">';
3275 $return .=
'<span class="info-box-icon bg-infobox-action">';
3277 $return .=
'</span>';
3278 $return .=
'<div class="info-box-content">';
3279 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->getNomUrl(1) : $this->ref).
'</span>';
3280 if ($selected >= 0) {
3281 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
3283 if (!empty($arraydata[
'user_assignment'])) {
3284 $return .=
'<br><span class="info-box-label" title="'.dol_escape_htmltag($langs->trans(
"AssignedTo")).
'">'.$arraydata[
'user_assignment'].
'</span>';
3286 if (property_exists($this,
'type_code') && !empty($this->type_code)) {
3288 $return .=
'<div class="tdoverflowmax125 inline-block">'.$langs->getLabelFromKey($this->db,
'TicketTypeShort'.$this->type_code,
'c_ticket_type',
'code',
'label', $this->type_code).
'</div>';
3290 if (method_exists($this,
'getLibStatut')) {
3291 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
3293 $return .=
'</div>';
3294 $return .=
'</div>';
3295 $return .=
'</div>';
3311 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
3315 $langs->load(
"ticket");
3316 $outputlangs->load(
"ticket");
3319 $modele =
'generic_ticket_odt';
3321 if (!empty($this->model_pdf)) {
3322 $modele = $this->model_pdf;
3328 $modelpath =
"core/modules/ticket/doc/";
3330 return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
setEntity($currentobject)
Set entity id to use when to create an 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.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
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_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Class to generate the form for creating a new ticket.
generate_random_id($car=16)
Generate a random id.