dolibarr  19.0.0-dev
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2013-2016 Jean-François FERRY <jfefe@aternatik.fr>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  */
17 
24 if (!defined('NOREQUIREMENU')) {
25  define('NOREQUIREMENU', '1');
26 }
27 // If there is no need to load and show top and left menu
28 if (!defined("NOLOGIN")) {
29  define("NOLOGIN", '1');
30 }
31 if (!defined('NOIPCHECK')) {
32  define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
33 }
34 if (!defined('NOBROWSERNOTIF')) {
35  define('NOBROWSERNOTIF', '1');
36 }
37 // If this page is public (can be called outside logged session)
38 
39 // For MultiCompany module.
40 // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
41 $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
42 if (is_numeric($entity)) {
43  define("DOLENTITY", $entity);
44 }
45 
46 // Load Dolibarr environment
47 require '../../main.inc.php';
48 require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php';
49 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php';
50 require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
51 require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php';
52 require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
53 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
54 require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
55 
56 // Load translation files required by the page
57 $langs->loadLangs(array("companies", "other", "ticket"));
58 
59 // Get parameters
60 $action = GETPOST('action', 'aZ09');
61 $cancel = GETPOST('cancel', 'aZ09');
62 
63 $track_id = GETPOST('track_id', 'alpha');
64 $email = strtolower(GETPOST('email', 'alpha'));
65 $suffix = "";
66 $moreforfilter = "";
67 
68 if (GETPOST('btn_view_ticket_list')) {
69  unset($_SESSION['track_id_customer']);
70  unset($_SESSION['email_customer']);
71 }
72 if (isset($_SESSION['track_id_customer'])) {
73  $track_id = $_SESSION['track_id_customer'];
74 }
75 if (isset($_SESSION['email_customer'])) {
76  $email = strtolower($_SESSION['email_customer']);
77 }
78 
79 $object = new Ticket($db);
80 
81 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
82 $hookmanager->initHooks(array('ticketpubliclist', 'globalcard'));
83 
84 if (!isModEnabled('ticket')) {
85  httponly_accessforbidden('Module Ticket not enabled');
86 }
87 
88 
89 
90 /*
91  * Actions
92  */
93 
94 if ($cancel) {
95  $backtopage = DOL_URL_ROOT.'/public/ticket/index.php';
96 
97  header("Location: ".$backtopage);
98  exit;
99 }
100 
101 if ($action == "view_ticketlist") {
102  $error = 0;
103  $display_ticket_list = false;
104  if (!strlen($track_id)) {
105  $error++;
106  array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketTrackId")));
107  $action = '';
108  }
109 
110  if (!strlen($email)) {
111  $error++;
112  array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Email")));
113  $action = '';
114  } else {
115  if (!isValidEmail($email)) {
116  $error++;
117  array_push($object->errors, $langs->trans("ErrorEmailOrTrackingInvalid"));
118  $action = '';
119  }
120  }
121 
122  if (!$error) {
123  $ret = $object->fetch('', '', $track_id);
124 
125  if ($ret && $object->id > 0) {
126  // vérifie si l'adresse email est bien dans les contacts du ticket
127  $contacts = $object->liste_contact(-1, 'external');
128  foreach ($contacts as $contact) {
129  if (strtolower($contact['email']) == $email) {
130  $display_ticket_list = true;
131  $_SESSION['email_customer'] = $email;
132  $_SESSION['track_id_customer'] = $track_id;
133  break;
134  } else {
135  $display_ticket_list = false;
136  }
137  }
138  if ($object->fk_soc > 0) {
139  $object->fetch_thirdparty();
140  if ($email == strtolower($object->thirdparty->email)) {
141  $display_ticket_list = true;
142  $_SESSION['email_customer'] = $email;
143  $_SESSION['track_id_customer'] = $track_id;
144  }
145  }
146  if ($object->fk_user_create > 0) {
147  $tmpuser = new User($db);
148  $tmpuser->fetch($object->fk_user_create);
149  if ($email == strtolower($tmpuser->email)) {
150  $display_ticket_list = true;
151  $_SESSION['email_customer'] = $email;
152  $_SESSION['track_id_customer'] = $track_id;
153  }
154  }
155 
156  $emailorigin = strtolower(CMailFile::getValidAddress($object->origin_email, 2));
157  if ($email == $emailorigin) {
158  $display_ticket_list = true;
159  $_SESSION['email_customer'] = $email;
160  $_SESSION['track_id_customer'] = $track_id;
161  }
162  } else {
163  $error++;
164  array_push($object->errors, $langs->trans("ErrorTicketNotFound", $track_id));
165  $action = '';
166  }
167  }
168 
169  if ($error || $errors) {
170  setEventMessages($object->error, $object->errors, 'errors');
171  $action = '';
172  }
173 }
174 
175 /*
176  * View
177  */
178 
179 $form = new Form($db);
180 $user_assign = new User($db);
181 $user_create = new User($db);
182 $formTicket = new FormTicket($db);
183 
184 if (!$conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) {
185  print '<div class="error">'.$langs->trans('TicketPublicInterfaceForbidden').'</div>';
186  $db->close();
187  exit();
188 }
189 
190 $arrayofjs = array();
191 $arrayofcss = array('/ticket/css/styles.css.php');
192 
193 llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss);
194 
195 
196 if ($action == "view_ticketlist") {
197  print '<div class="ticketpublicarealist ticketlargemargin centpercent">';
198 
199  print '<br>';
200  if ($display_ticket_list) {
201  // Filters
202  $search_fk_status = GETPOST("search_fk_status", 'alpha');
203  $search_subject = GETPOST("search_subject", 'alpha');
204  $search_type = GETPOST("search_type", 'alpha');
205  $search_category = GETPOST("search_category", 'alpha');
206  $search_severity = GETPOST("search_severity", 'alpha');
207  $search_fk_user_create = GETPOST("search_fk_user_create", 'int');
208  $search_fk_user_assign = GETPOST("search_fk_user_assign", 'int');
209 
210  // Store current page url
211  $url_page_current = dol_buildpath('/public/ticket/list.php', 1);
212 
213  // Do we click on purge search criteria ?
214  if (GETPOST("button_removefilter_x")) {
215  $search_fk_status = '';
216  $search_subject = '';
217  $search_type = '';
218  $search_category = '';
219  $search_severity = '';
220  $search_fk_user_create = '';
221  $search_fk_user_assign = '';
222  }
223 
224  // fetch optionals attributes and labels
225  $extrafields = new ExtraFields($db);
226  $extrafields->fetch_name_optionals_label($object->table_element);
227 
228  $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
229 
230  $filter = array();
231 
232  $param = '&action=view_ticketlist';
233  if (!empty($entity) && isModEnabled('multicompany')) {
234  $param .= '&entity='.((int) $entity);
235  }
236 
237  $param .= '&token='.newToken();
238 
239  // Definition of fields for list
240  $arrayfields = array(
241  't.datec' => array('label' => $langs->trans("Date"), 'checked' => 1),
242  't.date_read' => array('label' => $langs->trans("TicketReadOn"), 'checked' => 0),
243  't.date_close' => array('label' => $langs->trans("TicketCloseOn"), 'checked' => 0),
244  't.ref' => array('label' => $langs->trans("Ref"), 'checked' => 1),
245  //'t.track_id' => array('label' => $langs->trans("IDTracking"), 'checked' => 0),
246  't.fk_statut' => array('label' => $langs->trans("Status"), 'checked' => 1),
247  't.subject' => array('label' => $langs->trans("Subject"), 'checked' => 1),
248  'type.code' => array('label' => $langs->trans("Type"), 'checked' => 1),
249  'category.code' => array('label' => $langs->trans("Category"), 'checked' => 1),
250  'severity.code' => array('label' => $langs->trans("Severity"), 'checked' => 1),
251  't.progress' => array('label' => $langs->trans("Progression"), 'checked' => 0),
252  //'t.fk_contract' => array('label' => $langs->trans("Contract"), 'checked' => 0),
253  't.fk_user_create' => array('label' => $langs->trans("Author"), 'checked' => 1),
254  't.fk_user_assign' => array('label' => $langs->trans("AssignedTo"), 'checked' => 0),
255 
256  //'t.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(isModEnabled('multicompany') && empty($conf->multicompany->transverse_mode))),
257  //'t.datec' => array('label' => $langs->trans("DateCreation"), 'checked' => 0, 'position' => 500),
258  //'t.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => 0, 'position' => 2)
259  //'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
260  );
261 
262  if (empty($conf->global->TICKET_SHOW_PROGRESSION))
263  unset($arrayfields['t.progress']);
264 
265  // Extra fields
266  if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
267  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
268  if ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate') {
269  $enabled = abs(dol_eval($extrafields->attributes[$object->table_element]['list'][$key], 1, 1, 0));
270  $enabled = (($enabled == 0 || $enabled == 3) ? 0 : $enabled);
271  $arrayfields["ef.".$key] = array('label' => $extrafields->attributes[$object->table_element]['label'][$key], 'checked' => ($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1, 'position' => $extrafields->attributes[$object->table_element]['pos'][$key], 'enabled' => $enabled && $extrafields->attributes[$object->table_element]['perms'][$key]);
272  }
273  }
274  }
275  if (!empty($search_subject)) {
276  $filter['t.subject'] = $search_subject;
277  $param .= '&search_subject='.urlencode($search_subject);
278  }
279  if (!empty($search_type)) {
280  $filter['t.type_code'] = $search_type;
281  $param .= '&search_type='.urlencode($search_type);
282  }
283  if (!empty($search_category)) {
284  $filter['t.category_code'] = $search_category;
285  $param .= '&search_category='.urlencode($search_category);
286  }
287  if (!empty($search_severity)) {
288  $filter['t.severity_code'] = $search_severity;
289  $param .= '&search_severity='.urlencode($search_severity);
290  }
291  if (!empty($search_fk_user_assign)) {
292  // -1 value = all so no filter
293  if ($search_fk_user_assign > 0) {
294  $filter['t.fk_user_assign'] = $search_fk_user_assign;
295  $param .= '&search_fk_user_assign='.urlencode($search_fk_user_assign);
296  }
297  }
298  if (!empty($search_fk_user_create)) {
299  // -1 value = all so no filter
300  if ($search_fk_user_create > 0) {
301  $filter['t.fk_user_create'] = $search_fk_user_create;
302  $param .= '&search_fk_user_create='.urlencode($search_fk_user_create);
303  }
304  }
305  if ((isset($search_fk_status) && $search_fk_status != '') && $search_fk_status != '-1' && $search_fk_status != 'non_closed') {
306  $filter['t.fk_statut'] = $search_fk_status;
307  $param .= '&search_fk_status='.urlencode($search_fk_status);
308  }
309  if (isset($search_fk_status) && $search_fk_status == 'non_closed') {
310  $filter['t.fk_statut'] = array(0, 1, 3, 4, 5, 6);
311  $param .= '&search_fk_status=non_closed';
312  }
313 
314  require DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
315 
316  $sortfield = GETPOST('sortfield', 'aZ09comma');
317  $sortorder = GETPOST('sortorder', 'aZ09comma');
318 
319  if (!$sortfield) {
320  $sortfield = 't.datec';
321  }
322  if (!$sortorder) {
323  $sortorder = 'DESC';
324  }
325 
326  $limit = $conf->liste_limit;
327 
328  $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
329  if (empty($page) || $page == -1) {
330  $page = 0;
331  } // If $page is not defined, or '' or -1
332  $offset = $limit * $page;
333  $pageprev = $page - 1;
334  $pagenext = $page + 1;
335 
336  // Request SQL
337  $sql = "SELECT DISTINCT";
338  $sql .= " t.rowid,";
339  $sql .= " t.ref,";
340  $sql .= " t.track_id,";
341  $sql .= " t.fk_soc,";
342  $sql .= " t.fk_project,";
343  $sql .= " t.origin_email,";
344  $sql .= " t.fk_user_create, uc.lastname as user_create_lastname, uc.firstname as user_create_firstname,";
345  $sql .= " t.fk_user_assign, ua.lastname as user_assign_lastname, ua.firstname as user_assign_firstname,";
346  $sql .= " t.subject,";
347  $sql .= " t.message,";
348  $sql .= " t.fk_statut,";
349  $sql .= " t.resolution,";
350  if (!empty($conf->global->TICKET_SHOW_PROGRESSION))
351  $sql .= " t.progress,";
352  $sql .= " t.timing,";
353  $sql .= " t.type_code,";
354  $sql .= " t.category_code,";
355  $sql .= " t.severity_code,";
356  $sql .= " t.datec,";
357  $sql .= " t.date_read,";
358  $sql .= " t.date_close,";
359  $sql .= " t.tms,";
360  $sql .= " type.label as type_label, category.label as category_label, severity.label as severity_label";
361  // Add fields for extrafields
362  if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
363  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
364  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
365  }
366  }
367  $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t";
368  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code = t.type_code";
369  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code = t.category_code";
370  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code = t.severity_code";
371  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc";
372  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as uc ON uc.rowid = t.fk_user_create";
373  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as ua ON ua.rowid = t.fk_user_assign";
374  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact as ec ON ec.element_id = t.rowid";
375  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON ec.fk_c_type_contact = tc.rowid";
376  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople sp ON ec.fk_socpeople = sp.rowid";
377  if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
378  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."ticket_extrafields as ef on (t.rowid = ef.fk_object)";
379  }
380  $sql .= " WHERE t.entity IN (".getEntity('ticket').")";
381  $sql .= " AND ((tc.source = 'external'";
382  $sql .= " AND tc.element='".$db->escape($object->element)."'";
383  $sql .= " AND tc.active=1";
384  $sql .= " AND sp.email='".$db->escape($_SESSION['email_customer'])."')"; // email found into an external contact
385  $sql .= " OR s.email='".$db->escape($_SESSION['email_customer'])."'"; // or email of the linked company
386  $sql .= " OR t.origin_email='".$db->escape($_SESSION['email_customer'])."')"; // or email of the requester
387  // Manage filter
388  if (!empty($filter)) {
389  foreach ($filter as $key => $value) {
390  if (strpos($key, 'date')) { // To allow $filter['YEAR(s.dated)']=>$year
391  $sql .= " AND ".$key." = '".$db->escape($value)."'";
392  } elseif (($key == 't.fk_user_assign') || ($key == 't.type_code') || ($key == 't.category_code') || ($key == 't.severity_code')) {
393  $sql .= " AND ".$key." = '".$db->escape($value)."'";
394  } elseif ($key == 't.fk_statut') {
395  if (is_array($value) && count($value) > 0) {
396  $sql .= " AND ".$key." IN (".$db->sanitize(implode(',', $value)).")";
397  } else {
398  $sql .= " AND ".$key." = ".((int) $value);
399  }
400  } else {
401  $sql .= " AND ".$key." LIKE '%".$db->escape($value)."%'";
402  }
403  }
404  }
405  //$sql .= " GROUP BY t.track_id";
406  $sql .= $db->order($sortfield, $sortorder);
407 
408  $resql = $db->query($sql);
409  if ($resql) {
410  $num_total = $db->num_rows($resql);
411  if (!empty($limit)) {
412  $sql .= $db->plimit($limit + 1, $offset);
413  }
414 
415  $resql = $db->query($sql);
416  if ($resql) {
417  $num = $db->num_rows($resql);
418 
419  print_barre_liste($langs->trans('TicketList'), $page, 'list.php', $param, $sortfield, $sortorder, '', $num, $num_total, 'ticket');
420 
421  // Search bar
422  print '<form method="POST" action="'.$_SERVER['PHP_SELF'].(!empty($entity) && isModEnabled('multicompany')?'?entity='.$entity:'').'" id="searchFormList" >'."\n";
423  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
424  print '<input type="hidden" name="token" value="'.newToken().'">';
425  print '<input type="hidden" name="action" value="view_ticketlist">';
426  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
427  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
428 
429  $varpage = empty($contextpage) ? $url_page_current : $contextpage;
430  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
431 
432  // allow to display information before list
433  $parameters=array('arrayfields'=>$arrayfields);
434  $reshook=$hookmanager->executeHooks('printFieldListHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
435  print $hookmanager->resPrint;
436 
437  print '<div class="div-table-responsive">';
438  print '<table class="liste '.($moreforfilter ? "listwithfilterbefore" : "").'">';
439 
440  // Filter bar
441  print '<tr class="liste_titre">';
442 
443  if (!empty($arrayfields['t.datec']['checked'])) {
444  print '<td class="liste_titre"></td>';
445  }
446 
447  if (!empty($arrayfields['t.date_read']['checked'])) {
448  print '<td class="liste_titre"></td>';
449  }
450  if (!empty($arrayfields['t.date_close']['checked'])) {
451  print '<td class="liste_titre"></td>';
452  }
453 
454  if (!empty($arrayfields['t.ref']['checked'])) {
455  print '<td class="liste_titre"></td>';
456  }
457 
458  if (!empty($arrayfields['t.subject']['checked'])) {
459  print '<td class="liste_titre">';
460  print '<input type="text" class="flat maxwidth100" name="search_subject" value="'.$search_subject.'">';
461  print '</td>';
462  }
463 
464  if (!empty($arrayfields['type.code']['checked'])) {
465  print '<td class="liste_titre">';
466  $formTicket->selectTypesTickets($search_type, 'search_type', '', 2, 1, 1, 0, 'maxwidth150');
467  print '</td>';
468  }
469 
470  if (!empty($arrayfields['category.code']['checked'])) {
471  print '<td class="liste_titre">';
472  $formTicket->selectGroupTickets($search_category, 'search_category', 'public=1', 2, 1, 1);
473  print '</td>';
474  }
475 
476  if (!empty($arrayfields['severity.code']['checked'])) {
477  print '<td class="liste_titre">';
478  $formTicket->selectSeveritiesTickets($search_severity, 'search_severity', '', 2, 1, 1);
479  print '</td>';
480  }
481 
482  if ((!empty($conf->global->TICKET_SHOW_PROGRESSION)) && !empty($arrayfields['t.progress']['checked'])) {
483  print '<td class="liste_titre"></td>';
484  }
485 
486  if (!empty($arrayfields['t.fk_user_create']['checked'])) {
487  print '<td class="liste_titre"></td>';
488  }
489 
490  if (!empty($arrayfields['t.fk_user_assign']['checked'])) {
491  print '<td class="liste_titre"></td>';
492  }
493 
494  if (!empty($arrayfields['t.tms']['checked'])) {
495  print '<td class="liste_titre"></td>';
496  }
497 
498  // Extra fields
499  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
500 
501  // Fields from hook
502  $parameters = array('arrayfields'=>$arrayfields);
503  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
504  print $hookmanager->resPrint;
505 
506  // Status ticket
507  if (!empty($arrayfields['t.fk_statut']['checked'])) {
508  print '<td class="liste_titre">';
509  $selected = ($search_fk_status != "non_closed" ? $search_fk_status : '');
510  //$object->printSelectStatus($selected);
511  print '</td>';
512  }
513 
514  // Action column
515  print '<td class="liste_titre maxwidthsearch">';
516  $searchpicto = $form->showFilterButtons();
517  print $searchpicto;
518  print '</td>';
519  print '</tr>';
520 
521  // Field title
522  print '<tr class="liste_titre">';
523  if (!empty($arrayfields['t.datec']['checked'])) {
524  print_liste_field_titre($arrayfields['t.datec']['label'], $url_page_current, 't.datec', '', $param, '', $sortfield, $sortorder);
525  }
526  if (!empty($arrayfields['t.date_read']['checked'])) {
527  print_liste_field_titre($arrayfields['t.date_read']['label'], $url_page_current, 't.date_read', '', $param, '', $sortfield, $sortorder);
528  }
529  if (!empty($arrayfields['t.date_close']['checked'])) {
530  print_liste_field_titre($arrayfields['t.date_close']['label'], $url_page_current, 't.date_close', '', $param, '', $sortfield, $sortorder);
531  }
532  if (!empty($arrayfields['t.ref']['checked'])) {
533  print_liste_field_titre($arrayfields['t.ref']['label'], $url_page_current, 't.ref', '', $param, '', $sortfield, $sortorder);
534  }
535  if (!empty($arrayfields['t.subject']['checked'])) {
536  print_liste_field_titre($arrayfields['t.subject']['label']);
537  }
538  if (!empty($arrayfields['type.code']['checked'])) {
539  print_liste_field_titre($arrayfields['type.code']['label'], $url_page_current, 'type.code', '', $param, '', $sortfield, $sortorder);
540  }
541  if (!empty($arrayfields['category.code']['checked'])) {
542  print_liste_field_titre($arrayfields['category.code']['label'], $url_page_current, 'category.code', '', $param, '', $sortfield, $sortorder);
543  }
544  if (!empty($arrayfields['severity.code']['checked'])) {
545  print_liste_field_titre($arrayfields['severity.code']['label'], $url_page_current, 'severity.code', '', $param, '', $sortfield, $sortorder);
546  }
547  if ((!empty($conf->global->TICKET_SHOW_PROGRESSION)) && !empty($arrayfields['t.progress']['checked'])) {
548  print_liste_field_titre($arrayfields['t.progress']['label'], $url_page_current, 't.progress', '', $param, '', $sortfield, $sortorder);
549  }
550  if (!empty($arrayfields['t.fk_user_create']['checked'])) {
551  print_liste_field_titre($arrayfields['t.fk_user_create']['label'], $url_page_current, 't.fk_user_create', '', $param, '', $sortfield, $sortorder);
552  }
553  if (!empty($arrayfields['t.fk_user_assign']['checked'])) {
554  print_liste_field_titre($arrayfields['t.fk_user_assign']['label'], $url_page_current, 't.fk_user_assign', '', $param, '', $sortfield, $sortorder);
555  }
556  if (!empty($arrayfields['t.tms']['checked'])) {
557  print_liste_field_titre($arrayfields['t.tms']['label'], $url_page_current, 't.tms', '', $param, '', $sortfield, $sortorder);
558  }
559 
560  // Extra fields
561  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
562 
563  // Hook fields
564  $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
565  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
566  print $hookmanager->resPrint;
567 
568  if (!empty($arrayfields['t.fk_statut']['checked'])) {
569  print_liste_field_titre($arrayfields['t.fk_statut']['label'], $url_page_current, 't.fk_statut', '', $param, '', $sortfield, $sortorder);
570  }
571  print_liste_field_titre($selectedfields, $url_page_current, "", '', '', 'align="right"', $sortfield, $sortorder, 'center maxwidthsearch ');
572  print '</tr>';
573 
574  while ($obj = $db->fetch_object($resql)) {
575  print '<tr class="oddeven">';
576 
577  // Date ticket
578  if (!empty($arrayfields['t.datec']['checked'])) {
579  print '<td>';
580  print dol_print_date($db->jdate($obj->datec), 'dayhour');
581  print '</td>';
582  }
583 
584  // Date read
585  if (!empty($arrayfields['t.date_read']['checked'])) {
586  print '<td>';
587  print dol_print_date($db->jdate($obj->date_read), 'dayhour');
588  print '</td>';
589  }
590 
591  // Date close
592  if (!empty($arrayfields['t.date_close']['checked'])) {
593  print '<td>';
594  print dol_print_date($db->jdate($obj->date_close), 'dayhour');
595  print '</td>';
596  }
597 
598  // Ref
599  if (!empty($arrayfields['t.ref']['checked'])) {
600  print '<td class="nowraponall">';
601  print '<a rel="nofollow" href="javascript:viewticket(\''.dol_escape_js($obj->track_id).'\',\''.dol_escape_js($_SESSION['email_customer']).'\');">';
602  print img_picto('', 'ticket', 'class="paddingrightonly"');
603  print $obj->ref;
604  print '</a>';
605  print '</td>';
606  }
607 
608  // Subject
609  if (!empty($arrayfields['t.subject']['checked'])) {
610  print '<td>';
611  print '<a rel="nofollow" href="javascript:viewticket(\''.dol_escape_js($obj->track_id).'\',\''.dol_escape_js($_SESSION['email_customer']).'\');">';
612  print $obj->subject;
613  print '</a>';
614  print '</td>';
615  }
616 
617  // Type
618  if (!empty($arrayfields['type.code']['checked'])) {
619  print '<td>';
620  print $obj->type_label;
621  print '</td>';
622  }
623 
624  // Category
625  if (!empty($arrayfields['category.code']['checked'])) {
626  print '<td>';
627  print $obj->category_label;
628  print '</td>';
629  }
630 
631  // Severity
632  if (!empty($arrayfields['severity.code']['checked'])) {
633  print '<td>';
634  print $obj->severity_label;
635  print '</td>';
636  }
637 
638  // Progression
639  if ((!empty($conf->global->TICKET_SHOW_PROGRESSION)) && !empty($arrayfields['t.progress']['checked'])) {
640  print '<td>';
641  print $obj->progress;
642  print '</td>';
643  }
644 
645  // Message author
646  if (!empty($arrayfields['t.fk_user_create']['checked'])) {
647  print '<td title="'.dol_escape_htmltag($obj->origin_email).'">';
648  if ($obj->fk_user_create > 0) {
649  $user_create->firstname = (!empty($obj->user_create_firstname) ? $obj->user_create_firstname : '');
650  $user_create->name = (!empty($obj->user_create_lastname) ? $obj->user_create_lastname : '');
651  $user_create->id = (!empty($obj->fk_user_create) ? $obj->fk_user_create : '');
652  print $user_create->getFullName($langs);
653  } else {
654  print img_picto('', 'email', 'class="paddingrightonly"');
655  print $langs->trans('Email');
656  }
657  print '</td>';
658  }
659 
660  // Assigned author
661  if (!empty($arrayfields['t.fk_user_assign']['checked'])) {
662  print '<td>';
663  if ($obj->fk_user_assign > 0) {
664  $user_assign->firstname = (!empty($obj->user_assign_firstname) ? $obj->user_assign_firstname : '');
665  $user_assign->lastname = (!empty($obj->user_assign_lastname) ? $obj->user_assign_lastname : '');
666  $user_assign->id = (!empty($obj->fk_user_assign) ? $obj->fk_user_assign : '');
667  print img_picto('', 'user', 'class="paddingrightonly"');
668  print $user_assign->getFullName($langs);
669  }
670  print '</td>';
671  }
672 
673  if (!empty($arrayfields['t.tms']['checked'])) {
674  print '<td>'.dol_print_date($db->jdate($obj->tms), 'dayhour').'</td>';
675  }
676 
677  // Extra fields
678  if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
679  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
680  if (!empty($arrayfields["ef.".$key]['checked'])) {
681  print '<td';
682  $cssstring = $extrafields->getAlignFlag($key, $object->table_element);
683  if ($cssstring) {
684  print ' class="'.$cssstring.'"';
685  }
686  print '>';
687  $tmpkey = 'options_'.$key;
688  print $extrafields->showOutputField($key, $obj->$tmpkey, '', $object->table_element);
689  print '</td>';
690  }
691  }
692  }
693 
694  // Statut
695  if (!empty($arrayfields['t.fk_statut']['checked'])) {
696  print '<td class="nowraponall">';
697  $object->fk_statut = $obj->fk_statut;
698  print $object->getLibStatut(2);
699  print '</td>';
700  }
701 
702  print '<td></td>';
703 
704  $i++;
705  print '</tr>';
706  }
707 
708  print '</table>';
709  print '</div>';
710 
711  print '</form>';
712 
713  print '<form method="post" id="form_view_ticket" name="form_view_ticket" action="'.dol_buildpath('/public/ticket/view.php', 1).(!empty($entity) && isModEnabled('multicompany')?'?entity='.$entity:'').'" style="display:none;">';
714  print '<input type="hidden" name="token" value="'.newToken().'">';
715  print '<input type="hidden" name="action" value="view_ticket">';
716  print '<input type="hidden" name="btn_view_ticket_list" value="1">';
717  print '<input type="hidden" name="track_id" value="">';
718  print '<input type="hidden" name="email" value="">';
719  print "</form>";
720  print '<script type="text/javascript">
721  function viewticket(ticket_id, email) {
722  var form = $("#form_view_ticket");
723  form.find("input[name=\\"track_id\\"]").val(ticket_id);
724  form.find("input[name=\\"email\\"]").val(email);
725  form.submit();
726  }
727  </script>';
728  }
729  } else {
730  dol_print_error($db);
731  }
732  } else {
733  print '<div class="error">Not Allowed<br><a href="'.$_SERVER['PHP_SELF'].'?track_id='.$object->track_id.'">'.$langs->trans('Back').'</a></div>';
734  }
735 
736  print '</div>';
737 } else {
738  print '<div class="ticketpublicarea ticketlargemargin centpercent">';
739 
740  print '<p class="center opacitymedium">'.$langs->trans("TicketPublicMsgViewLogIn").'</p>';
741  print '<br>';
742 
743  print '<div id="form_view_ticket">';
744  print '<form method="post" name="form_view_ticketlist" action="'.$_SERVER['PHP_SELF'].(!empty($entity) && isModEnabled('multicompany')?'?entity='.$entity:'').'">';
745  print '<input type="hidden" name="token" value="'.newToken().'">';
746  print '<input type="hidden" name="action" value="view_ticketlist">';
747  //print '<input type="hidden" name="search_fk_status" value="non_closed">';
748 
749  print '<p><label for="track_id" style="display: inline-block; width: 30%; "><span class="fieldrequired">'.$langs->trans("OneOfTicketTrackId").'</span></label>';
750  print '<input size="30" id="track_id" name="track_id" value="'.(GETPOST('track_id', 'alpha') ? GETPOST('track_id', 'alpha') : '').'" />';
751  print '</p>';
752 
753  print '<p><label for="email" style="display: inline-block; width: 30%; "><span class="fieldrequired">'.$langs->trans('Email').'</span></label>';
754  print '<input size="30" id="email" name="email" value="'.(GETPOST('email', 'alpha') ? GETPOST('email', 'alpha') : (!empty($_SESSION['customer_email']) ? $_SESSION['customer_email'] : "")).'" />';
755  print '</p>';
756 
757  print '<p style="text-align: center; margin-top: 1.5em;">';
758  print '<input type="submit" class="button" name="btn_view_ticket_list" value="'.$langs->trans('ViewMyTicketList').'" />';
759  print ' &nbsp; ';
760  print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
761  print "</p>\n";
762 
763  print "</form>\n";
764  print "</div>\n";
765 
766  print "</div>";
767 }
768 
769 if (getDolGlobalInt('TICKET_SHOW_COMPANY_FOOTER')) {
770  // End of page
771  htmlPrintOnlineFooter($mysoc, $langs, 0, $suffix, $object);
772 }
773 
774 llxFooter('', 'public');
775 
776 $db->close();
static getValidAddress($address, $format, $encode=0, $maxnumberofemail=0)
Return a formatted address string for SMTP protocol.
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
Class to manage Dolibarr users.
Definition: user.class.php:48
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
isModEnabled($module)
Is Dolibarr module enabled.
table tableforfield button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
Definition: style.css.php:848
Class to generate the form for creating a new ticket.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:123
httponly_accessforbidden($message=1, $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.
llxHeaderTicket($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='')
Show http header, open body tag and show HTML header banner for public pages for tickets.
Definition: ticket.lib.php:216