dolibarr  16.0.1
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 $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
356 if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
357  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
358 }
359 // Add table from hooks
360 $parameters = array();
361 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
362 $sql .= $hookmanager->resPrint;
363 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (t.fk_soc = s.rowid)";
364 $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
365 if ($socid > 0) {
366  $sql .= " AND t.fk_soc = ".((int) $socid);
367 }
368 
369 foreach ($search as $key => $val) {
370  if ($key == 'fk_statut' && !empty($search['fk_statut'])) {
371  $newarrayofstatus = array();
372  foreach ($search['fk_statut'] as $key2 => $val2) {
373  if (in_array($val2, array('openall', 'closeall'))) {
374  continue;
375  }
376  $newarrayofstatus[] = $val2;
377  }
378  if ($search['fk_statut'] == 'openall' || in_array('openall', $search['fk_statut'])) {
379  $newarrayofstatus[] = Ticket::STATUS_NOT_READ;
380  $newarrayofstatus[] = Ticket::STATUS_READ;
381  $newarrayofstatus[] = Ticket::STATUS_ASSIGNED;
382  $newarrayofstatus[] = Ticket::STATUS_IN_PROGRESS;
383  $newarrayofstatus[] = Ticket::STATUS_NEED_MORE_INFO;
384  $newarrayofstatus[] = Ticket::STATUS_WAITING;
385  }
386  if ($search['fk_statut'] == 'closeall' || in_array('closeall', $search['fk_statut'])) {
387  $newarrayofstatus[] = Ticket::STATUS_CLOSED;
388  $newarrayofstatus[] = Ticket::STATUS_CANCELED;
389  }
390  if (count($newarrayofstatus)) {
391  $sql .= natural_search($key, join(',', $newarrayofstatus), 2);
392  }
393  continue;
394  } elseif ($key == 'fk_user_assign' || $key == 'fk_user_create' || $key == 'fk_project') {
395  if ($search[$key] > 0) {
396  $sql .= natural_search($key, $search[$key], 2);
397  }
398  continue;
399  }
400 
401  $mode_search = ((!empty($object->fields[$key]) && ($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))) ? 1 : 0);
402  // $search[$key] can be an array of values, or a string. We add filter if array not empty or if it is a string.
403  if ((is_array($search[$key]) && !empty($search[$key])) || (!is_array($search[$key]) && $search[$key] != '')) {
404  $sql .= natural_search($key, $search[$key], $mode_search);
405  }
406 }
407 if ($search_all) {
408  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
409 }
410 if ($search_societe) {
411  $sql .= natural_search('s.nom', $search_societe);
412 }
413 if ($search_fk_project > 0) {
414  $sql .= natural_search('fk_project', $search_fk_project, 2);
415 }
416 if ($search_date_start) {
417  $sql .= " AND t.datec >= '".$db->idate($search_date_start)."'";
418 }
419 if ($search_date_end) {
420  $sql .= " AND t.datec <= '".$db->idate($search_date_end)."'";
421 }
422 if ($search_dateread_start) {
423  $sql .= " AND t.date_read >= '".$db->idate($search_dateread_start)."'";
424 }
425 if ($search_dateread_end) {
426  $sql .= " AND t.date_read <= '".$db->idate($search_dateread_end)."'";
427 }
428 if ($search_dateclose_start) {
429  $sql .= " AND t.date_close >= '".$db->idate($search_dateclose_start)."'";
430 }
431 if ($search_dateclose_end) {
432  $sql .= " AND t.date_close <= '".$db->idate($search_dateclose_end)."'";
433 }
434 
435 if (!$user->socid && ($mode == "mine" || (!$user->admin && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY))) {
436  $sql .= " AND (t.fk_user_assign = ".((int) $user->id);
437  if (empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY)) {
438  $sql .= " OR t.fk_user_create = ".((int) $user->id);
439  }
440  $sql .= ")";
441 }
442 
443 // Add where from extra fields
444 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
445 // Add where from hooks
446 $parameters = array();
447 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
448 $sql .= $hookmanager->resPrint;
449 
450 // Count total nb of records
451 $nbtotalofrecords = '';
452 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
453  /* The fast and low memory method to get and count full list converts the sql into a sql count */
454  $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
455  $resql = $db->query($sqlforcount);
456  $objforcount = $db->fetch_object($resql);
457  $nbtotalofrecords = $objforcount->nbtotalofrecords;
458  if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
459  $page = 0;
460  $offset = 0;
461  }
462  $db->free($resql);
463 }
464 
465 // Complete request and execute it with limit
466 $sql .= $db->order($sortfield, $sortorder);
467 if ($limit) {
468  $sql .= $db->plimit($limit + 1, $offset);
469 }
470 
471 $resql = $db->query($sql);
472 if (!$resql) {
473  dol_print_error($db);
474  exit;
475 }
476 
477 $num = $db->num_rows($resql);
478 
479 // Direct jump if only one record found
480 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
481  $obj = $db->fetch_object($resql);
482  $id = $obj->rowid;
483  header("Location: ".DOL_URL_ROOT.'/ticket/card.php?id='.$id);
484  exit;
485 }
486 
487 
488 // Output page
489 // --------------------------------------------------------------------
490 
491 llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', '');
492 
493 if ($socid && !$projectid && !$project_ref && $user->rights->societe->lire) {
494  $socstat = new Societe($db);
495  $res = $socstat->fetch($socid);
496  if ($res > 0) {
497  $tmpobject = $object;
498  $object = $socstat; // $object must be of type Societe when calling societe_prepare_head
499  $head = societe_prepare_head($socstat);
500  $object = $tmpobject;
501 
502  print dol_get_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), -1, 'company');
503 
504  dol_banner_tab($socstat, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom');
505 
506  print '<div class="fichecenter">';
507 
508  print '<div class="underbanner clearboth"></div>';
509  print '<table class="border centpercent tableforfield">';
510 
511  // Type Prospect/Customer/Supplier
512  print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
513  print $socstat->getTypeUrl(1);
514  print '</td></tr>';
515 
516  // Customer code
517  if ($socstat->client && !empty($socstat->code_client)) {
518  print '<tr><td class="titlefield">';
519  print $langs->trans('CustomerCode').'</td><td>';
520  print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_client));
521  $tmpcheck = $socstat->check_codeclient();
522  if ($tmpcheck != 0 && $tmpcheck != -5) {
523  print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
524  }
525  print '</td>';
526  print '</tr>';
527  }
528  // Supplier code
529  if ($socstat->fournisseur && !empty($socstat->code_fournisseur)) {
530  print '<tr><td class="titlefield">';
531  print $langs->trans('SupplierCode').'</td><td>';
532  print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_fournisseur));
533  $tmpcheck = $socstat->check_codefournisseur();
534  if ($tmpcheck != 0 && $tmpcheck != -5) {
535  print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
536  }
537  print '</td>';
538  print '</tr>';
539  }
540 
541  print '</table>';
542  print '</div>';
543  print dol_get_fiche_end();
544  }
545 }
546 
547 if ($projectid > 0 || $project_ref) {
548  $projectstat = new Project($db);
549  if ($projectstat->fetch($projectid, $project_ref) > 0) {
550  $projectid = $projectstat->id;
551  $projectstat->fetch_thirdparty();
552 
553  $savobject = $object;
554  $object = $projectstat;
555 
556  // To verify role of users
557  //$userAccess = $object->restrictedProjectArea($user,'read');
558  $userWrite = $projectstat->restrictedProjectArea($user, 'write');
559  //$userDelete = $object->restrictedProjectArea($user,'delete');
560  //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
561 
562  $head = project_prepare_head($projectstat);
563  print dol_get_fiche_head($head, 'ticket', $langs->trans("Project"), -1, ($projectstat->public ? 'projectpub' : 'project'));
564 
565  // Project card
566 
567  $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
568 
569  $morehtmlref = '<div class="refidno">';
570  // Title
571  $morehtmlref .= $object->title;
572  // Thirdparty
573  if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
574  $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project');
575  }
576  $morehtmlref .= '</div>';
577 
578  // Define a complementary filter for search of next/prev ref.
579  if (empty($user->rights->projet->all->lire)) {
580  $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
581  $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
582  }
583 
584  dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
585 
586  print '<div class="fichecenter">';
587  print '<div class="underbanner clearboth"></div>';
588 
589  print '<table class="border tableforfield" width="100%">';
590 
591  // Visibility
592  print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
593  if ($projectstat->public) {
594  print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
595  print $langs->trans('SharedProject');
596  } else {
597  print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
598  print $langs->trans('PrivateProject');
599  }
600  print '</td></tr>';
601 
602  print "</table>";
603 
604  print '</div>';
605  print dol_get_fiche_end();
606 
607  $object = $savobject;
608  } else {
609  print "ErrorRecordNotFound";
610  }
611 }
612 
613 $arrayofselected = is_array($toselect) ? $toselect : array();
614 
615 $param = '';
616 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
617  $param .= '&contextpage='.urlencode($contextpage);
618 }
619 if ($limit > 0 && $limit != $conf->liste_limit) {
620  $param .= '&limit='.urlencode($limit);
621 }
622 foreach ($search as $key => $val) {
623  if (is_array($search[$key])) {
624  foreach ($search[$key] as $skey) {
625  if ($skey != '') {
626  $param .= (!empty($val)) ? '&search_'.$key.'[]='.urlencode($skey) : "";
627  }
628  }
629  } elseif ($search[$key] != '') {
630  $param .= '&search_'.$key.'='.urlencode($search[$key]);
631  }
632 }
633 if ($optioncss != '') {
634  $param .= '&optioncss='.urlencode($optioncss);
635 }
636 // Add $param from extra fields
637 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
638 // Add $param from hooks
639 $parameters = array();
640 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
641 $param .= $hookmanager->resPrint;
642 if ($socid > 0) {
643  $param .= '&socid='.urlencode($socid);
644 }
645 if ($search_societe) {
646  $param .= '&search_societe='.urlencode($search_societe);
647 }
648 if ($projectid > 0) {
649  $param .= '&projectid='.urlencode($projectid);
650 }
651 if ($search_date_start) {
652  $tmparray = dol_getdate($search_date_start);
653  $param .= '&search_date_startday='.urlencode($tmparray['mday']);
654  $param .= '&search_date_startmonth='.urlencode($tmparray['mon']);
655  $param .= '&search_date_startyear='.urlencode($tmparray['year']);
656 }
657 if ($search_date_end) {
658  $tmparray = dol_getdate($search_date_end);
659  $param .= '&search_date_endday='.urlencode($tmparray['mday']);
660  $param .= '&search_date_endmonth='.urlencode($tmparray['mon']);
661  $param .= '&search_date_endyear='.urlencode($tmparray['year']);
662 }
663 if ($search_dateread_start) {
664  $tmparray = dol_getdate($search_dateread_start);
665  $param .= '&search_dateread_startday='.urlencode($tmparray['mday']);
666  $param .= '&search_dateread_startmonth='.urlencode($tmparray['mon']);
667  $param .= '&search_dateread_startyear='.urlencode($tmparray['year']);
668 }
669 if ($search_dateread_end) {
670  $tmparray = dol_getdate($search_dateread_end);
671  $param .= '&search_dateread_endday='.urlencode($tmparray['mday']);
672  $param .= '&search_dateread_endmonth='.urlencode($tmparray['mon']);
673  $param .= '&search_dateread_endyear='.urlencode($tmparray['year']);
674 }
675 if ($search_dateclose_start) {
676  $tmparray = dol_getdate($search_dateclose_start);
677  $param .= '&search_dateclose_startday='.urlencode($tmparray['mday']);
678  $param .= '&search_dateclose_startmonth='.urlencode($tmparray['mon']);
679  $param .= '&search_dateclose_startyear='.urlencode($tmparray['year']);
680 }
681 if ($search_dateclose_end) {
682  $tmparray = dol_getdate($search_dateclose_end);
683  $param .= '&search_date_endday='.urlencode($tmparray['mday']);
684  $param .= '&search_date_endmonth='.urlencode($tmparray['mon']);
685  $param .= '&search_date_endyear='.urlencode($tmparray['year']);
686 }
687 
688 // List of mass actions available
689 $arrayofmassactions = array(
690  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
691  //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
692 );
693 if ($permissiontoadd) {
694  $arrayofmassactions['presendonclose'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Close");
695  $arrayofmassactions['reopen'] = img_picto('', 'folder-open', 'class="pictofixedwidth"').$langs->trans("ReOpen");
696 }
697 if ($permissiontodelete) {
698  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
699 }
700 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
701  $arrayofmassactions = array();
702 }
703 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
704 
705 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
706 if ($optioncss != '') {
707  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
708 }
709 print '<input type="hidden" name="token" value="'.newToken().'">';
710 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
711 print '<input type="hidden" name="action" value="list">';
712 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
713 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
714 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
715 print '<input type="hidden" name="mode" value="'.$mode.'" >';
716 
717 if ($socid) {
718  print '<input type="hidden" name="socid" value="'.$socid.'" >';
719 }
720 if ($projectid) {
721  print '<input type="hidden" name="projectid" value="'.$projectid.'" >';
722 }
723 
724 $url = DOL_URL_ROOT.'/ticket/card.php?action=create'.($socid ? '&socid='.$socid : '').($projectid ? '&origin=projet_project&originid='.$projectid : '');
725 if (!empty($socid)) {
726  $url .= '&socid='.$socid;
727 }
728 $newcardbutton = dolGetButtonTitle($langs->trans('NewTicket'), '', 'fa fa-plus-circle', $url, '', $user->rights->ticket->write);
729 
730 $picto = 'ticket';
731 if ($socid > 0) {
732  $picto = '';
733 }
734 
735 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
736 
737 if ($mode == 'mine') {
738  print '<div class="opacitymedium">'.$langs->trans('TicketAssignedToMeInfos').'</div><br>';
739 }
740 // Add code for pre mass action (confirmation or email presend form)
741 $topicmail = "SendTicketRef";
742 $modelmail = "ticket";
743 $objecttmp = new Ticket($db);
744 $trackid = 'tic'.$object->id;
745 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
746 
747 // confirm auto send on close
748 if ($massaction == 'presendonclose') {
749  $hidden_form = array([
750  "type" => "hidden",
751  "name" => "massaction",
752  "value" => "close"
753  ]);
754  $selectedchoice = (!empty($conf->global->TICKET_NOTIFY_AT_CLOSING)) ? "yes" : "no";
755  print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassTicketClosingSendEmail"), $langs->trans("ConfirmMassTicketClosingSendEmailQuestion"), 'confirm_send_close', $hidden_form, $selectedchoice, 0, 200, 500, 1);
756 }
757 
758 if ($search_all) {
759  $setupstring = '';
760  foreach ($fieldstosearchall as $key => $val) {
761  $fieldstosearchall[$key] = $langs->trans($val);
762  $setupstring .= $key."=".$val.";";
763  }
764  print '<!-- Search done like if PRODUCT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
765  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'."\n";
766 }
767 
768 $moreforfilter = '';
769 /*$moreforfilter.='<div class="divsearchfield">';
770 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
771 $moreforfilter.= '</div>';*/
772 
773 $parameters = array();
774 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
775 if (empty($reshook)) {
776  $moreforfilter .= $hookmanager->resPrint;
777 } else {
778  $moreforfilter = $hookmanager->resPrint;
779 }
780 
781 if (!empty($moreforfilter)) {
782  print '<div class="liste_titre liste_titre_bydiv centpercent">';
783  print $moreforfilter;
784  print '</div>';
785 }
786 
787 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
788 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
789 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
790 
791 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
792 print '<div class="div-table-responsive-inside">';
793 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
794 
795 
796 // Fields title search
797 // --------------------------------------------------------------------
798 print '<tr class="liste_titre">';
799 foreach ($object->fields as $key => $val) {
800  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
801  if ($key == 'fk_statut') {
802  $cssforfield .= ($cssforfield ? ' ' : '').'center';
803  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
804  $cssforfield .= ($cssforfield ? ' ' : '').'center';
805  } elseif (in_array($val['type'], array('timestamp'))) {
806  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
807  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
808  $cssforfield .= ($cssforfield ? ' ' : '').'right';
809  }
810  if (!empty($arrayfields['t.'.$key]['checked'])) {
811  if ($key == 'progress') {
812  print '<td class="liste_titre right'.($cssforfield ? ' '.$cssforfield : '').'">';
813  print '<input type="text" class="flat maxwidth50" name="search_'.$key.'" value="'.dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]).'">';
814  print '</td>';
815  } elseif ($key == 'type_code') {
816  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
817  $formTicket->selectTypesTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150'));
818  print '</td>';
819  } elseif ($key == 'category_code') {
820  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
821  $formTicket->selectGroupTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150'));
822  print '</td>';
823  } elseif ($key == 'severity_code') {
824  print '<td class="liste_titre center'.($cssforfield ? ' '.$cssforfield : '').'">';
825  $formTicket->selectSeveritiesTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150'));
826  print '</td>';
827  } elseif ($key == 'fk_user_assign' || $key == 'fk_user_create') {
828  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
829  print $form->select_dolusers((empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, 1, null, 0, '', '', '0', 0, 0, '', 0, '', ($val['css'] ? $val['css'] : 'maxwidth100'));
830  print '</td>';
831  } elseif ($key == 'fk_statut') {
832  $arrayofstatus = array();
833  $arrayofstatus['openall'] = '-- '.$langs->trans('OpenAll').' --';
834  foreach ($object->statuts_short as $key2 => $val2) {
835  if ($key2 == Ticket::STATUS_CLOSED) {
836  $arrayofstatus['closeall'] = '-- '.$langs->trans('ClosedAll').' --';
837  }
838  $arrayofstatus[$key2] = $val2;
839  }
840  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
841  //var_dump($arrayofstatus);
842  //var_dump($search['fk_statut']);
843  //var_dump(array_values($search[$key]));
844  $selectedarray = null;
845  if (!empty($search[$key])) {
846  $selectedarray = array_values($search[$key]);
847  }
848  print Form::multiselectarray('search_fk_statut', $arrayofstatus, $selectedarray, 0, 0, 'minwidth100imp maxwidth150', 1, 0, '', '', '');
849  print '</td>';
850  } elseif ($key == "fk_soc") {
851  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'"><input type="text" class="flat maxwidth75" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
852  } elseif ($key == "datec" || $key == 'date_read' || $key == 'date_close') {
853  print '<td class="liste_titre center">';
854  print '<div class="nowrap">';
855  switch ($key) {
856  case 'datec':
857  print $form->selectDate($search_date_start ?: -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
858  break;
859  case 'date_read':
860  print $form->selectDate($search_dateread_start ?: -1, 'search_dateread_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
861  break;
862  case 'date_close':
863  print $form->selectDate($search_dateclose_start ?: -1, 'search_dateclose_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
864  }
865  print '</div>';
866  print '<div class="nowrap">';
867  switch ($key) {
868  case 'datec':
869  print $form->selectDate($search_date_end ?: -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
870  break;
871  case 'date_read':
872  print $form->selectDate($search_dateread_end ?: -1, 'search_dateread_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
873  break;
874  case 'date_close':
875  print $form->selectDate($search_dateclose_end ?: -1, 'search_dateclose_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
876  }
877  print '</div>';
878  print '</td>';
879  } else {
880  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
881  if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
882  print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
883  } elseif (strpos($val['type'], 'integer:') === 0) {
884  print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
885  } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) {
886  print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]).'">';
887  }
888  print '</td>';
889  }
890  }
891 }
892 // Extra fields
893 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
894 
895 // Fields from hook
896 $parameters = array('arrayfields'=>$arrayfields);
897 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
898 print $hookmanager->resPrint;
899 // Action column
900 print '<td class="liste_titre maxwidthsearch">';
901 $searchpicto = $form->showFilterButtons();
902 print $searchpicto;
903 print '</td>';
904 print '</tr>'."\n";
905 
906 
907 // Fields title label
908 // --------------------------------------------------------------------
909 print '<tr class="liste_titre">';
910 foreach ($object->fields as $key => $val) {
911  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
912  if ($key == 'fk_statut' || $key == 'severity_code') {
913  $cssforfield .= ($cssforfield ? ' ' : '').'center';
914  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
915  $cssforfield .= ($cssforfield ? ' ' : '').'center';
916  } elseif (in_array($val['type'], array('timestamp'))) {
917  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
918  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
919  $cssforfield .= ($cssforfield ? ' ' : '').'right';
920  }
921  if (!empty($arrayfields['t.'.$key]['checked'])) {
922  print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
923  }
924 }
925 $totalarray = array(
926  'nbfield' => 0,
927 );
928 // Extra fields
929 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
930 // Hook fields
931 $parameters = array(
932  'arrayfields' => $arrayfields,
933  'param' => $param,
934  'sortfield' => $sortfield,
935  'sortorder' => $sortorder,
936  'totalarray' => &$totalarray,
937 );
938 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
939 print $hookmanager->resPrint;
940 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
941 print '</tr>'."\n";
942 
943 
944 // Detect if we need a fetch on each output line
945 $needToFetchEachLine = 0;
946 if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
947  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
948  if (preg_match('/\$object/', $val)) {
949  $needToFetchEachLine++; // There is at least one compute field that use $object
950  }
951  }
952 }
953 
954 
955 // Loop on record
956 // --------------------------------------------------------------------
957 $i = 0;
958 $totalarray = array();
959 $totalarray['nbfield'] = 0;
960 $now = dol_now();
961 
962 $cacheofoutputfield = array();
963 while ($i < ($limit ? min($num, $limit) : $num)) {
964  $obj = $db->fetch_object($resql);
965  if (empty($obj)) {
966  break; // Should not happen
967  }
968 
969  // Store properties in $object
970  $object->setVarsFromFetchObj($obj);
971  $object->status = $object->fk_statut; // fk_statut is deprecated
972 
973  // Show here line of result
974  print '<tr class="oddeven">';
975  foreach ($object->fields as $key => $val) {
976  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
977  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
978  $cssforfield .= ($cssforfield ? ' ' : '').'center';
979  }
980  if (in_array($val['type'], array('timestamp'))) {
981  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
982  }
983  if (in_array($key, array('ref', 'fk_project'))) {
984  $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
985  }
986  if ($key == 'fk_statut' || $key == 'severity_code') {
987  $cssforfield .= ($cssforfield ? ' ' : '').'center';
988  }
989  if (!empty($arrayfields['t.'.$key]['checked'])) {
990  print '<td';
991  if ($cssforfield || (array_key_exists('css', $val) && $val['css'])) {
992  print ' class="';
993  }
994  print $cssforfield;
995  if ($cssforfield && array_key_exists('css', $val) && $val['css']) {
996  print ' ';
997  }
998  if (array_key_exists('css', $val)) {
999  print $val['css'];
1000  }
1001  if ($cssforfield || (array_key_exists('css', $val) && $val['css'])) {
1002  print '"';
1003  }
1004  print '>';
1005  if ($key == 'fk_statut') {
1006  print $object->getLibStatut(5);
1007  } elseif ($key == 'subject') {
1008  $s = $obj->subject;
1009  print '<span title="'.dol_escape_htmltag($s).'">';
1010  print dol_escape_htmltag($s);
1011  print '</span>';
1012  } elseif ($key == 'type_code') {
1013  $s = $langs->getLabelFromKey($db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code);
1014  print '<span title="'.dol_escape_htmltag($s).'">';
1015  print $s;
1016  print '</span>';
1017  } elseif ($key == 'category_code') {
1018  $s = $langs->getLabelFromKey($db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code);
1019  print '<span title="'.dol_escape_htmltag($s).'">';
1020  print $s;
1021  print '</span>';
1022  } elseif ($key == 'severity_code') {
1023  $s = $langs->getLabelFromKey($db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code);
1024  print '<span title="'.dol_escape_htmltag($s).'">';
1025  print $s;
1026  print '</span>';
1027  } elseif ($key == 'tms') {
1028  print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser');
1029  } elseif ($key == 'fk_user_create') {
1030  if ($object->fk_user_create > 0) {
1031  if (isset($conf->cache['user'][$object->fk_user_create])) {
1032  $user_temp = $conf->cache['user'][$object->fk_user_create];
1033  } else {
1034  $user_temp = new User($db);
1035  $user_temp->fetch($object->fk_user_create);
1036  $conf->cache['user'][$object->fk_user_create] = $user_temp;
1037  }
1038  print $user_temp->getNomUrl(-1);
1039  }
1040  } elseif ($key == 'fk_user_assign') {
1041  if ($object->fk_user_assign > 0) {
1042  if (isset($conf->cache['user'][$object->fk_user_assign])) {
1043  $user_temp = $conf->cache['user'][$object->fk_user_assign];
1044  } else {
1045  $user_temp = new User($db);
1046  $user_temp->fetch($object->fk_user_assign);
1047  $conf->cache['user'][$object->fk_user_assign] = $user_temp;
1048  }
1049  print $user_temp->getNomUrl(-1);
1050  }
1051  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
1052  print $object->showOutputField($val, $key, $db->jdate($obj->$key), '');
1053  } elseif ($key == 'ref') {
1054  print $object->showOutputField($val, $key, $obj->$key, '');
1055 
1056  // display a warning on untreated tickets
1057  $is_open = ($object->status != Ticket::STATUS_CLOSED && $object->status != Ticket::STATUS_CANCELED );
1058  $should_show_warning = (!empty($conf->global->TICKET_DELAY_SINCE_LAST_RESPONSE) || !empty($conf->global->TICKET_DELAY_BEFORE_FIRST_RESPONSE));
1059  if ($is_open && $should_show_warning) {
1060  $date_last_msg_sent = (int) $object->date_last_msg_sent;
1061  $hour_diff = ($now - $date_last_msg_sent) / 3600 ;
1062 
1063  if (!empty($conf->global->TICKET_DELAY_BEFORE_FIRST_RESPONSE && $date_last_msg_sent == 0)) {
1064  $creation_date = $object->datec;
1065  $hour_diff_creation = ($now - $creation_date) / 3600 ;
1066  if ($hour_diff_creation > $conf->global->TICKET_DELAY_BEFORE_FIRST_RESPONSE) {
1067  print " " . img_picto($langs->trans('Late') . ' : ' . $langs->trans('TicketsDelayForFirstResponseTooLong', $conf->global->TICKET_DELAY_BEFORE_FIRST_RESPONSE), 'warning', 'style="color: red;"', false, 0, 0, '', '');
1068  }
1069  } elseif (!empty($conf->global->TICKET_DELAY_SINCE_LAST_RESPONSE) && $hour_diff > $conf->global->TICKET_DELAY_SINCE_LAST_RESPONSE) {
1070  print " " . img_picto($langs->trans('Late') . ' : ' . $langs->trans('TicketsDelayFromLastResponseTooLong', $conf->global->TICKET_DELAY_SINCE_LAST_RESPONSE), 'warning');
1071  }
1072  }
1073  } else { // Example: key=fk_soc, obj->key=123 val=array('type'=>'integer', ...
1074  $tmp = explode(':', $val['type']);
1075  if ($tmp[0] == 'integer' && !empty($tmp[1]) && class_exists($tmp[1])) {
1076  // It is a type of an foreign field. We will try to reduce the number of fetch that the showOutputField is making.
1077  //var_dump('eeee-'.$key.'-'.$obj->$key.'-'.$val['type']);
1078  if ($key && $obj->$key && $val['type'] && array_key_exists($key.'-'.$obj->$key.'-'.$val['type'], $cacheofoutputfield)) {
1079  $result = $cacheofoutputfield[$key.'-'.$obj->$key.'-'.$val['type']];
1080  } else {
1081  $result = $object->showOutputField($val, $key, $obj->$key, '');
1082  $cacheofoutputfield[$key.'-'.$obj->$key.'-'.$val['type']] = $result;
1083  }
1084  } else {
1085  $result = $object->showOutputField($val, $key, $obj->$key, '');
1086  }
1087  print $result;
1088  }
1089 
1090  print '</td>';
1091  if (!$i) {
1092  $totalarray['nbfield']++;
1093  }
1094  if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
1095  if (!$i) {
1096  $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
1097  }
1098  if (!isset($totalarray['val'])) {
1099  $totalarray['val'] = array();
1100  }
1101  if (!isset($totalarray['val']['t.'.$key])) {
1102  $totalarray['val']['t.'.$key] = 0;
1103  }
1104  $totalarray['val']['t.'.$key] += $object->$key;
1105  }
1106  }
1107  }
1108  // Extra fields
1109  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1110  // Fields from hook
1111  $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1112  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
1113  print $hookmanager->resPrint;
1114  // Action column
1115  print '<td class="nowrap center">';
1116  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1117  $selected = 0;
1118  if (in_array($obj->rowid, $arrayofselected)) {
1119  $selected = 1;
1120  }
1121  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1122  }
1123  print '</td>';
1124  if (!$i) {
1125  $totalarray['nbfield']++;
1126  }
1127 
1128  print '</tr>'."\n";
1129 
1130  $i++;
1131 }
1132 
1133 // Show total line
1134 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1135 
1136 
1137 // If no record found
1138 if ($num == 0) {
1139  $colspan = 1;
1140  foreach ($arrayfields as $key => $val) {
1141  if (!empty($val['checked'])) {
1142  $colspan++;
1143  }
1144  }
1145  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1146 }
1147 
1148 
1149 $db->free($resql);
1150 
1151 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1152 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
1153 print $hookmanager->resPrint;
1154 
1155 print '</table>'."\n";
1156 print '</div>'."\n";
1157 print '</div>'."\n"; // end div-responsive-inside
1158 
1159 print '</form>'."\n";
1160 
1161 
1162 
1163 if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
1164  $hidegeneratedfilelistifempty = 1;
1165  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1166  $hidegeneratedfilelistifempty = 0;
1167  }
1168 
1169  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
1170  $formfile = new FormFile($db);
1171 
1172  // Show list of available documents
1173  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1174  $urlsource .= str_replace('&amp;', '&', $param);
1175 
1176  $filedir = $diroutputmassaction;
1177  $genallowed = $permissiontoread;
1178  $delallowed = $permissiontoadd;
1179 
1180  print $formfile->showdocuments('massfilesarea_ticket', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1181 }
1182 
1183 // End of page
1184 llxFooter();
1185 $db->close();
project_prepare_head(Project $project, $moreparam= '')
Prepare array with list of tabs.
Definition: project.lib.php:38
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow= '')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Definition: card.php:142
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...
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_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
Definition: user.class.php:44
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
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...
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
Class to manage ticket.
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring= '1')
Replace eval function to add more security.
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.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage projects.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
dol_getdate($timestamp, $fast=false, $forcetimezone= '')
Return an array with locale date info.
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 ...
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...
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Definition: company.lib.php:42
Class to offer components to list and upload files.
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
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...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
const STATUS_NOT_READ
Status.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.
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.
llxFooter()
Empty footer.
Definition: wrapper.php:73