dolibarr  16.0.1
card.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2013-2016 Jean-François FERRY <hello@librethic.io>
3  * Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
4  * Copyright (C) 2018 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr>
6  * Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
7  * Copyright (C) 2022 Charlene Benke <charlene@patas-monkey.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
28 require '../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
37 if (isModEnabled('project')) {
38  include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
39  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
40  include_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
41 }
42 if (isModEnabled('contrat')) {
43  include_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
44  include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
45  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formcontract.class.php';
46 }
47 
48 // Load translation files required by the page
49 $langs->loadLangs(array("companies", "other", "ticket"));
50 
51 // Get parameters
52 $id = GETPOST('id', 'int');
53 $socid = GETPOST('socid', 'int');
54 $track_id = GETPOST('track_id', 'alpha', 3);
55 $ref = GETPOST('ref', 'alpha');
56 $projectid = GETPOST('projectid', 'int');
57 $cancel = GETPOST('cancel', 'alpha');
58 $action = GETPOST('action', 'aZ09');
59 $backtopage = GETPOST('backtopage', 'alpha');
60 $contactid = GETPOST('contactid', 'int');
61 
62 $notifyTiers = GETPOST("notify_tiers_at_create", 'alpha');
63 
64 $sortfield = GETPOST('sortfield', 'aZ09comma') ? GETPOST('sortfield', 'aZ09comma') : "a.datep";
65 $sortorder = GETPOST('sortorder', 'aZ09comma') ? GETPOST('sortorder', 'aZ09comma') : "desc";
66 
67 if (GETPOST('actioncode', 'array')) {
68  $actioncode = GETPOST('actioncode', 'array', 3);
69  if (!count($actioncode)) {
70  $actioncode = '0';
71  }
72 } else {
73  $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
74 }
75 $search_agenda_label = GETPOST('search_agenda_label');
76 
77 // Initialize technical object to manage hooks of ticket. Note that conf->hooks_modules contains array array
78 $hookmanager->initHooks(array('ticketcard', 'globalcard'));
79 
80 $object = new Ticket($db);
81 $extrafields = new ExtraFields($db);
82 
83 // Fetch optionals attributes and labels
84 $extrafields->fetch_name_optionals_label($object->table_element);
85 
86 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
87 
88 // Initialize array of search criterias
89 $search_all = GETPOST("search_all", 'alpha');
90 $search = array();
91 foreach ($object->fields as $key => $val) {
92  if (GETPOST('search_'.$key, 'alpha')) {
93  $search[$key] = GETPOST('search_'.$key, 'alpha');
94  }
95 }
96 
97 if (empty($action) && empty($id) && empty($ref)) {
98  $action = 'view';
99 }
100 
101 //Select mail models is same action as add_message
102 if (GETPOST('modelselected', 'alpha')) {
103  $action = 'presend';
104 }
105 
106 // Load object
107 //include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
108 if ($id || $track_id || $ref) {
109  $res = $object->fetch($id, $ref, $track_id);
110  if ($res >= 0) {
111  $id = $object->id;
112  $track_id = $object->track_id;
113  }
114 }
115 
116 // Store current page url
117 $url_page_current = DOL_URL_ROOT.'/ticket/card.php';
118 
119 // Security check - Protection if external user
120 if ($user->socid > 0) $socid = $user->socid;
121 $result = restrictedArea($user, 'ticket', $object->id);
122 
123 $triggermodname = 'TICKET_MODIFY';
124 $permissiontoadd = $user->rights->ticket->write;
125 
126 $actionobject = new ActionsTicket($db);
127 
128 $now = dol_now();
129 
130 
131 /*
132  * Actions
133  */
134 
135 $parameters = array();
136 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
137 if ($reshook < 0) {
138  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
139 }
140 
141 $error = 0;
142 if (empty($reshook)) {
143  // Purge search criteria
144  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers{
145  $actioncode = '';
146  $search_agenda_label = '';
147  }
148 
149  $backurlforlist = DOL_URL_ROOT.'/ticket/list.php';
150 
151  if (empty($backtopage) || ($cancel && empty($id))) {
152  if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
153  if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
154  $backtopage = $backurlforlist;
155  } else {
156  $backtopage = DOL_URL_ROOT.'/ticket/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
157  }
158  }
159  }
160 
161  if ($cancel) {
162  if (!empty($backtopageforcancel)) {
163  header("Location: ".$backtopageforcancel);
164  exit;
165  } elseif (!empty($backtopage)) {
166  header("Location: ".$backtopage);
167  exit;
168  }
169  $action = 'view';
170  }
171 
172  // Action to add an action (not a message)
173  if (GETPOST('save', 'alpha') && !empty($user->rights->ticket->write)) {
174  $error = 0;
175 
176  if (!GETPOST("subject", 'alphanohtml')) {
177  $error++;
178  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")), null, 'errors');
179  $action = 'create';
180  } elseif (!GETPOST("message", 'restricthtml')) {
181  $error++;
182  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")), null, 'errors');
183  $action = 'create';
184  }
185  $ret = $extrafields->setOptionalsFromPost(null, $object);
186  if ($ret < 0) {
187  $error++;
188  }
189 
190  if (!$error) {
191  $db->begin();
192 
193  $object->ref = GETPOST("ref", 'alphanohtml');
194  $object->fk_soc = GETPOST("socid", 'int') > 0 ? GETPOST("socid", 'int') : 0;
195  $object->subject = GETPOST("subject", 'alphanohtml');
196  $object->message = GETPOST("message", 'restricthtml');
197 
198  $object->type_code = GETPOST("type_code", 'alpha');
199  $object->type_label = $langs->trans($langs->getLabelFromKey($db, $object->type_code, 'c_ticket_type', 'code', 'label'));
200  $object->category_code = GETPOST("category_code", 'alpha');
201  $object->category_label = $langs->trans($langs->getLabelFromKey($db, $object->category_code, 'c_ticket_category', 'code', 'label'));
202  $object->severity_code = GETPOST("severity_code", 'alpha');
203  $object->severity_label = $langs->trans($langs->getLabelFromKey($db, $object->severity_code, 'c_ticket_severity', 'code', 'label'));
204  $object->email_from = $user->email;
205  $notifyTiers = GETPOST("notify_tiers_at_create", 'alpha');
206  $object->notify_tiers_at_create = empty($notifyTiers) ? 0 : 1;
207  $fk_user_assign = GETPOST("fk_user_assign", 'int');
208  if ($fk_user_assign > 0) {
209  $object->fk_user_assign = $fk_user_assign;
210  $object->status = $object::STATUS_ASSIGNED;
211  }
212 
213  $object->fk_project = $projectid;
214 
215  $id = $object->create($user);
216  if ($id <= 0) {
217  $error++;
218  setEventMessages($object->error, $object->errors, 'errors');
219  $action = 'create';
220  }
221 
222  if (!$error) {
223  // Add contact
224  $contactid = GETPOST('contactid', 'int');
225  $type_contact = GETPOST("type", 'alpha');
226 
227  // Category association
228  $categories = GETPOST('categories', 'array');
229  $object->setCategories($categories);
230 
231  if ($contactid > 0 && $type_contact) {
232  $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
233  $result = $object->add_contact($contactid, $typeid, 'external');
234  }
235 
236  // Link ticket to project
237  if (GETPOST('origin', 'alpha') == 'projet') {
238  $projectid = GETPOST('originid', 'int');
239  } else {
240  $projectid = GETPOST('projectid', 'int');
241  }
242 
243  if ($projectid > 0) {
244  $object->setProject($projectid);
245  }
246 
247  // Auto mark as read if created from backend
248  if (!empty($conf->global->TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND) && $user->rights->ticket->write) {
249  if ( ! $object->markAsRead($user) > 0) {
250  setEventMessages($object->error, $object->errors, 'errors');
251  }
252  }
253 
254  // Auto assign user
255  if (!empty($conf->global->TICKET_AUTO_ASSIGN_USER_CREATE)) {
256  $result = $object->assignUser($user, $user->id, 1);
257  $object->add_contact($user->id, "SUPPORTTEC", 'internal');
258  }
259  }
260 
261  if (!$error) {
262  // File transfer
263  $object->copyFilesForTicket();
264  }
265 
266  if (!$error) {
267  $db->commit();
268 
269  if (!empty($backtopage)) {
270  if (empty($id)) {
271  $url = $backtopage;
272  } else {
273  $url = 'card.php?track_id='.urlencode($object->track_id);
274  }
275  } else {
276  $url = 'card.php?track_id='.urlencode($object->track_id);
277  }
278 
279  header("Location: ".$url);
280  exit;
281  } else {
282  $db->rollback();
283  setEventMessages($object->error, $object->errors, 'errors');
284  }
285  } else {
286  setEventMessages($object->error, $object->errors, 'errors');
287  }
288  }
289 
290  if ($action == 'update' && $user->rights->ticket->write && $object->status < Ticket::STATUS_CLOSED) {
291  $error = 0;
292 
293  $ret = $object->fetch(GETPOST('id', 'int'), GETPOST('ref', 'alpha'), GETPOST('track_id', 'alpha'));
294  if ($ret < 0) {
295  $error++;
296  array_push($object->errors, $langs->trans('ErrorTicketIsNotValid'));
297  }
298 
299  // check fields
300  if (!$error) {
301  if (!GETPOST('subject', 'alpha')) {
302  $error++;
303  array_push($object->errors, $langs->trans('ErrorFieldRequired', $langs->transnoentities('Subject')));
304  }
305  $ret = $extrafields->setOptionalsFromPost(null, $object);
306  if ($ret < 0) {
307  $error++;
308  }
309  }
310 
311  if (!$error) {
312  $db->begin();
313 
314  $object->subject = GETPOST('subject', 'alpha');
315  $object->type_code = GETPOST('type_code', 'alpha');
316  $object->category_code = GETPOST('category_code', 'alpha');
317  $object->severity_code = GETPOST('severity_code', 'alpha');
318 
319  $ret = $object->update($user);
320  if ($ret > 0) {
321  // Category association
322  $categories = GETPOST('categories', 'array');
323  $object->setCategories($categories);
324  } else {
325  $error++;
326  }
327 
328  if ($error) {
329  $db->rollback();
330  } else {
331  $db->commit();
332  }
333  }
334 
335  if ($error) {
336  setEventMessages($object->error, $object->errors, 'errors');
337  $action = 'edit';
338  } else {
339  if (!empty($backtopage)) {
340  if (empty($id)) {
341  $url = $backtopage;
342  } else {
343  $url = 'card.php?track_id='.urlencode($object->track_id);
344  }
345  } else {
346  $url = 'card.php?track_id='.urlencode($object->track_id);
347  }
348 
349  header('Location: '.$url);
350  exit();
351  }
352  }
353 
354  // Mark as Read
355  if ($action == "mark_ticket_read" && $user->rights->ticket->write) {
356  $object->fetch('', '', GETPOST("track_id", 'alpha'));
357 
358  if ($object->markAsRead($user) > 0) {
359  setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs');
360 
361  header("Location: card.php?track_id=".$object->track_id."&action=view");
362  exit;
363  } else {
364  setEventMessages($object->error, $object->errors, 'errors');
365  }
366  $action = 'view';
367  }
368 
369  // Assign to someone
370  if ($action == "assign_user" && GETPOST('btn_assign_user', 'alpha') && $user->rights->ticket->write) {
371  $object->fetch('', '', GETPOST("track_id", 'alpha'));
372  $useroriginassign = $object->fk_user_assign;
373  $usertoassign = GETPOST('fk_user_assign', 'int');
374 
375  /*if (! ($usertoassign > 0)) {
376  $error++;
377  array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("AssignedTo")));
378  $action = 'view';
379  }*/
380 
381  if (!$error) {
382  $ret = $object->assignUser($user, $usertoassign);
383  if ($ret < 0) {
384  $error++;
385  }
386  }
387 
388  if (!$error) { // Update list of contacts
389  // Si déjà un user assigné on le supprime des contacts
390  if ($useroriginassign > 0) {
391  $internal_contacts = $object->listeContact(-1, 'internal', 0, 'SUPPORTTEC');
392  foreach ($internal_contacts as $key => $contact) {
393  if ($contact['id'] !== $usertoassign) {
394  $result = $object->delete_contact($contact['rowid']);
395  if ($result<0) {
396  $error++;
397  setEventMessages($object->error, $object->errors, 'errors');
398  }
399  }
400  }
401  }
402 
403  if ($usertoassign > 0 && $usertoassign!==$useroriginassign) {
404  $result = $object->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0);
405  if ($result<0) {
406  $error++;
407  setEventMessages($object->error, $object->errors, 'errors');
408  }
409  }
410  }
411 
412  if (!$error) {
413  // Log action in ticket logs table
414  $object->fetch_user($usertoassign);
415  //$log_action = $langs->trans('TicketLogAssignedTo', $object->user->getFullName($langs));
416 
417 
418  setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs');
419  header("Location: card.php?track_id=".$object->track_id."&action=view");
420  exit;
421  } else {
422  array_push($object->errors, $object->error);
423  }
424  $action = 'view';
425  }
426 
427  // Action to add an action (not a message)
428  if ($action == 'add_message' && GETPOSTISSET('btn_add_message') && $user->rights->ticket->read) {
429  $ret = $object->newMessage($user, $action, (GETPOST('private_message', 'alpha') == "on" ? 1 : 0));
430 
431  if ($ret > 0) {
432  if (!empty($backtopage)) {
433  if (empty($id)) {
434  $url = $backtopage;
435  } else {
436  $url = 'card.php?track_id='.urlencode($object->track_id);
437  }
438  } else {
439  $url = 'card.php?action=view&track_id='.urlencode($object->track_id);
440  }
441 
442  header("Location: ".$url);
443  exit;
444  } else {
445  setEventMessages($object->error, null, 'errors');
446  $action = 'presend';
447  }
448  }
449 
450  if (($action == "confirm_close" || $action == "confirm_abandon") && GETPOST('confirm', 'alpha') == 'yes' && $user->rights->ticket->write) {
451  $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha'));
452 
453  if ($object->close($user, ($action == "confirm_abandon" ? 1 : 0))) {
454  setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs');
455 
456  $url = 'card.php?action=view&track_id='.GETPOST('track_id', 'alpha');
457  header("Location: ".$url);
458  } else {
459  $action = '';
460  setEventMessages($object->error, $object->errors, 'errors');
461  }
462  }
463 
464  if ($action == "confirm_public_close" && GETPOST('confirm', 'alpha') == 'yes') {
465  $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha'));
466  if ($_SESSION['email_customer'] == $object->origin_email || $_SESSION['email_customer'] == $object->thirdparty->email) {
467  $object->close($user);
468 
469  // Log action in ticket logs table
470  //$log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']);
471 
472  setEventMessages('<div class="confirm">'.$langs->trans('TicketMarkedAsClosed').'</div>', null, 'mesgs');
473 
474  $url = 'card.php?action=view_ticket&track_id='.GETPOST('track_id', 'alpha');
475  header("Location: ".$url);
476  } else {
477  setEventMessages($object->error, $object->errors, 'errors');
478  $action = '';
479  }
480  }
481 
482  if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $user->rights->ticket->delete) {
483  if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
484  if ($object->delete($user) > 0) {
485  setEventMessages('<div class="confirm">'.$langs->trans('TicketDeletedSuccess').'</div>', null, 'mesgs');
486  Header("Location: ".DOL_URL_ROOT."/ticket/list.php");
487  exit;
488  } else {
489  $langs->load("errors");
490  $mesg = '<div class="error">'.$langs->trans($object->error).'</div>';
491  $action = '';
492  }
493  }
494  }
495 
496  // Set parent company
497  if ($action == 'set_thirdparty' && $user->rights->ticket->write) {
498  if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
499  $result = $object->setCustomer(GETPOST('editcustomer', 'int'));
500  $url = 'card.php?action=view&track_id='.GETPOST('track_id', 'alpha');
501  header("Location: ".$url);
502  exit();
503  }
504  }
505 
506  if ($action == 'set_progression' && $user->rights->ticket->write) {
507  if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
508  $result = $object->setProgression(GETPOST('progress', 'alpha'));
509 
510  $url = 'card.php?action=view&track_id='.$object->track_id;
511  header("Location: ".$url);
512  exit();
513  }
514  }
515 
516  if ($action == 'set_categories' && $user->rights->ticket->write) {
517  if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
518  $result = $object->setCategories(GETPOST('categories', 'array'));
519 
520  $url = 'card.php?action=view&track_id='.$object->track_id;
521  header("Location: ".$url);
522  exit();
523  }
524  }
525 
526  if ($action == 'setsubject' && $user->rights->ticket->write) {
527  if ($object->fetch(GETPOST('id', 'int'))) {
528  if ($action == 'setsubject') {
529  $object->subject = GETPOST('subject', 'alphanohtml');
530  }
531 
532  if ($action == 'setsubject' && empty($object->subject)) {
533  $error++;
534  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")), null, 'errors');
535  }
536 
537  if (!$error) {
538  if ($object->update($user) >= 0) {
539  header("Location: ".$_SERVER['PHP_SELF']."?track_id=".$object->track_id);
540  exit;
541  } else {
542  $error++;
543  setEventMessages($object->error, $object->errors, 'errors');
544  }
545  }
546  }
547  }
548 
549  if ($action == 'confirm_reopen' && $user->rights->ticket->manage && !GETPOST('cancel')) {
550  if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
551  // prevent browser refresh from reopening ticket several times
552  if ($object->status == Ticket::STATUS_CLOSED || $object->status == Ticket::STATUS_CANCELED) {
553  $res = $object->setStatut(Ticket::STATUS_ASSIGNED);
554  if ($res) {
555  // Log action in ticket logs table
556  //$log_action = $langs->trans('TicketLogReopen');
557 
558  $url = 'card.php?action=view&track_id='.$object->track_id;
559  header("Location: ".$url);
560  exit();
561  } else {
562  $error++;
563  setEventMessages($object->error, $object->errors, 'errors');
564  }
565  }
566  }
567  } elseif ($action == 'classin' && $user->rights->ticket->write) {
568  // Categorisation dans projet
569  if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
570  $object->setProject($projectid);
571  $url = 'card.php?action=view&track_id='.$object->track_id;
572  header("Location: ".$url);
573  exit();
574  }
575  } elseif ($action == 'setcontract' && $user->rights->ticket->write) {
576  // Categorisation dans contrat
577  if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
578  $object->setContract(GETPOST('contractid', 'int'));
579  $url = 'card.php?action=view&track_id='.$object->track_id;
580  header("Location: ".$url);
581  exit();
582  }
583  } elseif ($action == "set_message" && $user->rights->ticket->manage) {
584  // altairis: manage cancel button
585  if (!GETPOST('cancel')) {
586  $object->fetch('', '', GETPOST('track_id', 'alpha'));
587  $oldvalue_message = $object->message;
588  $fieldtomodify = GETPOST('message_initial', 'restricthtml');
589 
590  $object->message = $fieldtomodify;
591  $ret = $object->update($user);
592  if ($ret > 0) {
593  //$log_action = $langs->trans('TicketInitialMessageModified')." \n";
594  // include the Diff class
595  include_once DOL_DOCUMENT_ROOT.'/core/class/utils_diff.class.php';
596  // output the result of comparing two files as plain text
597  //$log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($object->message)));
598 
599  setEventMessages($langs->trans('TicketMessageSuccesfullyUpdated'), null, 'mesgs');
600  } else {
601  $error++;
602  setEventMessages($object->error, $object->errors, 'errors');
603  }
604  }
605 
606  $action = 'view';
607  } elseif ($action == 'confirm_set_status' && $user->rights->ticket->write && !GETPOST('cancel')) {
608  // Reopen ticket
609  if ($object->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
610  $new_status = GETPOST('new_status', 'int');
611  $old_status = $object->status;
612  $res = $object->setStatut($new_status);
613  if ($res) {
614  // Log action in ticket logs table
615  $log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status]));
616 
617  $url = 'card.php?action=view&track_id='.$object->track_id;
618  header("Location: ".$url);
619  exit();
620  } else {
621  $error++;
622  setEventMessages($object->error, $object->errors, 'errors');
623  }
624  }
625  }
626 
627  // Action to update one extrafield
628  if ($action == "update_extras" && !empty($permissiontoadd)) {
629  $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha'));
630 
631  $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
632  if ($ret < 0) {
633  $error++;
634  }
635 
636  if (!$error) {
637  $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user);
638  if ($result < 0) {
639  $error++;
640  }
641  }
642 
643  if ($error) {
644  setEventMessages($object->error, $object->errors, 'errors');
645  $action = 'edit_extras';
646  } else {
647  setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
648  $action = 'view';
649  }
650  }
651 
652  if ($action == "change_property" && GETPOST('btn_update_ticket_prop', 'alpha') && $user->rights->ticket->write) {
653  $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha'));
654 
655  $object->type_code = GETPOST('update_value_type', 'aZ09');
656  $object->severity_code = GETPOST('update_value_severity', 'aZ09');
657  $object->category_code = GETPOST('update_value_category', 'aZ09');
658 
659  $ret = $object->update($user);
660  if ($ret > 0) {
661  //$log_action = $langs->trans('TicketLogPropertyChanged', $oldvalue_label, $newvalue_label);
662 
663  setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs');
664  } else {
665  $error++;
666  setEventMessages($object->error, $object->errors, 'errors');
667  }
668  $action = 'view';
669  }
670 
671 
672  $permissiondellink = $user->rights->ticket->write;
673  include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
674 
675  // Actions to build doc
676  $upload_dir = $conf->ticket->dir_output;
677  $permissiontoadd = $user->rights->ticket->write;
678  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
679 
680  // Actions to send emails
681  $triggersendname = 'TICKET_SENTBYMAIL';
682  $paramname = 'id';
683  $autocopy = 'MAIN_MAIL_AUTOCOPY_TICKET_TO'; // used to know the automatic BCC to add
684  $trackid = 'tic'.$object->id;
685  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
686 
687  // Set $action to correct value for the case we used presend action to add a message
688  if (GETPOSTISSET('actionbis') && $action == 'presend') {
689  $action = 'presend_addmessage';
690  }
691 }
692 
693 
694 /*
695  * View
696  */
697 
698 $userstat = new User($db);
699 $form = new Form($db);
700 $formticket = new FormTicket($db);
701 if (isModEnabled('project')) {
702  $formproject = new FormProjets($db);
703 }
704 
705 $help_url = 'EN:Module_Ticket|FR:DocumentationModuleTicket';
706 
707 $page_title = $actionobject->getTitle($action);
708 
709 llxHeader('', $page_title, $help_url);
710 
711 if ($action == 'create' || $action == 'presend') {
712  $formticket = new FormTicket($db);
713 
714  print load_fiche_titre($langs->trans('NewTicket'), '', 'ticket');
715 
716  $formticket->withfromsocid = $socid ? $socid : $user->socid;
717  $formticket->withfromcontactid = $contactid ? $contactid : '';
718  $formticket->withtitletopic = 1;
719  $formticket->withnotifytiersatcreate = ($notifyTiers ? 1 : (empty($conf->global->TICKET_CHECK_NOTIFY_THIRDPARTY_AT_CREATION) ? 0 : 1));
720  $formticket->withusercreate = 0;
721  $formticket->withref = 1;
722  $formticket->fk_user_create = $user->id;
723  $formticket->withfile = 2;
724  $formticket->withextrafields = 1;
725  $formticket->param = array('origin' => GETPOST('origin'), 'originid' => GETPOST('originid'));
726 
727  $formticket->withcancel = 1;
728 
729  $formticket->showForm(1, 'create', 0);
730  /*} elseif ($action == 'edit' && $user->rights->ticket->write && $object->status < Ticket::STATUS_CLOSED) {
731  $formticket = new FormTicket($db);
732 
733  $head = ticket_prepare_head($object);
734 
735  print '<form method="POST" name="form_ticket" id="form_edit_ticket" action="'.$_SERVER['PHP_SELF'].'?track_id='.$object->track_id.'">';
736  print '<input type="hidden" name="token" value="'.newToken().'">';
737  print '<input type="hidden" name="action" value="update">';
738  print '<input type="hidden" name="tack_id" value="'.$object->track_id.'">';
739 
740  print dol_get_fiche_head($head, 'card', $langs->trans('Ticket'), 0, 'ticket');
741 
742  print '<div class="fichecenter2">';
743  print '<table class="border" width="100%">';
744 
745  // Type
746  print '<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">'.$langs->trans("TicketTypeRequest").'</span></label></td><td>';
747  $formticket->selectTypesTickets((GETPOSTISSET('type_code') ? GETPOST('type_code') : $object->type_code), 'type_code', '', '2');
748  print '</td></tr>';
749 
750  // Severity
751  print '<tr><td><span class="fieldrequired"><label for="selectseverity_code">'.$langs->trans("TicketSeverity").'</span></label></td><td>';
752  $formticket->selectSeveritiesTickets((GETPOSTISSET('severity_code') ? GETPOST('severity_code') : $object->severity_code), 'severity_code', '', '2');
753  print '</td></tr>';
754 
755  // Group
756  print '<tr><td><span class="fieldrequired"><label for="selectcategory_code">'.$langs->trans("TicketCategory").'</span></label></td><td>';
757  $formticket->selectGroupTickets((GETPOSTISSET('category_code') ? GETPOST('category_code') : $object->category_code), 'category_code', '', '2');
758  print '</td></tr>';
759 
760  // Subject
761  print '<tr><td><label for="subject"><span class="fieldrequired">'.$langs->trans("Subject").'</span></label></td><td>';
762  print '<input class="text minwidth200" id="subject" name="subject" value="'.dol_escape_htmltag(GETPOSTISSET('subject') ? GETPOST('subject', 'alpha') : $object->subject).'" />';
763  print '</td></tr>';
764 
765  // Other attributes
766  $parameters = array('colspan' => ' colspan="3"', 'colspanvalue' => '3');
767  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
768  print $hookmanager->resPrint;
769  if (empty($reshook)) {
770  print $object->showOptionals($extrafields, 'edit');
771  }
772 
773  print '</table>';
774  print '</div>';
775 
776  print dol_get_fiche_end();
777 
778  print $form->buttonsSaveCancel();
779 
780  print '</form>'; */
781 } elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'abandon' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'categories' || $action == 'reopen'
782  || $action == 'editsubject' || $action == 'edit_extras' || $action == 'update_extras' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink') {
783  if ($res > 0) {
784  // or for unauthorized internals users
785  if (!$user->socid && (!empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) {
786  accessforbidden('', 0, 1);
787  }
788 
789  // Confirmation close
790  if ($action == 'close') {
791  $thirdparty_contacts = $object->getInfosTicketExternalContact();
792  $contacts_select = array(
793  '-2' => $langs->trans('TicketNotifyAllTiersAtClose'),
794  '-3' => $langs->trans('TicketNotNotifyTiersAtClose')
795  );
796  foreach ($thirdparty_contacts as $thirdparty_contact) {
797  $contacts_select[$thirdparty_contact['id']] = $thirdparty_contact['civility'] . ' ' . $thirdparty_contact['lastname'] . ' ' . $thirdparty_contact['firstname'];
798  }
799 
800  // Default select all or no contact
801  $default = (!empty($conf->global->TICKET_NOTIFY_AT_CLOSING)) ? -2 : -3;
802  $formquestion = array(
803  array(
804  'name' => 'contactid',
805  'type' => 'select',
806  'label' => $langs->trans('NotifyThirdpartyOnTicketClosing'),
807  'values' => $contacts_select,
808  'default' => $default
809  ),
810  );
811 
812  print $form->formconfirm($url_page_current."?track_id=".$object->track_id, $langs->trans("CloseATicket"), $langs->trans("ConfirmCloseAticket"), "confirm_close", $formquestion, '', 1);
813  }
814  // Confirmation abandon
815  if ($action == 'abandon') {
816  print $form->formconfirm($url_page_current."?track_id=".$object->track_id, $langs->trans("AbandonTicket"), $langs->trans("ConfirmAbandonTicket"), "confirm_abandon", '', '', 1);
817  if ($ret == 'html') {
818  print '<br>';
819  }
820  }
821  // Confirmation delete
822  if ($action == 'delete') {
823  print $form->formconfirm($url_page_current."?track_id=".$object->track_id, $langs->trans("Delete"), $langs->trans("ConfirmDeleteTicket"), "confirm_delete_ticket", '', '', 1);
824  }
825  // Confirm reopen
826  if ($action == 'reopen') {
827  print $form->formconfirm($url_page_current.'?track_id='.$object->track_id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenTicket'), 'confirm_reopen', '', '', 1);
828  }
829  // Confirmation status change
830  if ($action == 'set_status') {
831  $new_status = GETPOST('new_status');
832  //var_dump($url_page_current . "?track_id=" . $object->track_id);
833  print $form->formconfirm($url_page_current."?track_id=".$object->track_id."&new_status=".GETPOST('new_status'), $langs->trans("TicketChangeStatus"), $langs->trans("TicketConfirmChangeStatus", $langs->transnoentities($object->statuts_short[$new_status])), "confirm_set_status", '', '', 1);
834  }
835 
836  // project info
837  if ($projectid > 0) {
838  $projectstat = new Project($db);
839  if ($projectstat->fetch($projectid) > 0) {
840  $projectstat->fetch_thirdparty();
841 
842  // To verify role of users
843  //$userAccess = $object->restrictedProjectArea($user,'read');
844  $userWrite = $projectstat->restrictedProjectArea($user, 'write');
845  //$userDelete = $object->restrictedProjectArea($user,'delete');
846  //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
847 
848  $head = project_prepare_head($projectstat);
849 
850  print dol_get_fiche_head($head, 'ticket', $langs->trans("Project"), 0, ($projectstat->public ? 'projectpub' : 'project'));
851 
852  /*
853  * Projet synthese pour rappel
854  */
855  print '<table class="border centpercent">';
856 
857  $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
858 
859  // Ref
860  print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">';
861  // Define a complementary filter for search of next/prev ref.
862  if (empty($user->rights->projet->all->lire)) {
863  $objectsListId = $projectstat->getProjectsAuthorizedForUser($user, $mine, 0);
864  $projectstat->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
865  }
866  print $form->showrefnav($projectstat, 'ref', $linkback, 1, 'ref', 'ref', '');
867  print '</td></tr>';
868 
869  // Label
870  print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projectstat->title.'</td></tr>';
871 
872  // Customer
873  print "<tr><td>".$langs->trans("ThirdParty")."</td>";
874  print '<td colspan="3">';
875  if ($projectstat->thirdparty->id > 0) {
876  print $projectstat->thirdparty->getNomUrl(1);
877  } else {
878  print '&nbsp;';
879  }
880 
881  print '</td></tr>';
882 
883  // Visibility
884  print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
885  if ($projectstat->public) {
886  print $langs->trans('SharedProject');
887  } else {
888  print $langs->trans('PrivateProject');
889  }
890 
891  print '</td></tr>';
892 
893  // Statut
894  print '<tr><td>'.$langs->trans("Status").'</td><td>'.$projectstat->getLibStatut(4).'</td></tr>';
895 
896  print "</table>";
897 
898  print dol_get_fiche_end();
899  } else {
900  print "ErrorRecordNotFound";
901  }
902  } elseif ($socid > 0) {
903  $object->fetch_thirdparty();
904  $head = societe_prepare_head($object->thirdparty);
905 
906  print dol_get_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company');
907 
908  dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom');
909 
910  print dol_get_fiche_end();
911  }
912 
913  if (!$user->socid && !empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY)) {
914  $object->next_prev_filter = "te.fk_user_assign = '".$user->id."'";
915  } elseif ($user->socid > 0) {
916  $object->next_prev_filter = "te.fk_soc = '".$user->socid."'";
917  }
918 
919  $head = ticket_prepare_head($object);
920 
921  print dol_get_fiche_head($head, 'tabTicket', $langs->trans("Ticket"), -1, 'ticket');
922 
923  $morehtmlref = '<div class="refidno">';
924  $morehtmlref .= $object->subject;
925  // Author
926  if ($object->fk_user_create > 0) {
927  $morehtmlref .= '<br>'.$langs->trans("CreatedBy").' : ';
928 
929  $fuser = new User($db);
930  $fuser->fetch($object->fk_user_create);
931  $morehtmlref .= $fuser->getNomUrl(-1);
932  } elseif (!empty($object->email_msgid)) {
933  $morehtmlref .= '<br>'.$langs->trans("CreatedBy").' : ';
934  $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"');
935  $morehtmlref .= dol_escape_htmltag($object->origin_email).' <small class="hideonsmartphone opacitymedium">('.$form->textwithpicto($langs->trans("CreatedByEmailCollector"), $langs->trans("EmailMsgID").': '.$object->email_msgid).')</small>';
936  } elseif (!empty($object->origin_email)) {
937  $morehtmlref .= '<br>'.$langs->trans("CreatedBy").' : ';
938  $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"');
939  $morehtmlref .= dol_escape_htmltag($object->origin_email).' <small class="hideonsmartphone opacitymedium">('.$langs->trans("CreatedByPublicPortal").')</small>';
940  }
941 
942  // Thirdparty
943  if (isModEnabled('societe')) {
944  $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' ';
945  if ($action != 'editcustomer' && $object->status < 8 && !$user->socid && $user->rights->ticket->write) {
946  $morehtmlref .= '<a class="editfielda" href="'.$url_page_current.'?action=editcustomer&token='.newToken().'&track_id='.$object->track_id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 0).'</a> : ';
947  }
948  if ($action == 'editcustomer') {
949  $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1);
950  } else {
951  $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'none', '', 1, 0, 0, array(), 1);
952  }
953  }
954 
955  // Project
956  if (isModEnabled('project')) {
957  $langs->load("projects");
958  $morehtmlref .= '<br>'.$langs->trans('Project').' ';
959  if ($user->rights->ticket->write) {
960  if ($action != 'classify') {
961  $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a>';
962  }
963  $morehtmlref .= ' : ';
964  if ($action == 'classify') {
965  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
966  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
967  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
968  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
969  $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500');
970  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
971  $morehtmlref .= '</form>';
972  } else {
973  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
974  }
975  } else {
976  if (!empty($object->fk_project)) {
977  $proj = new Project($db);
978  $proj->fetch($object->fk_project);
979  $morehtmlref .= $proj->getNomUrl(1);
980  } else {
981  $morehtmlref .= '';
982  }
983  }
984  }
985 
986  $morehtmlref .= '</div>';
987 
988  $linkback = '<a href="'.DOL_URL_ROOT.'/ticket/list.php?restore_lastsearch_values=1"><strong>'.$langs->trans("BackToList").'</strong></a> ';
989 
990  dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref);
991 
992  print '<div class="fichecenter">';
993  print '<div class="fichehalfleft">';
994  print '<div class="underbanner clearboth"></div>';
995 
996  print '<table class="border tableforfield centpercent">';
997 
998  // Track ID
999  print '<tr><td class="titlefield">'.$langs->trans("TicketTrackId").'</td><td>';
1000  if (!empty($object->track_id)) {
1001  if (empty($object->ref)) {
1002  $object->ref = $object->id;
1003  print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'track_id');
1004  } else {
1005  print $object->track_id;
1006  }
1007  } else {
1008  print $langs->trans('None');
1009  }
1010  print '</td></tr>';
1011 
1012  // Subject
1013  print '<tr><td>';
1014  print $form->editfieldkey("Subject", 'subject', $object->subject, $object, $user->rights->ticket->write && !$user->socid, 'string');
1015  print '</td><td>';
1016  print $form->editfieldval("Subject", 'subject', $object->subject, $object, $user->rights->ticket->write && !$user->socid, 'string');
1017  print '</td></tr>';
1018 
1019  // Creation date
1020  print '<tr><td>'.$langs->trans("DateCreation").'</td><td>';
1021  print dol_print_date($object->datec, 'dayhour', 'tzuser');
1022  print '<span class="opacitymedium"> - '.$langs->trans("TimeElapsedSince").': <i>'.convertSecondToTime(roundUpToNextMultiple($now - $object->datec, 60)).'</i></span>';
1023  print '</td></tr>';
1024 
1025  // Origin
1026  /*
1027  if ($object->email_msgid) {
1028  $texttoshow = $langs->trans("CreatedByEmailCollector");
1029  } elseif ($object->origin_email) {
1030  $texttoshow = $langs->trans("FromPublicEmail");
1031  }
1032  if ($texttoshow) {
1033  print '<tr><td class="titlefield fieldname_email_origin">';
1034  print $langs->trans("Origin");
1035  print '</td>';
1036  print '<td class="valuefield fieldname_email_origin">';
1037  print $texttoshow;
1038  print '</td></tr>';
1039  }
1040  */
1041 
1042  // Read date
1043  print '<tr><td>'.$langs->trans("TicketReadOn").'</td><td>';
1044  if (!empty($object->date_read)) {
1045  print dol_print_date($object->date_read, 'dayhour', 'tzuser');
1046  print '<span class="opacitymedium"> - '.$langs->trans("TicketTimeElapsedBeforeSince").': <i>'.convertSecondToTime(roundUpToNextMultiple($object->date_read - $object->datec, 60)).'</i>';
1047  print ' / <i>'.convertSecondToTime(roundUpToNextMultiple($now - $object->date_read, 60)).'</i></span>';
1048  }
1049  print '</td></tr>';
1050 
1051  // Close date
1052  print '<tr><td>'.$langs->trans("TicketCloseOn").'</td><td>';
1053  if (!empty($object->date_close)) {
1054  print dol_print_date($object->date_close, 'dayhour', 'tzuser');
1055  }
1056  print '</td></tr>';
1057 
1058  // User assigned
1059  print '<tr><td>';
1060  print '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">';
1061  print $langs->trans("AssignedTo");
1062  if (isset($object->status) && $object->status < $object::STATUS_CLOSED && GETPOST('set', 'alpha') != "assign_ticket" && $user->rights->ticket->manage) {
1063  print '</td><td class="right"><a class="editfielda" href="'.$url_page_current.'?track_id='.$object->track_id.'&action=view&set=assign_ticket">'.img_edit($langs->trans('Modify'), '').'</a>';
1064  }
1065  print '</td></tr></table>';
1066  print '</td><td>';
1067  if (GETPOST('set', 'alpha') != "assign_ticket" && $object->fk_user_assign > 0) {
1068  $userstat->fetch($object->fk_user_assign);
1069  print $userstat->getNomUrl(-1);
1070  }
1071 
1072  // Show user list to assignate one if status is "read"
1073  if (GETPOST('set', 'alpha') == "assign_ticket" && $object->status < 8 && !$user->socid && $user->rights->ticket->write) {
1074  print '<form method="post" name="ticket" enctype="multipart/form-data" action="'.$url_page_current.'">';
1075  print '<input type="hidden" name="token" value="'.newToken().'">';
1076  print '<input type="hidden" name="action" value="assign_user">';
1077  print '<input type="hidden" name="track_id" value="'.$object->track_id.'">';
1078  //print '<label for="fk_user_assign">'.$langs->trans("AssignUser").'</label> ';
1079  print $form->select_dolusers(empty($object->fk_user_assign)?$user->id:$object->fk_user_assign, 'fk_user_assign', 1);
1080  print ' <input type="submit" class="button small" name="btn_assign_user" value="'.$langs->trans("Validate").'" />';
1081  print '</form>';
1082  }
1083  print '</td></tr>';
1084 
1085  // Progression
1086  print '<tr><td>';
1087  print '<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
1088  print $langs->trans('Progression').'</td><td class="left">';
1089  print '</td>';
1090  if ($action != 'progression' && isset($object->status) && $object->status < $object::STATUS_CLOSED && !$user->socid) {
1091  print '<td class="right"><a class="editfielda" href="'.$url_page_current.'?action=progression&amp;track_id='.$object->track_id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
1092  }
1093  print '</tr></table>';
1094  print '</td><td>';
1095  if ($user->rights->ticket->write && $action == 'progression') {
1096  print '<form action="'.$url_page_current.'" method="post">';
1097  print '<input type="hidden" name="token" value="'.newToken().'">';
1098  print '<input type="hidden" name="track_id" value="'.$track_id.'">';
1099  print '<input type="hidden" name="action" value="set_progression">';
1100  print '<input type="text" class="flat width75" name="progress" value="'.$object->progress.'">';
1101  print ' <input type="submit" class="button button-edit small" value="'.$langs->trans('Modify').'">';
1102  print '</form>';
1103  } else {
1104  print($object->progress > 0 ? $object->progress : '0').'%';
1105  }
1106  print '</td>';
1107  print '</tr>';
1108 
1109  // Timing (Duration sum of linked fichinter)
1110  if (isModEnabled('ficheinter')) {
1111  $object->fetchObjectLinked();
1112  $num = count($object->linkedObjects);
1113  $timing = 0;
1114  $foundinter = 0;
1115  if ($num) {
1116  foreach ($object->linkedObjects as $objecttype => $objects) {
1117  if ($objecttype = "fichinter") {
1118  foreach ($objects as $fichinter) {
1119  $foundinter++;
1120  $timing += $fichinter->duration;
1121  }
1122  }
1123  }
1124  }
1125  print '<tr><td>';
1126  print $form->textwithpicto($langs->trans("TicketDurationAuto"), $langs->trans("TicketDurationAutoInfos"), 1);
1127  print '</td><td>';
1128  print $foundinter ? convertSecondToTime($timing, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY) : '';
1129  print '</td></tr>';
1130  }
1131 
1132  // Other attributes
1133  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
1134 
1135  print '</table>';
1136 
1137 
1138  // Fin colonne gauche et début colonne droite
1139  print '</div><div class="fichehalfright">';
1140 
1141 
1142  print '<form method="post" name="formticketproperties" action="'.$url_page_current.'">';
1143  print '<input type="hidden" name="token" value="'.newToken().'">';
1144  print '<input type="hidden" name="action" value="change_property">';
1145  print '<input type="hidden" name="track_id" value="'.$track_id.'">';
1146 
1147  print '<div class="underbanner clearboth"></div>';
1148 
1149  // Categories
1150  if (isModEnabled('categorie')) {
1151  print '<table class="border centpercent tableforfield">';
1152  print '<tr>';
1153  print '<td class="valignmiddle titlefield">';
1154  print '<table class="nobordernopadding centpercent"><tr><td class="titlefield">';
1155  print $langs->trans("Categories");
1156  if ($action != 'categories' && !$user->socid) {
1157  print '<td class="right"><a class="editfielda" href="'.$url_page_current.'?action=categories&amp;track_id='.$object->track_id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
1158  }
1159  print '</table>';
1160  print '</td>';
1161 
1162  if ($user->rights->ticket->write && $action == 'categories') {
1163  $cate_arbo = $form->select_all_categories(Categorie::TYPE_TICKET, '', 'parent', 64, 0, 1);
1164  if (is_array($cate_arbo)) {
1165  // Categories
1166  print '<td colspan="3">';
1167  print '<form action="'.$url_page_current.'" method="post">';
1168  print '<input type="hidden" name="token" value="'.newToken().'">';
1169  print '<input type="hidden" name="track_id" value="'.$track_id.'">';
1170  print '<input type="hidden" name="action" value="set_categories">';
1171 
1172  $category = new Categorie($db);
1173  $cats = $category->containing($object->id, 'ticket');
1174  $arrayselected = array();
1175  foreach ($cats as $cat) {
1176  $arrayselected[] = $cat->id;
1177  }
1178 
1179  print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
1180  print '<input type="submit" class="button button-edit small" value="'.$langs->trans('Save').'">';
1181  print '</form>';
1182  print "</td>";
1183  }
1184  } else {
1185  print '<td colspan="3">';
1186  print $form->showCategories($object->id, Categorie::TYPE_TICKET, 1);
1187  print "</td></tr>";
1188  }
1189 
1190  print '</table>';
1191  }
1192 
1193  // View Original message
1194  $actionobject->viewTicketOriginalMessage($user, $action, $object);
1195 
1196  // Classification of ticket
1197  print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
1198  print '<table class="noborder tableforfield centpercent margintable">';
1199  print '<tr class="liste_titre">';
1200  print '<td>';
1201  print $langs->trans('TicketProperties');
1202  print '</td>';
1203  print '<td>';
1204  if (GETPOST('set', 'alpha') == 'properties' && $user->rights->ticket->write) {
1205  print '<input type="submit" class="button small" name="btn_update_ticket_prop" value="'.$langs->trans("Modify").'" />';
1206  } else {
1207  // Button to edit Properties
1208  if (isset($object->status) && $object->status < $object::STATUS_NEED_MORE_INFO && $user->rights->ticket->write) {
1209  print ' <a class="editfielda" href="card.php?track_id='.$object->track_id.'&action=view&set=properties">'.img_edit($langs->trans('Modify')).'</a>';
1210  }
1211  }
1212  print '</td>';
1213  print '</tr>';
1214 
1215  if (GETPOST('set', 'alpha') == 'properties' && $user->rights->ticket->write) {
1216  print '<tr>';
1217  // Type
1218  print '<td class="titlefield">';
1219  print $langs->trans('Type');
1220  print '</td><td>';
1221  $formticket->selectTypesTickets($object->type_code, 'update_value_type', '', 2);
1222  print '</td>';
1223  print '</tr>';
1224  // Group
1225  print '<tr>';
1226  print '<td>';
1227  print $langs->trans('TicketCategory');
1228  print '</td><td>';
1229  $formticket->selectGroupTickets($object->category_code, 'update_value_category', '', 2, 0, 0, 0, 'maxwidth500 widthcentpercentminusxx');
1230  print '</td>';
1231  print '</tr>';
1232  // Severity
1233  print '<tr>';
1234  print '<td>';
1235  print $langs->trans('TicketSeverity');
1236  print '</td><td>';
1237  $formticket->selectSeveritiesTickets($object->severity_code, 'update_value_severity', '', 2);
1238  print '</td>';
1239  print '</tr>';
1240  } else {
1241  // Type
1242  print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td>';
1243  if (!empty($object->type_code)) {
1244  print $langs->getLabelFromKey($db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code);
1245  }
1246  print '</td></tr>';
1247  // Group
1248  print '<tr><td>'.$langs->trans("TicketCategory").'</td><td>';
1249  if (!empty($object->category_code)) {
1250  print $langs->getLabelFromKey($db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code);
1251  }
1252  print '</td></tr>';
1253  // Severity
1254  print '<tr><td>'.$langs->trans("TicketSeverity").'</td><td>';
1255  if (!empty($object->severity_code)) {
1256  print $langs->getLabelFromKey($db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code);
1257  }
1258  print '</td></tr>';
1259  }
1260  print '</table>'; // End table actions
1261  print '</div>';
1262 
1263  print '</form>';
1264 
1265  // Display navbar with links to change ticket status
1266  print '<!-- navbar with status -->';
1267  if (!$user->socid && $user->rights->ticket->write && isset($object->status) && $object->status < $object::STATUS_CLOSED && GETPOST('set') !== 'properties') {
1268  $actionobject->viewStatusActions($object);
1269  }
1270 
1271 
1272  if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
1273  print load_fiche_titre($langs->trans('Contacts'), '', 'title_companies.png');
1274 
1275  print '<div class="div-table-responsive-no-min">';
1276  print '<div class="tagtable centpercent noborder allwidth">';
1277 
1278  print '<div class="tagtr liste_titre">';
1279  print '<div class="tagtd">'.$langs->trans("Source").'</div>
1280  <div class="tagtd">' . $langs->trans("Company").'</div>
1281  <div class="tagtd">' . $langs->trans("Contacts").'</div>
1282  <div class="tagtd">' . $langs->trans("ContactType").'</div>
1283  <div class="tagtd">' . $langs->trans("Phone").'</div>
1284  <div class="tagtd center">' . $langs->trans("Status").'</div>';
1285  print '</div><!-- tagtr -->';
1286 
1287  // Contact list
1288  $companystatic = new Societe($db);
1289  $contactstatic = new Contact($db);
1290  $userstatic = new User($db);
1291  $var = false;
1292  foreach (array('internal', 'external') as $source) {
1293  $tmpobject = $object;
1294  $tab = $tmpobject->listeContact(-1, $source);
1295  $num = count($tab);
1296  $i = 0;
1297  while ($i < $num) {
1298  $var = !$var;
1299  print '<div class="tagtr '.($var ? 'pair' : 'impair').'">';
1300 
1301  print '<div class="tagtd left">';
1302  if ($tab[$i]['source'] == 'internal') {
1303  echo $langs->trans("User");
1304  }
1305 
1306  if ($tab[$i]['source'] == 'external') {
1307  echo $langs->trans("ThirdPartyContact");
1308  }
1309 
1310  print '</div>';
1311  print '<div class="tagtd left">';
1312 
1313  if ($tab[$i]['socid'] > 0) {
1314  $companystatic->fetch($tab[$i]['socid']);
1315  echo $companystatic->getNomUrl(-1);
1316  }
1317  if ($tab[$i]['socid'] < 0) {
1318  echo $conf->global->MAIN_INFO_SOCIETE_NOM;
1319  }
1320  if (!$tab[$i]['socid']) {
1321  echo '&nbsp;';
1322  }
1323  print '</div>';
1324 
1325  print '<div class="tagtd">';
1326  if ($tab[$i]['source'] == 'internal') {
1327  if ($userstatic->fetch($tab[$i]['id'])) {
1328  print $userstatic->getNomUrl(-1);
1329  }
1330  }
1331  if ($tab[$i]['source'] == 'external') {
1332  if ($contactstatic->fetch($tab[$i]['id'])) {
1333  print $contactstatic->getNomUrl(-1);
1334  }
1335  }
1336  print ' </div>
1337  <div class="tagtd">' . $tab[$i]['libelle'].'</div>';
1338 
1339  print '<div class="tagtd">';
1340 
1341  print dol_print_phone($tab[$i]['phone'], '', '', '', 'AC_TEL').'<br>';
1342 
1343  if (!empty($tab[$i]['phone_perso'])) {
1344  //print img_picto($langs->trans('PhonePerso'),'object_phoning.png','',0,0,0).' ';
1345  print '<br>'.dol_print_phone($tab[$i]['phone_perso'], '', '', '', 'AC_TEL').'<br>';
1346  }
1347  if (!empty($tab[$i]['phone_mobile'])) {
1348  //print img_picto($langs->trans('PhoneMobile'),'object_phoning.png','',0,0,0).' ';
1349  print dol_print_phone($tab[$i]['phone_mobile'], '', '', '', 'AC_TEL').'<br>';
1350  }
1351  print '</div>';
1352 
1353  print '<div class="tagtd center">';
1354  if ($object->status >= 0) {
1355  echo '<a href="contact.php?track_id='.$object->track_id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">';
1356  }
1357 
1358  if ($tab[$i]['source'] == 'internal') {
1359  $userstatic->id = $tab[$i]['id'];
1360  $userstatic->lastname = $tab[$i]['lastname'];
1361  $userstatic->firstname = $tab[$i]['firstname'];
1362  echo $userstatic->LibStatut($tab[$i]['statuscontact'], 3);
1363  }
1364  if ($tab[$i]['source'] == 'external') {
1365  $contactstatic->id = $tab[$i]['id'];
1366  $contactstatic->lastname = $tab[$i]['lastname'];
1367  $contactstatic->firstname = $tab[$i]['firstname'];
1368  echo $contactstatic->LibStatut($tab[$i]['statuscontact'], 3);
1369  }
1370  if ($object->status >= 0) {
1371  echo '</a>';
1372  }
1373 
1374  print '</div>';
1375 
1376  print '</div><!-- tagtr -->';
1377 
1378  $i++;
1379  }
1380  }
1381 
1382  print '</div><!-- contact list -->';
1383  print '</div>';
1384  }
1385 
1386  print '</div></div>';
1387  print '<div style="clear:both"></div>';
1388 
1389  print dol_get_fiche_end();
1390 
1391 
1392  // Buttons for actions
1393  if ($action != 'presend' && $action != 'presend_addmessage' && $action != 'editline') {
1394  print '<div class="tabsAction">'."\n";
1395  $parameters = array();
1396  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1397  if ($reshook < 0) {
1398  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1399  }
1400 
1401  if (empty($reshook)) {
1402  // Show link to add a message (if read and not closed)
1403  if (isset($object->status) && $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage") {
1404  print dolGetButtonAction('', $langs->trans('TicketAddMessage'), 'default', $_SERVER["PHP_SELF"].'?action=presend_addmessage&mode=init&token='.newToken().'&track_id='.$object->track_id, '');
1405  }
1406 
1407  // Link to create an intervention
1408  // socid is needed otherwise fichinter ask it and forgot origin after form submit :\
1409  if (!$object->fk_soc && $user->hasRight("ficheinter", "creer")) {
1410  print dolGetButtonAction($langs->trans('UnableToCreateInterIfNoSocid'), $langs->trans('TicketAddIntervention'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
1411  }
1412  if ($object->fk_soc > 0 && isset($object->status) && $object->status < Ticket::STATUS_CLOSED && $user->rights->ficheinter->creer) {
1413  print dolGetButtonAction('', $langs->trans('TicketAddIntervention'), 'default', DOL_URL_ROOT.'/fichinter/card.php?action=create&token='.newToken().'&socid='. $object->fk_soc.'&origin=ticket_ticket&originid='. $object->id, '');
1414  }
1415 
1416  /* This is useless. We can already modify each field individually
1417  if ($user->rights->ticket->write && $object->status < Ticket::STATUS_CLOSED) {
1418  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?track_id='.$object->track_id.'&action=edit&token='.newToken().'">'.$langs->trans('Modify').'</a></div>';
1419  }
1420  */
1421 
1422  // Close ticket if statut is read
1423  if (isset($object->status) && $object->status > 0 && $object->status < Ticket::STATUS_CLOSED && $user->rights->ticket->write) {
1424  print dolGetButtonAction('', $langs->trans('CloseTicket'), 'default', $_SERVER["PHP_SELF"].'?action=close&token='.newToken().'&track_id='.$object->track_id, '');
1425  }
1426 
1427  // Abadon ticket if statut is read
1428  if (isset($object->status) && $object->status > 0 && $object->status < Ticket::STATUS_CLOSED && $user->rights->ticket->write) {
1429  print dolGetButtonAction('', $langs->trans('AbandonTicket'), 'default', $_SERVER["PHP_SELF"].'?action=abandon&token='.newToken().'&track_id='.$object->track_id, '');
1430  }
1431 
1432  // Re-open ticket
1433  if (!$user->socid && (isset($object->status) && ($object->status == Ticket::STATUS_CLOSED || $object->status == Ticket::STATUS_CANCELED)) && !$user->socid) {
1434  print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&track_id='.$object->track_id, '');
1435  }
1436 
1437  // Delete ticket
1438  if ($user->rights->ticket->delete && !$user->socid) {
1439  print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&track_id='.$object->track_id, '');
1440  }
1441  }
1442  print '</div>'."\n";
1443  } else {
1444  //print '<br>';
1445  }
1446 
1447  // Select mail models is same action as presend
1448  if (GETPOST('modelselected')) {
1449  $action = 'presend';
1450  }
1451  // Set $action to correct value for the case we used presend action to add a message
1452  if (GETPOSTISSET('actionbis') && $action == 'presend') {
1453  $action = 'presend_addmessage';
1454  }
1455 
1456  // add a message
1457  if ($action == 'presend' || $action == 'presend_addmessage') {
1458  if ($object->fk_soc > 0) {
1459  $object->fetch_thirdparty();
1460  }
1461 
1462  $outputlangs = $langs;
1463  $newlang = '';
1464  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
1465  $newlang = GETPOST('lang_id', 'aZ09');
1466  } elseif ($conf->global->MAIN_MULTILANGS && empty($newlang) && is_object($object->thirdparty)) {
1467  $newlang = $object->thirdparty->default_lang;
1468  }
1469  if (!empty($newlang)) {
1470  $outputlangs = new Translate("", $conf);
1471  $outputlangs->setDefaultLang($newlang);
1472  }
1473 
1474  $arrayoffamiliestoexclude = array('objectamount');
1475 
1476  $action = 'add_message'; // action to use to post the message
1477  $modelmail = 'ticket_send';
1478 
1479  // Substitution array
1480  $morehtmlright = '';
1481  $help = "";
1482  $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $arrayoffamiliestoexclude, $object);
1483  $morehtmlright .= $form->textwithpicto('<span class="opacitymedium">'.$langs->trans("TicketMessageSubstitutionReplacedByGenericValues").'</span>', $help, 1, 'helpclickable', '', 0, 3, 'helpsubstitution');
1484 
1485  print '<div>';
1486 
1487  print load_fiche_titre($langs->trans('TicketAddMessage'), $morehtmlright, 'messages@ticket');
1488 
1489  print '<hr>';
1490 
1491  $formticket = new FormTicket($db);
1492 
1493  $formticket->action = $action;
1494  $formticket->track_id = $object->track_id;
1495  $formticket->ref = $object->ref;
1496  $formticket->id = $object->id;
1497 
1498  $formticket->withfile = 2;
1499  $formticket->withcancel = 1;
1500  $formticket->param = array('fk_user_create' => $user->id);
1501  $formticket->param['langsmodels'] = (empty($newlang) ? $langs->defaultlang : $newlang);
1502 
1503  // Tableau des parametres complementaires du post
1504  $formticket->param['models'] = $modelmail;
1505  $formticket->param['models_id'] = GETPOST('modelmailselected', 'int');
1506  //$formticket->param['socid']=$object->fk_soc;
1507  $formticket->param['returnurl'] = $_SERVER["PHP_SELF"].'?track_id='.$object->track_id;
1508 
1509  $formticket->withsubstit = 1;
1510  $formticket->substit = $substitutionarray;
1511  $formticket->backtopage = $backtopage;
1512 
1513  $formticket->showMessageForm('100%');
1514  print '</div>';
1515  }
1516 
1517  // Show messages on card (Note: this is a duplicate of the view Events/Agenda but on the main tab)
1518  if (!empty($conf->global->TICKET_SHOW_MESSAGES_ON_CARD)) {
1519  $param = '&id='.$object->id;
1520  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
1521  $param .= '&contextpage='.$contextpage;
1522  }
1523  if ($limit > 0 && $limit != $conf->liste_limit) {
1524  $param .= '&limit='.$limit;
1525  }
1526  if ($actioncode) {
1527  $param .= '&actioncode='.urlencode($actioncode);
1528  }
1529  if ($search_agenda_label) {
1530  $param .= '&search_agenda_label='.urlencode($search_agenda_label);
1531  }
1532 
1533  $morehtmlright = '';
1534 
1535  $messagingUrl = DOL_URL_ROOT.'/ticket/agenda.php?track_id='.$object->track_id;
1536  $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 1);
1537 
1538  // Show link to add a message (if read and not closed)
1539  $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage" && $action != "add_message";
1540  $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init';
1541  $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus);
1542 
1543  // Show link to add event (if read and not closed)
1544  $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage" && $action != "add_message"; ;
1545  $url = dol_buildpath('/comm/action/card.php', 1).'?action=create&datep='.date('YmdHi').'&origin=ticket&originid='.$object->id.'&projectid='.$object->fk_project.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id);
1546  $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, 'add-new-ticket-even-button', $btnstatus);
1547 
1548  print_barre_liste($langs->trans("ActionsOnTicket"), 0, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1);
1549 
1550  // List of all actions
1551  $filters = array();
1552  $filters['search_agenda_label'] = $search_agenda_label;
1553  show_ticket_messaging($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
1554  }
1555 
1556  if ($action != 'presend' && $action != 'presend_addmessage' && $action != 'add_message') {
1557  print '<div class="fichecenter"><div class="fichehalfleft">';
1558  print '<a name="builddoc"></a>'; // ancre
1559 
1560  // Show links to link elements
1561  $linktoelem = $form->showLinkToObjectBlock($object, null, array('ticket'));
1562  $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
1563 
1564  // Show direct link to public interface
1565  print '<br><!-- Link to public interface -->'."\n";
1566  print showDirectPublicLink($object).'<br>';
1567  print '</div>';
1568 
1569  if (empty($conf->global->TICKET_SHOW_MESSAGES_ON_CARD)) {
1570  print '<div class="fichehalfright">';
1571 
1572  $MAXEVENT = 10;
1573 
1574  $morehtmlcenter = '<div class="nowraponall">';
1575  $morehtmlcenter .= dolGetButtonTitle($langs->trans('FullConversation'), '', 'fa fa-comments imgforviewmode', DOL_URL_ROOT.'/ticket/messaging.php?id='.$object->id);
1576  $morehtmlcenter .= ' ';
1577  $morehtmlcenter .= dolGetButtonTitle($langs->trans('FullList'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/ticket/agenda.php?id='.$object->id);
1578  $morehtmlcenter .= '</div>';
1579 
1580  // List of actions on element
1581  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
1582  $formactions = new FormActions($db);
1583  $somethingshown = $formactions->showactions($object, 'ticket', $socid, 1, 'listactions', $MAXEVENT, '', $morehtmlcenter);
1584 
1585  print '</div>';
1586  }
1587 
1588  print '</div>';
1589  }
1590  }
1591 }
1592 
1593 // End of page
1594 llxFooter();
1595 $db->close();
project_prepare_head(Project $project, $moreparam= '')
Prepare array with list of tabs.
Definition: project.lib.php:38
show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon= '', $noprint=0, $actioncode= '', $donetodo= 'done', $filters=array(), $sortfield= 'a.datep, a.id', $sortorder= 'DESC')
Show html area with actions for ticket messaging.
Definition: ticket.lib.php:281
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action== 'set') elseif($action== 'specimen') elseif($action== 'setmodel') elseif($action== 'del') elseif($action== 'setdoc') $formactions
View.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Definition: card.php:142
Class to manage building of HTML components.
ticket_prepare_head($object)
Build tabs for a Ticket object.
Definition: ticket.lib.php:76
Class to manage contact/addresses.
dolGetButtonTitle($label, $helpText= '', $iconClass= 'fa fa-file', $url= '', $id= '', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
Definition: user.class.php:44
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
dol_print_phone($phone, $countrycode= '', $cid=0, $socid=0, $addlink= '', $separ="&nbsp;", $withpicto= '', $titlealt= '', $adddivfloat=0)
Format phone numbers according to country.
dolGetButtonAction($label, $html= '', $actionType= 'default', $url= '', $id= '', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $help_url
View.
Definition: agenda.php:116
Class to manage ticket.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage categories.
Class to manage projects.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
Class to manage building of HTML components.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage translations.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Definition: company.lib.php:42
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
showDirectPublicLink($object)
Return string with full Url.
Definition: ticket.lib.php:147
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Class Actions of the module ticket.
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
isModEnabled($module)
Is Dolibarr module enabled.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
llxFooter()
Empty footer.
Definition: wrapper.php:73
roundUpToNextMultiple($n, $x=5)
Round to next multiple.
convertSecondToTime($iSecond, $format= 'all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
Definition: date.lib.php:236