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