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