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