dolibarr 25.0.0-alpha
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
7 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
8 * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
9 * Copyright (C) 2021-2026 Frédéric France <frederic.france@free.fr>
10 * Copyright (C) 2022-2026 Charlène Benke <charlene@patas-monkey.com>
11 * Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
12 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
13 * Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.fr>
14 * Copyright (C) 2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program. If not, see <https://www.gnu.org/licenses/>.
28 */
29
36// Load Dolibarr environment
37require '../main.inc.php';
46require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
47require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
48require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
49require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
50if (isModEnabled('project')) {
51 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
52}
53if (isModEnabled('category')) {
54 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
55 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
56}
57if (isModEnabled('contract')) {
58 require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
59}
60
61
62// Load translation files required by the page
63$langs->loadLangs(array('companies', 'bills', 'interventions'));
64if (isModEnabled('project')) {
65 $langs->load("projects");
66}
67if (isModEnabled('contract')) {
68 $langs->load("contracts");
69}
70if (isModEnabled('category')) {
71 $langs->load("categories");
72}
73
74$action = GETPOST('action', 'aZ09');
75$massaction = GETPOST('massaction', 'alpha');
76$show_files = GETPOSTINT('show_files');
77$confirm = GETPOST('confirm', 'alpha');
78$toselect = GETPOST('toselect', 'array:int');
79$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'interventionlist';
80$mode = GETPOST('mode', 'alpha');
81
82if (getDolGlobalInt('MAIN_SEE_SUBORDINATES')) {
83 $userschilds = $user->getAllChildIds();
84} else {
85 $userschilds = array();
86}
87
88$search_ref = GETPOST('search_ref') ? GETPOST('search_ref', 'alpha') : GETPOST('search_inter', 'alpha');
89$search_ref_client = GETPOST('search_ref_client', 'alpha');
90$search_company = GETPOST('search_company', 'alpha');
91$search_alias = GETPOST('search_alias', 'alpha');
92$search_desc = GETPOST('search_desc', 'alpha');
93$search_projet_ref = GETPOST('search_projet_ref', 'alpha');
94$search_contrat_ref = GETPOST('search_contrat_ref', 'alpha');
95$search_status = GETPOST('search_status', 'alpha');
96$search_signed_status = GETPOST('search_signed_status', 'alpha');
97$search_all = trim(GETPOST('search_all', 'alphanohtml'));
98$search_date_startday = GETPOSTINT('search_date_startday');
99$search_date_startmonth = GETPOSTINT('search_date_startmonth');
100$search_date_startyear = GETPOSTINT('search_date_startyear');
101$search_date_endday = GETPOSTINT('search_date_endday');
102$search_date_endmonth = GETPOSTINT('search_date_endmonth');
103$search_date_endyear = GETPOSTINT('search_date_endyear');
104$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
105$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
106$optioncss = GETPOST('optioncss', 'alpha');
107$socid = GETPOSTINT('socid');
108
109$searchCategoryFichinterOperator = 0;
110if (GETPOSTISSET('formfilteraction')) {
111 $searchCategoryFichinterOperator = GETPOSTINT('search_category_fichinter_operator');
112} elseif (getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT')) {
113 $searchCategoryFichinterOperator = getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT');
114}
115$searchCategoryFichinterList = GETPOST('search_category_fichinter_list', 'array');
116$catid = GETPOST('catid', 'int');
117if (!empty($catid) && empty($searchCategoryFichinterList)) {
118 $searchCategoryFichinterList = array($catid);
119}
120
121$diroutputmassaction = $conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id;
122
123// Load variable for pagination
124$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
125$sortfield = GETPOST('sortfield', 'aZ09comma');
126$sortorder = GETPOST('sortorder', 'aZ09comma');
127$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
128if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
129 // If $page is not defined, or '' or -1 or if we click on clear filters
130 $page = 0;
131}
132$offset = $limit * $page;
133$pageprev = $page - 1;
134$pagenext = $page + 1;
135if (!$sortorder) {
136 $sortorder = "DESC";
137}
138if (!$sortfield) {
139 $sortfield = "f.ref";
140}
141
142// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
143$object = new Fichinter($db);
144$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array of activated contexes
145
146// Fetch optionals attributes and labels
147$extrafields->fetch_name_optionals_label($object->table_element);
148
149$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
150
151// List of fields to search into when doing a "search in all"
152$fieldstosearchall = array(
153 'f.ref' => 'Ref',
154 's.nom' => "ThirdParty",
155 'f.description' => 'Description',
156 'f.note_public' => 'NotePublic',
157 'fd.description' => 'DescriptionOfLine',
158);
159if (empty($user->socid)) {
160 $fieldstosearchall["f.note_private"] = "NotePrivate";
161}
162if (getDolGlobalString('FICHINTER_DISABLE_DETAILS')) {
163 unset($fieldstosearchall['fd.description']);
164}
165
166// Definition of fields for list
167$arrayfields = array(
168 'f.ref' => array('label' => 'Ref', 'checked' => '1'),
169 'f.ref_client' => array('label' => 'RefCustomer', 'checked' => '1'),
170 's.nom' => array('label' => 'ThirdParty', 'checked' => '1'),
171 's.name_alias' => array('label' => 'AliasNameShort', 'checked' => '0'),
172 'pr.ref' => array('label' => 'Project', 'checked' => '1', 'enabled' => (!isModEnabled('project') ? '0' : '1')),
173 'c.ref' => array('label' => 'Contract', 'checked' => '1', 'enabled' => (empty($conf->contrat->enabled) ? '0' : '1')),
174 'f.description' => array('label' => 'Description', 'checked' => '1'),
175 'f.datec' => array('label' => 'DateCreation', 'checked' => '0', 'position' => 500),
176 'f.tms' => array('label' => 'DateModificationShort', 'checked' => '0', 'position' => 500),
177 'f.note_public' => array('label' => 'NotePublic', 'checked' => '0', 'position' => 510, 'enabled' => (string) (!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES'))),
178 'f.note_private' => array('label' => 'NotePrivate', 'checked' => '0', 'position' => 511, 'enabled' => (string) (!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES'))),
179 'f.fk_statut' => array('label' => 'Status', 'checked' => '1', 'position' => 1000),
180 'f.signed_status' => array('label' => 'SignedStatus', 'checked' => '0', 'position' => 1001),
181 'fd.description' => array('label' => "DescriptionOfLine", 'checked' => '1', 'enabled' => getDolGlobalString('FICHINTER_DISABLE_DETAILS') != '1' ? '1' : '0'),
182 'fd.date' => array('label' => 'DateOfLine', 'checked' => '1', 'enabled' => getDolGlobalString('FICHINTER_DISABLE_DETAILS') != '1' ? '1' : '0'),
183 'fd.duree' => array('label' => 'DurationOfLine', 'type' => 'duration', 'checked' => '1', 'enabled' => !getDolGlobalString('FICHINTER_DISABLE_DETAILS') ? '1' : '0'), //type duration is here because in database, column 'duree' is double
184);
185// Extra fields
186include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
187
188// Add hook to complete $arrayfields
189$parameters = array('arrayfields' => &$arrayfields);
190$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
191
192$object->fields = dol_sort_array($object->fields, 'position');
193$arrayfields = dol_sort_array($arrayfields, 'position');
194
195// Security check
196$id = GETPOSTINT('id');
197if ($user->socid) {
198 $socid = $user->socid;
199}
200$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
201
202$permissiontoreadallthirdparty = $user->hasRight('societe', 'client', 'voir');
203$permissiontoread = $user->hasRight('ficheinter', 'lire');
204$permissiontoadd = $user->hasRight('ficheinter', 'creer');
205$permissiontodelete = $user->hasRight('ficheinter', 'supprimer');
206
207
208/*
209 * Actions
210 */
211
212if (GETPOST('cancel', 'alpha')) {
213 $action = 'list';
214 $massaction = '';
215}
216if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
217 $massaction = '';
218}
219
220$parameters = array('socid' => $socid, 'arrayfields' => &$arrayfields);
221$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
222if ($reshook < 0) {
223 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
224}
225
226if (empty($reshook)) {
227 // Selection of new fields
228 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
229
230 // Purge search criteria
231 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
232 $search_ref = "";
233 $search_ref_client = "";
234 $searchCategoryFichinterList = array();
235 $search_company = "";
236 $search_alias = "";
237 $search_projet_ref = "";
238 $search_contrat_ref = "";
239 $search_desc = "";
240 $search_status = "";
241 $search_signed_status = '';
242 $search_date_startday = '';
243 $search_date_startmonth = '';
244 $search_date_startyear = '';
245 $search_date_endday = '';
246 $search_date_endmonth = '';
247 $search_date_endyear = '';
248 $search_date_start = '';
249 $search_date_end = '';
250 $toselect = array();
251 $search_array_options = array();
252 }
253
254 // Mass actions
255 $objectclass = 'Fichinter';
256 $objectlabel = 'Interventions';
257 $uploaddir = $conf->ficheinter->dir_output;
258 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
259}
260
261
262
263/*
264 * View
265 */
266
267
268$form = new Form($db);
269$formfile = new FormFile($db);
270$objectstatic = new Fichinter($db);
271$companystatic = new Societe($db);
272$projetstatic = null;
273$contratstatic = null;
274if (isModEnabled('project')) {
275 $projetstatic = new Project($db);
276}
277if (isModEnabled('contract')) {
278 $contratstatic = new Contrat($db);
279}
280
281$now = dol_now();
282
283$title = $langs->trans("Interventions");
284$help_url = '';
285$morejs = array();
286$morecss = array();
287
288
289$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
290$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
291
292$atleastonefieldinlines = 0;
293foreach ($arrayfields as $tmpkey => $tmpval) {
294 if (preg_match('/^fd\./', $tmpkey) && !empty($arrayfields[$tmpkey]['checked'])) {
295 $atleastonefieldinlines++;
296 break;
297 }
298}
299
300$sql = "SELECT";
301$sql .= " f.ref, f.ref_client, f.rowid, f.fk_statut as status, f.signed_status as signed_status, f.description, f.datec as date_creation, f.tms as date_modification, f.note_public, f.note_private,";
302if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') && $atleastonefieldinlines) {
303 $sql .= " fd.rowid as lineid, fd.description as descriptiondetail, fd.date as dp, fd.duree,";
304}
305$sql .= " s.nom as name, s.name_alias as alias, s.rowid as socid, s.client, s.fournisseur, s.email, s.status as thirdpartystatus";
306if (isModEnabled('project')) {
307 $sql .= ", pr.rowid as projet_id, pr.ref as projet_ref, pr.title as projet_title";
308}
309if (isModEnabled('contract')) {
310 $sql .= ", c.rowid as contrat_id, c.ref as contrat_ref, c.ref_customer as contrat_ref_customer, c.ref_supplier as contrat_ref_supplier";
311}
312// Add fields from extrafields
313if (!empty($extrafields->attributes[$object->table_element]['label'])) {
314 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
315 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
316 }
317}
318// Add fields from hooks
319$parameters = array();
320$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
321$sql .= $hookmanager->resPrint;
322
323$sqlfields = $sql; // $sql fields to remove for count total
324
325$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
326if (isModEnabled('project')) {
327 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr on f.fk_projet = pr.rowid";
328}
329if (isModEnabled('contract')) {
330 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contrat as c on f.fk_contrat = c.rowid";
331}
332if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
333 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)";
334}
335if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') && $atleastonefieldinlines) {
336 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid";
337}
338
339// Add table from hooks
340$parameters = array();
341$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
342$sql .= $hookmanager->resPrint;
343
344$sql .= ", ".MAIN_DB_PREFIX."societe as s";
345$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
346$sql .= " AND f.fk_soc = s.rowid";
347if ($search_ref) {
348 $sql .= natural_search('f.ref', $search_ref);
349}
350if ($search_ref_client) {
351 $sql .= natural_search('f.ref_client', $search_ref_client);
352}
353if ($search_company) {
354 $sql .= natural_search('s.nom', $search_company);
355}
356if ($search_alias) {
357 $sql .= natural_search('s.name_alias', $search_alias);
358}
359if ($search_projet_ref) {
360 $sql .= natural_search('pr.ref', $search_projet_ref);
361}
362if ($search_contrat_ref) {
363 $sql .= natural_search('c.ref', $search_contrat_ref);
364}
365if ($search_desc) {
366 if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') && $atleastonefieldinlines) {
367 $sql .= natural_search(array('f.description', 'fd.description'), $search_desc);
368 } else {
369 $sql .= natural_search(array('f.description'), $search_desc);
370 }
371}
372// Search for tag/category ($searchCategoryFichinterList is an array of ID)
373if (!empty($searchCategoryFichinterList)) {
374 $searchCategoryFichinterSqlList = array();
375 $listofcategoryid = '';
376 foreach ($searchCategoryFichinterList as $searchCategoryFichinter) {
377 if (intval($searchCategoryFichinter) == -2) {
378 $searchCategoryFichinterSqlList[] = "NOT EXISTS (SELECT ck.fk_fichinter FROM ".MAIN_DB_PREFIX."categorie_fichinter as ck WHERE f.rowid = ck.fk_fichinter)";
379 } elseif (intval($searchCategoryFichinter) > 0) {
380 if ($searchCategoryFichinterOperator == 0) {
381 $searchCategoryFichinterSqlList[] = " EXISTS (SELECT ck.fk_fichinter FROM ".MAIN_DB_PREFIX."categorie_fichinter as ck WHERE f.rowid = ck.fk_fichinter AND ck.fk_categorie = ".((int) $searchCategoryFichinter).")";
382 } else {
383 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryFichinter);
384 }
385 }
386 }
387 if ($listofcategoryid) {
388 $searchCategoryFichinterSqlList[] = " EXISTS (SELECT ck.fk_fichinter FROM ".MAIN_DB_PREFIX."categorie_fichinter as ck WHERE f.rowid = ck.fk_fichinter AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
389 }
390 if ($searchCategoryFichinterOperator == 1) {
391 if (!empty($searchCategoryFichinterSqlList)) {
392 $sql .= " AND (".implode(' OR ', $searchCategoryFichinterSqlList).")";
393 }
394 } else {
395 if (!empty($searchCategoryFichinterSqlList)) {
396 $sql .= " AND (".implode(' AND ', $searchCategoryFichinterSqlList).")";
397 }
398 }
399}
400if ($search_status != '' && $search_status >= 0) {
401 $sql .= ' AND f.fk_statut = '.((int) ($search_status));
402}
403if ($search_signed_status != '' && $search_signed_status >= 0) {
404 $sql .= ' AND f.signed_status = '.((int) $search_signed_status);
405}
406if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') && $atleastonefieldinlines) {
407 if ($search_date_start) {
408 $sql .= " AND fd.date >= '".$db->idate($search_date_start)."'";
409 }
410 if ($search_date_end) {
411 $sql .= " AND fd.date <= '".$db->idate($search_date_end)."'";
412 }
413}
414if ($socid > 0) {
415 $sql .= " AND s.rowid = ".((int) $socid);
416}
417// Restriction on sale representative
418if (empty($user->socid) && !$permissiontoreadallthirdparty) {
419 $sql .= " AND (EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc AND sc.fk_user = ".((int) $user->id).")";
420 if (getDolGlobalInt('MAIN_SEE_SUBORDINATES') && $userschilds) {
421 $sql .= " OR EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc AND sc.fk_user IN (".$db->sanitize(implode(',', $userschilds))."))";
422 }
423 $sql .= ")";
424}
425
426if ($search_all) {
427 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
428}
429// Search on sale representative
430/*
431if ($search_sale && $search_sale != '-1') {
432 if ($search_sale == -2) {
433 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc)";
434 } elseif ($search_sale > 0) {
435 $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
436 }
437}*/
438// Add where from extra fields
439include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
440// Add where from hooks
441$parameters = array();
442$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
443$sql .= $hookmanager->resPrint;
444// Add GroupBy from hooks
445$parameters = array('search_all' => $search_all, 'fieldstosearchall' => $fieldstosearchall);
446$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
447$sql .= $hookmanager->resPrint;
448
449// Count total nb of records
450$nbtotalofrecords = '';
451if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
452 /* The fast and low memory method to get and count full list converts the sql into a sql count */
453 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
454 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
455 $resql = $db->query($sqlforcount);
456 if ($resql) {
457 $objforcount = $db->fetch_object($resql);
458 $nbtotalofrecords = $objforcount->nbtotalofrecords;
459 } else {
460 dol_print_error($db);
461 }
462
463 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
464 $page = 0;
465 $offset = 0;
466 }
467 $db->free($resql);
468}
469
470// Complete request and execute it with limit
471$sql .= $db->order($sortfield, $sortorder);
472if ($limit) {
473 $sql .= $db->plimit($limit + 1, $offset);
474}
475
476$resql = $db->query($sql);
477if (!$resql) {
478 dol_print_error($db);
479 exit;
480}
481
482$num = $db->num_rows($resql);
483
484
485// Direct jump if only one record found
486if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
487 $obj = $db->fetch_object($resql);
488 $id = $obj->rowid;
489 header("Location: ".dol_buildpath('/fichinter/card.php', 1).'?id='.$id);
490 exit;
491}
492
493
494// Output page
495// --------------------------------------------------------------------
496$paramsCat = '';
497foreach ($searchCategoryFichinterList as $searchCategoryFichinter) {
498 $paramsCat .= "&search_category_fichinter_list[]=".urlencode($searchCategoryFichinter);
499}
500
501llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist mod-fichinter page-list'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
502
503
504$arrayofselected = is_array($toselect) ? $toselect : array();
505
506if ($socid > 0) {
507 $soc = new Societe($db);
508 $soc->fetch($socid);
509 if (empty($search_company)) {
510 $search_company = $soc->name;
511 }
512}
513
514$param = '';
515if (!empty($mode)) {
516 $param .= '&mode='.urlencode($mode);
517}
518if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
519 $param .= '&contextpage='.urlencode($contextpage);
520}
521if ($limit > 0 && $limit != $conf->liste_limit) {
522 $param .= '&limit='.((int) $limit);
523}
524if ($search_all) {
525 $param .= "&search_all=".urlencode($search_all);
526}
527if ($socid) {
528 $param .= "&socid=".urlencode((string) ($socid));
529}
530if ($searchCategoryFichinterOperator == 1) {
531 $param .= "&search_category_fichinter_operator=".urlencode((string) $searchCategoryFichinterOperator);
532}
533foreach ($searchCategoryFichinterList as $searchCategoryFichinter) {
534 $param .= "&search_category_fichinter_list[]=".urlencode($searchCategoryFichinter);
535}
536if ($search_ref) {
537 $param .= "&search_ref=".urlencode($search_ref);
538}
539if ($search_ref_client) {
540 $param .= "&search_ref_client=".urlencode($search_ref_client);
541}
542if ($search_company) {
543 $param .= "&search_company=".urlencode($search_company);
544}
545if ($search_alias) {
546 $param .= "&search_alias=".urlencode($search_alias);
547}
548if ($search_desc) {
549 $param .= "&search_desc=".urlencode($search_desc);
550}
551if ($search_projet_ref) {
552 $param .= "&search_projet_ref=".urlencode($search_projet_ref);
553}
554if ($search_contrat_ref) {
555 $param .= "&search_contrat_ref=".urlencode($search_contrat_ref);
556}
557if ($search_status != '' && $search_status > -1) {
558 $param .= "&search_status=".urlencode($search_status);
559}
560if ($search_signed_status != '' && $search_signed_status >= 0) {
561 $param .= '&search_signed_status='.urlencode($search_signed_status);
562}
563if ($search_date_startday > 0) {
564 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
565}
566if ($search_date_startmonth > 0) {
567 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
568}
569if ($search_date_startyear > 0) {
570 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
571}
572if ($search_date_endday > 0) {
573 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
574}
575if ($search_date_endmonth > 0) {
576 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
577}
578if ($search_date_endyear > 0) {
579 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
580}
581if ($show_files) {
582 $param .= '&show_files='.urlencode((string) ($show_files));
583}
584if ($optioncss != '') {
585 $param .= '&optioncss='.urlencode($optioncss);
586}
587// Add $param from extra fields
588include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
589// Add $param from hooks
590$parameters = array('param' => &$param);
591$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
592$param .= $hookmanager->resPrint;
593
594// List of mass actions available
595$arrayofmassactions = array(
596 'generate_doc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
597 'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
598 //'presend'=>$langs->trans("SendByMail"),
599);
600if (!empty($permissiontodelete)) {
601 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
602}
603if (isModEnabled('category') && $user->hasRight('categorie', 'creer')) {
604 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
605}
606if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) {
607 $arrayofmassactions = array();
608}
609$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
610
611
612print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
613if ($optioncss != '') {
614 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
615}
616print '<input type="hidden" name="token" value="'.newToken().'">';
617print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
618print '<input type="hidden" name="action" value="list">';
619print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
620print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
621print '<input type="hidden" name="page" value="'.$page.'">';
622print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
623print '<input type="hidden" name="page_y" value="">';
624print '<input type="hidden" name="mode" value="'.$mode.'">';
625
626$newcardbutton = '';
627$url = DOL_URL_ROOT.'/fichinter/card.php?action=create';
628if (!empty($socid)) {
629 $url .= '&socid='.$socid;
630}
631$newcardbutton = '';
632$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'));
633$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'));
634$newcardbutton .= dolGetButtonTitle($langs->trans('Statistics'), '', 'fa fa-chart-bar imgforviewmode', DOL_URL_ROOT.'/fichinter/stats/index.php?'.preg_replace('/(&|\?)*(mode|groupby)=[^&]+/', '', $param), '', ($mode == 'statistics' ? 2 : 1), array('morecss' => 'reposition'));
635$newcardbutton .= dolGetButtonTitleSeparator();
636$newcardbutton .= dolGetButtonTitle($langs->trans('NewIntervention'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('ficheinter', 'creer'));
637
638print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
639
640$topicmail = "Information";
641$modelmail = "intervention";
642$objecttmp = new Fichinter($db);
643$trackid = 'int'.$object->id;
644include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
645
646if (!empty($catid)) {
647 print "<div id='ways'>";
648 $c = new Categorie($db);
649 $ways = $c->print_all_ways(' &gt; ', 'fichinter/list.php');
650 print " &gt; ".$ways[0]."<br>\n";
651 print "</div><br>";
652}
653
654if ($search_all) {
655 $setupstring = '';
656 foreach ($fieldstosearchall as $key => $val) {
657 $fieldstosearchall[$key] = $langs->trans($val);
658 $setupstring .= $key."=".$val.";";
659 }
660 print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
661 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
662}
663
664// Filter on categories
665$moreforfilter = '';
666if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
667 $formcategory = new FormCategory($db);
668 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_FICHINTER, $searchCategoryFichinterList, 'minwidth300', $searchCategoryFichinterOperator ? $searchCategoryFichinterOperator : 0);
669}
670$parameters = array();
671$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
672if (empty($reshook)) {
673 $moreforfilter .= $hookmanager->resPrint;
674} else {
675 $moreforfilter = $hookmanager->resPrint;
676}
677
678if (!empty($moreforfilter)) {
679 print '<div class="liste_titre liste_titre_bydiv centpercent">';
680 print $moreforfilter;
681 print '</div>';
682}
683
684$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
685$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
686$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
687$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
688
689print '<div class="div-table-responsive">';
690print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
691
692// Fields title search
693// --------------------------------------------------------------------
694print '<tr class="liste_titre_filter">';
695// Action column
696if ($conf->main_checkbox_left_column) {
697 print '<td class="liste_titre center maxwidthsearch">';
698 $searchpicto = $form->showFilterButtons('left');
699 print $searchpicto;
700 print '</td>';
701}
702if (!empty($arrayfields['f.ref']['checked'])) {
703 print '<td class="liste_titre">';
704 print '<input type="text" class="flat" name="search_ref" value="'.$search_ref.'" size="8">';
705 print '</td>';
706}
707if (!empty($arrayfields['f.ref_client']['checked'])) {
708 print '<td class="liste_titre">';
709 print '<input type="text" class="flat" name="search_ref_client" value="'.$search_ref_client.'" size="8">';
710 print '</td>';
711}
712if (!empty($arrayfields['s.nom']['checked'])) {
713 print '<td class="liste_titre">';
714 print '<input type="text" class="flat" name="search_company" value="'.$search_company.'" size="10">';
715 print '</td>';
716}
717if (!empty($arrayfields['s.name_alias']['checked'])) {
718 print '<td class="liste_titre">';
719 print '<input type="text" class="flat maxwidth75" name="search_alias" value="'.dolPrintHTMLForAttribute($search_alias).'">';
720 print '</td>';
721}
722if (!empty($arrayfields['pr.ref']['checked'])) {
723 print '<td class="liste_titre">';
724 print '<input type="text" class="flat" name="search_projet_ref" value="'.$search_projet_ref.'" size="8">';
725 print '</td>';
726}
727if (!empty($arrayfields['c.ref']['checked'])) {
728 print '<td class="liste_titre">';
729 print '<input type="text" class="flat" name="search_contrat_ref" value="'.$search_contrat_ref.'" size="8">';
730 print '</td>';
731}
732if (!empty($arrayfields['f.description']['checked'])) {
733 print '<td class="liste_titre">';
734 print '<input type="text" class="flat" name="search_desc" value="'.$search_desc.'" size="12">';
735 print '</td>';
736}
737// Extra fields
738include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
739
740// Fields from hook
741$parameters = array('arrayfields' => $arrayfields);
742$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
743print $hookmanager->resPrint;
744if (!empty($arrayfields['f.datec']['checked'])) {
745 // Date creation
746 print '<td class="liste_titre">';
747 print '</td>';
748}
749if (!empty($arrayfields['f.tms']['checked'])) {
750 // Date modification
751 print '<td class="liste_titre">';
752 print '</td>';
753}
754if (!empty($arrayfields['f.note_public']['checked'])) {
755 // Note public
756 print '<td class="liste_titre">';
757 print '</td>';
758}
759if (!empty($arrayfields['f.note_private']['checked'])) {
760 // Note private
761 print '<td class="liste_titre">';
762 print '</td>';
763}
764// Status
765if (!empty($arrayfields['f.fk_statut']['checked'])) {
766 print '<td class="liste_titre right parentonrightofpage">';
767 $objecttmp->getLibStatut();
768
769 if (!getDolGlobalString('FICHINTER_CLASSIFY_BILLED')) {
770 unset($objecttmp->labelStatus[Fichinter::STATUS_BILLED]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
771 }
772
773 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
774 print $form->selectarray('search_status', $objecttmp->labelStatus, $search_status, 1, 0, 0, '', 1, 0, 0, '', 'search_status width100 onrightofpage');
775 print '</td>';
776}
777// Signed status
778if (!empty($arrayfields['f.signed_status']['checked'])) {
779 print '<td class="liste_titre center">';
780 $list_signed_status = $object->getSignedStatusLocalisedArray();
781 print $form->selectarray('search_signed_status', $list_signed_status, $search_signed_status, 1, 0, 0, '', 1, 0, 0, '', 'search_status');
782 print '</td>';
783}
784// Fields of detail line
785if (!empty($arrayfields['fd.description']['checked'])) {
786 print '<td class="liste_titre">&nbsp;</td>';
787}
788if (!empty($arrayfields['fd.date']['checked'])) {
789 print '<td class="liste_titre center">';
790 print '<div class="nowrapfordate">';
791 print $form->selectDate($search_date_start ?: -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
792 print '</div>';
793 print '<div class="nowrapfordate">';
794 print $form->selectDate($search_date_end ?: -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
795 print '</div>';
796 print '</td>';
797}
798if (!empty($arrayfields['fd.duree']['checked'])) {
799 print '<td class="liste_titre">&nbsp;</td>';
800}
801// Action column
802if (!$conf->main_checkbox_left_column) {
803 print '<td class="liste_titre center maxwidthsearch">';
804 $searchpicto = $form->showFilterButtons();
805 print $searchpicto;
806 print '</td>';
807}
808print '</tr>'."\n";
809
810$totalarray = array();
811$totalarray['nbfield'] = 0;
812
813// Fields title label
814// --------------------------------------------------------------------
815print '<tr class="liste_titre">';
816// Action column
817if ($conf->main_checkbox_left_column) {
818 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
819 $totalarray['nbfield']++;
820}
821if (!empty($arrayfields['f.ref']['checked'])) {
822 // @phan-suppress-next-line PhanTypeInvalidDimOffset
823 print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
824 $totalarray['nbfield']++;
825}
826if (!empty($arrayfields['f.ref_client']['checked'])) {
827 print_liste_field_titre($arrayfields['f.ref_client']['label'], $_SERVER["PHP_SELF"], "f.ref_client", "", $param, '', $sortfield, $sortorder);
828 $totalarray['nbfield']++;
829}
830if (!empty($arrayfields['s.nom']['checked'])) {
831 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
832 $totalarray['nbfield']++;
833}
834if (!empty($arrayfields['s.name_alias']['checked'])) {
835 print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, '', $sortfield, $sortorder);
836 $totalarray['nbfield']++;
837}
838if (!empty($arrayfields['pr.ref']['checked'])) {
839 print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], "pr.ref", "", $param, '', $sortfield, $sortorder);
840 $totalarray['nbfield']++;
841}
842if (!empty($arrayfields['c.ref']['checked'])) {
843 print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder);
844 $totalarray['nbfield']++;
845}
846if (!empty($arrayfields['f.description']['checked'])) {
847 print_liste_field_titre($arrayfields['f.description']['label'], $_SERVER["PHP_SELF"], "f.description", "", $param, '', $sortfield, $sortorder);
848 $totalarray['nbfield']++;
849}
850// Extra fields
851include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
852// Hook fields
853$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
854$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
855print $hookmanager->resPrint;
856if (!empty($arrayfields['f.datec']['checked'])) {
857 print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
858 $totalarray['nbfield']++;
859}
860if (!empty($arrayfields['f.tms']['checked'])) {
861 print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
862 $totalarray['nbfield']++;
863}
864if (!empty($arrayfields['f.note_public']['checked'])) {
865 print_liste_field_titre($arrayfields['f.note_public']['label'], $_SERVER["PHP_SELF"], "f.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
866 $totalarray['nbfield']++;
867}
868if (!empty($arrayfields['f.note_private']['checked'])) {
869 print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
870 $totalarray['nbfield']++;
871}
872if (!empty($arrayfields['f.fk_statut']['checked'])) {
873 print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
874 $totalarray['nbfield']++;
875}
876if (!empty($arrayfields['f.signed_status']['checked'])) {
877 print_liste_field_titre($arrayfields['f.signed_status']['label'], $_SERVER["PHP_SELF"], "f.signed_status", "", $param, '', $sortfield, $sortorder, 'center ');
878 $totalarray['nbfield']++;
879}
880if (!empty($arrayfields['fd.description']['checked'])) {
881 print_liste_field_titre($arrayfields['fd.description']['label'], $_SERVER["PHP_SELF"], '');
882 $totalarray['nbfield']++;
883}
884if (!empty($arrayfields['fd.date']['checked'])) {
885 print_liste_field_titre($arrayfields['fd.date']['label'], $_SERVER["PHP_SELF"], "fd.date", "", $param, '', $sortfield, $sortorder, 'center ');
886 $totalarray['nbfield']++;
887}
888if (!empty($arrayfields['fd.duree']['checked'])) {
889 print_liste_field_titre($arrayfields['fd.duree']['label'], $_SERVER["PHP_SELF"], "fd.duree", "", $param, '', $sortfield, $sortorder, 'right ');
890 $totalarray['nbfield']++;
891}
892
893// Action column
894if (!$conf->main_checkbox_left_column) {
895 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
896 $totalarray['nbfield']++;
897}
898print "</tr>\n";
899
900
901// Loop on record
902// --------------------------------------------------------------------
903$i = 0;
904$savnbfield = $totalarray['nbfield'];
905$totalarray = array();
906$totalarray['nbfield'] = 0;
907$totalarray['val'] = array();
908$totalarray['val']['fd.duree'] = 0;
909$total = 0;
910$imaxinloop = ($limit ? min($num, $limit) : $num);
911while ($i < $imaxinloop) {
912 $obj = $db->fetch_object($resql);
913 if (empty($obj)) {
914 break; // Should not happen
915 }
916
917 // Store properties in $object
918 //$object->setVarsFromFetchObj($obj);
919
920 $objectstatic->id = $obj->rowid;
921 $objectstatic->ref = $obj->ref;
922 $objectstatic->ref_client = $obj->ref_client;
923 $objectstatic->statut = $obj->status; // deprecated
924 $objectstatic->status = $obj->status;
925 $objectstatic->signed_status = $obj->signed_status;
926
927 $companystatic->name = $obj->name;
928 $companystatic->id = $obj->socid;
929 $companystatic->client = $obj->client;
930 $companystatic->fournisseur = $obj->fournisseur;
931 $companystatic->email = $obj->email;
932 $companystatic->status = $obj->thirdpartystatus;
933
934 //mode kanban
935 if ($mode == 'kanban') {
936 if ($i == 0) {
937 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
938 print '<div class="box-flex-container kanban">';
939 }
940
941 // Output Kanban
942 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
943 $selected = 0;
944 if (in_array($object->id, $arrayofselected)) {
945 $selected = 1;
946 }
947 }
948
949 $objectstatic->duration = $obj->duree;
950 $arraydata = array();
951 $arraydata['thirdparty'] = $companystatic;
952 print $objectstatic->getKanbanView('', $arraydata);
953 if ($i == ($imaxinloop - 1)) {
954 print '</div>';
955 print '</td></tr>';
956 }
957 } else {
958 // Show here line of result
959 $j = 0;
960 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
961 // Action column
962 if ($conf->main_checkbox_left_column) {
963 print '<td class="nowrap center">';
964 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
965 $selected = 0;
966 if (in_array($obj->rowid, $arrayofselected)) {
967 $selected = 1;
968 }
969 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
970 }
971 print '</td>';
972 if (!$i) {
973 $totalarray['nbfield']++;
974 }
975 }
976
977 // Picto + Ref
978 if (!empty($arrayfields['f.ref']['checked'])) {
979 print "<td>";
980
981 print '<table class="nobordernopadding"><tr class="nocellnopadd">';
982 print '<td class="nobordernopadding nowraponall">';
983 print $objectstatic->getNomUrl(1);
984 print '</td>';
985 // Warning
986 $warnornote = '';
987 //if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late"));
988 if (!empty($obj->note_private)) {
989 $warnornote .= ($warnornote ? ' ' : '');
990 $warnornote .= '<span class="note">';
991 $warnornote .= '<a href="note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>';
992 $warnornote .= '</span>';
993 }
994 if ($warnornote) {
995 print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
996 print $warnornote;
997 print '</td>';
998 }
999
1000 // Other picto tool
1001 print '<td width="16" class="right nobordernopadding hideonsmartphone">';
1002 $filename = dol_sanitizeFileName($obj->ref);
1003 $filedir = $conf->ficheinter->dir_output.'/'.dol_sanitizeFileName($obj->ref);
1004 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
1005 print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
1006 print '</td></tr></table>';
1007
1008 print "</td>\n";
1009 if (!$i) {
1010 $totalarray['nbfield']++;
1011 }
1012 }
1013
1014 // Customer ref
1015 if (!empty($arrayfields['f.ref_client']['checked'])) {
1016 print '<td class="nowrap tdoverflowmax200">';
1017 print dol_escape_htmltag($obj->ref_client);
1018 print '</td>';
1019 if (!$i) {
1020 $totalarray['nbfield']++;
1021 }
1022 }
1023 // Third party
1024 if (!empty($arrayfields['s.nom']['checked'])) {
1025 print '<td class="tdoverflowmax125">';
1026 print $companystatic->getNomUrl(1, '', 44);
1027 print '</td>';
1028 if (!$i) {
1029 $totalarray['nbfield']++;
1030 }
1031 }
1032 // Alias name
1033 if (!empty($arrayfields['s.name_alias']['checked'])) {
1034 print '<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($obj->alias).'">';
1035 print '<span class="spantitle">'.dolPrintHTML($obj->alias).'</span>';
1036 print '</td>';
1037 if (!$i) {
1038 $totalarray['nbfield']++;
1039 }
1040 }
1041 // Project ref
1042 if (!empty($arrayfields['pr.ref']['checked']) && $projetstatic !== null) {
1043 print '<td class="tdoverflowmax150">';
1044 $projetstatic->id = $obj->projet_id;
1045 $projetstatic->ref = $obj->projet_ref;
1046 $projetstatic->title = $obj->projet_title;
1047 if ($projetstatic->id > 0) {
1048 print $projetstatic->getNomUrl(1, '');
1049 }
1050 print '</td>';
1051 if (!$i) {
1052 $totalarray['nbfield']++;
1053 }
1054 }
1055 // Contract
1056 if (!empty($arrayfields['c.ref']['checked']) && $contratstatic !== null) {
1057 print '<td class="tdoverflowmax150">';
1058 $contratstatic->id = $obj->contrat_id;
1059 $contratstatic->ref = $obj->contrat_ref;
1060 $contratstatic->ref_customer = $obj->contrat_ref_customer;
1061 $contratstatic->ref_supplier = $obj->contrat_ref_supplier;
1062 if ($contratstatic->id > 0) {
1063 print $contratstatic->getNomUrl(1, 0);
1064 print '</td>';
1065 }
1066 if (!$i) {
1067 $totalarray['nbfield']++;
1068 }
1069 }
1070 if (!empty($arrayfields['f.description']['checked'])) {
1071 print '<td>'.dol_trunc(dolGetFirstLineOfText(dol_string_nohtmltag($obj->description, 1)), 48).'</td>';
1072 if (!$i) {
1073 $totalarray['nbfield']++;
1074 }
1075 }
1076
1077 // Extra fields
1078 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1079 // Fields from hook
1080 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1081 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1082 print $hookmanager->resPrint;
1083 // Date creation
1084 if (!empty($arrayfields['f.datec']['checked'])) {
1085 print '<td class="center nowraponall">';
1086 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1087 print '</td>';
1088 if (!$i) {
1089 $totalarray['nbfield']++;
1090 }
1091 }
1092 // Date modification
1093 if (!empty($arrayfields['f.tms']['checked'])) {
1094 print '<td class="center nowraponall">';
1095 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser');
1096 print '</td>';
1097 if (!$i) {
1098 $totalarray['nbfield']++;
1099 }
1100 }
1101 // Note public
1102 if (!empty($arrayfields['f.note_public']['checked'])) {
1103 print '<td class="sensiblehtmlcontent center">';
1104 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_public, 5)).'</div>';
1105 print '</td>';
1106 if (!$i) {
1107 $totalarray['nbfield']++;
1108 }
1109 }
1110 // Note private
1111 if (!empty($arrayfields['f.note_private']['checked'])) {
1112 print '<td class="sensiblehtmlcontent center">';
1113 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_private, 5)).'</div>';
1114 print '</td>';
1115 if (!$i) {
1116 $totalarray['nbfield']++;
1117 }
1118 }
1119 // Status
1120 if (!empty($arrayfields['f.fk_statut']['checked'])) {
1121 print '<td class="center">'.$objectstatic->getLibStatut(5).'</td>';
1122 if (!$i) {
1123 $totalarray['nbfield']++;
1124 }
1125 }
1126 // Signed Status
1127 if (!empty($arrayfields['f.signed_status']['checked'])) {
1128 print '<td class="center">'.$objectstatic->getLibSignedStatus(5).'</td>';
1129 if (!$i) {
1130 $totalarray['nbfield']++;
1131 }
1132 }
1133 // Fields of detail of line
1134 if (!empty($arrayfields['fd.description']['checked'])) {
1135 $text = dolGetFirstLineOfText(dol_string_nohtmltag($obj->descriptiondetail, 1));
1136 print '<td>';
1137 print '<div class="classfortooltip tdoverflowmax250 small" title="'.dol_escape_htmltag($obj->descriptiondetail, 1, 1).'">';
1138 print dol_escape_htmltag($text);
1139 print '</div>';
1140 print '</td>';
1141 if (!$i) {
1142 $totalarray['nbfield']++;
1143 }
1144 }
1145 // Date line
1146 if (!empty($arrayfields['fd.date']['checked'])) {
1147 print '<td class="center nowraponall" title="'.dol_print_date($db->jdate($obj->dp), 'dayhour').'">'.dol_print_date($db->jdate($obj->dp), 'dayhour')."</td>\n";
1148 if (!$i) {
1149 $totalarray['nbfield']++;
1150 }
1151 }
1152 // Duration line
1153 if (!empty($arrayfields['fd.duree']['checked'])) {
1154 print '<td class="right">'.convertSecondToTime($obj->duree, 'allhourmin').'</td>';
1155 if (!$i) {
1156 $totalarray['nbfield']++;
1157 }
1158 if (!$i) {
1159 $totalarray['type'][$totalarray['nbfield']] = 'duration';
1160 }
1161 if (!$i) {
1162 $totalarray['pos'][$totalarray['nbfield']] = 'fd.duree';
1163 }
1164 $totalarray['val']['fd.duree'] += $obj->duree;
1165 }
1166 // Action column
1167 if (!$conf->main_checkbox_left_column) {
1168 print '<td class="nowrap center">';
1169 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1170 $selected = 0;
1171 if (in_array($obj->rowid, $arrayofselected)) {
1172 $selected = 1;
1173 }
1174 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1175 }
1176 print '</td>';
1177 if (!$i) {
1178 $totalarray['nbfield']++;
1179 }
1180 }
1181
1182 print '</tr>'."\n";
1183
1184 $total += (isset($obj->duree) ? $obj->duree : 0);
1185 }
1186 $i++;
1187}
1188
1189
1190// Show total line
1191include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1192
1193// If no record found
1194if ($num == 0) {
1195 $colspan = 1;
1196 foreach ($arrayfields as $key => $val) {
1197 if (!empty($val['checked'])) {
1198 $colspan++;
1199 }
1200 }
1201 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1202}
1203
1204$db->free($resql);
1205
1206$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1207$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1208print $hookmanager->resPrint;
1209
1210print '</table>'."\n";
1211print '</div>'."\n";
1212
1213print '</form>'."\n";
1214
1215if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
1216 $hidegeneratedfilelistifempty = 1;
1217 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1218 $hidegeneratedfilelistifempty = 0;
1219 }
1220
1221 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
1222 $formfile = new FormFile($db);
1223
1224 // Show list of available documents
1225 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1226 $urlsource .= str_replace('&amp;', '&', $param);
1227
1228 $filedir = $diroutputmassaction;
1229 $genallowed = $permissiontoread;
1230 $delallowed = $permissiontoadd;
1231
1232 print $formfile->showdocuments('massfilesarea_interventions', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1233}
1234
1235// End of page
1236llxFooter();
1237$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
$c
Definition line.php:353
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage categories.
const STATUS_BILLED
Billed.
Class to manage forms for categories.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_now($mode='gmt')
Return date for now.
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...
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Definition html.lib.php:183
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.