dolibarr 20.0.5
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013-2018 Jean-François FERRY <hello@librethic.io>
3 * Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
4 * Copyright (C) 2018 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2019-2021 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2019-2020 Laurent Destailleur <eldy@users.sourceforge.net>
7 * 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 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
31// Load Dolibarr environment
32require '../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
38include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
39include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
40include_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
41
42// Load translation files required by the page
43$langs->loadLangs(array("ticket", "companies", "other", "projects", "contracts"));
44
45// Get parameters
46$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
47$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
48$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
49$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
50$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
51$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
52$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'ticketlist'; // To manage different context of search
53$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
54$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
55$mode = GETPOST('mode', 'alpha');
56
57$id = GETPOSTINT('id');
58$msg_id = GETPOSTINT('msg_id');
59$socid = GETPOSTINT('socid');
60$contractid = GETPOSTINT('contractid');
61$projectid = GETPOSTINT('projectid');
62$project_ref = GETPOST('project_ref', 'alpha');
63$search_societe = GETPOST('search_societe', 'alpha');
64$search_fk_project = GETPOSTINT('search_fk_project') ? GETPOSTINT('search_fk_project') : GETPOSTINT('projectid');
65$search_fk_contract = GETPOSTINT('search_fk_contract') ? GETPOSTINT('search_fk_contract') : GETPOSTINT('contractid');
66
67$search_date_start = dol_mktime(0, 0, 0, GETPOSTINT('search_date_startmonth'), GETPOSTINT('search_date_startday'), GETPOSTINT('search_date_startyear'));
68$search_date_end = dol_mktime(23, 59, 59, GETPOSTINT('search_date_endmonth'), GETPOSTINT('search_date_endday'), GETPOSTINT('search_date_endyear'));
69$search_dateread_start = dol_mktime(0, 0, 0, GETPOSTINT('search_dateread_startmonth'), GETPOSTINT('search_dateread_startday'), GETPOSTINT('search_dateread_startyear'));
70$search_dateread_end = dol_mktime(23, 59, 59, GETPOSTINT('search_dateread_endmonth'), GETPOSTINT('search_dateread_endday'), GETPOSTINT('search_dateread_endyear'));
71$search_dateclose_start = dol_mktime(0, 0, 0, GETPOSTINT('search_dateclose_startmonth'), GETPOSTINT('search_dateclose_startday'), GETPOSTINT('search_dateclose_startyear'));
72$search_dateclose_end = dol_mktime(23, 59, 59, GETPOSTINT('search_dateclose_endmonth'), GETPOSTINT('search_dateclose_endday'), GETPOSTINT('search_dateclose_endyear'));
73
74
75// Load variable for pagination
76$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
77$sortfield = GETPOST('sortfield', 'aZ09comma');
78$sortorder = GETPOST('sortorder', 'aZ09comma');
79$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
80if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
81 // If $page is not defined, or '' or -1 or if we click on clear filters
82 $page = 0;
83}
84$offset = $limit * $page;
85$pageprev = $page - 1;
86$pagenext = $page + 1;
87
88// Initialize technical objects
89$object = new Ticket($db);
90$extrafields = new ExtraFields($db);
91$diroutputmassaction = $conf->ticket->dir_output.'/temp/massgeneration/'.$user->id;
92if ($socid > 0) {
93 $hookmanager->initHooks(array('thirdpartyticket', 'globalcard'));
94} elseif ($projectid > 0) {
95 $hookmanager->initHooks(array('projectticket', 'globalcard'));
96} else {
97 $hookmanager->initHooks(array('ticketlist'));
98}
99// Fetch optionals attributes and labels
100$extrafields->fetch_name_optionals_label($object->table_element);
101$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
102
103// Default sort order (if not yet defined by previous GETPOST)
104if (!$sortfield) {
105 $sortfield = "t.datec";
106}
107if (!$sortorder) {
108 $sortorder = "DESC";
109}
110
111/*if (GETPOST('search_fk_status', 'alpha') == 'non_closed') {
112 $_GET['search_fk_statut'][] = 'openall'; // For backward compatibility
113}*/
114
115// Initialize array of search criteria
116$search_all = (GETPOSTISSET("search_all") ? GETPOST("search_all", 'alpha') : GETPOST('sall'));
117$search = array();
118foreach ($object->fields as $key => $val) {
119 if (GETPOST('search_'.$key, 'alpha') !== '') {
120 $search[$key] = GETPOST('search_'.$key, 'alpha');
121 } else {
122 $search[$key] = "";
123 }
124 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
125 $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOSTINT('search_'.$key.'_dtstartmonth'), GETPOSTINT('search_'.$key.'_dtstartday'), GETPOSTINT('search_'.$key.'_dtstartyear'));
126 $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOSTINT('search_'.$key.'_dtendmonth'), GETPOSTINT('search_'.$key.'_dtendday'), GETPOSTINT('search_'.$key.'_dtendyear'));
127 }
128}
129
130// List of fields to search into when doing a "search in all"
131$fieldstosearchall = array();
132foreach ($object->fields as $key => $val) {
133 if (!empty($val['searchall'])) {
134 $fieldstosearchall['t.'.$key] = $val['label'];
135 }
136}
137$fieldstosearchall['s.name_alias'] = "AliasNameShort";
138$fieldstosearchall['s.zip'] = "Zip";
139$fieldstosearchall['s.town'] = "Town";
140
141// Definition of array of fields for columns
142$arrayfields = array();
143foreach ($object->fields as $key => $val) {
144 // If $val['visible']==0, then we never show the field
145 if (!empty($val['visible'])) {
146 $visible = (int) dol_eval($val['visible'], 1);
147 $arrayfields['t.'.$key] = array(
148 'label' => $val['label'],
149 'checked' => (($visible < 0) ? 0 : 1),
150 'enabled' => (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)),
151 'position' => $val['position'],
152 'help' => isset($val['help']) ? $val['help'] : ''
153 );
154 }
155}
156// Extra fields
157include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
158
159$object->fields = dol_sort_array($object->fields, 'position');
160$arrayfields = dol_sort_array($arrayfields, 'position');
161
162
163// Security check
164if (!$user->hasRight('ticket', 'read')) {
166}
167// restrict view to current user's company
168if ($user->socid > 0) {
169 $socid = $user->socid;
170}
171
172// Store current page url
173$url_page_current = DOL_URL_ROOT.'/ticket/list.php';
174
175if ($project_ref) {
176 $tmpproject = new Project($db);
177 $tmpproject->fetch(0, $project_ref);
178 $projectid = $tmpproject->id;
179 $search_fk_project = $projectid;
180}
181
182$permissiontoread = $user->hasRight('ticket', 'read');
183$permissiontoadd = $user->hasRight('ticket', 'write');
184$permissiontodelete = $user->hasRight('ticket', 'delete');
185
186$error = 0;
187
188
189/*
190 * Actions
191 */
192
193if (GETPOST('cancel', 'alpha')) {
194 $action = 'list';
195 $massaction = '';
196}
197if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'presendonclose' && $massaction != 'close') {
198 $massaction = '';
199}
200
201$parameters = array('arrayfields' => &$arrayfields);
202if ($socid > 0) {
203 $parameters['socid'] = $socid;
204}
205if ($projectid > 0) {
206 $parameters['projectid'] = $projectid;
207}
208$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
209if ($reshook < 0) {
210 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
211}
212
213if (empty($reshook)) {
214 // Selection of new fields
215 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
216
217 // Purge search criteria
218 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
219 foreach ($object->fields as $key => $val) {
220 $search[$key] = '';
221 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
222 $search[$key.'_dtstart'] = '';
223 $search[$key.'_dtend'] = '';
224 }
225 }
226 $toselect = array();
227 $search_array_options = array();
228 $search_date_start = '';
229 $search_date_end = '';
230 $search_dateread_start = '';
231 $search_dateread_end = '';
232 $search_dateclose_start = '';
233 $search_dateclose_end = '';
234 }
235 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
236 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
237 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
238 }
239
240 // Mass actions
241 $objectclass = 'Ticket';
242 $objectlabel = 'Ticket';
243 $uploaddir = $conf->ticket->dir_output;
244 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
245
246 // Close records
247 if (!$error && $massaction == 'close' && $permissiontoadd) {
248 $objecttmp = new $objectclass($db);
249 if (!$error) {
250 $db->begin();
251
252 $nbok = 0;
253 foreach ($toselect as $toselectid) {
254 $result = $objecttmp->fetch($toselectid);
255 if ($result > 0) {
256 $result = $objecttmp->close($user);
257 if ($result < 0) {
258 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
259 $error++;
260 break;
261 } else {
262 $nbok++;
263 }
264 } else {
265 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
266 $error++;
267 break;
268 }
269 }
270
271 if (!$error) {
272 setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
273 $db->commit();
274 } else {
275 $db->rollback();
276 }
277 //var_dump($listofobjectthirdparties);exit;
278 }
279 }
280
281 // Reopen records
282 if (!$error && $massaction == 'reopen' && $permissiontoadd) {
283 $objecttmp = new $objectclass($db);
284 if (!$error) {
285 $db->begin();
286
287 $nbok = 0;
288 foreach ($toselect as $toselectid) {
289 $result = $objecttmp->fetch($toselectid);
290 if ($result > 0) {
291 if ($objecttmp->status == Ticket::STATUS_CLOSED || $objecttmp->status == Ticket::STATUS_CANCELED) {
292 $result = $objecttmp->setStatut(Ticket::STATUS_ASSIGNED);
293 if ($result < 0) {
294 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
295 $error++;
296 break;
297 } else {
298 $nbok++;
299 }
300 } else {
301 $langs->load("errors");
302 setEventMessages($langs->trans("ErrorObjectMustHaveStatusClosedToBeReOpened", $objecttmp->ref), null, 'errors');
303 $error++;
304 break;
305 }
306 } else {
307 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
308 $error++;
309 break;
310 }
311 }
312
313 if (!$error) {
314 setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
315 $db->commit();
316 } else {
317 $db->rollback();
318 }
319 //var_dump($listofobjectthirdparties);exit;
320 }
321 }
322}
323
324
325
326/*
327 * View
328 */
329
330$form = new Form($db);
331$formTicket = new FormTicket($db);
332
333$now = dol_now();
334
335$user_temp = new User($db);
336$socstatic = new Societe($db);
337
338$help_url = '';
339
340$moretitle = '';
341if ($socid > 0) {
342 $socstatic->fetch($socid);
343 $moretitle = $langs->trans("ThirdParty") . ' - ';
344 if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $socstatic->name) {
345 $moretitle = $socstatic->name . ' - ';
346 }
347}
348
349$title = $moretitle . $langs->trans('Tickets');
350$morejs = array();
351$morecss = array();
352
353
354// Build and execute select
355// --------------------------------------------------------------------
356$sql = 'SELECT ';
357$sql .= $object->getFieldList('t');
358// Add fields from extrafields
359if (!empty($extrafields->attributes[$object->table_element]['label'])) {
360 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
361 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
362 }
363}
364// Add fields from hooks
365$parameters = array();
366$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
367$sql .= $hookmanager->resPrint;
368$sql = preg_replace('/,\s*$/', '', $sql);
369
370$sqlfields = $sql; // $sql fields to remove for count total
371
372$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
373if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
374 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
375}
376// Add table from hooks
377$parameters = array();
378$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
379$sql .= $hookmanager->resPrint;
380$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (t.fk_soc = s.rowid)";
381$sql .= " WHERE t.entity IN (".getEntity($object->element).")";
382if ($socid > 0) {
383 $sql .= " AND t.fk_soc = ".((int) $socid);
384}
385
386foreach ($search as $key => $val) {
387 $tmpkey = 't.' . $key;
388 if ($key == 'fk_statut' && !empty($search['fk_statut'])) {
389 $newarrayofstatus = array();
390 if (is_array($search['fk_statut'])) {
391 foreach ($search['fk_statut'] as $key2 => $val2) {
392 if (in_array($val2, array('openall', 'closeall'))) {
393 continue;
394 }
395 $newarrayofstatus[] = $val2;
396 }
397 }
398 if ($search['fk_statut'] == 'openall' || (is_array($search['fk_statut']) && in_array('openall', $search['fk_statut']))) {
399 $newarrayofstatus[] = Ticket::STATUS_NOT_READ;
400 $newarrayofstatus[] = Ticket::STATUS_READ;
401 $newarrayofstatus[] = Ticket::STATUS_ASSIGNED;
402 $newarrayofstatus[] = Ticket::STATUS_IN_PROGRESS;
403 $newarrayofstatus[] = Ticket::STATUS_NEED_MORE_INFO;
404 $newarrayofstatus[] = Ticket::STATUS_WAITING;
405 }
406 if ($search['fk_statut'] == 'closeall' || (is_array($search['fk_statut']) && in_array('closeall', $search['fk_statut']))) {
407 $newarrayofstatus[] = Ticket::STATUS_CLOSED;
408 $newarrayofstatus[] = Ticket::STATUS_CANCELED;
409 }
410 if (count($newarrayofstatus)) {
411 $sql .= natural_search($tmpkey, implode(',', $newarrayofstatus), 2);
412 }
413 continue;
414 } elseif ($key == 'fk_user_assign' || $key == 'fk_user_create' || $key == 'fk_project' || $key == 'fk_contract') {
415 if ($search[$key] > 0) {
416 $sql .= natural_search($tmpkey, $search[$key], 2);
417 }
418 continue;
419 } elseif ($key == 'type_code') {
420 $newarrayoftypecodes = is_array($search[$key]) ? $search[$key] : (!empty($search[$key]) ? explode(',', $search[$key]) : array());
421 if (count($newarrayoftypecodes)) {
422 $sql .= natural_search($tmpkey, implode(',', $newarrayoftypecodes), 3);
423 }
424 continue;
425 }
426
427 $mode_search = ((!empty($object->fields[$key]) && ($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))) ? 1 : 0);
428 // $search[$key] can be an array of values, or a string. We add filter if array not empty or if it is a string.
429 if ((is_array($search[$key]) && !empty($search[$key])) || (!is_array($search[$key]) && $search[$key] != '')) {
430 $sql .= natural_search($tmpkey, $search[$key], $mode_search);
431 }
432}
433if ($search_all) {
434 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
435}
436if ($search_societe) {
437 $sql .= natural_search('s.nom', $search_societe);
438}
439if ($search_fk_project > 0) {
440 $sql .= natural_search('t.fk_project', $search_fk_project, 2);
441}
442if ($search_fk_contract > 0) {
443 $sql .= natural_search('fk_contract', $search_fk_contract, 2);
444}
445if ($search_date_start) {
446 $sql .= " AND t.datec >= '".$db->idate($search_date_start)."'";
447}
448if ($search_date_end) {
449 $sql .= " AND t.datec <= '".$db->idate($search_date_end)."'";
450}
451if ($search_dateread_start) {
452 $sql .= " AND t.date_read >= '".$db->idate($search_dateread_start)."'";
453}
454if ($search_dateread_end) {
455 $sql .= " AND t.date_read <= '".$db->idate($search_dateread_end)."'";
456}
457if ($search_dateclose_start) {
458 $sql .= " AND t.date_close >= '".$db->idate($search_dateclose_start)."'";
459}
460if ($search_dateclose_end) {
461 $sql .= " AND t.date_close <= '".$db->idate($search_dateclose_end)."'";
462}
463
464if (!$user->socid && ($mode == "mine" || (!$user->admin && getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY')))) {
465 $sql .= " AND (t.fk_user_assign = ".((int) $user->id);
466 if (!getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY')) {
467 $sql .= " OR t.fk_user_create = ".((int) $user->id);
468 }
469 $sql .= ")";
470}
471
472// Add where from extra fields
473include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
474// Add where from hooks
475$parameters = array();
476$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
477$sql .= $hookmanager->resPrint;
478
479// Count total nb of records
480$nbtotalofrecords = '';
481if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
482 /* The fast and low memory method to get and count full list converts the sql into a sql count */
483 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
484 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
485 $resql = $db->query($sqlforcount);
486 if ($resql) {
487 $objforcount = $db->fetch_object($resql);
488 $nbtotalofrecords = $objforcount->nbtotalofrecords;
489 } else {
490 dol_print_error($db);
491 }
492
493 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
494 $page = 0;
495 $offset = 0;
496 }
497 $db->free($resql);
498}
499
500// Complete request and execute it with limit
501$sql .= $db->order($sortfield, $sortorder);
502if ($limit) {
503 $sql .= $db->plimit($limit + 1, $offset);
504}
505
506$resql = $db->query($sql);
507if (!$resql) {
508 dol_print_error($db);
509 exit;
510}
511
512$num = $db->num_rows($resql);
513
514// Direct jump if only one record found
515if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
516 $obj = $db->fetch_object($resql);
517 $id = $obj->rowid;
518 header("Location: ".DOL_URL_ROOT.'/ticket/card.php?id='.$id);
519 exit;
520}
521
522
523// Output page
524// --------------------------------------------------------------------
525
526llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-ticket page-list bodyforlist');
527
528if ($socid && !$projectid && !$project_ref && $user->hasRight('societe', 'lire')) {
529 $socstat = new Societe($db);
530 $res = $socstat->fetch($socid);
531 if ($res > 0) {
532 $tmpobject = $object;
533 $object = $socstat; // $object must be of type Societe when calling societe_prepare_head
534 $head = societe_prepare_head($socstat);
535 $object = $tmpobject;
536
537 print dol_get_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), -1, 'company');
538
539 dol_banner_tab($socstat, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom');
540
541 print '<div class="fichecenter">';
542
543 print '<div class="underbanner clearboth"></div>';
544 print '<table class="border centpercent tableforfield">';
545
546 // Type Prospect/Customer/Supplier
547 print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
548 print $socstat->getTypeUrl(1);
549 print '</td></tr>';
550
551 // Customer code
552 if ($socstat->client && !empty($socstat->code_client)) {
553 print '<tr><td class="titlefield">';
554 print $langs->trans('CustomerCode').'</td><td>';
555 print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_client));
556 $tmpcheck = $socstat->check_codeclient();
557 if ($tmpcheck != 0 && $tmpcheck != -5) {
558 print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
559 }
560 print '</td>';
561 print '</tr>';
562 }
563 // Supplier code
564 if ($socstat->fournisseur && !empty($socstat->code_fournisseur)) {
565 print '<tr><td class="titlefield">';
566 print $langs->trans('SupplierCode').'</td><td>';
567 print showValueWithClipboardCPButton(dol_escape_htmltag($socstat->code_fournisseur));
568 $tmpcheck = $socstat->check_codefournisseur();
569 if ($tmpcheck != 0 && $tmpcheck != -5) {
570 print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
571 }
572 print '</td>';
573 print '</tr>';
574 }
575
576 print '</table>';
577 print '</div>';
578 print dol_get_fiche_end();
579
580 print '<br>';
581 }
582}
583
584if ($projectid > 0 || $project_ref) {
585 $projectstat = new Project($db);
586 if ($projectstat->fetch($projectid, $project_ref) > 0) {
587 $projectid = $projectstat->id;
588 $projectstat->fetch_thirdparty();
589
590 $savobject = $object;
591 $object = $projectstat;
592
593 // To verify role of users
594 //$userAccess = $object->restrictedProjectArea($user,'read');
595 $userWrite = $projectstat->restrictedProjectArea($user, 'write');
596 //$userDelete = $object->restrictedProjectArea($user,'delete');
597 //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
598
599 $head = project_prepare_head($projectstat);
600 print dol_get_fiche_head($head, 'ticket', $langs->trans("Project"), -1, ($projectstat->public ? 'projectpub' : 'project'));
601
602 // Project card
603
604 $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
605
606 $morehtmlref = '<div class="refidno">';
607 // Title
608 $morehtmlref .= $object->title;
609 // Thirdparty
610 if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
611 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'project');
612 }
613 $morehtmlref .= '</div>';
614
615 // Define a complementary filter for search of next/prev ref.
616 if (!$user->hasRight('projet', 'all', 'lire')) {
617 $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
618 $object->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? implode(',', array_keys($objectsListId)) : '0').")";
619 }
620
621 dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
622
623 print '<div class="fichecenter">';
624 print '<div class="underbanner clearboth"></div>';
625
626 print '<table class="border tableforfield centpercent">';
627
628 // Visibility
629 print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
630 if ($projectstat->public) {
631 print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
632 print $langs->trans('SharedProject');
633 } else {
634 print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
635 print $langs->trans('PrivateProject');
636 }
637 print '</td></tr>';
638
639 print "</table>";
640
641 print '</div>';
642 print dol_get_fiche_end();
643
644 print '<br>';
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='.(GETPOSTINT('search_'.$key.'month'));
673 $param .= '&search_'.$key.'day='.(GETPOSTINT('search_'.$key.'day'));
674 $param .= '&search_'.$key.'year='.(GETPOSTINT('search_'.$key.'year'));
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((string) ($socid));
690}
691if ($search_societe) {
692 $param .= '&search_societe='.urlencode($search_societe);
693}
694if ($projectid > 0) {
695 $param .= '&projectid='.urlencode((string) ($projectid));
696}
697if ($contractid > 0) {
698 $param .= '&contractid='.urlencode((string) ($contractid));
699}
700if ($search_date_start) {
701 $tmparray = dol_getdate($search_date_start);
702 $param .= '&search_date_startday='.((int) $tmparray['mday']);
703 $param .= '&search_date_startmonth='.((int) $tmparray['mon']);
704 $param .= '&search_date_startyear='.((int) $tmparray['year']);
705}
706if ($search_date_end) {
707 $tmparray = dol_getdate($search_date_end);
708 $param .= '&search_date_endday='.((int) $tmparray['mday']);
709 $param .= '&search_date_endmonth='.((int) $tmparray['mon']);
710 $param .= '&search_date_endyear='.((int) $tmparray['year']);
711}
712if ($search_dateread_start) {
713 $tmparray = dol_getdate($search_dateread_start);
714 $param .= '&search_dateread_startday='.((int) $tmparray['mday']);
715 $param .= '&search_dateread_startmonth='.((int) $tmparray['mon']);
716 $param .= '&search_dateread_startyear='.((int) $tmparray['year']);
717}
718if ($search_dateread_end) {
719 $tmparray = dol_getdate($search_dateread_end);
720 $param .= '&search_dateread_endday='.((int) $tmparray['mday']);
721 $param .= '&search_dateread_endmonth='.((int) $tmparray['mon']);
722 $param .= '&search_dateread_endyear='.((int) $tmparray['year']);
723}
724if ($search_dateclose_start) {
725 $tmparray = dol_getdate($search_dateclose_start);
726 $param .= '&search_dateclose_startday='.((int) $tmparray['mday']);
727 $param .= '&search_dateclose_startmonth='.((int) $tmparray['mon']);
728 $param .= '&search_dateclose_startyear='.((int) $tmparray['year']);
729}
730if ($search_dateclose_end) {
731 $tmparray = dol_getdate($search_dateclose_end);
732 $param .= '&search_date_endday='.((int) $tmparray['mday']);
733 $param .= '&search_date_endmonth='.((int) $tmparray['mon']);
734 $param .= '&search_date_endyear='.((int) $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 (GETPOSTINT('nomassaction') || 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).implode(', ', $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, $action); // 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 don't need reserved height for your table
844print '<div class="div-table-responsive-inside">';
845print '<table class="tagtable noborder 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 if (is_array($search[$key])) {
907 $selectedarray = array_values($search[$key]);
908 } else {
909 $selectedarray = array($search[$key]); // Compatibility with "Default search filters"
910 }
911 }
912 print Form::multiselectarray('search_fk_statut', $arrayofstatus, $selectedarray, 0, 0, 'search_status width150 onrightofpage', 1, 0, '', '', '');
913 print '</td>';
914 } elseif ($key == "fk_soc") {
915 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'"><input type="text" class="flat maxwidth75" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
916 } elseif ($key == "datec" || $key == 'date_read' || $key == 'date_close') {
917 print '<td class="liste_titre center">';
918 print '<div class="nowrap">';
919 switch ($key) {
920 case 'datec':
921 print $form->selectDate($search_date_start ?: -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
922 break;
923 case 'date_read':
924 print $form->selectDate($search_dateread_start ?: -1, 'search_dateread_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
925 break;
926 case 'date_close':
927 print $form->selectDate($search_dateclose_start ?: -1, 'search_dateclose_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
928 }
929 print '</div>';
930 print '<div class="nowrap">';
931 switch ($key) {
932 case 'datec':
933 print $form->selectDate($search_date_end ?: -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
934 break;
935 case 'date_read':
936 print $form->selectDate($search_dateread_end ?: -1, 'search_dateread_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
937 break;
938 case 'date_close':
939 print $form->selectDate($search_dateclose_end ?: -1, 'search_dateclose_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
940 }
941 print '</div>';
942 print '</td>';
943 } else {
944 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
945 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
946 print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
947 } elseif (strpos($val['type'], 'integer:') === 0) {
948 print $object->showInputField($val, $key, !empty($search[$key]) ? $search[$key] : "", '', '', 'search_', 'maxwidth150', 1);
949 } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) {
950 print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]).'">';
951 }
952 print '</td>';
953 }
954 }
955}
956// Extra fields
957include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
958
959// Fields from hook
960$parameters = array('arrayfields' => $arrayfields);
961$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
962print $hookmanager->resPrint;
963// Action column
964if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
965 print '<td class="liste_titre center maxwidthsearch">';
966 $searchpicto = $form->showFilterButtons();
967 print $searchpicto;
968 print '</td>';
969}
970print '</tr>'."\n";
971
972$totalarray = array();
973$totalarray['nbfield'] = 0;
974
975// Fields title label
976// --------------------------------------------------------------------
977print '<tr class="liste_titre">';
978if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
979 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
980 $totalarray['nbfield']++;
981}
982foreach ($object->fields as $key => $val) {
983 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
984 if ($key == 'fk_statut' || $key == 'severity_code') {
985 $cssforfield .= ($cssforfield ? ' ' : '').'center';
986 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
987 $cssforfield .= ($cssforfield ? ' ' : '').'center';
988 } elseif (in_array($val['type'], array('timestamp'))) {
989 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
990 } 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'])) {
991 $cssforfield .= ($cssforfield ? ' ' : '').'right';
992 }
993 $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
994 if (!empty($arrayfields['t.'.$key]['checked'])) {
995 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";
996 $totalarray['nbfield']++;
997 }
998}
999// Extra fields
1000include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1001// Hook fields
1002$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
1003$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1004print $hookmanager->resPrint;
1005if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1006 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1007 $totalarray['nbfield']++;
1008}
1009print '</tr>'."\n";
1010
1011
1012// Detect if we need a fetch on each output line
1013$needToFetchEachLine = 0;
1014if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
1015 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
1016 if (!is_null($val) && preg_match('/\$object/', $val)) {
1017 $needToFetchEachLine++; // There is at least one compute field that use $object
1018 }
1019 }
1020}
1021
1022
1023// Loop on record
1024// --------------------------------------------------------------------
1025$i = 0;
1026$savnbfield = $totalarray['nbfield'];
1027$totalarray = array();
1028$totalarray['nbfield'] = 0;
1029$imaxinloop = ($limit ? min($num, $limit) : $num);
1030$cacheofoutputfield = array();
1031while ($i < $imaxinloop) {
1032 $obj = $db->fetch_object($resql);
1033 if (empty($obj)) {
1034 break; // Should not happen
1035 }
1036
1037 // Store properties in $object
1038 $object->setVarsFromFetchObj($obj);
1039 $object->type_code = $obj->type_code;
1040 $object->status = $object->fk_statut; // because field name is fk_statut
1041
1042 if ($mode == 'kanban') {
1043 if ($i == 0) {
1044 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1045 print '<div class="box-flex-container kanban">';
1046 }
1047
1048 // get infos needed from object
1049 // TODO Create a cache on users
1050 $arraydata = array();
1051 if ($obj->fk_user_assign > 0) {
1052 $user_temp->fetch($obj->fk_user_assign);
1053 $arraydata['user_assignment'] = $user_temp->getNomUrl(-3);
1054 }
1055 $arraydata['selected'] = in_array($object->id, $arrayofselected);
1056
1057 // Output Kanban
1058 print $object->getKanbanView('', $arraydata);
1059 if ($i == ($imaxinloop - 1)) {
1060 print '</div>';
1061 print '</td></tr>';
1062 }
1063 } else {
1064 // Show line of result
1065 $j = 0;
1066 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
1067
1068 // Action column
1069 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1070 print '<td class="nowrap center">';
1071 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1072 $selected = 0;
1073 if (in_array($object->id, $arrayofselected)) {
1074 $selected = 1;
1075 }
1076 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
1077 }
1078 print '</td>';
1079 if (!$i) {
1080 $totalarray['nbfield']++;
1081 }
1082 }
1083 // Fields
1084 foreach ($object->fields as $key => $val) {
1085 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
1086 if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
1087 $cssforfield .= ($cssforfield ? ' ' : '').'center';
1088 }
1089
1090 if (in_array($val['type'], array('timestamp'))) {
1091 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
1092 }
1093 if (in_array($key, array('ref', 'fk_project'))) {
1094 $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
1095 }
1096
1097 if ($key == 'fk_statut' || $key == 'severity_code') {
1098 $cssforfield .= ($cssforfield ? ' ' : '').'center';
1099 }
1100 if (!empty($arrayfields['t.'.$key]['checked'])) {
1101 print '<td'.($cssforfield ? ' class="'.$cssforfield.((preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) ? ' classfortooltip' : '').'"' : '');
1102 if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) {
1103 print ' title="'.dol_escape_htmltag($object->$key).'"';
1104 }
1105 print '>';
1106 if ($key == 'fk_statut') {
1107 print $object->getLibStatut(5);
1108 } elseif ($key == 'subject') {
1109 $s = $obj->subject;
1110 print '<span title="'.dol_escape_htmltag($s).'">';
1111 print dol_escape_htmltag($s);
1112 print '</span>';
1113 } elseif ($key == 'type_code') {
1114 $s = $langs->getLabelFromKey($db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code);
1115 print '<span title="'.dol_escape_htmltag($s).'">';
1116 print $s;
1117 print '</span>';
1118 } elseif ($key == 'category_code') {
1119 $s = $langs->getLabelFromKey($db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code);
1120 print '<span title="'.dol_escape_htmltag($s).'">';
1121 print $s;
1122 print '</span>';
1123 } elseif ($key == 'severity_code') {
1124 $s = $langs->getLabelFromKey($db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code);
1125 print '<span title="'.dol_escape_htmltag($s).'">';
1126 print $s;
1127 print '</span>';
1128 } elseif ($key == 'tms') {
1129 print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser');
1130 } elseif ($key == 'fk_user_create') {
1131 if ($object->fk_user_create > 0) {
1132 if (isset($conf->cache['user'][$object->fk_user_create])) {
1133 $user_temp = $conf->cache['user'][$object->fk_user_create];
1134 } else {
1135 $user_temp = new User($db);
1136 $user_temp->fetch($object->fk_user_create);
1137 $conf->cache['user'][$object->fk_user_create] = $user_temp;
1138 }
1139 print $user_temp->getNomUrl(-1);
1140 }
1141 } elseif ($key == 'fk_user_assign') {
1142 if ($object->fk_user_assign > 0) {
1143 if (isset($conf->cache['user'][$object->fk_user_assign])) {
1144 $user_temp = $conf->cache['user'][$object->fk_user_assign];
1145 } else {
1146 $user_temp = new User($db);
1147 $user_temp->fetch($object->fk_user_assign);
1148 $conf->cache['user'][$object->fk_user_assign] = $user_temp;
1149 }
1150 print $user_temp->getNomUrl(-1);
1151 }
1152 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
1153 print $object->showOutputField($val, $key, $db->jdate($obj->$key), '');
1154 } elseif ($key == 'ref') {
1155 print $object->showOutputField($val, $key, $obj->$key, '');
1156
1157 // display a warning on untreated tickets
1158 $is_open = ($object->status != Ticket::STATUS_CLOSED && $object->status != Ticket::STATUS_CANCELED);
1159 $should_show_warning = (getDolGlobalString('TICKET_DELAY_SINCE_LAST_RESPONSE') || getDolGlobalString('TICKET_DELAY_BEFORE_FIRST_RESPONSE'));
1160 if ($is_open && $should_show_warning) {
1161 $date_last_msg_sent = (int) $object->date_last_msg_sent;
1162 $hour_diff = ($now - $date_last_msg_sent) / 3600 ;
1163
1164 if (getDolGlobalString('TICKET_DELAY_BEFORE_FIRST_RESPONSE') && $date_last_msg_sent == 0) {
1165 $creation_date = $object->datec;
1166 $hour_diff_creation = ($now - $creation_date) / 3600 ;
1167 if ($hour_diff_creation > getDolGlobalInt('TICKET_DELAY_BEFORE_FIRST_RESPONSE')) {
1168 print " " . img_picto($langs->trans('Late') . ' : ' . $langs->trans('TicketsDelayForFirstResponseTooLong', getDolGlobalString('TICKET_DELAY_BEFORE_FIRST_RESPONSE')), 'warning', 'style="color: red;"', false, 0, 0, '', '');
1169 }
1170 } elseif (getDolGlobalString('TICKET_DELAY_SINCE_LAST_RESPONSE') && $hour_diff > getDolGlobalInt('TICKET_DELAY_SINCE_LAST_RESPONSE')) {
1171 print " " . img_picto($langs->trans('Late') . ' : ' . $langs->trans('TicketsDelayFromLastResponseTooLong', getDolGlobalString('TICKET_DELAY_SINCE_LAST_RESPONSE')), 'warning');
1172 }
1173 }
1174 } else { // Example: key=fk_soc, obj->key=123 val=array('type'=>'integer', ...
1175 $tmp = explode(':', $val['type']);
1176 if ($tmp[0] == 'integer' && !empty($tmp[1]) && class_exists($tmp[1])) {
1177 // It is a type of an foreign field. We will try to reduce the number of fetch that the showOutputField is making.
1178 //var_dump('eeee-'.$key.'-'.$obj->$key.'-'.$val['type']);
1179 if ($key && $obj->$key && $val['type'] && array_key_exists($key.'-'.$obj->$key.'-'.$val['type'], $cacheofoutputfield)) {
1180 $result = $cacheofoutputfield[$key.'-'.$obj->$key.'-'.$val['type']];
1181 } else {
1182 $result = $object->showOutputField($val, $key, $obj->$key, '');
1183 $cacheofoutputfield[$key.'-'.$obj->$key.'-'.$val['type']] = $result;
1184 }
1185 } else {
1186 $result = $object->showOutputField($val, $key, $obj->$key, '');
1187 }
1188 print $result;
1189 }
1190
1191 print '</td>';
1192 if (!$i) {
1193 $totalarray['nbfield']++;
1194 }
1195 if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
1196 if (!$i) {
1197 $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
1198 }
1199 if (!isset($totalarray['val'])) {
1200 $totalarray['val'] = array();
1201 }
1202 if (!isset($totalarray['val']['t.'.$key])) {
1203 $totalarray['val']['t.'.$key] = 0;
1204 }
1205 $totalarray['val']['t.'.$key] += $object->$key;
1206 }
1207 }
1208 }
1209 // Extra fields
1210 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1211 // Fields from hook
1212 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1213 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1214 print $hookmanager->resPrint;
1215
1216 // Action column
1217 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1218 print '<td class="nowrap center">';
1219 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1220 $selected = 0;
1221 if (in_array($object->id, $arrayofselected)) {
1222 $selected = 1;
1223 }
1224 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
1225 }
1226 print '</td>';
1227 if (!$i) {
1228 $totalarray['nbfield']++;
1229 }
1230 }
1231
1232 print '</tr>'."\n";
1233 }
1234
1235 $i++;
1236}
1237
1238// Show total line
1239include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1240
1241
1242// If no record found
1243if ($num == 0) {
1244 $colspan = 1;
1245 foreach ($arrayfields as $key => $val) {
1246 if (!empty($val['checked'])) {
1247 $colspan++;
1248 }
1249 }
1250 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1251}
1252
1253
1254$db->free($resql);
1255
1256$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1257$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
1258print $hookmanager->resPrint;
1259
1260print '</table>'."\n";
1261print '</div>'."\n";
1262print '</div>'."\n"; // end div-responsive-inside
1263
1264print '</form>'."\n";
1265
1266
1267
1268if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
1269 $hidegeneratedfilelistifempty = 1;
1270 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1271 $hidegeneratedfilelistifempty = 0;
1272 }
1273
1274 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
1275 $formfile = new FormFile($db);
1276
1277 // Show list of available documents
1278 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1279 $urlsource .= str_replace('&amp;', '&', $param);
1280
1281 $filedir = $diroutputmassaction;
1282 $genallowed = $permissiontoread;
1283 $delallowed = $permissiontoadd;
1284
1285 print $formfile->showdocuments('massfilesarea_ticket', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1286}
1287
1288// End of page
1289llxFooter();
1290$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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_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...
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)
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.
print_barre_liste($title, $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.
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.
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 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.