29require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticket.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/commonhookactions.class.php';
68 public $errors = array();
122 if (!is_object($this->dao)) {
123 $this->dao =
new Ticket($this->db);
135 public function fetch(
$id = 0, $ref =
'', $track_id =
'')
138 return $this->dao->fetch(
$id, $ref, $track_id);
150 $this->dao->fk_statut = $this->fk_statut;
151 return $this->dao->getLibStatut($mode);
163 $this->dao->fetch(
$id);
165 $this->label = $this->dao->label;
180 if ($action ==
'create') {
181 return $langs->trans(
"CreateTicket");
182 } elseif ($action ==
'edit') {
183 return $langs->trans(
"EditTicket");
184 } elseif ($action ==
'view') {
185 return $langs->trans(
"Ticket").(is_null(
$object) ?
'' :
' '.$object->ref);
186 } elseif ($action ==
'add_message') {
187 return $langs->trans(
"TicketAddMessage");
189 return $langs->trans(
"Ticket");
206 $closeStatuses = [Ticket::STATUS_CLOSED, Ticket::STATUS_CANCELED];
208 $permissiontoadd = $user->hasRight(
'ticket',
'write');
210 print
'<!-- initial message of ticket -->'.
"\n";
211 if ($permissiontoadd && !in_array(
$object->status, $closeStatuses) && $action ==
'edit_message_init') {
213 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="post">';
214 print
'<input type="hidden" name="token" value="'.newToken().
'">';
215 print
'<input type="hidden" name="track_id" value="'.$object->track_id.
'">';
216 print
'<input type="hidden" name="action" value="set_message">';
220 print
'<div class="div-table-responsive-no-min">';
221 print
'<table class="border tableforfield centpercent margintable">';
222 print
'<tr class="liste_titre trforfield"><td class="nowrap titlefield">';
224 print
'<table class="nobordernopadding centpercent "><tr><td class="noborder" style="border-bottom: none !important;">';
225 print $langs->trans(
'InitialMessage');
226 if ($action !=
'edit_message_init' && $permissiontoadd && !in_array(
$object->status, $closeStatuses)) {
227 print
'</td><td class="right noborder" style="border-bottom: none !important;">';
228 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit_message_init&token='.newToken().
'&track_id='.
$object->track_id.
'">'.
img_edit($langs->trans(
'Modify')).
'</a>';
230 print
'</td></tr></table>';
233 if ($action ==
'edit_message_init' && $permissiontoadd && !in_array(
$object->status, $closeStatuses)) {
234 print
'<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
'Modify').
'">';
235 print
' <input type="submit" class="button button-cancel smallpaddingimp" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
240 print
'<td colspan="2">';
241 if ($permissiontoadd && !in_array(
$object->status, $closeStatuses) && $action ==
'edit_message_init') {
243 $msg = GETPOSTISSET(
'message_initial') ?
GETPOST(
'message_initial',
'restricthtml') :
$object->message;
244 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
245 $uselocalbrowser = -1;
247 if (!$ckeditorenabledforticket) {
250 $doleditor =
new DolEditor(
'message_initial', $msg,
'100%', 250,
'dolibarr_details',
'In',
true, $uselocalbrowser, $ckeditorenabledforticket, ROWS_9,
'95%');
251 $doleditor->Create();
253 print
'<div class="longmessagecut small">';
267 if ($permissiontoadd && !in_array(
$object->status, $closeStatuses) && $action ==
'edit_message_init') {
283 global $langs, $user;
286 $ret = $this->dao->loadCacheMsgsTicket();
291 $action =
GETPOST(
'action',
'aZ09');
293 print
'<div class="ticketpublicarea ticketlargemargin" style="padding-top: 0">';
297 if (is_array($this->dao->cache_msgs_ticket) && count($this->dao->cache_msgs_ticket) > 0) {
298 print
'<div class="ticketpublicarea ticketlargemargin">';
300 print
'<div class="div-table-responsive-no-min">';
301 print
'<table class="border centpercent">';
303 print
'<tr class="liste_titre">';
307 print $langs->trans(
'TicketMessagesList');
314 print $langs->trans(
'Author');
320 $ticket_message_nr = 1;
321 foreach ($this->dao->cache_msgs_ticket as
$id => $arraymsgs) {
322 if (!$arraymsgs[
'private']
323 || ($arraymsgs[
'private'] ==
"1" && $show_private)
326 print
'<tr id="ticket_message_header_'.$ticket_message_nr.
'" class="oddeven nohover">';
327 print
'<td><strong>';
328 print
img_picto(
'',
'object_action',
'class="paddingright"').dol_print_date($arraymsgs[
'datep'],
'dayhour');
329 print
'<strong></td>';
332 if ($arraymsgs[
'fk_user_author'] > 0) {
333 $userstat =
new User($this->db);
334 $res = $userstat->fetch($arraymsgs[
'fk_user_author']);
336 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
337 print $userstat->getNomUrl(0);
339 } elseif (isset($arraymsgs[
'fk_contact_author'])) {
340 $contactstat =
new Contact($this->db);
341 $res = $contactstat->fetch(0,
null,
'', $arraymsgs[
'fk_contact_author']);
343 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
344 print $arraymsgs[
'fk_contact_author'];
346 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
347 print $contactstat->getNomUrl(0,
'nolink');
349 print $arraymsgs[
'fk_contact_author'];
352 print
'<span class="opacitymedium">'.$langs->trans(
'Unknown').
'</span>';
358 print
'<tr id="ticket_message_body_'.$ticket_message_nr.
'" class="oddeven nohover">';
359 print
'<td'.($show_author ?
' colspan="2"' :
'').
'>';
360 print $arraymsgs[
'message'];
364 $documents = array();
366 $sql =
'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id, ecm.agenda_id';
367 $sql .=
', ecm.filepath, ecm.filename, ecm.share';
368 $sql .=
' FROM '.MAIN_DB_PREFIX.
'ecm_files ecm';
369 $sql .=
" WHERE ecm.filepath = 'agenda/".(int) $arraymsgs[
'id'].
"'";
370 $sql .=
" OR (ecm.agenda_id = ".(int) $arraymsgs[
'id'].
" AND ecm.src_object_type = 'ticket' AND ecm.src_object_id = ".(
int) $this->dao->id.
")";
371 $sql .=
' ORDER BY ecm.position ASC';
373 $resql = $this->db->query($sql);
375 if ($this->db->num_rows($resql)) {
376 while ($obj = $this->db->fetch_object($resql)) {
377 $documents[$obj->id] = $obj;
381 if (!empty($documents)) {
383 $footer =
'<div class="timeline-documents-container">';
384 foreach ($documents as $doc) {
385 if (!empty($doc->share) || ($doc->src_object_type ==
'ticket')) {
387 $footer .=
'<span id="document_'.$doc->id.
'" class="timeline-documents" ';
388 $footer .=
' data-id="'.$doc->id.
'" ';
389 $footer .=
' data-path="'.$doc->filepath.
'"';
390 $footer .=
' data-filename="'.dol_escape_htmltag($doc->filename).
'" ';
393 if (empty($doc->agenda_id)) {
394 $dir_ref = $arraymsgs[
'id'];
395 $modulepart =
'actions';
397 $split_dir = explode(
'/', $doc->filepath);
398 $modulepart = array_shift($split_dir);
399 $dir_ref = implode(
'/', $split_dir);
401 $filePath = DOL_DATA_ROOT.
'/'.$doc->filepath.
'/'.$doc->filename;
402 $file_relative_path = $dir_ref.
'/'.$doc->filename;
403 $mime = dol_mimetype($filePath);
405 if (!empty($doc->share)) {
406 $doclink = DOL_URL_ROOT.
'/document.php?hashp='.urlencode($doc->share);
407 } elseif ($doc->src_object_type ==
'ticket') {
410 global $dolibarr_main_instance_unique_id;
411 $securekey =
dol_hash(
'dolibarr-'.$file_relative_path.
'-'.$dolibarr_main_instance_unique_id,
'sha256');
412 $doclink = $downloadwrapper.
'?modulepart='.$modulepart.
'&attachment=0&entity='.
getEntity(
'ticket', 0).
'&securekey='.urlencode($securekey).
'&file='.urlencode($file_relative_path);
415 $mimeAttr =
' mime="'.$mime.
'" ';
417 if (in_array($mime, array(
'image/png',
'image/jpeg',
'application/pdf'))) {
418 $class .=
' documentpreview';
421 $footer .=
'<a href="'.$doclink.
'" class="btn-link '.$class.
'" target="_blank" '.$mimeAttr.
' >';
422 $footer .=
img_mime($filePath).
' '.$doc->filename;
425 $footer .=
'</span>';
429 if ($isshared == 1) {
438 $ticket_message_nr++;
445 print
'<div class="ticketpublicarea ticketlargemargin">';
446 print
'<div class="info">'.$langs->trans(
'NoMsgForThisTicket').
'</div>';
464 $object->loadCacheMsgsTicket();
466 if (is_array(
$object->cache_msgs_ticket) && count(
$object->cache_msgs_ticket) > 0) {
467 print
'<section id="cd-timeline">';
469 foreach (
$object->cache_msgs_ticket as
$id => $arraymsgs) {
470 if (!$arraymsgs[
'private']
471 || ($arraymsgs[
'private'] ==
"1" && $show_private)
473 print
'<div class="cd-timeline-block">';
474 print
'<div class="cd-timeline-img">';
475 print
'<img src="img/messages.png" alt="">';
476 print
'</div> <!-- cd-timeline-img -->';
478 print
'<div class="cd-timeline-content">';
479 print $arraymsgs[
'message'];
481 print
'<span class="cd-date">';
485 if ($arraymsgs[
'fk_user_action'] > 0) {
486 $userstat =
new User($this->db);
487 $res = $userstat->fetch($arraymsgs[
'fk_user_action']);
490 print $userstat->getNomUrl(1);
494 print $langs->trans(
'Customer');
498 print
'</div> <!-- cd-timeline-content -->';
499 print
'</div> <!-- cd-timeline-block -->';
504 print
'<div class="info">'.$langs->trans(
'NoMsgForThisTicket').
'</div>';
518 print
'<div class="div-table-responsive-no-min margintoponly navBarForStatus">';
519 print
'<div class="centpercent right">';
521 $exclude_status = array(Ticket::STATUS_CLOSED, Ticket::STATUS_CANCELED);
523 $exclude_status = array_merge($exclude_status, array((
int)
$object->status));
526 $exclude_status[] = $object::STATUS_WAITING;
532 foreach (
$object->labelStatusShort as $status => $status_label) {
533 if (!in_array($status, $exclude_status)) {
534 print
'<div class="inline-block center margintoponly marginbottomonly">';
537 $urlforbutton = $_SERVER[
'PHP_SELF'].
'?track_id='.
$object->track_id.
'&action=set_read&token='.newToken();
539 $urlforbutton = $_SERVER[
'PHP_SELF'].
'?track_id='.
$object->track_id.
'&action=confirm_set_status&token='.newToken().
'&new_status='.((int) $status);
542 print
'<a class="butAction butStatus marginbottomonly" href="'.$urlforbutton.
'">';
543 print
$object->LibStatut($status, 3, 1).
' ';
545 print $langs->trans(
$object->labelStatusShort[$status]);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
Class Actions of the module ticket.
__construct($db)
Constructor.
fetch($id=0, $ref='', $track_id='')
Fetch object.
viewTicketOriginalMessage($user, $action, $object)
Show ticket original message.
getInstanceDao()
Instantiation of DAO class.
getLibStatut($mode=0)
Print statut.
getTitle($action='', $object=null)
Get action title.
viewTicketMessages($show_private, $show_author, $object)
View html list of message for ticket.
viewTicketTimelineMessages($show_private, $show_author, Ticket $object)
View list of message for ticket with timeline display.
viewStatusActions(Ticket $object)
Print html navbar with link to set ticket status.
getInfo($id)
Get ticket info.
Parent class of all other hook actions classes.
Class to manage a WYSIWYG editor.
Class to manage Dolibarr users.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
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.
Class to generate the form for creating a new ticket.
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.