dolibarr  16.0.5
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 
230  $param = '&action=view_ticketlist';
231  if (!empty($entity) && !empty($conf->multicompany->enabled)) {
232  $param .= '&entity='.((int) $entity);
233  }
234 
235  // Definition of fields for list
236  $arrayfields = array(
237  't.datec' => array('label' => $langs->trans("Date"), 'checked' => 1),
238  't.date_read' => array('label' => $langs->trans("TicketReadOn"), 'checked' => 0),
239  't.date_close' => array('label' => $langs->trans("TicketCloseOn"), 'checked' => 0),
240  't.ref' => array('label' => $langs->trans("Ref"), 'checked' => 1),
241  //'t.track_id' => array('label' => $langs->trans("IDTracking"), 'checked' => 0),
242  't.fk_statut' => array('label' => $langs->trans("Status"), 'checked' => 1),
243  't.subject' => array('label' => $langs->trans("Subject"), 'checked' => 1),
244  'type.code' => array('label' => $langs->trans("Type"), 'checked' => 1),
245  'category.code' => array('label' => $langs->trans("Category"), 'checked' => 1),
246  'severity.code' => array('label' => $langs->trans("Severity"), 'checked' => 1),
247  't.progress' => array('label' => $langs->trans("Progression"), 'checked' => 0),
248  //'t.fk_contract' => array('label' => $langs->trans("Contract"), 'checked' => 0),
249  't.fk_user_create' => array('label' => $langs->trans("Author"), 'checked' => 1),
250  't.fk_user_assign' => array('label' => $langs->trans("AssignedTo"), 'checked' => 0),
251 
252  //'t.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))),
253  //'t.datec' => array('label' => $langs->trans("DateCreation"), 'checked' => 0, 'position' => 500),
254  //'t.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => 0, 'position' => 2)
255  //'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
256  );
257 
258  // Extra fields
259  if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
260  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
261  if ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate') {
262  $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]);
263  }
264  }
265  }
266  if (!empty($search_subject)) {
267  $filter['t.subject'] = $search_subject;
268  $param .= '&search_subject='.urlencode($search_subject);
269  }
270  if (!empty($search_type)) {
271  $filter['t.type_code'] = $search_type;
272  $param .= '&search_type='.urlencode($search_type);
273  }
274  if (!empty($search_category)) {
275  $filter['t.category_code'] = $search_category;
276  $param .= '&search_category='.urlencode($search_category);
277  }
278  if (!empty($search_severity)) {
279  $filter['t.severity_code'] = $search_severity;
280  $param .= '&search_severity='.urlencode($search_severity);
281  }
282  if (!empty($search_fk_user_assign)) {
283  // -1 value = all so no filter
284  if ($search_fk_user_assign > 0) {
285  $filter['t.fk_user_assign'] = $search_fk_user_assign;
286  $param .= '&search_fk_user_assign='.urlencode($search_fk_user_assign);
287  }
288  }
289  if (!empty($search_fk_user_create)) {
290  // -1 value = all so no filter
291  if ($search_fk_user_create > 0) {
292  $filter['t.fk_user_create'] = $search_fk_user_create;
293  $param .= '&search_fk_user_create='.urlencode($search_fk_user_create);
294  }
295  }
296  if ((isset($search_fk_status) && $search_fk_status != '') && $search_fk_status != '-1' && $search_fk_status != 'non_closed') {
297  $filter['t.fk_statut'] = $search_fk_status;
298  $param .= '&search_fk_status='.urlencode($search_fk_status);
299  }
300  if (isset($search_fk_status) && $search_fk_status == 'non_closed') {
301  $filter['t.fk_statut'] = array(0, 1, 3, 4, 5, 6);
302  $param .= '&search_fk_status=non_closed';
303  }
304 
305  require DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
306 
307  $sortfield = GETPOST('sortfield', 'aZ09comma');
308  $sortorder = GETPOST('sortorder', 'aZ09comma');
309 
310  if (!$sortfield) {
311  $sortfield = 't.datec';
312  }
313  if (!$sortorder) {
314  $sortorder = 'DESC';
315  }
316 
317  $limit = $conf->liste_limit;
318 
319  $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
320  if (empty($page) || $page == -1) {
321  $page = 0;
322  } // If $page is not defined, or '' or -1
323  $offset = $limit * $page;
324  $pageprev = $page - 1;
325  $pagenext = $page + 1;
326 
327  // Request SQL
328  $sql = "SELECT DISTINCT";
329  $sql .= " t.rowid,";
330  $sql .= " t.ref,";
331  $sql .= " t.track_id,";
332  $sql .= " t.fk_soc,";
333  $sql .= " t.fk_project,";
334  $sql .= " t.origin_email,";
335  $sql .= " t.fk_user_create, uc.lastname as user_create_lastname, uc.firstname as user_create_firstname,";
336  $sql .= " t.fk_user_assign, ua.lastname as user_assign_lastname, ua.firstname as user_assign_firstname,";
337  $sql .= " t.subject,";
338  $sql .= " t.message,";
339  $sql .= " t.fk_statut,";
340  $sql .= " t.resolution,";
341  $sql .= " t.progress,";
342  $sql .= " t.timing,";
343  $sql .= " t.type_code,";
344  $sql .= " t.category_code,";
345  $sql .= " t.severity_code,";
346  $sql .= " t.datec,";
347  $sql .= " t.date_read,";
348  $sql .= " t.date_close,";
349  $sql .= " t.tms,";
350  $sql .= " type.label as type_label, category.label as category_label, severity.label as severity_label";
351  // Add fields for extrafields
352  if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
353  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
354  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
355  }
356  }
357  $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t";
358  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code = t.type_code";
359  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code = t.category_code";
360  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code = t.severity_code";
361  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc";
362  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as uc ON uc.rowid = t.fk_user_create";
363  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as ua ON ua.rowid = t.fk_user_assign";
364  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact as ec ON ec.element_id = t.rowid";
365  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON ec.fk_c_type_contact = tc.rowid";
366  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople sp ON ec.fk_socpeople = sp.rowid";
367  if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
368  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."ticket_extrafields as ef on (t.rowid = ef.fk_object)";
369  }
370  $sql .= " WHERE t.entity IN (".getEntity('ticket').")";
371  $sql .= " AND ((tc.source = 'external'";
372  $sql .= " AND tc.element='".$db->escape($object->element)."'";
373  $sql .= " AND tc.active=1";
374  $sql .= " AND sp.email='".$db->escape($_SESSION['email_customer'])."')"; // email found into an external contact
375  $sql .= " OR s.email='".$db->escape($_SESSION['email_customer'])."'"; // or email of the linked company
376  $sql .= " OR t.origin_email='".$db->escape($_SESSION['email_customer'])."')"; // or email of the requester
377  // Manage filter
378  if (!empty($filter)) {
379  foreach ($filter as $key => $value) {
380  if (strpos($key, 'date')) { // To allow $filter['YEAR(s.dated)']=>$year
381  $sql .= " AND ".$key." = '".$db->escape($value)."'";
382  } elseif (($key == 't.fk_user_assign') || ($key == 't.type_code') || ($key == 't.category_code') || ($key == 't.severity_code')) {
383  $sql .= " AND ".$key." = '".$db->escape($value)."'";
384  } elseif ($key == 't.fk_statut') {
385  if (is_array($value) && count($value) > 0) {
386  $sql .= " AND ".$key." IN (".$db->sanitize(implode(',', $value)).")";
387  } else {
388  $sql .= " AND ".$key." = ".((int) $value);
389  }
390  } else {
391  $sql .= " AND ".$key." LIKE '%".$db->escape($value)."%'";
392  }
393  }
394  }
395  //$sql .= " GROUP BY t.track_id";
396  $sql .= $db->order($sortfield, $sortorder);
397 
398  $resql = $db->query($sql);
399  if ($resql) {
400  $num_total = $db->num_rows($resql);
401  if (!empty($limit)) {
402  $sql .= $db->plimit($limit + 1, $offset);
403  }
404 
405  $resql = $db->query($sql);
406  if ($resql) {
407  $num = $db->num_rows($resql);
408 
409  print_barre_liste($langs->trans('TicketList'), $page, 'list.php', $param, $sortfield, $sortorder, '', $num, $num_total, 'ticket');
410 
411  // Search bar
412  print '<form method="POST" action="'.$_SERVER['PHP_SELF'].(!empty($entity) && !empty($conf->multicompany->enabled)?'?entity='.$entity:'').'" id="searchFormList" >'."\n";
413  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
414  print '<input type="hidden" name="action" value="view_ticketlist">';
415  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
416  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
417 
418  $varpage = empty($contextpage) ? $url_page_current : $contextpage;
419  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
420 
421  // allow to display information before list
422  $parameters=array('arrayfields'=>$arrayfields);
423  $reshook=$hookmanager->executeHooks('printFieldListHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
424  print $hookmanager->resPrint;
425 
426  print '<table class="liste '.($moreforfilter ? "listwithfilterbefore" : "").'">';
427 
428  // Filter bar
429  print '<tr class="liste_titre">';
430 
431  if (!empty($arrayfields['t.datec']['checked'])) {
432  print '<td class="liste_titre"></td>';
433  }
434 
435  if (!empty($arrayfields['t.date_read']['checked'])) {
436  print '<td class="liste_titre"></td>';
437  }
438  if (!empty($arrayfields['t.date_close']['checked'])) {
439  print '<td class="liste_titre"></td>';
440  }
441 
442  if (!empty($arrayfields['t.ref']['checked'])) {
443  print '<td class="liste_titre"></td>';
444  }
445 
446  if (!empty($arrayfields['t.subject']['checked'])) {
447  print '<td class="liste_titre">';
448  print '<input type="text" class="flat maxwidth100" name="search_subject" value="'.$search_subject.'">';
449  print '</td>';
450  }
451 
452  if (!empty($arrayfields['type.code']['checked'])) {
453  print '<td class="liste_titre">';
454  $formTicket->selectTypesTickets($search_type, 'search_type', '', 2, 1, 1, 0, 'maxwidth150');
455  print '</td>';
456  }
457 
458  if (!empty($arrayfields['category.code']['checked'])) {
459  print '<td class="liste_titre">';
460  $formTicket->selectGroupTickets($search_category, 'search_category', 'public=1', 2, 1, 1);
461  print '</td>';
462  }
463 
464  if (!empty($arrayfields['severity.code']['checked'])) {
465  print '<td class="liste_titre">';
466  $formTicket->selectSeveritiesTickets($search_severity, 'search_severity', '', 2, 1, 1);
467  print '</td>';
468  }
469 
470  if (!empty($arrayfields['t.progress']['checked'])) {
471  print '<td class="liste_titre"></td>';
472  }
473 
474  if (!empty($arrayfields['t.fk_user_create']['checked'])) {
475  print '<td class="liste_titre"></td>';
476  }
477 
478  if (!empty($arrayfields['t.fk_user_assign']['checked'])) {
479  print '<td class="liste_titre"></td>';
480  }
481 
482  if (!empty($arrayfields['t.tms']['checked'])) {
483  print '<td class="liste_titre"></td>';
484  }
485 
486  // Extra fields
487  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
488 
489  // Fields from hook
490  $parameters = array('arrayfields'=>$arrayfields);
491  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
492  print $hookmanager->resPrint;
493 
494  // Status
495  if (!empty($arrayfields['t.fk_statut']['checked'])) {
496  print '<td class="liste_titre">';
497  $selected = ($search_fk_status != "non_closed" ? $search_fk_status : '');
498  //$object->printSelectStatus($selected);
499  print '</td>';
500  }
501 
502  // Action column
503  print '<td class="liste_titre maxwidthsearch">';
504  $searchpicto = $form->showFilterButtons();
505  print $searchpicto;
506  print '</td>';
507  print '</tr>';
508 
509  // Field title
510  print '<tr class="liste_titre">';
511  if (!empty($arrayfields['t.datec']['checked'])) {
512  print_liste_field_titre($arrayfields['t.datec']['label'], $url_page_current, 't.datec', '', $param, '', $sortfield, $sortorder);
513  }
514  if (!empty($arrayfields['t.date_read']['checked'])) {
515  print_liste_field_titre($arrayfields['t.date_read']['label'], $url_page_current, 't.date_read', '', $param, '', $sortfield, $sortorder);
516  }
517  if (!empty($arrayfields['t.date_close']['checked'])) {
518  print_liste_field_titre($arrayfields['t.date_close']['label'], $url_page_current, 't.date_close', '', $param, '', $sortfield, $sortorder);
519  }
520  if (!empty($arrayfields['t.ref']['checked'])) {
521  print_liste_field_titre($arrayfields['t.ref']['label'], $url_page_current, 't.ref', '', $param, '', $sortfield, $sortorder);
522  }
523  if (!empty($arrayfields['t.subject']['checked'])) {
524  print_liste_field_titre($arrayfields['t.subject']['label']);
525  }
526  if (!empty($arrayfields['type.code']['checked'])) {
527  print_liste_field_titre($arrayfields['type.code']['label'], $url_page_current, 'type.code', '', $param, '', $sortfield, $sortorder);
528  }
529  if (!empty($arrayfields['category.code']['checked'])) {
530  print_liste_field_titre($arrayfields['category.code']['label'], $url_page_current, 'category.code', '', $param, '', $sortfield, $sortorder);
531  }
532  if (!empty($arrayfields['severity.code']['checked'])) {
533  print_liste_field_titre($arrayfields['severity.code']['label'], $url_page_current, 'severity.code', '', $param, '', $sortfield, $sortorder);
534  }
535  if (!empty($arrayfields['t.progress']['checked'])) {
536  print_liste_field_titre($arrayfields['t.progress']['label'], $url_page_current, 't.progress', '', $param, '', $sortfield, $sortorder);
537  }
538  if (!empty($arrayfields['t.fk_user_create']['checked'])) {
539  print_liste_field_titre($arrayfields['t.fk_user_create']['label'], $url_page_current, 't.fk_user_create', '', $param, '', $sortfield, $sortorder);
540  }
541  if (!empty($arrayfields['t.fk_user_assign']['checked'])) {
542  print_liste_field_titre($arrayfields['t.fk_user_assign']['label'], $url_page_current, 't.fk_user_assign', '', $param, '', $sortfield, $sortorder);
543  }
544  if (!empty($arrayfields['t.tms']['checked'])) {
545  print_liste_field_titre($arrayfields['t.tms']['label'], $url_page_current, 't.tms', '', $param, '', $sortfield, $sortorder);
546  }
547 
548  // Extra fields
549  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
550 
551  // Hook fields
552  $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
553  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
554  print $hookmanager->resPrint;
555 
556  if (!empty($arrayfields['t.fk_statut']['checked'])) {
557  print_liste_field_titre($arrayfields['t.fk_statut']['label'], $url_page_current, 't.fk_statut', '', $param, '', $sortfield, $sortorder);
558  }
559  print_liste_field_titre($selectedfields, $url_page_current, "", '', '', 'align="right"', $sortfield, $sortorder, 'center maxwidthsearch ');
560  print '</tr>';
561 
562  while ($obj = $db->fetch_object($resql)) {
563  print '<tr class="oddeven">';
564 
565  // Date ticket
566  if (!empty($arrayfields['t.datec']['checked'])) {
567  print '<td>';
568  print dol_print_date($db->jdate($obj->datec), 'dayhour');
569  print '</td>';
570  }
571 
572  // Date read
573  if (!empty($arrayfields['t.date_read']['checked'])) {
574  print '<td>';
575  print dol_print_date($db->jdate($obj->date_read), 'dayhour');
576  print '</td>';
577  }
578 
579  // Date close
580  if (!empty($arrayfields['t.date_close']['checked'])) {
581  print '<td>';
582  print dol_print_date($db->jdate($obj->date_close), 'dayhour');
583  print '</td>';
584  }
585 
586  // Ref
587  if (!empty($arrayfields['t.ref']['checked'])) {
588  print '<td class="nowraponall">';
589  print '<a rel="nofollow" href="javascript:viewticket(\''.dol_escape_js($obj->track_id).'\',\''.dol_escape_js($_SESSION['email_customer']).'\');">';
590  print img_picto('', 'ticket', 'class="paddingrightonly"');
591  print $obj->ref;
592  print '</a>';
593  print '</td>';
594  }
595 
596  // Subject
597  if (!empty($arrayfields['t.subject']['checked'])) {
598  print '<td>';
599  print '<a rel="nofollow" href="javascript:viewticket(\''.dol_escape_js($obj->track_id).'\',\''.dol_escape_js($_SESSION['email_customer']).'\');">';
600  print $obj->subject;
601  print '</a>';
602  print '</td>';
603  }
604 
605  // Type
606  if (!empty($arrayfields['type.code']['checked'])) {
607  print '<td>';
608  print $obj->type_label;
609  print '</td>';
610  }
611 
612  // Category
613  if (!empty($arrayfields['category.code']['checked'])) {
614  print '<td>';
615  print $obj->category_label;
616  print '</td>';
617  }
618 
619  // Severity
620  if (!empty($arrayfields['severity.code']['checked'])) {
621  print '<td>';
622  print $obj->severity_label;
623  print '</td>';
624  }
625 
626  // Progression
627  if (!empty($arrayfields['t.progress']['checked'])) {
628  print '<td>';
629  print $obj->progress;
630  print '</td>';
631  }
632 
633  // Message author
634  if (!empty($arrayfields['t.fk_user_create']['checked'])) {
635  print '<td title="'.dol_escape_htmltag($obj->origin_email).'">';
636  if ($obj->fk_user_create > 0) {
637  $user_create->firstname = (!empty($obj->user_create_firstname) ? $obj->user_create_firstname : '');
638  $user_create->name = (!empty($obj->user_create_lastname) ? $obj->user_create_lastname : '');
639  $user_create->id = (!empty($obj->fk_user_create) ? $obj->fk_user_create : '');
640  print $user_create->getFullName($langs);
641  } else {
642  print img_picto('', 'email', 'class="paddingrightonly"');
643  print $langs->trans('Email');
644  }
645  print '</td>';
646  }
647 
648  // Assigned author
649  if (!empty($arrayfields['t.fk_user_assign']['checked'])) {
650  print '<td>';
651  if ($obj->fk_user_assign > 0) {
652  $user_assign->firstname = (!empty($obj->user_assign_firstname) ? $obj->user_assign_firstname : '');
653  $user_assign->lastname = (!empty($obj->user_assign_lastname) ? $obj->user_assign_lastname : '');
654  $user_assign->id = (!empty($obj->fk_user_assign) ? $obj->fk_user_assign : '');
655  print img_picto('', 'user', 'class="paddingrightonly"');
656  print $user_assign->getFullName($langs);
657  }
658  print '</td>';
659  }
660 
661  if (!empty($arrayfields['t.tms']['checked'])) {
662  print '<td>'.dol_print_date($db->jdate($obj->tms), 'dayhour').'</td>';
663  }
664 
665  // Extra fields
666  if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
667  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
668  if (!empty($arrayfields["ef.".$key]['checked'])) {
669  print '<td';
670  $cssstring = $extrafields->getAlignFlag($key, $object->table_element);
671  if ($cssstring) {
672  print ' class="'.$cssstring.'"';
673  }
674  print '>';
675  $tmpkey = 'options_'.$key;
676  print $extrafields->showOutputField($key, $obj->$tmpkey, '', $object->table_element);
677  print '</td>';
678  }
679  }
680  }
681 
682  // Statut
683  if (!empty($arrayfields['t.fk_statut']['checked'])) {
684  print '<td class="nowraponall">';
685  $object->fk_statut = $obj->fk_statut;
686  print $object->getLibStatut(2);
687  print '</td>';
688  }
689 
690  print '<td></td>';
691 
692  $i++;
693  print '</tr>';
694  }
695 
696  print '</table>';
697  print '</form>';
698 
699  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;">';
700  print '<input type="hidden" name="token" value="'.newToken().'">';
701  print '<input type="hidden" name="action" value="view_ticket">';
702  print '<input type="hidden" name="btn_view_ticket_list" value="1">';
703  print '<input type="hidden" name="track_id" value="">';
704  print '<input type="hidden" name="email" value="">';
705  print "</form>";
706  print '<script type="text/javascript">
707  function viewticket(ticket_id, email) {
708  var form = $("#form_view_ticket");
709  form.find("input[name=\\"track_id\\"]").val(ticket_id);
710  form.find("input[name=\\"email\\"]").val(email);
711  form.submit();
712  }
713  </script>';
714  }
715  } else {
716  dol_print_error($db);
717  }
718  } else {
719  print '<div class="error">Not Allowed<br><a href="'.$_SERVER['PHP_SELF'].'?track_id='.$object->track_id.'">'.$langs->trans('Back').'</a></div>';
720  }
721 
722  print '</div>';
723 } else {
724  print '<div class="ticketpublicarea">';
725 
726  print '<p class="center opacitymedium">'.$langs->trans("TicketPublicMsgViewLogIn").'</p>';
727  print '<br>';
728 
729  print '<div id="form_view_ticket">';
730  print '<form method="post" name="form_view_ticketlist" action="'.$_SERVER['PHP_SELF'].(!empty($entity) && !empty($conf->multicompany->enabled)?'?entity='.$entity:'').'">';
731  print '<input type="hidden" name="token" value="'.newToken().'">';
732  print '<input type="hidden" name="action" value="view_ticketlist">';
733  //print '<input type="hidden" name="search_fk_status" value="non_closed">';
734 
735  print '<p><label for="track_id" style="display: inline-block; width: 30%; "><span class="fieldrequired">'.$langs->trans("OneOfTicketTrackId").'</span></label>';
736  print '<input size="30" id="track_id" name="track_id" value="'.(GETPOST('track_id', 'alpha') ? GETPOST('track_id', 'alpha') : '').'" />';
737  print '</p>';
738 
739  print '<p><label for="email" style="display: inline-block; width: 30%; "><span class="fieldrequired">'.$langs->trans('Email').'</span></label>';
740  print '<input size="30" id="email" name="email" value="'.(GETPOST('email', 'alpha') ? GETPOST('email', 'alpha') : $_SESSION['customer_email']).'" />';
741  print '</p>';
742 
743  print '<p style="text-align: center; margin-top: 1.5em;">';
744  print '<input type="submit" class="button" name="btn_view_ticket_list" value="'.$langs->trans('ViewMyTicketList').'" />';
745  print ' &nbsp; ';
746  print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
747  print "</p>\n";
748 
749  print "</form>\n";
750  print "</div>\n";
751 
752  print "</div>";
753 }
754 
755 // End of page
756 htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix, $object);
757 
758 llxFooter('', 'public');
759 
760 $db->close();
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1062
llxHeaderTicket
llxHeaderTicket($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='')
Show header for public pages.
Definition: ticket.lib.php:206
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
name
$conf db name
Definition: repair.php:122
CMailFile\getValidAddress
static getValidAddress($address, $format, $encode=0, $maxnumberofemail=0)
Return a formatted address string for SMTP protocol.
Definition: CMailFile.class.php:1570
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
dol_escape_js
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
Definition: functions.lib.php:1423
isValidEmail
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
Definition: functions.lib.php:3681
print_barre_liste
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.
Definition: functions.lib.php:5257
FormTicket
Definition: html.formticket.class.php:43
User
Class to manage Dolibarr users.
Definition: user.class.php:44
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
print_liste_field_titre
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Definition: functions.lib.php:5026
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
$resql
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
Ticket
Class to generate the form for creating a new ticket.
Definition: html.formticket.class.php:31
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
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 ...
Definition: security.lib.php:933