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