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