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