dolibarr 23.0.3
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013-2018 Jean-François FERRY <hello@librethic.io>
3 * Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
4 * Copyright (C) 2018 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2019-2021 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2019-2020 Laurent Destailleur <eldy@users.sourceforge.net>
7 * Copyright (C) 2023 Charlene Benke <charlene@patas-monkey.com>
8 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
9 * Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.fr>
10 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 */
25
32// Load Dolibarr environment
33require '../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php';
35require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
39include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
40include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
41include_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
42
51// Load translation files required by the page
52$langs->loadLangs(array("ticket", "companies", "other", "projects", "contracts"));
53
54// Get parameters
55$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
56$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
57$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
58$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
59$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
60$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
61$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'ticketlist'; // To manage different context of search
62$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
63$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
64$mode = GETPOST('mode', 'alpha');
65
66$id = GETPOSTINT('id');
67$socid = GETPOSTINT('socid');
68$contractid = GETPOSTINT('contractid');
69$projectid = GETPOSTINT('projectid');
70$project_ref = GETPOST('project_ref', 'alpha');
71$search_societe = GETPOST('search_societe', 'alpha');
72$search_fk_project = GETPOSTINT('search_fk_project') ? GETPOSTINT('search_fk_project') : GETPOSTINT('projectid');
73$search_fk_contract = GETPOSTINT('search_fk_contract') ? GETPOSTINT('search_fk_contract') : GETPOSTINT('contractid');
74
75$search_date_start = dol_mktime(0, 0, 0, GETPOSTINT('search_date_startmonth'), GETPOSTINT('search_date_startday'), GETPOSTINT('search_date_startyear'));
76$search_date_end = dol_mktime(23, 59, 59, GETPOSTINT('search_date_endmonth'), GETPOSTINT('search_date_endday'), GETPOSTINT('search_date_endyear'));
77$search_dateread_start = dol_mktime(0, 0, 0, GETPOSTINT('search_dateread_startmonth'), GETPOSTINT('search_dateread_startday'), GETPOSTINT('search_dateread_startyear'));
78$search_dateread_end = dol_mktime(23, 59, 59, GETPOSTINT('search_dateread_endmonth'), GETPOSTINT('search_dateread_endday'), GETPOSTINT('search_dateread_endyear'));
79$search_dateclose_start = dol_mktime(0, 0, 0, GETPOSTINT('search_dateclose_startmonth'), GETPOSTINT('search_dateclose_startday'), GETPOSTINT('search_dateclose_startyear'));
80$search_dateclose_end = dol_mktime(23, 59, 59, GETPOSTINT('search_dateclose_endmonth'), GETPOSTINT('search_dateclose_endday'), GETPOSTINT('search_dateclose_endyear'));
81
82
83// Load variable for pagination
84$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
85$sortfield = GETPOST('sortfield', 'aZ09comma');
86$sortorder = GETPOST('sortorder', 'aZ09comma');
87$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
88if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
89 // If $page is not defined, or '' or -1 or if we click on clear filters
90 $page = 0;
91}
92$offset = $limit * $page;
93$pageprev = $page - 1;
94$pagenext = $page + 1;
95
96// Initialize a technical objects
97$object = new Ticket($db);
98$extrafields = new ExtraFields($db);
99$diroutputmassaction = $conf->ticket->dir_output.'/temp/massgeneration/'.$user->id;
100if ($socid > 0) {
101 $hookmanager->initHooks(array('thirdpartyticket', 'globalcard'));
102} elseif ($projectid > 0) {
103 $hookmanager->initHooks(array('projectticket', 'globalcard'));
104} else {
105 $hookmanager->initHooks(array('ticketlist'));
106}
107// Fetch optionals attributes and labels
108$extrafields->fetch_name_optionals_label($object->table_element);
109$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
110
111// Default sort order (if not yet defined by previous GETPOST)
112if (!$sortfield) {
113 $sortfield = "t.datec";
114}
115if (!$sortorder) {
116 $sortorder = "DESC";
117}
118
119/*if (GETPOST('search_fk_status', 'alpha') == 'non_closed') {
120 $_GET['search_fk_statut'][] = 'openall'; // For backward compatibility
121}*/
122
123// Initialize array of search criteria
124$search_all = trim(GETPOST("search_all", 'alphanohtml'));
125$search = array();
126foreach ($object->fields as $key => $val) {
127 if (GETPOSTISARRAY('search_'.$key)) {
128 $search[$key] = GETPOST('search_'.$key, 'array:alpha');
129 } elseif (GETPOST('search_'.$key, 'alpha') !== '') {
130 $search[$key] = GETPOST('search_'.$key, 'alpha');
131 } else {
132 $search[$key] = "";
133 }
134 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
135 $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOSTINT('search_'.$key.'_dtstartmonth'), GETPOSTINT('search_'.$key.'_dtstartday'), GETPOSTINT('search_'.$key.'_dtstartyear'));
136 $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOSTINT('search_'.$key.'_dtendmonth'), GETPOSTINT('search_'.$key.'_dtendday'), GETPOSTINT('search_'.$key.'_dtendyear'));
137 }
138}
139
140// List of fields to search into when doing a "search in all"
141$fieldstosearchall = array();
142foreach ($object->fields as $key => $val) {
143 if (!empty($val['searchall'])) {
144 $fieldstosearchall['t.'.$key] = $val['label'];
145 }
146}
147$fieldstosearchall['s.name_alias'] = "AliasNameShort";
148$fieldstosearchall['s.zip'] = "Zip";
149$fieldstosearchall['s.town'] = "Town";
150
151// Definition of array of fields for columns
152$arrayfields = array();
153foreach ($object->fields as $key => $val) {
154 // If $val['visible']==0, then we never show the field
155 if (!empty($val['visible'])) {
156 $visible = (int) dol_eval((string) $val['visible'], 1);
157 $arrayfields['t.'.$key] = array(
158 'label' => $val['label'],
159 'checked' => (($visible < 0) ? 0 : 1),
160 'enabled' => (abs($visible) != 3 && (bool) dol_eval((string) $val['enabled'], 1)),
161 'position' => $val['position'],
162 'help' => isset($val['help']) ? $val['help'] : ''
163 );
164 }
165}
166// Extra fields
167include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
168
169$object->fields = dol_sort_array($object->fields, 'position');
170$arrayfields = dol_sort_array($arrayfields, 'position');
171
172
173// Security check
174if (!$user->hasRight('ticket', 'read')) {
176}
177// restrict view to current user's company
178if ($user->socid > 0) {
179 $socid = $user->socid;
180}
181
182// Store current page url
183$url_page_current = DOL_URL_ROOT.'/ticket/list.php';
184
185if ($project_ref) {
186 $tmpproject = new Project($db);
187 $tmpproject->fetch(0, $project_ref);
188 $projectid = $tmpproject->id;
189 $search_fk_project = $projectid;
190}
191
192$permissiontoread = $user->hasRight('ticket', 'read');
193$permissiontoadd = $user->hasRight('ticket', 'write');
194$permissiontodelete = $user->hasRight('ticket', 'delete');
195
196$error = 0;
197
198
199/*
200 * Actions
201 */
202
203if (GETPOST('cancel', 'alpha')) {
204 $action = 'list';
205 $massaction = '';
206}
207if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'presendonclose' && $massaction != 'close') {
208 $massaction = '';
209}
210
211$parameters = array('arrayfields' => &$arrayfields);
212if ($socid > 0) {
213 $parameters['socid'] = $socid;
214}
215if ($projectid > 0) {
216 $parameters['projectid'] = $projectid;
217}
218$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
219if ($reshook < 0) {
220 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
221}
222
223if (empty($reshook)) {
224 // Selection of new fields
225 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
226
227 // Purge search criteria
228 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
229 foreach ($object->fields as $key => $val) {
230 $search[$key] = '';
231 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
232 $search[$key.'_dtstart'] = '';
233 $search[$key.'_dtend'] = '';
234 }
235 }
236 $toselect = array();
237 $search_array_options = array();
238 $search_societe = '';
239 $search_date_start = '';
240 $search_date_end = '';
241 $search_dateread_start = '';
242 $search_dateread_end = '';
243 $search_dateclose_start = '';
244 $search_dateclose_end = '';
245 }
246 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
247 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
248 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
249 }
250
251 // Mass actions
252 $objectclass = 'Ticket';
253 $objectlabel = 'Ticket';
254 $uploaddir = $conf->ticket->dir_output;
255
256 global $error;
257 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
258
259 // Close records
260 if (!$error && $massaction == 'close' && $permissiontoadd) {
261 $objecttmp = new Ticket($db);
262 $db->begin();
263
264 $nbok = 0;
265 foreach ($toselect as $toselectid) {
266 $result = $objecttmp->fetch($toselectid);
267 if ($result > 0) {
268 $result = $objecttmp->close($user);
269 if ($result < 0) {
270 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
271 $error++;
272 break;
273 } else {
274 $nbok++;
275 }
276 } else {
277 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
278 $error++;
279 break;
280 }
281 }
282
283 if (!$error) {
284 setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
285 $db->commit();
286 } else {
287 $db->rollback();
288 }
289 //var_dump($listofobjectthirdparties);exit;
290 }
291
292 // Reopen records
293 if (!$error && $massaction == 'reopen' && $permissiontoadd) {
294 $objecttmp = new Ticket($db);
295 $db->begin();
296
297 $nbok = 0;
298 foreach ($toselect as $toselectid) {
299 $result = $objecttmp->fetch($toselectid);
300 if ($result > 0) {
301 if ($objecttmp->status == Ticket::STATUS_CLOSED || $objecttmp->status == Ticket::STATUS_CANCELED) {
302 // Set status
303 $result = $objecttmp->setStatut(Ticket::STATUS_ASSIGNED, null, '', 'TICKET_MODIFY');
304
305 if ($result < 0) {
306 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
307 $error++;
308 break;
309 } else {
310 $nbok++;
311 }
312 } else {
313 $langs->load("errors");
314 setEventMessages($langs->trans("ErrorObjectMustHaveStatusClosedToBeReOpened", $objecttmp->ref), null, 'errors');
315 $error++;
316 break;
317 }
318 } else {
319 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
320 $error++;
321 break;
322 }
323 }
324
325 if (!$error) {
326 setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
327 $db->commit();
328 } else {
329 $db->rollback();
330 }
331 //var_dump($listofobjectthirdparties);exit;
332 }
333}
334
335
336
337/*
338 * View
339 */
340
341$form = new Form($db);
342$formTicket = new FormTicket($db);
343
344$now = dol_now();
345
346$user_temp = new User($db);
347$socstatic = new Societe($db);
348
349$help_url = '';
350
351$moretitle = '';
352if ($socid > 0) {
353 $socstatic->fetch($socid);
354 $moretitle = $langs->trans("ThirdParty") . ' - ';
355 if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $socstatic->name) {
356 $moretitle = $socstatic->name . ' - ';
357 }
358}
359
360$title = $moretitle . $langs->trans('Tickets');
361$morejs = array();
362$morecss = array();
363
364
365// Build and execute select
366// --------------------------------------------------------------------
367$sql = 'SELECT ';
368$sql .= $object->getFieldList('t');
369// Add fields from extrafields
370if (!empty($extrafields->attributes[$object->table_element]['label'])) {
371 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
372 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
373 }
374}
375// Add fields from hooks
376$parameters = array();
377$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
378$sql .= $hookmanager->resPrint;
379$sql = preg_replace('/,\s*$/', '', $sql);
380
381$sqlfields = $sql; // $sql fields to remove for count total
382
383$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
384if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
385 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
386}
387// Add table from hooks
388$parameters = array();
389$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
390$sql .= $hookmanager->resPrint;
391$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (t.fk_soc = s.rowid)";
392$sql .= " WHERE t.entity IN (".getEntity($object->element).")";
393if ($socid > 0) {
394 $sql .= " AND t.fk_soc = ".((int) $socid);
395}
396
397foreach ($search as $key => $val) {
398 $tmpkey = 't.' . $key;
399 if ($key == 'fk_statut' && !empty($search['fk_statut'])) {
400 $newarrayofstatus = array();
401 if (is_array($search['fk_statut'])) {
402 foreach ($search['fk_statut'] as $key2 => $val2) {
403 if (in_array($val2, array('openall', 'closeall'))) {
404 continue;
405 }
406 $newarrayofstatus[] = $val2;
407 }
408 }
409 if ($search['fk_statut'] === 'openall' || (is_array($search['fk_statut']) && in_array('openall', $search['fk_statut']))) {
410 $newarrayofstatus[] = Ticket::STATUS_NOT_READ;
411 $newarrayofstatus[] = Ticket::STATUS_READ;
412 $newarrayofstatus[] = Ticket::STATUS_ASSIGNED;
413 $newarrayofstatus[] = Ticket::STATUS_IN_PROGRESS;
414 $newarrayofstatus[] = Ticket::STATUS_NEED_MORE_INFO;
415 $newarrayofstatus[] = Ticket::STATUS_WAITING;
416 }
417 if ($search['fk_statut'] === 'closeall' || (is_array($search['fk_statut']) && in_array('closeall', $search['fk_statut']))) {
418 $newarrayofstatus[] = Ticket::STATUS_CLOSED;
419 $newarrayofstatus[] = Ticket::STATUS_CANCELED;
420 }
421 if (count($newarrayofstatus)) {
422 $sql .= natural_search($tmpkey, implode(',', $newarrayofstatus), 2);
423 }
424 continue;
425 } elseif ($key == 'fk_user_assign' || $key == 'fk_user_create' || $key == 'fk_project' || $key == 'fk_contract') {
426 if ($search[$key] > 0) {
427 $sql .= natural_search($tmpkey, $search[$key], 2);
428 }
429 continue;
430 } elseif ($key == 'type_code') {
431 $newarrayoftypecodes = is_array($search[$key]) ? $search[$key] : (!empty($search[$key]) ? explode(',', $search[$key]) : array());
432 if (count($newarrayoftypecodes)) {
433 $sql .= natural_search($tmpkey, implode(',', $newarrayoftypecodes), 3);
434 }
435 continue;
436 }
437
438 $mode_search = ((!empty($object->fields[$key]) && ($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))) ? 1 : 0);
439 // $search[$key] can be an array of values, or a string. We add filter if array not empty or if it is a string.
440 if ((is_array($search[$key]) && !empty($search[$key])) || (!is_array($search[$key]) && $search[$key] != '')) {
441 $sql .= natural_search($tmpkey, $search[$key], $mode_search);
442 }
443}
444if ($search_all) {
445 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
446}
447if ($search_societe) {
448 $sql .= natural_search('s.nom', $search_societe);
449}
450if ($search_fk_project > 0) {
451 $sql .= natural_search('t.fk_project', (string) $search_fk_project, 2);
452}
453if ($search_fk_contract > 0) {
454 $sql .= natural_search('t.fk_contract', (string) $search_fk_contract, 2);
455}
456if ($search_date_start) {
457 $sql .= " AND t.datec >= '".$db->idate($search_date_start)."'";
458}
459if ($search_date_end) {
460 $sql .= " AND t.datec <= '".$db->idate($search_date_end)."'";
461}
462if ($search_dateread_start) {
463 $sql .= " AND t.date_read >= '".$db->idate($search_dateread_start)."'";
464}
465if ($search_dateread_end) {
466 $sql .= " AND t.date_read <= '".$db->idate($search_dateread_end)."'";
467}
468if ($search_dateclose_start) {
469 $sql .= " AND t.date_close >= '".$db->idate($search_dateclose_start)."'";
470}
471if ($search_dateclose_end) {
472 $sql .= " AND t.date_close <= '".$db->idate($search_dateclose_end)."'";
473}
474
475if (!$user->socid && ($mode == "mine" || (!$user->admin && getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY')))) {
476 $sql .= " AND (t.fk_user_assign = ".((int) $user->id);
477 if (!getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY')) {
478 $sql .= " OR t.fk_user_create = ".((int) $user->id);
479 }
480 $sql .= ")";
481}
482
483// Add where from extra fields
484include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
485// Add where from hooks
486$parameters = array();
487$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
488$sql .= $hookmanager->resPrint;
489
490// Count total nb of records
491$nbtotalofrecords = '';
492if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
493 /* The fast and low memory method to get and count full list converts the sql into a sql count */
494 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
495 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
496 $resql = $db->query($sqlforcount);
497 if ($resql) {
498 $objforcount = $db->fetch_object($resql);
499 $nbtotalofrecords = $objforcount->nbtotalofrecords;
500 } else {
501 dol_print_error($db);
502 }
503
504 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
505 $page = 0;
506 $offset = 0;
507 }
508 $db->free($resql);
509}
510
511// Complete request and execute it with limit
512$sql .= $db->order($sortfield, $sortorder);
513if ($limit) {
514 $sql .= $db->plimit($limit + 1, $offset);
515}
516
517$resql = $db->query($sql);
518if (!$resql) {
519 dol_print_error($db);
520 exit;
521}
522
523$num = $db->num_rows($resql);
524
525// Direct jump if only one record found
526if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
527 $obj = $db->fetch_object($resql);
528 $id = $obj->rowid;
529 header("Location: ".DOL_URL_ROOT.'/ticket/card.php?id='.$id);
530 exit;
531}
532
533
534// Output page
535// --------------------------------------------------------------------
536
537llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-ticket page-list bodyforlist');
538
539if ($socid && !$projectid && !$project_ref && $user->hasRight('societe', 'lire')) {
540 $socstat = new Societe($db);
541 $res = $socstat->fetch($socid);
542 if ($res > 0) {
543 $tmpobject = $object;
544 $object = $socstat; // $object must be of type Societe when calling societe_prepare_head
545 $head = societe_prepare_head($socstat);
546 $object = $tmpobject;
547
548 print dol_get_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), -1, 'company');
549
550 dol_banner_tab($socstat, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom');
551
552 print '<div class="fichecenter">';
553
554 print '<div class="underbanner clearboth"></div>';
555 print '<table class="border centpercent tableforfield">';
556
557 // Type Prospect/Customer/Supplier
558 print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
559 print $socstat->getTypeUrl(1);
560 print '</td></tr>';
561
562 // Customer code
563 if ($socstat->client && !empty($socstat->code_client)) {
564 print '<tr><td class="titlefield">';
565 print $langs->trans('CustomerCode').'</td><td>';
566 print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_client));
567 $tmpcheck = $socstat->check_codeclient();
568 if ($tmpcheck != 0 && $tmpcheck != -5) {
569 print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
570 }
571 print '</td>';
572 print '</tr>';
573 }
574 // Supplier code
575 if ($socstat->fournisseur && !empty($socstat->code_fournisseur)) {
576 print '<tr><td class="titlefield">';
577 print $langs->trans('SupplierCode').'</td><td>';
578 print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_fournisseur));
579 $tmpcheck = $socstat->check_codefournisseur();
580 if ($tmpcheck != 0 && $tmpcheck != -5) {
581 print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
582 }
583 print '</td>';
584 print '</tr>';
585 }
586
587 print '</table>';
588 print '</div>';
589 print dol_get_fiche_end();
590
591 print '<br>';
592 }
593}
594
595if ($projectid > 0 || $project_ref) {
596 $projectstat = new Project($db);
597 if ($projectstat->fetch($projectid, $project_ref) > 0) {
598 $projectid = $projectstat->id;
599 $projectstat->fetch_thirdparty();
600
601 $savobject = $object;
602 $object = $projectstat;
603
604 // To verify role of users
605 //$userAccess = $object->restrictedProjectArea($user,'read');
606 $userWrite = $projectstat->restrictedProjectArea($user, 'write');
607 //$userDelete = $object->restrictedProjectArea($user,'delete');
608 //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
609
610 $head = project_prepare_head($projectstat);
611 print dol_get_fiche_head($head, 'ticket', $langs->trans("Project"), -1, ($projectstat->public ? 'projectpub' : 'project'));
612
613 // Project card
614
615 $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
616
617 $morehtmlref = '<div class="refidno">';
618 // Title
619 $morehtmlref .= $object->title;
620 // Thirdparty
621 if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
622 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'project');
623 }
624 $morehtmlref .= '</div>';
625
626 // Define a complementary filter for search of next/prev ref.
627 if (!$user->hasRight('projet', 'all', 'lire')) {
628 $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
629 $object->next_prev_filter = "rowid:IN:".$db->sanitize(count($objectsListId) ? implode(',', array_keys($objectsListId)) : '0');
630 }
631
632 dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
633
634 print '<div class="fichecenter">';
635 print '<div class="underbanner clearboth"></div>';
636
637 print '<table class="border tableforfield centpercent">';
638
639 // Visibility
640 print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
641 if ($projectstat->public) {
642 print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
643 print $langs->trans('SharedProject');
644 } else {
645 print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
646 print $langs->trans('PrivateProject');
647 }
648 print '</td></tr>';
649
650 print "</table>";
651
652 print '</div>';
653 print dol_get_fiche_end();
654
655 print '<br>';
656
657 $object = $savobject;
658 } else {
659 print "ErrorRecordNotFound";
660 }
661}
662
663$arrayofselected = is_array($toselect) ? $toselect : array();
664
665$param = '';
666if (!empty($mode)) {
667 $param .= '&mode='.urlencode($mode);
668}
669if (/* !empty($contextpage) && */ $contextpage != $_SERVER["PHP_SELF"]) { // $contextpage can't be empty
670 $param .= '&contextpage='.urlencode($contextpage);
671}
672if ($limit > 0 && $limit != $conf->liste_limit) {
673 $param .= '&limit='.((int) $limit);
674}
675foreach ($search as $key => $val) {
676 if (is_array($search[$key])) {
677 foreach ($search[$key] as $skey) {
678 if ($skey != '') {
679 $param .= '&search_'.$key.'[]='.urlencode($skey);
680 }
681 }
682 } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
683 $param .= '&search_'.$key.'month='.(GETPOSTINT('search_'.$key.'month'));
684 $param .= '&search_'.$key.'day='.(GETPOSTINT('search_'.$key.'day'));
685 $param .= '&search_'.$key.'year='.(GETPOSTINT('search_'.$key.'year'));
686 } elseif ($search[$key] != '') {
687 $param .= '&search_'.$key.'='.urlencode($search[$key]);
688 }
689}
690if ($optioncss != '') {
691 $param .= '&optioncss='.urlencode($optioncss);
692}
693// Add $param from extra fields
694include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
695// Add $param from hooks
696$parameters = array('param' => &$param);
697$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
698$param .= $hookmanager->resPrint;
699if ($socid > 0) {
700 $param .= '&socid='.urlencode((string) ($socid));
701}
702if ($search_societe) {
703 $param .= '&search_societe='.urlencode($search_societe);
704}
705if ($projectid > 0) {
706 $param .= '&projectid='.urlencode((string) ($projectid));
707}
708if ($contractid > 0) {
709 $param .= '&contractid='.urlencode((string) ($contractid));
710}
711if ($search_date_start) {
712 $tmparray = dol_getdate($search_date_start);
713 $param .= '&search_date_startday='.((int) $tmparray['mday']);
714 $param .= '&search_date_startmonth='.((int) $tmparray['mon']);
715 $param .= '&search_date_startyear='.((int) $tmparray['year']);
716}
717if ($search_date_end) {
718 $tmparray = dol_getdate($search_date_end);
719 $param .= '&search_date_endday='.((int) $tmparray['mday']);
720 $param .= '&search_date_endmonth='.((int) $tmparray['mon']);
721 $param .= '&search_date_endyear='.((int) $tmparray['year']);
722}
723if ($search_dateread_start) {
724 $tmparray = dol_getdate($search_dateread_start);
725 $param .= '&search_dateread_startday='.((int) $tmparray['mday']);
726 $param .= '&search_dateread_startmonth='.((int) $tmparray['mon']);
727 $param .= '&search_dateread_startyear='.((int) $tmparray['year']);
728}
729if ($search_dateread_end) {
730 $tmparray = dol_getdate($search_dateread_end);
731 $param .= '&search_dateread_endday='.((int) $tmparray['mday']);
732 $param .= '&search_dateread_endmonth='.((int) $tmparray['mon']);
733 $param .= '&search_dateread_endyear='.((int) $tmparray['year']);
734}
735if ($search_dateclose_start) {
736 $tmparray = dol_getdate($search_dateclose_start);
737 $param .= '&search_dateclose_startday='.((int) $tmparray['mday']);
738 $param .= '&search_dateclose_startmonth='.((int) $tmparray['mon']);
739 $param .= '&search_dateclose_startyear='.((int) $tmparray['year']);
740}
741if ($search_dateclose_end) {
742 $tmparray = dol_getdate($search_dateclose_end);
743 $param .= '&search_date_endday='.((int) $tmparray['mday']);
744 $param .= '&search_date_endmonth='.((int) $tmparray['mon']);
745 $param .= '&search_date_endyear='.((int) $tmparray['year']);
746}
747// List of mass actions available
748$arrayofmassactions = array(
749 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
750 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
751);
752if ($permissiontoadd) {
753 $arrayofmassactions['presendonclose'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Close");
754 $arrayofmassactions['reopen'] = img_picto('', 'folder-open', 'class="pictofixedwidth"').$langs->trans("ReOpen");
755}
756if ($permissiontodelete) {
757 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
758}
759if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
760 $arrayofmassactions = array();
761}
762$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
763
764print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
765if ($optioncss != '') {
766 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
767}
768print '<input type="hidden" name="token" value="'.newToken().'">';
769print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
770print '<input type="hidden" name="action" value="list">';
771print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
772print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
773print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
774print '<input type="hidden" name="mode" value="'.$mode.'" >';
775
776if ($socid) {
777 print '<input type="hidden" name="socid" value="'.$socid.'" >';
778}
779if ($projectid) {
780 print '<input type="hidden" name="projectid" value="'.$projectid.'" >';
781}
782
783$url = DOL_URL_ROOT.'/ticket/card.php?action=create&mode=init'.($socid ? '&socid='.$socid : '').($projectid ? '&origin=projet_project&originid='.$projectid : '');
784if (!empty($socid)) {
785 $url .= '&socid='.$socid;
786}
787$newcardbutton = '';
788$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition'));
789$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition'));
790$newcardbutton .= dolGetButtonTitleSeparator();
791$newcardbutton .= dolGetButtonTitle($langs->trans('NewTicket'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('ticket', 'write'));
792
793$picto = 'ticket';
794if ($socid > 0) {
795 $picto = '';
796}
797
798print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
799
800if ($mode == 'mine') {
801 print '<div class="opacitymedium">'.$langs->trans('TicketAssignedToMeInfos').'</div><br>';
802}
803// Add code for pre mass action (confirmation or email presend form)
804$topicmail = "SendTicketRef";
805$modelmail = "ticket";
806$objecttmp = new Ticket($db);
807$trackid = 'tic'.$object->id;
808include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
809
810// confirm auto send on close
811if ($massaction == 'presendonclose') {
812 $hidden_form = array([
813 "type" => "hidden",
814 "name" => "massaction",
815 "value" => "close"
816 ]);
817 $selectedchoice = getDolGlobalString('TICKET_NOTIFY_AT_CLOSING') ? "yes" : "no";
818 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassTicketClosingSendEmail"), $langs->trans("ConfirmMassTicketClosingSendEmailQuestion"), 'confirm_send_close', $hidden_form, $selectedchoice, 0, 200, 500, 1);
819}
820
821if ($search_all) {
822 $setupstring = '';
823 foreach ($fieldstosearchall as $key => $val) {
824 $fieldstosearchall[$key] = $langs->trans($val);
825 $setupstring .= $key."=".$val.";";
826 }
827 print '<!-- Search done like if TICKET_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
828 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
829}
830
831$moreforfilter = '';
832/*$moreforfilter.='<div class="divsearchfield">';
833$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
834$moreforfilter.= '</div>';*/
835
836$parameters = array();
837$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
838if (empty($reshook)) {
839 $moreforfilter .= $hookmanager->resPrint;
840} else {
841 $moreforfilter = $hookmanager->resPrint;
842}
843
844if (!empty($moreforfilter)) {
845 print '<div class="liste_titre liste_titre_bydiv centpercent">';
846 print $moreforfilter;
847 print '</div>';
848}
849
850$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
851$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
852$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
853
854print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
855print '<div class="div-table-responsive-inside">';
856print '<table class="tagtable noborder nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
857
858
859// Fields title search
860// --------------------------------------------------------------------
861print '<tr class="liste_titre_filter">';
862// Action column
863if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
864 print '<td class="liste_titre maxwidthsearch center">';
865 $searchpicto = $form->showFilterButtons('left');
866 print $searchpicto;
867 print '</td>';
868}
869foreach ($object->fields as $key => $val) {
870 $searchkey = empty($search[$key]) ? '' : $search[$key];
871 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
872 if ($key == 'fk_statut') {
873 $cssforfield .= ($cssforfield ? ' ' : '').'center';
874 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
875 $cssforfield .= ($cssforfield ? ' ' : '').'center';
876 } elseif (in_array($val['type'], array('timestamp'))) {
877 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
878 } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
879 $cssforfield .= ($cssforfield ? ' ' : '').'right';
880 }
881 if (!empty($arrayfields['t.'.$key]['checked'])) {
882 if ($key == 'progress') {
883 print '<td class="liste_titre right'.($cssforfield ? ' '.$cssforfield : '').'">';
884 print '<input type="text" class="flat maxwidth50" name="search_'.$key.'" value="'.dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]).'">';
885 print '</td>';
886 } elseif ($key == 'type_code') {
887 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
888 $formTicket->selectTypesTickets(empty($search[$key]) ? '' : $search[$key], 'search_'.$key, '', 2, 1, 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150'), 1);
889 print '</td>';
890 } elseif ($key == 'category_code') {
891 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
892 $formTicket->selectGroupTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, '', 2, 1, 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150'));
893 print '</td>';
894 } elseif ($key == 'severity_code') {
895 print '<td class="liste_titre center'.($cssforfield ? ' '.$cssforfield : '').'">';
896 $formTicket->selectSeveritiesTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, '', 2, 1, 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150'));
897 print '</td>';
898 } elseif ($key == 'fk_user_assign' || $key == 'fk_user_create') {
899 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
900 print $form->select_dolusers((empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, 1, null, 0, '', '', '0', 0, 0, '', 0, '', (!empty($val['css']) ? $val['css'] : 'maxwidth100'));
901 print '</td>';
902 } elseif ($key == 'fk_statut') {
903 $arrayofstatus = array();
904 $langs->load("ticket");
905 $arrayofstatus['openall'] = array('id' => 'openall', 'labelhtml' => '<b>-- '.$langs->trans('OpenAll').'</b>', 'label' => '-- '.$langs->trans('OpenAll'));
906 foreach ($object->labelStatusShort as $key2 => $val2) {
907 if ($key2 == Ticket::STATUS_CLOSED) {
908 $arrayofstatus['closeall'] = array('id' => 'closeall', 'labelhtml' => '<b>-- '.$langs->trans('ClosedAll').'</b>', 'label' => '-- '.$langs->trans('ClosedAll'));
909 }
910 $arrayofstatus[$key2] = array('id' => $key2, 'labelhtml' => $val2, 'label' => $val2);
911 }
912 print '<td class="liste_titre center parentonrightofpage'.($cssforfield ? ' '.$cssforfield : '').'">';
913 //var_dump($arrayofstatus);
914 //var_dump($search['fk_statut']);
915 //var_dump(array_values($search[$key]));
916 $selectedarray = null;
917 if (!empty($search[$key])) {
918 if (is_array($search[$key])) {
919 $selectedarray = array_values($search[$key]);
920 } else {
921 $selectedarray = array($search[$key]); // Compatibility with "Default search filters"
922 }
923 }
924 print Form::multiselectarray('search_fk_statut', $arrayofstatus, $selectedarray, 0, 0, 'search_status width150 onrightofpage', 1, 0, '', '', '');
925 print '</td>';
926 } elseif ($key == "fk_soc") {
927 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'"><input type="text" class="flat maxwidth75" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
928 } elseif ($key == "datec" || $key == 'date_read' || $key == 'date_close') {
929 print '<td class="liste_titre center">';
930 print '<div class="nowrap">';
931 switch ($key) {
932 case 'datec':
933 print $form->selectDate($search_date_start ?: -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
934 break;
935 case 'date_read':
936 print $form->selectDate($search_dateread_start ?: -1, 'search_dateread_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
937 break;
938 case 'date_close':
939 print $form->selectDate($search_dateclose_start ?: -1, 'search_dateclose_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
940 }
941 print '</div>';
942 print '<div class="nowrap">';
943 switch ($key) {
944 case 'datec':
945 print $form->selectDate($search_date_end ?: -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
946 break;
947 case 'date_read':
948 print $form->selectDate($search_dateread_end ?: -1, 'search_dateread_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
949 break;
950 case 'date_close':
951 print $form->selectDate($search_dateclose_end ?: -1, 'search_dateclose_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
952 }
953 print '</div>';
954 print '</td>';
955 } else {
956 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
957 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
958 print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
959 } elseif (strpos($val['type'], 'integer:') === 0) {
960 print $object->showInputField($val, $key, !empty($search[$key]) ? $search[$key] : "", '', '', 'search_', 'maxwidth150', 1);
961 } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) {
962 print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]).'">';
963 }
964 print '</td>';
965 }
966 }
967}
968// Extra fields
969include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
970
971// Fields from hook
972$parameters = array('arrayfields' => $arrayfields);
973$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
974print $hookmanager->resPrint;
975// Action column
976if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
977 print '<td class="liste_titre center maxwidthsearch">';
978 $searchpicto = $form->showFilterButtons();
979 print $searchpicto;
980 print '</td>';
981}
982print '</tr>'."\n";
983
984$totalarray = array();
985$totalarray['nbfield'] = 0;
986
987// Fields title label
988// --------------------------------------------------------------------
989print '<tr class="liste_titre">';
990if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
991 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
992 $totalarray['nbfield']++;
993}
994foreach ($object->fields as $key => $val) {
995 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
996 if ($key == 'fk_statut' || $key == 'severity_code') {
997 $cssforfield .= ($cssforfield ? ' ' : '').'center';
998 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
999 $cssforfield .= ($cssforfield ? ' ' : '').'center';
1000 } elseif (in_array($val['type'], array('timestamp'))) {
1001 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
1002 } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
1003 $cssforfield .= ($cssforfield ? ' ' : '').'right';
1004 }
1005 $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
1006 if (!empty($arrayfields['t.'.$key]['checked'])) {
1007 print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''), 0, (empty($val['helplist']) ? '' : $val['helplist']))."\n";
1008 $totalarray['nbfield']++;
1009 }
1010}
1011// Extra fields
1012include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1013// Hook fields
1014$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
1015$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1016print $hookmanager->resPrint;
1017if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1018 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1019 $totalarray['nbfield']++;
1020}
1021print '</tr>'."\n";
1022
1023
1024// Detect if we need a fetch on each output line
1025$needToFetchEachLine = 0;
1026if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
1027 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
1028 if (!is_null($val) && preg_match('/\$object/', $val)) {
1029 $needToFetchEachLine++; // There is at least one compute field that use $object
1030 }
1031 }
1032}
1033
1034
1035// Loop on record
1036// --------------------------------------------------------------------
1037$i = 0;
1038$savnbfield = $totalarray['nbfield'];
1039$totalarray = array();
1040$totalarray['nbfield'] = 0;
1041$imaxinloop = ($limit ? min($num, $limit) : $num);
1042$cacheofoutputfield = array();
1043while ($i < $imaxinloop) {
1044 $obj = $db->fetch_object($resql);
1045 if (empty($obj)) {
1046 break; // Should not happen
1047 }
1048
1049 // Store properties in $object
1050 $object->setVarsFromFetchObj($obj);
1051 $object->type_code = $obj->type_code;
1052 $object->status = $object->fk_statut; // because field name is fk_statut
1053
1054 if ($mode == 'kanban') {
1055 if ($i == 0) {
1056 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1057 print '<div class="box-flex-container kanban">';
1058 }
1059
1060 // get infos needed from object
1061 // TODO Create a cache on users
1062 $arraydata = array();
1063 if ($obj->fk_user_assign > 0) {
1064 $user_temp->fetch($obj->fk_user_assign);
1065 $arraydata['user_assignment'] = $user_temp->getNomUrl(-3);
1066 }
1067 $arraydata['selected'] = in_array($object->id, $arrayofselected);
1068
1069 // Output Kanban
1070 print $object->getKanbanView('', $arraydata);
1071 if ($i == ($imaxinloop - 1)) {
1072 print '</div>';
1073 print '</td></tr>';
1074 }
1075 } else {
1076 // Show line of result
1077 $j = 0;
1078 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
1079
1080 // Action column
1081 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1082 print '<td class="nowrap center">';
1083 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1084 $selected = 0;
1085 if (in_array($object->id, $arrayofselected)) {
1086 $selected = 1;
1087 }
1088 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
1089 }
1090 print '</td>';
1091 if (!$i) {
1092 $totalarray['nbfield']++;
1093 }
1094 }
1095 // Fields
1096 foreach ($object->fields as $key => $val) {
1097 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
1098 if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
1099 $cssforfield .= ($cssforfield ? ' ' : '').'center';
1100 }
1101
1102 if (in_array($val['type'], array('timestamp'))) {
1103 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
1104 }
1105 if (in_array($key, array('ref', 'fk_project'))) {
1106 $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
1107 }
1108
1109 if ($key == 'fk_statut' || $key == 'severity_code') {
1110 $cssforfield .= ($cssforfield ? ' ' : '').'center';
1111 }
1112 if (!empty($arrayfields['t.'.$key]['checked'])) {
1113 print '<td'.($cssforfield ? ' class="'.$cssforfield.((preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) ? ' classfortooltip' : '').'"' : '');
1114 if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) {
1115 print ' title="'.dol_escape_htmltag((string) $object->$key).'"';
1116 }
1117 print '>';
1118 if ($key == 'fk_statut') {
1119 print $object->getLibStatut(5);
1120 } elseif ($key == 'subject') {
1121 $s = $obj->subject;
1122 print '<span title="'.dol_escape_htmltag($s).'">';
1123 print dol_escape_htmltag($s);
1124 print '</span>';
1125 } elseif ($key == 'type_code') {
1126 $s = $langs->getLabelFromKey($db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code);
1127 print '<span title="'.dol_escape_htmltag($s).'">';
1128 print $s;
1129 print '</span>';
1130 } elseif ($key == 'category_code') {
1131 $s = $langs->getLabelFromKey($db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code);
1132 print '<span title="'.dol_escape_htmltag($s).'">';
1133 print $s;
1134 print '</span>';
1135 } elseif ($key == 'severity_code') {
1136 $s = $langs->getLabelFromKey($db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code);
1137 print '<span title="'.dol_escape_htmltag($s).'">';
1138 print $s;
1139 print '</span>';
1140 } elseif ($key == 'tms') {
1141 print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser');
1142 } elseif ($key == 'fk_user_create') {
1143 if ($object->fk_user_create > 0) {
1144 if (isset($conf->cache['user'][$object->fk_user_create])) {
1145 $user_temp = $conf->cache['user'][$object->fk_user_create];
1146 } else {
1147 $user_temp = new User($db);
1148 $user_temp->fetch($object->fk_user_create);
1149 $conf->cache['user'][$object->fk_user_create] = $user_temp;
1150 }
1151 print $user_temp->getNomUrl(-1);
1152 }
1153 } elseif ($key == 'fk_user_assign') {
1154 if ($object->fk_user_assign > 0) {
1155 if (isset($conf->cache['user'][$object->fk_user_assign])) {
1156 $user_temp = $conf->cache['user'][$object->fk_user_assign];
1157 } else {
1158 $user_temp = new User($db);
1159 $user_temp->fetch($object->fk_user_assign);
1160 $conf->cache['user'][$object->fk_user_assign] = $user_temp;
1161 }
1162 print $user_temp->getNomUrl(-1);
1163 }
1164 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
1165 print $object->showOutputField($val, $key, $db->jdate($obj->$key), '');
1166 } elseif ($key == 'ref') {
1167 print $object->showOutputField($val, $key, $obj->$key, '');
1168
1169 // display a warning on untreated tickets
1170 $is_open = ($object->status != Ticket::STATUS_CLOSED && $object->status != Ticket::STATUS_CANCELED);
1171 $should_show_warning = (getDolGlobalString('TICKET_DELAY_SINCE_LAST_RESPONSE') || getDolGlobalString('TICKET_DELAY_BEFORE_FIRST_RESPONSE'));
1172 if ($is_open && $should_show_warning) {
1173 $date_last_msg_sent = (int) $object->date_last_msg_sent;
1174 $hour_diff = ($now - $date_last_msg_sent) / 3600 ;
1175
1176 if (getDolGlobalString('TICKET_DELAY_BEFORE_FIRST_RESPONSE') && $date_last_msg_sent == 0) {
1177 $creation_date = $object->datec;
1178 $hour_diff_creation = ($now - $creation_date) / 3600 ;
1179 if ($hour_diff_creation > getDolGlobalInt('TICKET_DELAY_BEFORE_FIRST_RESPONSE')) {
1180 print " " . img_picto($langs->trans('Late') . ' : ' . $langs->trans('TicketsDelayForFirstResponseTooLong', getDolGlobalString('TICKET_DELAY_BEFORE_FIRST_RESPONSE')), 'warning', 'style="color: red;"', 0, 0, 0, '', '');
1181 }
1182 } elseif (getDolGlobalString('TICKET_DELAY_SINCE_LAST_RESPONSE') && $hour_diff > getDolGlobalInt('TICKET_DELAY_SINCE_LAST_RESPONSE')) {
1183 print " " . img_picto($langs->trans('Late') . ' : ' . $langs->trans('TicketsDelayFromLastResponseTooLong', getDolGlobalString('TICKET_DELAY_SINCE_LAST_RESPONSE')), 'warning');
1184 }
1185 }
1186 } else { // Example: key=fk_soc, obj->key=123 val=array('type'=>'integer', ...
1187 $tmp = explode(':', $val['type']);
1188 if ($tmp[0] == 'integer' && !empty($tmp[1]) && class_exists($tmp[1])) {
1189 // It is a type of an foreign field. We will try to reduce the number of fetch that the showOutputField is making.
1190 //var_dump('eeee-'.$key.'-'.$obj->$key.'-'.$val['type']);
1191 if ($key && $obj->$key && $val['type'] && array_key_exists($key.'-'.$obj->$key.'-'.$val['type'], $cacheofoutputfield)) {
1192 $result = $cacheofoutputfield[$key.'-'.$obj->$key.'-'.$val['type']];
1193 } else {
1194 $result = $object->showOutputField($val, $key, $obj->$key, '');
1195 $cacheofoutputfield[$key.'-'.$obj->$key.'-'.$val['type']] = $result;
1196 }
1197 } else {
1198 $result = $object->showOutputField($val, $key, $obj->$key, '');
1199 }
1200 print $result;
1201 }
1202
1203 print '</td>';
1204 if (!$i) {
1205 $totalarray['nbfield']++;
1206 }
1207 if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
1208 if (!$i) {
1209 $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
1210 }
1211 if (!isset($totalarray['val'])) {
1212 $totalarray['val'] = array();
1213 }
1214 if (!isset($totalarray['val']['t.'.$key])) {
1215 $totalarray['val']['t.'.$key] = 0;
1216 }
1217 $totalarray['val']['t.'.$key] += $object->$key;
1218 }
1219 }
1220 }
1221 // Extra fields
1222 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1223 // Fields from hook
1224 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1225 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1226 print $hookmanager->resPrint;
1227
1228 // Action column
1229 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1230 print '<td class="nowrap center">';
1231 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1232 $selected = 0;
1233 if (in_array($object->id, $arrayofselected)) {
1234 $selected = 1;
1235 }
1236 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
1237 }
1238 print '</td>';
1239 if (!$i) {
1240 $totalarray['nbfield']++;
1241 }
1242 }
1243
1244 print '</tr>'."\n";
1245 }
1246
1247 $i++;
1248}
1249
1250// Show total line
1251include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1252
1253
1254// If no record found
1255if ($num == 0) {
1256 $colspan = 1;
1257 foreach ($arrayfields as $key => $val) {
1258 if (!empty($val['checked'])) {
1259 $colspan++;
1260 }
1261 }
1262 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1263}
1264
1265
1266$db->free($resql);
1267
1268$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1269$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
1270print $hookmanager->resPrint;
1271
1272print '</table>'."\n";
1273print '</div>'."\n";
1274print '</div>'."\n"; // end div-responsive-inside
1275
1276print '</form>'."\n";
1277
1278
1279
1280if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
1281 $hidegeneratedfilelistifempty = 1;
1282 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1283 $hidegeneratedfilelistifempty = 0;
1284 }
1285
1286 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
1287 $formfile = new FormFile($db);
1288
1289 // Show list of available documents
1290 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1291 $urlsource .= str_replace('&amp;', '&', $param);
1292
1293 $filedir = $diroutputmassaction;
1294 $genallowed = $permissiontoread;
1295 $delallowed = $permissiontoadd;
1296
1297 print $formfile->showdocuments('massfilesarea_ticket', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1298}
1299
1300// End of page
1301llxFooter();
1302$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition export.php:1216
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage standard extra fields.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
static multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $morecss='', $translate=0, $width=0, $moreattrib='', $nu='', $placeholder='', $addjscombo=-1)
Show a multiselect form from an array.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
const STATUS_NOT_READ
Status.
Class to manage Dolibarr users.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
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...
Class to generate the form for creating a new ticket.
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.