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