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