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