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