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