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