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