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_date_start = '';
239 $search_date_end = '';
240 $search_dateread_start = '';
241 $search_dateread_end = '';
242 $search_dateclose_start = '';
243 $search_dateclose_end = '';
244 }
245 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
246 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
247 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
248 }
249
250 // Mass actions
251 $objectclass = 'Ticket';
252 $objectlabel = 'Ticket';
253 $uploaddir = $conf->ticket->dir_output;
254
255 global $error;
256 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
257
258 // Close records
259 if (!$error && $massaction == 'close' && $permissiontoadd) {
260 $objecttmp = new Ticket($db);
261 $db->begin();
262
263 $nbok = 0;
264 foreach ($toselect as $toselectid) {
265 $result = $objecttmp->fetch($toselectid);
266 if ($result > 0) {
267 $result = $objecttmp->close($user);
268 if ($result < 0) {
269 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
270 $error++;
271 break;
272 } else {
273 $nbok++;
274 }
275 } else {
276 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
277 $error++;
278 break;
279 }
280 }
281
282 if (!$error) {
283 setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
284 $db->commit();
285 } else {
286 $db->rollback();
287 }
288 //var_dump($listofobjectthirdparties);exit;
289 }
290
291 // Reopen records
292 if (!$error && $massaction == 'reopen' && $permissiontoadd) {
293 $objecttmp = new Ticket($db);
294 $db->begin();
295
296 $nbok = 0;
297 foreach ($toselect as $toselectid) {
298 $result = $objecttmp->fetch($toselectid);
299 if ($result > 0) {
300 if ($objecttmp->status == Ticket::STATUS_CLOSED || $objecttmp->status == Ticket::STATUS_CANCELED) {
301 // Set status
302 $result = $objecttmp->setStatut(Ticket::STATUS_ASSIGNED, null, '', 'TICKET_MODIFY');
303
304 if ($result < 0) {
305 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
306 $error++;
307 break;
308 } else {
309 $nbok++;
310 }
311 } else {
312 $langs->load("errors");
313 setEventMessages($langs->trans("ErrorObjectMustHaveStatusClosedToBeReOpened", $objecttmp->ref), null, 'errors');
314 $error++;
315 break;
316 }
317 } else {
318 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
319 $error++;
320 break;
321 }
322 }
323
324 if (!$error) {
325 setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
326 $db->commit();
327 } else {
328 $db->rollback();
329 }
330 //var_dump($listofobjectthirdparties);exit;
331 }
332}
333
334
335
336/*
337 * View
338 */
339
340$form = new Form($db);
341$formTicket = new FormTicket($db);
342
343$now = dol_now();
344
345$user_temp = new User($db);
346$socstatic = new Societe($db);
347
348$help_url = '';
349
350$moretitle = '';
351if ($socid > 0) {
352 $socstatic->fetch($socid);
353 $moretitle = $langs->trans("ThirdParty") . ' - ';
354 if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $socstatic->name) {
355 $moretitle = $socstatic->name . ' - ';
356 }
357}
358
359$title = $moretitle . $langs->trans('Tickets');
360$morejs = array();
361$morecss = array();
362
363
364// Build and execute select
365// --------------------------------------------------------------------
366$sql = 'SELECT ';
367$sql .= $object->getFieldList('t');
368// Add fields from extrafields
369if (!empty($extrafields->attributes[$object->table_element]['label'])) {
370 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
371 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
372 }
373}
374// Add fields from hooks
375$parameters = array();
376$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
377$sql .= $hookmanager->resPrint;
378$sql = preg_replace('/,\s*$/', '', $sql);
379
380$sqlfields = $sql; // $sql fields to remove for count total
381
382$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
383if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
384 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
385}
386// Add table from hooks
387$parameters = array();
388$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
389$sql .= $hookmanager->resPrint;
390$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (t.fk_soc = s.rowid)";
391$sql .= " WHERE t.entity IN (".getEntity($object->element).")";
392if ($socid > 0) {
393 $sql .= " AND t.fk_soc = ".((int) $socid);
394}
395
396foreach ($search as $key => $val) {
397 $tmpkey = 't.' . $key;
398 if ($key == 'fk_statut' && !empty($search['fk_statut'])) {
399 $newarrayofstatus = array();
400 if (is_array($search['fk_statut'])) {
401 foreach ($search['fk_statut'] as $key2 => $val2) {
402 if (in_array($val2, array('openall', 'closeall'))) {
403 continue;
404 }
405 $newarrayofstatus[] = $val2;
406 }
407 }
408 if ($search['fk_statut'] === 'openall' || (is_array($search['fk_statut']) && in_array('openall', $search['fk_statut']))) {
409 $newarrayofstatus[] = Ticket::STATUS_NOT_READ;
410 $newarrayofstatus[] = Ticket::STATUS_READ;
411 $newarrayofstatus[] = Ticket::STATUS_ASSIGNED;
412 $newarrayofstatus[] = Ticket::STATUS_IN_PROGRESS;
413 $newarrayofstatus[] = Ticket::STATUS_NEED_MORE_INFO;
414 $newarrayofstatus[] = Ticket::STATUS_WAITING;
415 }
416 if ($search['fk_statut'] === 'closeall' || (is_array($search['fk_statut']) && in_array('closeall', $search['fk_statut']))) {
417 $newarrayofstatus[] = Ticket::STATUS_CLOSED;
418 $newarrayofstatus[] = Ticket::STATUS_CANCELED;
419 }
420 if (count($newarrayofstatus)) {
421 $sql .= natural_search($tmpkey, implode(',', $newarrayofstatus), 2);
422 }
423 continue;
424 } elseif ($key == 'fk_user_assign' || $key == 'fk_user_create' || $key == 'fk_project' || $key == 'fk_contract') {
425 if ($search[$key] > 0) {
426 $sql .= natural_search($tmpkey, $search[$key], 2);
427 }
428 continue;
429 } elseif ($key == 'type_code') {
430 $newarrayoftypecodes = is_array($search[$key]) ? $search[$key] : (!empty($search[$key]) ? explode(',', $search[$key]) : array());
431 if (count($newarrayoftypecodes)) {
432 $sql .= natural_search($tmpkey, implode(',', $newarrayoftypecodes), 3);
433 }
434 continue;
435 }
436
437 $mode_search = ((!empty($object->fields[$key]) && ($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))) ? 1 : 0);
438 // $search[$key] can be an array of values, or a string. We add filter if array not empty or if it is a string.
439 if ((is_array($search[$key]) && !empty($search[$key])) || (!is_array($search[$key]) && $search[$key] != '')) {
440 $sql .= natural_search($tmpkey, $search[$key], $mode_search);
441 }
442}
443if ($search_all) {
444 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
445}
446if ($search_societe) {
447 $sql .= natural_search('s.nom', $search_societe);
448}
449if ($search_fk_project > 0) {
450 $sql .= natural_search('t.fk_project', (string) $search_fk_project, 2);
451}
452if ($search_fk_contract > 0) {
453 $sql .= natural_search('t.fk_contract', (string) $search_fk_contract, 2);
454}
455if ($search_date_start) {
456 $sql .= " AND t.datec >= '".$db->idate($search_date_start)."'";
457}
458if ($search_date_end) {
459 $sql .= " AND t.datec <= '".$db->idate($search_date_end)."'";
460}
461if ($search_dateread_start) {
462 $sql .= " AND t.date_read >= '".$db->idate($search_dateread_start)."'";
463}
464if ($search_dateread_end) {
465 $sql .= " AND t.date_read <= '".$db->idate($search_dateread_end)."'";
466}
467if ($search_dateclose_start) {
468 $sql .= " AND t.date_close >= '".$db->idate($search_dateclose_start)."'";
469}
470if ($search_dateclose_end) {
471 $sql .= " AND t.date_close <= '".$db->idate($search_dateclose_end)."'";
472}
473
474if (!$user->socid && ($mode == "mine" || (!$user->admin && getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY')))) {
475 $sql .= " AND (t.fk_user_assign = ".((int) $user->id);
476 if (!getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY')) {
477 $sql .= " OR t.fk_user_create = ".((int) $user->id);
478 }
479 $sql .= ")";
480}
481
482// Add where from extra fields
483include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
484// Add where from hooks
485$parameters = array();
486$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
487$sql .= $hookmanager->resPrint;
488
489// Count total nb of records
490$nbtotalofrecords = '';
491if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
492 /* The fast and low memory method to get and count full list converts the sql into a sql count */
493 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
494 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
495 $resql = $db->query($sqlforcount);
496 if ($resql) {
497 $objforcount = $db->fetch_object($resql);
498 $nbtotalofrecords = $objforcount->nbtotalofrecords;
499 } else {
500 dol_print_error($db);
501 }
502
503 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
504 $page = 0;
505 $offset = 0;
506 }
507 $db->free($resql);
508}
509
510// Complete request and execute it with limit
511$sql .= $db->order($sortfield, $sortorder);
512if ($limit) {
513 $sql .= $db->plimit($limit + 1, $offset);
514}
515
516$resql = $db->query($sql);
517if (!$resql) {
518 dol_print_error($db);
519 exit;
520}
521
522$num = $db->num_rows($resql);
523
524// Direct jump if only one record found
525if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
526 $obj = $db->fetch_object($resql);
527 $id = $obj->rowid;
528 header("Location: ".DOL_URL_ROOT.'/ticket/card.php?id='.$id);
529 exit;
530}
531
532
533// Output page
534// --------------------------------------------------------------------
535
536llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-ticket page-list bodyforlist');
537
538if ($socid && !$projectid && !$project_ref && $user->hasRight('societe', 'lire')) {
539 $socstat = new Societe($db);
540 $res = $socstat->fetch($socid);
541 if ($res > 0) {
542 $tmpobject = $object;
543 $object = $socstat; // $object must be of type Societe when calling societe_prepare_head
544 $head = societe_prepare_head($socstat);
545 $object = $tmpobject;
546
547 print dol_get_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), -1, 'company');
548
549 dol_banner_tab($socstat, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom');
550
551 print '<div class="fichecenter">';
552
553 print '<div class="underbanner clearboth"></div>';
554 print '<table class="border centpercent tableforfield">';
555
556 // Type Prospect/Customer/Supplier
557 print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
558 print $socstat->getTypeUrl(1);
559 print '</td></tr>';
560
561 // Customer code
562 if ($socstat->client && !empty($socstat->code_client)) {
563 print '<tr><td class="titlefield">';
564 print $langs->trans('CustomerCode').'</td><td>';
565 print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_client));
566 $tmpcheck = $socstat->check_codeclient();
567 if ($tmpcheck != 0 && $tmpcheck != -5) {
568 print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
569 }
570 print '</td>';
571 print '</tr>';
572 }
573 // Supplier code
574 if ($socstat->fournisseur && !empty($socstat->code_fournisseur)) {
575 print '<tr><td class="titlefield">';
576 print $langs->trans('SupplierCode').'</td><td>';
577 print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_fournisseur));
578 $tmpcheck = $socstat->check_codefournisseur();
579 if ($tmpcheck != 0 && $tmpcheck != -5) {
580 print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
581 }
582 print '</td>';
583 print '</tr>';
584 }
585
586 print '</table>';
587 print '</div>';
588 print dol_get_fiche_end();
589
590 print '<br>';
591 }
592}
593
594if ($projectid > 0 || $project_ref) {
595 $projectstat = new Project($db);
596 if ($projectstat->fetch($projectid, $project_ref) > 0) {
597 $projectid = $projectstat->id;
598 $projectstat->fetch_thirdparty();
599
600 $savobject = $object;
601 $object = $projectstat;
602
603 // To verify role of users
604 //$userAccess = $object->restrictedProjectArea($user,'read');
605 $userWrite = $projectstat->restrictedProjectArea($user, 'write');
606 //$userDelete = $object->restrictedProjectArea($user,'delete');
607 //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
608
609 $head = project_prepare_head($projectstat);
610 print dol_get_fiche_head($head, 'ticket', $langs->trans("Project"), -1, ($projectstat->public ? 'projectpub' : 'project'));
611
612 // Project card
613
614 $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
615
616 $morehtmlref = '<div class="refidno">';
617 // Title
618 $morehtmlref .= $object->title;
619 // Thirdparty
620 if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
621 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'project');
622 }
623 $morehtmlref .= '</div>';
624
625 // Define a complementary filter for search of next/prev ref.
626 if (!$user->hasRight('projet', 'all', 'lire')) {
627 $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
628 $object->next_prev_filter = "rowid:IN:".$db->sanitize(count($objectsListId) ? implode(',', array_keys($objectsListId)) : '0');
629 }
630
631 dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
632
633 print '<div class="fichecenter">';
634 print '<div class="underbanner clearboth"></div>';
635
636 print '<table class="border tableforfield centpercent">';
637
638 // Visibility
639 print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
640 if ($projectstat->public) {
641 print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
642 print $langs->trans('SharedProject');
643 } else {
644 print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
645 print $langs->trans('PrivateProject');
646 }
647 print '</td></tr>';
648
649 print "</table>";
650
651 print '</div>';
652 print dol_get_fiche_end();
653
654 print '<br>';
655
656 $object = $savobject;
657 } else {
658 print "ErrorRecordNotFound";
659 }
660}
661
662$arrayofselected = is_array($toselect) ? $toselect : array();
663
664$param = '';
665if (!empty($mode)) {
666 $param .= '&mode='.urlencode($mode);
667}
668if (/* !empty($contextpage) && */ $contextpage != $_SERVER["PHP_SELF"]) { // $contextpage can't be empty
669 $param .= '&contextpage='.urlencode($contextpage);
670}
671if ($limit > 0 && $limit != $conf->liste_limit) {
672 $param .= '&limit='.((int) $limit);
673}
674foreach ($search as $key => $val) {
675 if (is_array($search[$key])) {
676 foreach ($search[$key] as $skey) {
677 if ($skey != '') {
678 $param .= '&search_'.$key.'[]='.urlencode($skey);
679 }
680 }
681 } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
682 $param .= '&search_'.$key.'month='.(GETPOSTINT('search_'.$key.'month'));
683 $param .= '&search_'.$key.'day='.(GETPOSTINT('search_'.$key.'day'));
684 $param .= '&search_'.$key.'year='.(GETPOSTINT('search_'.$key.'year'));
685 } elseif ($search[$key] != '') {
686 $param .= '&search_'.$key.'='.urlencode($search[$key]);
687 }
688}
689if ($optioncss != '') {
690 $param .= '&optioncss='.urlencode($optioncss);
691}
692// Add $param from extra fields
693include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
694// Add $param from hooks
695$parameters = array('param' => &$param);
696$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
697$param .= $hookmanager->resPrint;
698if ($socid > 0) {
699 $param .= '&socid='.urlencode((string) ($socid));
700}
701if ($search_societe) {
702 $param .= '&search_societe='.urlencode($search_societe);
703}
704if ($projectid > 0) {
705 $param .= '&projectid='.urlencode((string) ($projectid));
706}
707if ($contractid > 0) {
708 $param .= '&contractid='.urlencode((string) ($contractid));
709}
710if ($search_date_start) {
711 $tmparray = dol_getdate($search_date_start);
712 $param .= '&search_date_startday='.((int) $tmparray['mday']);
713 $param .= '&search_date_startmonth='.((int) $tmparray['mon']);
714 $param .= '&search_date_startyear='.((int) $tmparray['year']);
715}
716if ($search_date_end) {
717 $tmparray = dol_getdate($search_date_end);
718 $param .= '&search_date_endday='.((int) $tmparray['mday']);
719 $param .= '&search_date_endmonth='.((int) $tmparray['mon']);
720 $param .= '&search_date_endyear='.((int) $tmparray['year']);
721}
722if ($search_dateread_start) {
723 $tmparray = dol_getdate($search_dateread_start);
724 $param .= '&search_dateread_startday='.((int) $tmparray['mday']);
725 $param .= '&search_dateread_startmonth='.((int) $tmparray['mon']);
726 $param .= '&search_dateread_startyear='.((int) $tmparray['year']);
727}
728if ($search_dateread_end) {
729 $tmparray = dol_getdate($search_dateread_end);
730 $param .= '&search_dateread_endday='.((int) $tmparray['mday']);
731 $param .= '&search_dateread_endmonth='.((int) $tmparray['mon']);
732 $param .= '&search_dateread_endyear='.((int) $tmparray['year']);
733}
734if ($search_dateclose_start) {
735 $tmparray = dol_getdate($search_dateclose_start);
736 $param .= '&search_dateclose_startday='.((int) $tmparray['mday']);
737 $param .= '&search_dateclose_startmonth='.((int) $tmparray['mon']);
738 $param .= '&search_dateclose_startyear='.((int) $tmparray['year']);
739}
740if ($search_dateclose_end) {
741 $tmparray = dol_getdate($search_dateclose_end);
742 $param .= '&search_date_endday='.((int) $tmparray['mday']);
743 $param .= '&search_date_endmonth='.((int) $tmparray['mon']);
744 $param .= '&search_date_endyear='.((int) $tmparray['year']);
745}
746// List of mass actions available
747$arrayofmassactions = array(
748 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
749 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
750);
751if ($permissiontoadd) {
752 $arrayofmassactions['presendonclose'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Close");
753 $arrayofmassactions['reopen'] = img_picto('', 'folder-open', 'class="pictofixedwidth"').$langs->trans("ReOpen");
754}
755if ($permissiontodelete) {
756 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
757}
758if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
759 $arrayofmassactions = array();
760}
761$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
762
763print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
764if ($optioncss != '') {
765 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
766}
767print '<input type="hidden" name="token" value="'.newToken().'">';
768print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
769print '<input type="hidden" name="action" value="list">';
770print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
771print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
772print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
773print '<input type="hidden" name="mode" value="'.$mode.'" >';
774
775if ($socid) {
776 print '<input type="hidden" name="socid" value="'.$socid.'" >';
777}
778if ($projectid) {
779 print '<input type="hidden" name="projectid" value="'.$projectid.'" >';
780}
781
782$url = DOL_URL_ROOT.'/ticket/card.php?action=create&mode=init'.($socid ? '&socid='.$socid : '').($projectid ? '&origin=projet_project&originid='.$projectid : '');
783if (!empty($socid)) {
784 $url .= '&socid='.$socid;
785}
786$newcardbutton = '';
787$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'));
788$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'));
789$newcardbutton .= dolGetButtonTitleSeparator();
790$newcardbutton .= dolGetButtonTitle($langs->trans('NewTicket'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('ticket', 'write'));
791
792$picto = 'ticket';
793if ($socid > 0) {
794 $picto = '';
795}
796
797print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
798
799if ($mode == 'mine') {
800 print '<div class="opacitymedium">'.$langs->trans('TicketAssignedToMeInfos').'</div><br>';
801}
802// Add code for pre mass action (confirmation or email presend form)
803$topicmail = "SendTicketRef";
804$modelmail = "ticket";
805$objecttmp = new Ticket($db);
806$trackid = 'tic'.$object->id;
807include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
808
809// confirm auto send on close
810if ($massaction == 'presendonclose') {
811 $hidden_form = array([
812 "type" => "hidden",
813 "name" => "massaction",
814 "value" => "close"
815 ]);
816 $selectedchoice = getDolGlobalString('TICKET_NOTIFY_AT_CLOSING') ? "yes" : "no";
817 print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassTicketClosingSendEmail"), $langs->trans("ConfirmMassTicketClosingSendEmailQuestion"), 'confirm_send_close', $hidden_form, $selectedchoice, 0, 200, 500, 1);
818}
819
820if ($search_all) {
821 $setupstring = '';
822 foreach ($fieldstosearchall as $key => $val) {
823 $fieldstosearchall[$key] = $langs->trans($val);
824 $setupstring .= $key."=".$val.";";
825 }
826 print '<!-- Search done like if TICKET_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
827 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
828}
829
830$moreforfilter = '';
831/*$moreforfilter.='<div class="divsearchfield">';
832$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
833$moreforfilter.= '</div>';*/
834
835$parameters = array();
836$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
837if (empty($reshook)) {
838 $moreforfilter .= $hookmanager->resPrint;
839} else {
840 $moreforfilter = $hookmanager->resPrint;
841}
842
843if (!empty($moreforfilter)) {
844 print '<div class="liste_titre liste_titre_bydiv centpercent">';
845 print $moreforfilter;
846 print '</div>';
847}
848
849$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
850$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
851$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
852
853print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
854print '<div class="div-table-responsive-inside">';
855print '<table class="tagtable noborder nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
856
857
858// Fields title search
859// --------------------------------------------------------------------
860print '<tr class="liste_titre_filter">';
861// Action column
862if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
863 print '<td class="liste_titre maxwidthsearch center">';
864 $searchpicto = $form->showFilterButtons('left');
865 print $searchpicto;
866 print '</td>';
867}
868foreach ($object->fields as $key => $val) {
869 $searchkey = empty($search[$key]) ? '' : $search[$key];
870 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
871 if ($key == 'fk_statut') {
872 $cssforfield .= ($cssforfield ? ' ' : '').'center';
873 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
874 $cssforfield .= ($cssforfield ? ' ' : '').'center';
875 } elseif (in_array($val['type'], array('timestamp'))) {
876 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
877 } 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'])) {
878 $cssforfield .= ($cssforfield ? ' ' : '').'right';
879 }
880 if (!empty($arrayfields['t.'.$key]['checked'])) {
881 if ($key == 'progress') {
882 print '<td class="liste_titre right'.($cssforfield ? ' '.$cssforfield : '').'">';
883 print '<input type="text" class="flat maxwidth50" name="search_'.$key.'" value="'.dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]).'">';
884 print '</td>';
885 } elseif ($key == 'type_code') {
886 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
887 $formTicket->selectTypesTickets(empty($search[$key]) ? '' : $search[$key], 'search_'.$key, '', 2, 1, 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150'), 1);
888 print '</td>';
889 } elseif ($key == 'category_code') {
890 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
891 $formTicket->selectGroupTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, '', 2, 1, 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150'));
892 print '</td>';
893 } elseif ($key == 'severity_code') {
894 print '<td class="liste_titre center'.($cssforfield ? ' '.$cssforfield : '').'">';
895 $formTicket->selectSeveritiesTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, '', 2, 1, 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150'));
896 print '</td>';
897 } elseif ($key == 'fk_user_assign' || $key == 'fk_user_create') {
898 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
899 print $form->select_dolusers((empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, 1, null, 0, '', '', '0', 0, 0, '', 0, '', (!empty($val['css']) ? $val['css'] : 'maxwidth100'));
900 print '</td>';
901 } elseif ($key == 'fk_statut') {
902 $arrayofstatus = array();
903 $langs->load("ticket");
904 $arrayofstatus['openall'] = array('id' => 'openall', 'labelhtml' => '<b>-- '.$langs->trans('OpenAll').'</b>', 'label' => '-- '.$langs->trans('OpenAll'));
905 foreach ($object->labelStatusShort as $key2 => $val2) {
906 if ($key2 == Ticket::STATUS_CLOSED) {
907 $arrayofstatus['closeall'] = array('id' => 'closeall', 'labelhtml' => '<b>-- '.$langs->trans('ClosedAll').'</b>', 'label' => '-- '.$langs->trans('ClosedAll'));
908 }
909 $arrayofstatus[$key2] = array('id' => $key2, 'labelhtml' => $val2, 'label' => $val2);
910 }
911 print '<td class="liste_titre center parentonrightofpage'.($cssforfield ? ' '.$cssforfield : '').'">';
912 //var_dump($arrayofstatus);
913 //var_dump($search['fk_statut']);
914 //var_dump(array_values($search[$key]));
915 $selectedarray = null;
916 if (!empty($search[$key])) {
917 if (is_array($search[$key])) {
918 $selectedarray = array_values($search[$key]);
919 } else {
920 $selectedarray = array($search[$key]); // Compatibility with "Default search filters"
921 }
922 }
923 print Form::multiselectarray('search_fk_statut', $arrayofstatus, $selectedarray, 0, 0, 'search_status width150 onrightofpage', 1, 0, '', '', '');
924 print '</td>';
925 } elseif ($key == "fk_soc") {
926 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'"><input type="text" class="flat maxwidth75" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
927 } elseif ($key == "datec" || $key == 'date_read' || $key == 'date_close') {
928 print '<td class="liste_titre center">';
929 print '<div class="nowrap">';
930 switch ($key) {
931 case 'datec':
932 print $form->selectDate($search_date_start ?: -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
933 break;
934 case 'date_read':
935 print $form->selectDate($search_dateread_start ?: -1, 'search_dateread_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
936 break;
937 case 'date_close':
938 print $form->selectDate($search_dateclose_start ?: -1, 'search_dateclose_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
939 }
940 print '</div>';
941 print '<div class="nowrap">';
942 switch ($key) {
943 case 'datec':
944 print $form->selectDate($search_date_end ?: -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
945 break;
946 case 'date_read':
947 print $form->selectDate($search_dateread_end ?: -1, 'search_dateread_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
948 break;
949 case 'date_close':
950 print $form->selectDate($search_dateclose_end ?: -1, 'search_dateclose_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
951 }
952 print '</div>';
953 print '</td>';
954 } else {
955 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
956 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
957 print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
958 } elseif (strpos($val['type'], 'integer:') === 0) {
959 print $object->showInputField($val, $key, !empty($search[$key]) ? $search[$key] : "", '', '', 'search_', 'maxwidth150', 1);
960 } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) {
961 print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]).'">';
962 }
963 print '</td>';
964 }
965 }
966}
967// Extra fields
968include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
969
970// Fields from hook
971$parameters = array('arrayfields' => $arrayfields);
972$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
973print $hookmanager->resPrint;
974// Action column
975if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
976 print '<td class="liste_titre center maxwidthsearch">';
977 $searchpicto = $form->showFilterButtons();
978 print $searchpicto;
979 print '</td>';
980}
981print '</tr>'."\n";
982
983$totalarray = array();
984$totalarray['nbfield'] = 0;
985
986// Fields title label
987// --------------------------------------------------------------------
988print '<tr class="liste_titre">';
989if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
990 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
991 $totalarray['nbfield']++;
992}
993foreach ($object->fields as $key => $val) {
994 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
995 if ($key == 'fk_statut' || $key == 'severity_code') {
996 $cssforfield .= ($cssforfield ? ' ' : '').'center';
997 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
998 $cssforfield .= ($cssforfield ? ' ' : '').'center';
999 } elseif (in_array($val['type'], array('timestamp'))) {
1000 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
1001 } 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'])) {
1002 $cssforfield .= ($cssforfield ? ' ' : '').'right';
1003 }
1004 $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
1005 if (!empty($arrayfields['t.'.$key]['checked'])) {
1006 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";
1007 $totalarray['nbfield']++;
1008 }
1009}
1010// Extra fields
1011include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1012// Hook fields
1013$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
1014$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1015print $hookmanager->resPrint;
1016if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1017 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1018 $totalarray['nbfield']++;
1019}
1020print '</tr>'."\n";
1021
1022
1023// Detect if we need a fetch on each output line
1024$needToFetchEachLine = 0;
1025if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
1026 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
1027 if (!is_null($val) && preg_match('/\$object/', $val)) {
1028 $needToFetchEachLine++; // There is at least one compute field that use $object
1029 }
1030 }
1031}
1032
1033
1034// Loop on record
1035// --------------------------------------------------------------------
1036$i = 0;
1037$savnbfield = $totalarray['nbfield'];
1038$totalarray = array();
1039$totalarray['nbfield'] = 0;
1040$imaxinloop = ($limit ? min($num, $limit) : $num);
1041$cacheofoutputfield = array();
1042while ($i < $imaxinloop) {
1043 $obj = $db->fetch_object($resql);
1044 if (empty($obj)) {
1045 break; // Should not happen
1046 }
1047
1048 // Store properties in $object
1049 $object->setVarsFromFetchObj($obj);
1050 $object->type_code = $obj->type_code;
1051 $object->status = $object->fk_statut; // because field name is fk_statut
1052
1053 if ($mode == 'kanban') {
1054 if ($i == 0) {
1055 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1056 print '<div class="box-flex-container kanban">';
1057 }
1058
1059 // get infos needed from object
1060 // TODO Create a cache on users
1061 $arraydata = array();
1062 if ($obj->fk_user_assign > 0) {
1063 $user_temp->fetch($obj->fk_user_assign);
1064 $arraydata['user_assignment'] = $user_temp->getNomUrl(-3);
1065 }
1066 $arraydata['selected'] = in_array($object->id, $arrayofselected);
1067
1068 // Output Kanban
1069 print $object->getKanbanView('', $arraydata);
1070 if ($i == ($imaxinloop - 1)) {
1071 print '</div>';
1072 print '</td></tr>';
1073 }
1074 } else {
1075 // Show line of result
1076 $j = 0;
1077 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
1078
1079 // Action column
1080 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1081 print '<td class="nowrap center">';
1082 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1083 $selected = 0;
1084 if (in_array($object->id, $arrayofselected)) {
1085 $selected = 1;
1086 }
1087 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
1088 }
1089 print '</td>';
1090 if (!$i) {
1091 $totalarray['nbfield']++;
1092 }
1093 }
1094 // Fields
1095 foreach ($object->fields as $key => $val) {
1096 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
1097 if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
1098 $cssforfield .= ($cssforfield ? ' ' : '').'center';
1099 }
1100
1101 if (in_array($val['type'], array('timestamp'))) {
1102 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
1103 }
1104 if (in_array($key, array('ref', 'fk_project'))) {
1105 $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
1106 }
1107
1108 if ($key == 'fk_statut' || $key == 'severity_code') {
1109 $cssforfield .= ($cssforfield ? ' ' : '').'center';
1110 }
1111 if (!empty($arrayfields['t.'.$key]['checked'])) {
1112 print '<td'.($cssforfield ? ' class="'.$cssforfield.((preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) ? ' classfortooltip' : '').'"' : '');
1113 if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) {
1114 print ' title="'.dol_escape_htmltag((string) $object->$key).'"';
1115 }
1116 print '>';
1117 if ($key == 'fk_statut') {
1118 print $object->getLibStatut(5);
1119 } elseif ($key == 'subject') {
1120 $s = $obj->subject;
1121 print '<span title="'.dol_escape_htmltag($s).'">';
1122 print dol_escape_htmltag($s);
1123 print '</span>';
1124 } elseif ($key == 'type_code') {
1125 $s = $langs->getLabelFromKey($db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code);
1126 print '<span title="'.dol_escape_htmltag($s).'">';
1127 print $s;
1128 print '</span>';
1129 } elseif ($key == 'category_code') {
1130 $s = $langs->getLabelFromKey($db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code);
1131 print '<span title="'.dol_escape_htmltag($s).'">';
1132 print $s;
1133 print '</span>';
1134 } elseif ($key == 'severity_code') {
1135 $s = $langs->getLabelFromKey($db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code);
1136 print '<span title="'.dol_escape_htmltag($s).'">';
1137 print $s;
1138 print '</span>';
1139 } elseif ($key == 'tms') {
1140 print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser');
1141 } elseif ($key == 'fk_user_create') {
1142 if ($object->fk_user_create > 0) {
1143 if (isset($conf->cache['user'][$object->fk_user_create])) {
1144 $user_temp = $conf->cache['user'][$object->fk_user_create];
1145 } else {
1146 $user_temp = new User($db);
1147 $user_temp->fetch($object->fk_user_create);
1148 $conf->cache['user'][$object->fk_user_create] = $user_temp;
1149 }
1150 print $user_temp->getNomUrl(-1);
1151 }
1152 } elseif ($key == 'fk_user_assign') {
1153 if ($object->fk_user_assign > 0) {
1154 if (isset($conf->cache['user'][$object->fk_user_assign])) {
1155 $user_temp = $conf->cache['user'][$object->fk_user_assign];
1156 } else {
1157 $user_temp = new User($db);
1158 $user_temp->fetch($object->fk_user_assign);
1159 $conf->cache['user'][$object->fk_user_assign] = $user_temp;
1160 }
1161 print $user_temp->getNomUrl(-1);
1162 }
1163 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
1164 print $object->showOutputField($val, $key, $db->jdate($obj->$key), '');
1165 } elseif ($key == 'ref') {
1166 print $object->showOutputField($val, $key, $obj->$key, '');
1167
1168 // display a warning on untreated tickets
1169 $is_open = ($object->status != Ticket::STATUS_CLOSED && $object->status != Ticket::STATUS_CANCELED);
1170 $should_show_warning = (getDolGlobalString('TICKET_DELAY_SINCE_LAST_RESPONSE') || getDolGlobalString('TICKET_DELAY_BEFORE_FIRST_RESPONSE'));
1171 if ($is_open && $should_show_warning) {
1172 $date_last_msg_sent = (int) $object->date_last_msg_sent;
1173 $hour_diff = ($now - $date_last_msg_sent) / 3600 ;
1174
1175 if (getDolGlobalString('TICKET_DELAY_BEFORE_FIRST_RESPONSE') && $date_last_msg_sent == 0) {
1176 $creation_date = $object->datec;
1177 $hour_diff_creation = ($now - $creation_date) / 3600 ;
1178 if ($hour_diff_creation > getDolGlobalInt('TICKET_DELAY_BEFORE_FIRST_RESPONSE')) {
1179 print " " . img_picto($langs->trans('Late') . ' : ' . $langs->trans('TicketsDelayForFirstResponseTooLong', getDolGlobalString('TICKET_DELAY_BEFORE_FIRST_RESPONSE')), 'warning', 'style="color: red;"', 0, 0, 0, '', '');
1180 }
1181 } elseif (getDolGlobalString('TICKET_DELAY_SINCE_LAST_RESPONSE') && $hour_diff > getDolGlobalInt('TICKET_DELAY_SINCE_LAST_RESPONSE')) {
1182 print " " . img_picto($langs->trans('Late') . ' : ' . $langs->trans('TicketsDelayFromLastResponseTooLong', getDolGlobalString('TICKET_DELAY_SINCE_LAST_RESPONSE')), 'warning');
1183 }
1184 }
1185 } else { // Example: key=fk_soc, obj->key=123 val=array('type'=>'integer', ...
1186 $tmp = explode(':', $val['type']);
1187 if ($tmp[0] == 'integer' && !empty($tmp[1]) && class_exists($tmp[1])) {
1188 // It is a type of an foreign field. We will try to reduce the number of fetch that the showOutputField is making.
1189 //var_dump('eeee-'.$key.'-'.$obj->$key.'-'.$val['type']);
1190 if ($key && $obj->$key && $val['type'] && array_key_exists($key.'-'.$obj->$key.'-'.$val['type'], $cacheofoutputfield)) {
1191 $result = $cacheofoutputfield[$key.'-'.$obj->$key.'-'.$val['type']];
1192 } else {
1193 $result = $object->showOutputField($val, $key, $obj->$key, '');
1194 $cacheofoutputfield[$key.'-'.$obj->$key.'-'.$val['type']] = $result;
1195 }
1196 } else {
1197 $result = $object->showOutputField($val, $key, $obj->$key, '');
1198 }
1199 print $result;
1200 }
1201
1202 print '</td>';
1203 if (!$i) {
1204 $totalarray['nbfield']++;
1205 }
1206 if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
1207 if (!$i) {
1208 $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
1209 }
1210 if (!isset($totalarray['val'])) {
1211 $totalarray['val'] = array();
1212 }
1213 if (!isset($totalarray['val']['t.'.$key])) {
1214 $totalarray['val']['t.'.$key] = 0;
1215 }
1216 $totalarray['val']['t.'.$key] += $object->$key;
1217 }
1218 }
1219 }
1220 // Extra fields
1221 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1222 // Fields from hook
1223 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1224 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1225 print $hookmanager->resPrint;
1226
1227 // Action column
1228 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1229 print '<td class="nowrap center">';
1230 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1231 $selected = 0;
1232 if (in_array($object->id, $arrayofselected)) {
1233 $selected = 1;
1234 }
1235 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
1236 }
1237 print '</td>';
1238 if (!$i) {
1239 $totalarray['nbfield']++;
1240 }
1241 }
1242
1243 print '</tr>'."\n";
1244 }
1245
1246 $i++;
1247}
1248
1249// Show total line
1250include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1251
1252
1253// If no record found
1254if ($num == 0) {
1255 $colspan = 1;
1256 foreach ($arrayfields as $key => $val) {
1257 if (!empty($val['checked'])) {
1258 $colspan++;
1259 }
1260 }
1261 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1262}
1263
1264
1265$db->free($resql);
1266
1267$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1268$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
1269print $hookmanager->resPrint;
1270
1271print '</table>'."\n";
1272print '</div>'."\n";
1273print '</div>'."\n"; // end div-responsive-inside
1274
1275print '</form>'."\n";
1276
1277
1278
1279if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
1280 $hidegeneratedfilelistifempty = 1;
1281 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1282 $hidegeneratedfilelistifempty = 0;
1283 }
1284
1285 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
1286 $formfile = new FormFile($db);
1287
1288 // Show list of available documents
1289 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1290 $urlsource .= str_replace('&amp;', '&', $param);
1291
1292 $filedir = $diroutputmassaction;
1293 $genallowed = $permissiontoread;
1294 $delallowed = $permissiontoadd;
1295
1296 print $formfile->showdocuments('massfilesarea_ticket', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1297}
1298
1299// End of page
1300llxFooter();
1301$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.