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