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