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