35 $langs->load(
"ticket");
40 $head[$h][0] = DOL_URL_ROOT.
'/admin/ticket.php';
41 $head[$h][1] = $langs->trans(
"TicketSettings");
42 $head[$h][2] =
'settings';
45 $head[$h][0] = DOL_URL_ROOT.
'/admin/ticket_extrafields.php';
46 $head[$h][1] = $langs->trans(
"ExtraFieldsTicket");
47 $head[$h][2] =
'attributes';
50 $head[$h][0] = DOL_URL_ROOT.
'/admin/ticket_public.php';
51 $head[$h][1] = $langs->trans(
"PublicInterface");
52 $head[$h][2] =
'public';
78 global $db, $langs, $conf, $user;
82 $head[$h][0] = DOL_URL_ROOT.
'/ticket/card.php?action=view&track_id='.$object->track_id;
83 $head[$h][1] = $langs->trans(
"Ticket");
84 $head[$h][2] =
'tabTicket';
87 if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid) &&
isModEnabled(
"societe")) {
88 $nbContact = count($object->liste_contact(-1,
'internal')) + count($object->liste_contact(-1,
'external'));
89 $head[$h][0] = DOL_URL_ROOT.
'/ticket/contact.php?track_id='.$object->track_id;
90 $head[$h][1] = $langs->trans(
'ContactsAddresses');
92 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContact.
'</span>';
94 $head[$h][2] =
'contact';
101 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
102 $upload_dir = $conf->ticket->dir_output.
"/".$object->ref;
104 $head[$h][0] = DOL_URL_ROOT.
'/ticket/document.php?id='.$object->id;
105 $head[$h][1] = $langs->trans(
"Documents");
107 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbFiles.
'</span>';
110 $head[$h][2] =
'tabTicketDocument';
115 $ticketViewType =
"messaging";
116 if (empty($_SESSION[
'ticket-view-type'])) {
117 $_SESSION[
'ticket-view-type'] = $ticketViewType;
119 $ticketViewType = $_SESSION[
'ticket-view-type'];
122 if ($ticketViewType ==
"messaging") {
123 $head[$h][0] = DOL_URL_ROOT.
'/ticket/messaging.php?track_id='.$object->track_id;
126 $head[$h][0] = DOL_URL_ROOT.
'/ticket/agenda.php?track_id='.$object->track_id;
128 $head[$h][1] = $langs->trans(
'Events');
129 if (
isModEnabled(
'agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
131 $head[$h][1] .= $langs->trans(
"Agenda");
133 $head[$h][2] =
'tabTicketLogs';
149 global $conf, $langs;
151 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
155 $url =
dol_buildpath(
'/public/ticket/view.php', 3).
'?track_id='.$object->track_id.
'&email='.$email;
159 if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) {
160 $langs->load(
'errors');
161 $out .=
'<span class="opacitymedium">'.$langs->trans(
"ErrorPublicInterfaceNotEnabled").
'</span>';
163 $out .=
img_picto(
'',
'object_globe.png').
' <span class="opacitymedium">'.$langs->trans(
"TicketPublicAccess").
'</span><br>';
165 $out .=
'<div class="urllink">';
166 $out .=
'<input type="text" id="directpubliclink" class="quatrevingtpercentminusx" value="'.$url.
'">';
167 $out .=
'<a href="'.$url.
'" target="_blank" rel="noopener noreferrer">'.
img_picto(
'',
'object_globe.png',
'class="paddingleft"').
'</a>';
171 $out .=
'<span class="opacitymedium">'.$langs->trans(
"TicketNotCreatedFromPublicInterface").
'</span>';
187 $chaine =
"abcdefghijklmnopqrstuvwxyz123456789";
188 mt_srand((
double) microtime() * 1000000);
189 for ($i = 0; $i < $car; $i++) {
190 $string .= $chaine[mt_rand() % strlen($chaine)];
206 function llxHeaderTicket($title, $head =
"", $disablejs = 0, $disablehead = 0, $arrayofjs =
'', $arrayofcss =
'')
208 global $user, $conf, $langs, $mysoc;
210 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss, 0, 1);
212 print
'<body id="mainbody" class="publicnewticketform">';
213 print
'<div class="center">';
216 if (!empty($conf->global->TICKET_SHOW_COMPANY_LOGO) || !empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) {
218 if (!empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) {
219 $urllogo = DOL_URL_ROOT.
'/theme/common/login_logo.png';
221 if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.
'/logos/thumbs/'.$mysoc->logo_small)) {
222 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$mysoc->logo_small);
223 } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.
'/logos/'.$mysoc->logo)) {
224 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$mysoc->logo);
225 } elseif (is_readable(DOL_DOCUMENT_ROOT.
'/theme/dolibarr_logo.svg')) {
226 $urllogo = DOL_URL_ROOT.
'/theme/dolibarr_logo.svg';
232 if ($urllogo || !empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) {
233 print
'<div class="backgreypublicpayment">';
234 print
'<div class="logopublicpayment">';
236 print
'<a href="'.($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE :
dol_buildpath(
'/public/ticket/index.php?entity='.$conf->entity, 1)).
'">';
237 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
241 if (!empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) {
242 print
'<div class="clearboth"></div><strong>'.($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans(
"TicketSystem")).
'</strong>';
245 if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
246 print
'<div class="poweredbypublicpayment opacitymedium right"><a class="poweredbyhref" href="https://www.dolibarr.org?utm_medium=website&utm_source=poweredby" target="dolibarr" rel="noopener">'.$langs->trans(
"PoweredBy").
'<br><img src="'.DOL_URL_ROOT.
'/theme/dolibarr_logo.svg" width="80px"></a></div>';
251 if (!empty($conf->global->TICKET_IMAGE_PUBLIC_INTERFACE)) {
252 print
'<div class="backimagepublicticket">';
253 print
'<img id="idRECRUITMENT_IMAGE_PUBLIC_INTERFACE" src="'.$conf->global->MEMBER_IMAGE_PUBLIC_REGISTRATION.
'">';
259 print
'<div class="ticketlargemargin">';
281 function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon =
'', $noprint = 0, $actioncode =
'', $donetodo =
'done', $filters = array(), $sortfield =
'a.datep,a.id', $sortorder =
'DESC')
286 global $param, $massactionbutton;
291 if (!is_object($filterobj) && !is_object($objcon)) {
299 $sortfield_list = explode(
',', $sortfield);
300 $sortfield_label_list = array(
'a.id' =>
'id',
'a.datep' =>
'dp',
'a.percent' =>
'percent');
301 $sortfield_new_list = array();
302 foreach ($sortfield_list as $sortfield_value) {
303 $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
305 $sortfield_new = implode(
',', $sortfield_new_list);
309 if (is_object($objcon) && $objcon->id > 0) {
310 $sql =
"SELECT DISTINCT a.id, a.label as label,";
312 $sql =
"SELECT a.id, a.label as label,";
314 $sql .=
" a.datep as dp,";
315 $sql .=
" a.note as message,";
316 $sql .=
" a.datep2 as dp2,";
317 $sql .=
" a.percent as percent, 'action' as type,";
318 $sql .=
" a.fk_element, a.elementtype,";
319 $sql .=
" a.fk_contact,";
320 $sql .=
" c.code as acode, c.libelle as alabel, c.picto as apicto,";
321 $sql .=
" u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname";
322 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
323 $sql .=
", sp.lastname, sp.firstname";
324 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
325 $sql .=
", m.lastname, m.firstname";
326 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
328 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
330 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
332 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
334 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
337 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
338 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_action";
339 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_actioncomm as c ON a.fk_action = c.id";
341 $force_filter_contact =
false;
342 if (is_object($objcon) && $objcon->id > 0) {
343 $force_filter_contact =
true;
344 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as r ON a.id = r.fk_actioncomm";
345 $sql .=
" AND r.element_type = '".$db->escape($objcon->table_element).
"' AND r.fk_element = ".((int) $objcon->id);
348 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
349 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON a.fk_contact = sp.rowid";
350 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
351 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"element_resources as er";
352 $sql .=
" ON er.resource_type = 'dolresource'";
353 $sql .=
" AND er.element_id = a.id";
354 $sql .=
" AND er.resource_id = ".((int) $filterobj->id);
355 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
356 $sql .=
", ".MAIN_DB_PREFIX.
"adherent as m";
357 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
358 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as o";
359 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
360 $sql .=
", ".MAIN_DB_PREFIX.
"product as o";
361 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
362 $sql .=
", ".MAIN_DB_PREFIX.
"ticket as o";
363 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
364 $sql .=
", ".MAIN_DB_PREFIX.
"bom_bom as o";
365 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
366 $sql .=
", ".MAIN_DB_PREFIX.
"contrat as o";
369 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
370 if ($force_filter_contact ===
false) {
371 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur')) && $filterobj->id) {
372 $sql .=
" AND a.fk_soc = ".((int) $filterobj->id);
373 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project' && $filterobj->id) {
374 $sql .=
" AND a.fk_project = ".((int) $filterobj->id);
375 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
376 $sql .=
" AND a.fk_element = m.rowid AND a.elementtype = 'member'";
377 if ($filterobj->id) {
378 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
380 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
381 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
382 if ($filterobj->id) {
383 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
385 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
386 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'product'";
387 if ($filterobj->id) {
388 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
390 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
391 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
392 if ($filterobj->id) {
393 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
395 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
396 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
397 if ($filterobj->id) {
398 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
400 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
401 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
402 if ($filterobj->id) {
403 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
409 if (!empty($actioncode)) {
410 if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
411 if ($actioncode ==
'AC_NON_AUTO') {
412 $sql .=
" AND c.type != 'systemauto'";
413 } elseif ($actioncode ==
'AC_ALL_AUTO') {
414 $sql .=
" AND c.type = 'systemauto'";
416 if ($actioncode ==
'AC_OTH') {
417 $sql .=
" AND c.type != 'systemauto'";
418 } elseif ($actioncode ==
'AC_OTH_AUTO') {
419 $sql .=
" AND c.type = 'systemauto'";
423 if ($actioncode ==
'AC_NON_AUTO') {
424 $sql .=
" AND c.type != 'systemauto'";
425 } elseif ($actioncode ==
'AC_ALL_AUTO') {
426 $sql .=
" AND c.type = 'systemauto'";
428 $sql .=
" AND c.code = '".$db->escape($actioncode).
"'";
432 if ($donetodo ==
'todo') {
433 $sql .=
" AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now).
"'))";
434 } elseif ($donetodo ==
'done') {
435 $sql .=
" AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now).
"'))";
437 if (is_array($filters) && $filters[
'search_agenda_label']) {
438 $sql .=
natural_search(
'a.label', $filters[
'search_agenda_label']);
443 if (!empty($conf->mailing->enabled) && !empty($objcon->email)
444 && (empty($actioncode) || $actioncode ==
'AC_OTH_AUTO' || $actioncode ==
'AC_EMAILING')) {
445 $langs->load(
"mails");
447 $sql2 =
"SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type";
448 $sql2 .=
", null as fk_element, '' as elementtype, null as contact_id";
449 $sql2 .=
", 'AC_EMAILING' as acode, '' as alabel, '' as apicto";
450 $sql2 .=
", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname";
451 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
452 $sql2 .=
", '' as lastname, '' as firstname";
453 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
454 $sql2 .=
", '' as lastname, '' as firstname";
455 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
456 $sql2 .=
", '' as ref";
457 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
458 $sql2 .=
", '' as ref";
459 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
460 $sql2 .=
", '' as ref";
462 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m, ".MAIN_DB_PREFIX.
"mailing_cibles as mc, ".MAIN_DB_PREFIX.
"user as u";
463 $sql2 .=
" WHERE mc.email = '".$db->escape($objcon->email).
"'";
464 $sql2 .=
" AND mc.statut = 1";
465 $sql2 .=
" AND u.rowid = m.fk_user_valid";
466 $sql2 .=
" AND mc.fk_mailing=m.rowid";
469 if (!empty($sql) && !empty($sql2)) {
470 $sql = $sql.
" UNION ".$sql2;
471 } elseif (empty($sql) && !empty($sql2)) {
477 $sql .= $db->order($sortfield_new, $sortorder);
479 dol_syslog(
"ticket.lib::show_ticket_messaging", LOG_DEBUG);
480 $resql = $db->query($sql);
483 $num = $db->num_rows(
$resql);
486 $obj = $db->fetch_object(
$resql);
488 if ($obj->type ==
'action') {
490 $contactaction->id = $obj->id;
491 $result = $contactaction->fetchResources();
494 setEventMessage(
"ticket.lib::show_ticket_messaging Error fetch ressource",
'errors');
500 if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) {
504 $histo[$numaction] = array(
506 'tododone'=>$tododone,
508 'datestart'=>$db->jdate($obj->dp),
509 'dateend'=>$db->jdate($obj->dp2),
511 'message'=>$obj->message,
512 'percent'=>$obj->percent,
514 'userid'=>$obj->user_id,
515 'login'=>$obj->user_login,
516 'userfirstname'=>$obj->user_firstname,
517 'userlastname'=>$obj->user_lastname,
518 'userphoto'=>$obj->user_photo,
520 'contact_id'=>$obj->fk_contact,
521 'socpeopleassigned' => $contactaction->socpeopleassigned,
522 'lastname'=>$obj->lastname,
523 'firstname'=>$obj->firstname,
524 'fk_element'=>$obj->fk_element,
525 'elementtype'=>$obj->elementtype,
527 'acode'=>$obj->acode,
528 'alabel'=>$obj->alabel,
529 'libelle'=>$obj->alabel,
530 'apicto'=>$obj->apicto
533 $histo[$numaction] = array(
537 'datestart'=>$db->jdate($obj->dp),
538 'dateend'=>$db->jdate($obj->dp2),
540 'message'=>$obj->message,
541 'percent'=>$obj->percent,
542 'acode'=>$obj->acode,
544 'userid'=>$obj->user_id,
545 'login'=>$obj->user_login,
546 'userfirstname'=>$obj->user_firstname,
547 'userlastname'=>$obj->user_lastname,
548 'userphoto'=>$obj->user_photo
563 if (empty($conf->agenda->enabled)) {
564 $langs->loadLangs(array(
"admin",
"errors"));
565 $out =
info_admin($langs->trans(
"WarningModuleXDisabledSoYouMayMissEventHere", $langs->transnoentitiesnoconv(
"Module2400Name")), 0, 0,
'warning');
568 if (
isModEnabled(
'agenda') || (!empty($conf->mailing->enabled) && !empty($objcon->email))) {
569 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
571 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
572 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
573 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
574 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
579 $userstatic =
new User($db);
580 $contactstatic =
new Contact($db);
581 $userGetNomUrlCache = array();
583 $out .=
'<div class="filters-container" >';
584 $out .=
'<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
585 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
587 if ($objcon && get_class($objcon) ==
'Contact' &&
588 (is_null($filterobj) || get_class($filterobj) ==
'Societe')) {
589 $out .=
'<input type="hidden" name="id" value="'.$objcon->id.
'" />';
591 $out .=
'<input type="hidden" name="id" value="'.$filterobj->id.
'" />';
593 if ($filterobj && get_class($filterobj) ==
'Societe') {
594 $out .=
'<input type="hidden" name="socid" value="'.$filterobj->id.
'" />';
599 $out .=
'<div class="div-table-responsive-no-min">';
600 $out .=
'<table class="noborder borderbottom centpercent">';
602 $out .=
'<tr class="liste_titre">';
604 $out .=
getTitleFieldOfList(
'Date', 0, $_SERVER[
"PHP_SELF"],
'a.datep',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
606 $out .=
'<th class="liste_titre"><strong class="hideonsmartphone">'.$langs->trans(
"Search").
' : </strong></th>';
608 $out .=
'<th class="liste_titre"></th>';
610 $out .=
'<th class="liste_titre">';
611 $out .=
'<span class="fas fa-square inline-block fawidth30" style=" color: #ddd;" title="'.$langs->trans(
"ActionType").
'"></span>';
613 $out .=
$formactions->select_type_actions($actioncode,
"actioncode",
'', empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1, 0, 0, 1,
'minwidth200imp');
615 $out .=
'<th class="liste_titre maxwidth100onsmartphone">';
616 $out .=
'<input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters[
'search_agenda_label'].
'" placeholder="'.$langs->trans(
"Label").
'">';
619 $out .=
'<th class="liste_titre width50 middle">';
620 $searchpicto =
$form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
621 $out .= $searchpicto;
633 $out .=
'<ul class="timeline">';
637 if (get_class($filterobj) ==
'Societe') {
638 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
640 $tmp .= ($donetodo !=
'done' ? $langs->trans(
"ActionsToDoShort") :
'');
641 $tmp .= ($donetodo !=
'done' && $donetodo !=
'todo' ?
' / ' :
'');
642 $tmp .= ($donetodo !=
'todo' ? $langs->trans(
"ActionsDoneShort") :
'');
644 if (get_class($filterobj) ==
'Societe') {
655 $actualCycleDate =
false;
657 foreach ($histo as $key => $value) {
658 $actionstatic->fetch($histo[$key][
'id']);
660 $actionstatic->type_picto = $histo[$key][
'apicto'];
661 $actionstatic->type_code = $histo[$key][
'acode'];
663 $url = DOL_URL_ROOT.
'/comm/action/card.php?id='.$histo[$key][
'id'];
665 $tmpa =
dol_getdate($histo[$key][
'datestart'],
false);
666 if ($actualCycleDate !== $tmpa[
'year'].
'-'.$tmpa[
'yday']) {
667 $actualCycleDate = $tmpa[
'year'].
'-'.$tmpa[
'yday'];
668 $out .=
'<!-- timeline time label -->';
669 $out .=
'<li class="time-label">';
670 $out .=
'<span class="timeline-badge-date">';
671 $out .=
dol_print_date($histo[$key][
'datestart'],
'daytext',
'tzuserrel', $langs);
674 $out .=
'<!-- /.timeline-label -->';
678 $out .=
'<!-- timeline item -->'.
"\n";
679 $out .=
'<li class="timeline-code-'.strtolower($actionstatic->code).
'">';
683 $out .=
'<div class="timeline-item">'.
"\n";
685 $out .=
'<span class="timeline-header-action">';
687 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
688 $out .=
'<a class="timeline-btn" href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
689 $out .= $histo[$key][
'id'];
692 $out .= $actionstatic->getNomUrl(1, -1,
'valignmiddle').
' ';
700 if ($user->rights->agenda->allactions->create ||
701 (($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
702 $out .=
'<a class="timeline-btn" href="'.DOL_MAIN_URL_ROOT.
'/comm/action/card.php?action=edit&token='.
newToken().
'&id='.$actionstatic->id.
'"><i class="fa fa-pencil" title="'.$langs->trans(
"Modify").
'" ></i></a>';
707 $out .=
'<span class="time"><i class="fa fa-clock-o"></i> ';
708 $out .=
dol_print_date($histo[$key][
'datestart'],
'dayhour',
'tzuserrel');
709 if ($histo[$key][
'dateend'] && $histo[$key][
'dateend'] != $histo[$key][
'datestart']) {
710 $tmpa =
dol_getdate($histo[$key][
'datestart'],
true);
711 $tmpb =
dol_getdate($histo[$key][
'dateend'],
true);
712 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
713 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'hour',
'tzuserrel');
715 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'dayhour',
'tzuserrel');
719 if ($histo[$key][
'percent'] == 0 && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
722 if ($histo[$key][
'percent'] == 0 && !$histo[$key][
'datestart'] && $histo[$key][
'dateend'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
725 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && $histo[$key][
'dateend'] && $histo[$key][
'dateend'] < ($now - $delay_warning)) {
728 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && !$histo[$key][
'dateend'] && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
737 $out .=
'<h3 class="timeline-header">';
740 $out .=
'<span class="messaging-author">';
741 if ($histo[$key][
'userid'] > 0) {
742 if (!isset($userGetNomUrlCache[$histo[$key][
'userid']])) {
743 $userstatic->fetch($histo[$key][
'userid']);
744 $userGetNomUrlCache[$histo[$key][
'userid']] = $userstatic->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
746 $out .= $userGetNomUrlCache[$histo[$key][
'userid']];
751 $out .=
' <span class="messaging-title">';
753 if ($actionstatic->code ==
'TICKET_MSG') {
754 $out .= $langs->trans(
'TicketNewMessage');
755 } elseif ($actionstatic->code ==
'TICKET_MSG_PRIVATE') {
756 $out .= $langs->trans(
'TicketNewMessage').
' <em>('.$langs->trans(
'Private').
')</em>';
758 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'action') {
759 $transcode = $langs->trans(
"Action".$histo[$key][
'acode']);
760 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode : $histo[$key][
'alabel']);
761 $libelle = $histo[$key][
'note'];
762 $actionstatic->id = $histo[$key][
'id'];
765 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
766 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
767 $transcode = $langs->trans(
"Action".$histo[$key][
'acode']);
768 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode :
'Send mass mailing');
777 if (!empty($histo[$key][
'message'])
778 && $actionstatic->code !=
'AC_TICKET_CREATE'
779 && $actionstatic->code !=
'AC_TICKET_MODIFY'
781 $out .=
'<div class="timeline-body">';
782 $out .= $histo[$key][
'message'];
790 if (isset($histo[$key][
'socpeopleassigned']) && is_array($histo[$key][
'socpeopleassigned']) && count($histo[$key][
'socpeopleassigned']) > 0) {
792 foreach ($histo[$key][
'socpeopleassigned'] as $cid => $Tab) {
794 $result = $contact->fetch($cid);
801 $contactList .= !empty($contactList) ?
', ' :
'';
802 $contactList .= $contact->getNomUrl(1);
803 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
804 if (!empty($contact->phone_pro)) {
805 $contactList .=
'('.dol_print_phone($contact->phone_pro).
')';
811 $footer .= $langs->trans(
'ActionOnContact').
' : '.$contactList;
812 } elseif (empty($objcon->id) && isset($histo[$key][
'contact_id']) && $histo[$key][
'contact_id'] > 0) {
814 $result = $contact->fetch($histo[$key][
'contact_id']);
821 $footer .= $contact->getNomUrl(1);
822 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
823 if (!empty($contact->phone_pro)) {
824 $footer .=
'('.dol_print_phone($contact->phone_pro).
')';
831 if (!empty($documents)) {
832 $footer .=
'<div class="timeline-documents-container">';
833 foreach ($documents as $doc) {
834 $footer .=
'<span id="document_'.$doc->id.
'" class="timeline-documents" ';
835 $footer .=
' data-id="'.$doc->id.
'" ';
836 $footer .=
' data-path="'.$doc->filepath.
'"';
837 $footer .=
' data-filename="'.dol_escape_htmltag($doc->filename).
'" ';
840 $filePath = DOL_DATA_ROOT.
'/'.$doc->filepath.
'/'.$doc->filename;
842 $file = $actionstatic->id.
'/'.$doc->filename;
843 $thumb = $actionstatic->id.
'/thumbs/'.substr($doc->filename, 0, strrpos($doc->filename,
'.')).
'_mini'.substr($doc->filename, strrpos($doc->filename,
'.'));
844 $doclink =
dol_buildpath(
'document.php', 1).
'?modulepart=actions&attachment=0&file='.urlencode($file).
'&entity='.$conf->entity;
845 $viewlink =
dol_buildpath(
'viewimage.php', 1).
'?modulepart=actions&file='.urlencode($thumb).
'&entity='.$conf->entity;
847 $mimeAttr =
' mime="'.$mime.
'" ';
849 if (in_array($mime, array(
'image/png',
'image/jpeg',
'application/pdf'))) {
850 $class .=
' documentpreview';
853 $footer .=
'<a href="'.$doclink.
'" class="btn-link '.$class.
'" target="_blank" rel="noopener noreferrer" '.$mimeAttr.
' >';
854 $footer .=
img_mime($filePath).
' '.$doc->filename;
857 $footer .=
'</span>';
862 if (!empty($footer)) {
863 $out .=
'<div class="timeline-footer">'.$footer.
'</div>';
866 $out .=
'</div>'.
"\n";
869 $out .=
'<!-- END timeline item -->';
892 global $conf, $langs;
893 $out =
'<!-- timeline icon -->'.
"\n";
894 $iconClass =
'fa fa-comments';
899 if ($histo[$key][
'percent'] == -1) {
900 $colorClass =
'timeline-icon-not-applicble';
901 $pictoTitle = $langs->trans(
'StatusNotApplicable');
902 } elseif ($histo[$key][
'percent'] == 0) {
903 $colorClass =
'timeline-icon-todo';
904 $pictoTitle = $langs->trans(
'StatusActionToDo').
' (0%)';
905 } elseif ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100) {
906 $colorClass =
'timeline-icon-in-progress';
907 $pictoTitle = $langs->trans(
'StatusActionInProcess').
' ('.$histo[$key][
'percent'].
'%)';
908 } elseif ($histo[$key][
'percent'] >= 100) {
909 $colorClass =
'timeline-icon-done';
910 $pictoTitle = $langs->trans(
'StatusActionDone').
' (100%)';
913 if ($actionstatic->code ==
'AC_TICKET_CREATE') {
914 $iconClass =
'fa fa-ticket';
915 } elseif ($actionstatic->code ==
'AC_TICKET_MODIFY') {
916 $iconClass =
'fa fa-pencilxxx';
917 } elseif ($actionstatic->code ==
'TICKET_MSG') {
918 $iconClass =
'fa fa-comments';
919 } elseif ($actionstatic->code ==
'TICKET_MSG_PRIVATE') {
920 $iconClass =
'fa fa-mask';
921 } elseif (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
922 if ($actionstatic->type_picto) {
923 $img_picto =
img_picto(
'', $actionstatic->type_picto);
925 if ($actionstatic->type_code ==
'AC_RDV') {
926 $iconClass =
'fa fa-handshake';
927 } elseif ($actionstatic->type_code ==
'AC_TEL') {
928 $iconClass =
'fa fa-phone';
929 } elseif ($actionstatic->type_code ==
'AC_FAX') {
930 $iconClass =
'fa fa-fax';
931 } elseif ($actionstatic->type_code ==
'AC_EMAIL') {
932 $iconClass =
'fa fa-envelope';
933 } elseif ($actionstatic->type_code ==
'AC_INT') {
934 $iconClass =
'fa fa-shipping-fast';
935 } elseif ($actionstatic->type_code ==
'AC_OTH_AUTO') {
936 $iconClass =
'fa fa-robot';
937 } elseif (!preg_match(
'/_AUTO/', $actionstatic->type_code)) {
938 $iconClass =
'fa fa-robot';
943 $out .=
'<i class="'.$iconClass.
' '.$colorClass.
'" title="'.$pictoTitle.
'">'.$img_picto.
'</i>'.
"\n";
957 $documents = array();
959 $sql =
'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id, ecm.filepath, ecm.filename';
960 $sql .=
' FROM '.MAIN_DB_PREFIX.
'ecm_files ecm';
961 $sql .=
" WHERE ecm.filepath = 'agenda/".((int) $object->id).
"'";
963 $sql .=
' ORDER BY ecm.position ASC';
965 $resql = $db->query($sql);
967 if ($db->num_rows(
$resql)) {
968 while ($obj = $db->fetch_object(
$resql)) {
969 $documents[$obj->id] = $obj;