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");
205 print
'<!-- initial message of ticket -->'.
"\n";
206 if ($user->hasRight(
'ticket',
'manage') && $action ==
'edit_message_init') {
208 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="post">';
209 print
'<input type="hidden" name="token" value="'.newToken().
'">';
210 print
'<input type="hidden" name="track_id" value="'.$object->track_id.
'">';
211 print
'<input type="hidden" name="action" value="set_message">';
215 print
'<div class="div-table-responsive-no-min">';
216 print
'<table class="border tableforfield centpercent margintable">';
217 print
'<tr class="liste_titre trforfield"><td class="nowrap titlefield">';
218 print $langs->trans(
"InitialMessage");
220 if ($user->hasRight(
"ticket",
"manage")) {
221 if ($action !=
'edit_message_init') {
222 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>';
224 print
'<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
'Modify').
'">';
225 print
' <input type="submit" class="button button-cancel smallpaddingimp" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
231 print
'<td colspan="2">';
232 if ($user->hasRight(
'ticket',
'manage') && $action ==
'edit_message_init') {
234 $msg = GETPOSTISSET(
'message_initial') ?
GETPOST(
'message_initial',
'restricthtml') :
$object->message;
235 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
236 $uselocalbrowser =
true;
238 if (!$ckeditorenabledforticket) {
241 $doleditor =
new DolEditor(
'message_initial', $msg,
'100%', 250,
'dolibarr_details',
'In',
true, $uselocalbrowser, $ckeditorenabledforticket, ROWS_9,
'95%');
242 $doleditor->Create();
244 print
'<div class="longmessagecut small">';
258 if ($user->hasRight(
'ticket',
'manage') && $action ==
'edit_message_init') {
274 global $langs, $user;
277 $ret = $this->dao->loadCacheMsgsTicket();
282 $action =
GETPOST(
'action',
'aZ09');
284 print
'<div class="ticketpublicarea ticketlargemargin" style="padding-top: 0">';
288 if (is_array($this->dao->cache_msgs_ticket) && count($this->dao->cache_msgs_ticket) > 0) {
289 print
'<div class="ticketpublicarea ticketlargemargin">';
291 print
'<div class="div-table-responsive-no-min">';
292 print
'<table class="border centpercent">';
294 print
'<tr class="liste_titre">';
297 print $langs->trans(
'TicketMessagesList');
302 print $langs->trans(
'User');
307 foreach ($this->dao->cache_msgs_ticket as
$id => $arraymsgs) {
308 if (!$arraymsgs[
'private']
309 || ($arraymsgs[
'private'] ==
"1" && $show_private)
312 print
'<tr class="oddeven nohover">';
313 print
'<td><strong>';
314 print
img_picto(
'',
'object_action',
'class="paddingright"').dol_print_date($arraymsgs[
'datep'],
'dayhour');
315 print
'<strong></td>';
318 if ($arraymsgs[
'fk_user_author'] > 0) {
319 $userstat =
new User($this->db);
320 $res = $userstat->fetch($arraymsgs[
'fk_user_author']);
322 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
323 print $userstat->getNomUrl(0);
325 } elseif (isset($arraymsgs[
'fk_contact_author'])) {
326 $contactstat =
new Contact($this->db);
327 $res = $contactstat->fetch(0,
null,
'', $arraymsgs[
'fk_contact_author']);
329 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
330 print $contactstat->getNomUrl(0,
'nolink');
332 print $arraymsgs[
'fk_contact_author'];
335 print
'<span class="opacitymedium">'.$langs->trans(
'Unknown').
'</span>';
341 print
'<tr class="oddeven nohover borderbottom">';
342 print
'<td'.($show_user ?
' colspan="2"' :
'').
'>';
343 print $arraymsgs[
'message'];
347 $documents = array();
349 $sql =
'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id, ecm.agenda_id';
350 $sql .=
', ecm.filepath, ecm.filename, ecm.share';
351 $sql .=
' FROM '.MAIN_DB_PREFIX.
'ecm_files ecm';
352 $sql .=
" WHERE ecm.filepath = 'agenda/".(int) $arraymsgs[
'id'].
"'";
353 $sql .=
" OR (ecm.agenda_id = ".(int) $arraymsgs[
'id'].
" AND ecm.src_object_type = 'ticket' AND ecm.src_object_id = ".(
int) $this->dao->id.
")";
354 $sql .=
' ORDER BY ecm.position ASC';
356 $resql = $this->db->query($sql);
358 if ($this->db->num_rows($resql)) {
359 while ($obj = $this->db->fetch_object($resql)) {
360 $documents[$obj->id] = $obj;
364 if (!empty($documents)) {
366 $footer =
'<div class="timeline-documents-container">';
367 foreach ($documents as $doc) {
368 if (!empty($doc->share) || ($doc->src_object_type ==
'ticket')) {
370 $footer .=
'<span id="document_'.$doc->id.
'" class="timeline-documents" ';
371 $footer .=
' data-id="'.$doc->id.
'" ';
372 $footer .=
' data-path="'.$doc->filepath.
'"';
373 $footer .=
' data-filename="'.dol_escape_htmltag($doc->filename).
'" ';
376 if (empty($doc->agenda_id)) {
377 $dir_ref = $arraymsgs[
'id'];
378 $modulepart =
'actions';
380 $split_dir = explode(
'/', $doc->filepath);
381 $modulepart = array_shift($split_dir);
382 $dir_ref = implode(
'/', $split_dir);
384 $filePath = DOL_DATA_ROOT.
'/'.$doc->filepath.
'/'.$doc->filename;
385 $file_relative_path = $dir_ref.
'/'.$doc->filename;
388 if (!empty($doc->share)) {
389 $doclink = DOL_URL_ROOT.
'/document.php?hashp='.urlencode($doc->share);
390 } elseif ($doc->src_object_type ==
'ticket') {
391 $doclink =
dol_buildpath(
'document.php', 1).
'?modulepart='.$modulepart.
'&attachment=0&file='.urlencode($file_relative_path).
'&entity='.
getEntity(
'ticket', 0);
394 $mimeAttr =
' mime="'.$mime.
'" ';
396 if (in_array($mime, array(
'image/png',
'image/jpeg',
'application/pdf'))) {
397 $class .=
' documentpreview';
400 $footer .=
'<a href="'.$doclink.
'" class="btn-link '.$class.
'" target="_blank" '.$mimeAttr.
' >';
401 $footer .=
img_mime($filePath).
' '.$doc->filename;
404 $footer .=
'</span>';
408 if ($isshared == 1) {
423 print
'<div class="ticketpublicarea ticketlargemargin">';
424 print
'<div class="info">'.$langs->trans(
'NoMsgForThisTicket').
'</div>';
439 global $conf, $langs, $user;
442 $ret =
$object->loadCacheMsgsTicket();
445 if (is_array(
$object->cache_msgs_ticket) && count(
$object->cache_msgs_ticket) > 0) {
446 print
'<section id="cd-timeline">';
448 foreach (
$object->cache_msgs_ticket as
$id => $arraymsgs) {
449 if (!$arraymsgs[
'private']
450 || ($arraymsgs[
'private'] ==
"1" && $show_private)
452 print
'<div class="cd-timeline-block">';
453 print
'<div class="cd-timeline-img">';
454 print
'<img src="img/messages.png" alt="">';
455 print
'</div> <!-- cd-timeline-img -->';
457 print
'<div class="cd-timeline-content">';
458 print $arraymsgs[
'message'];
460 print
'<span class="cd-date">';
464 if ($arraymsgs[
'fk_user_action'] > 0) {
465 $userstat =
new User($this->db);
466 $res = $userstat->fetch($arraymsgs[
'fk_user_action']);
469 print $userstat->getNomUrl(1);
473 print $langs->trans(
'Customer');
477 print
'</div> <!-- cd-timeline-content -->';
478 print
'</div> <!-- cd-timeline-block -->';
483 print
'<div class="info">'.$langs->trans(
'NoMsgForThisTicket').
'</div>';
497 print
'<div class="div-table-responsive-no-min margintoponly navBarForStatus">';
498 print
'<div class="centpercent right">';
500 $exclude_status = array(Ticket::STATUS_CLOSED, Ticket::STATUS_CANCELED);
502 $exclude_status = array_merge($exclude_status, array((
int)
$object->status));
505 $exclude_status[] = $object::STATUS_WAITING;
511 foreach (
$object->labelStatusShort as $status => $status_label) {
512 if (!in_array($status, $exclude_status)) {
513 print
'<div class="inline-block center margintoponly marginbottomonly">';
516 $urlforbutton = $_SERVER[
'PHP_SELF'].
'?track_id='.
$object->track_id.
'&action=set_read&token='.
newToken();
518 $urlforbutton = $_SERVER[
'PHP_SELF'].
'?track_id='.
$object->track_id.
'&action=confirm_set_status&token='.
newToken().
'&new_status='.((int) $status);
521 print
'<a class="butAction butStatus marginbottomonly" href="'.$urlforbutton.
'">';
522 print
$object->LibStatut($status, 3, 1).
' ';
524 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.
viewTicketMessages($show_private, $show_user, $object)
View html list of message for ticket.
__construct($db)
Constructor.
fetch($id=0, $ref='', $track_id='')
Fetch object.
viewTicketOriginalMessage($user, $action, $object)
Show ticket original message.
viewTicketTimelineMessages($show_private, $show_user, Ticket $object)
View list of message for ticket with timeline display.
getInstanceDao()
Instantiation of DAO class.
getLibStatut($mode=0)
Print statut.
getTitle($action='', $object=null)
Get action title.
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)
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
dolPrintHTML($s, $allowiframe=0)
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
Class to generate the form for creating a new ticket.