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