dolibarr 24.0.3
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// The table of lines is joined only if a field of lines is shown, so do not search into it otherwise
297if (!$atleastonefieldinlines) {
298 unset($fieldstosearchall['fd.description']);
299}
300
301$sql = "SELECT";
302$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,";
303if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') && $atleastonefieldinlines) {
304 $sql .= " fd.rowid as lineid, fd.description as descriptiondetail, fd.date as dp, fd.duree,";
305}
306$sql .= " s.nom as name, s.rowid as socid, s.client, s.fournisseur, s.email, s.status as thirdpartystatus";
307if (isModEnabled('project')) {
308 $sql .= ", pr.rowid as projet_id, pr.ref as projet_ref, pr.title as projet_title";
309}
310if (isModEnabled('contract')) {
311 $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";
312}
313// Add fields from extrafields
314if (!empty($extrafields->attributes[$object->table_element]['label'])) {
315 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
316 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
317 }
318}
319// Add fields from hooks
320$parameters = array();
321$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
322$sql .= $hookmanager->resPrint;
323
324$sqlfields = $sql; // $sql fields to remove for count total
325
326$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
327if (isModEnabled('project')) {
328 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr on f.fk_projet = pr.rowid";
329}
330if (isModEnabled('contract')) {
331 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contrat as c on f.fk_contrat = c.rowid";
332}
333if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
334 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)";
335}
336if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') && $atleastonefieldinlines) {
337 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid";
338}
339
340// Add table from hooks
341$parameters = array();
342$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
343$sql .= $hookmanager->resPrint;
344
345$sql .= ", ".MAIN_DB_PREFIX."societe as s";
346$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
347$sql .= " AND f.fk_soc = s.rowid";
348if ($search_ref) {
349 $sql .= natural_search('f.ref', $search_ref);
350}
351if ($search_ref_client) {
352 $sql .= natural_search('f.ref_client', $search_ref_client);
353}
354if ($search_company) {
355 $sql .= natural_search('s.nom', $search_company);
356}
357if ($search_projet_ref) {
358 $sql .= natural_search('pr.ref', $search_projet_ref);
359}
360if ($search_contrat_ref) {
361 $sql .= natural_search('c.ref', $search_contrat_ref);
362}
363if ($search_desc) {
364 if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') && $atleastonefieldinlines) {
365 $sql .= natural_search(array('f.description', 'fd.description'), $search_desc);
366 } else {
367 $sql .= natural_search(array('f.description'), $search_desc);
368 }
369}
370// Search for tag/category ($searchCategoryFichinterList is an array of ID)
371if (!empty($searchCategoryFichinterList)) {
372 $searchCategoryFichinterSqlList = array();
373 $listofcategoryid = '';
374 foreach ($searchCategoryFichinterList as $searchCategoryFichinter) {
375 if (intval($searchCategoryFichinter) == -2) {
376 $searchCategoryFichinterSqlList[] = "NOT EXISTS (SELECT ck.fk_fichinter FROM ".MAIN_DB_PREFIX."categorie_fichinter as ck WHERE f.rowid = ck.fk_fichinter)";
377 } elseif (intval($searchCategoryFichinter) > 0) {
378 if ($searchCategoryFichinterOperator == 0) {
379 $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).")";
380 } else {
381 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryFichinter);
382 }
383 }
384 }
385 if ($listofcategoryid) {
386 $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)."))";
387 }
388 if ($searchCategoryFichinterOperator == 1) {
389 if (!empty($searchCategoryFichinterSqlList)) {
390 $sql .= " AND (".implode(' OR ', $searchCategoryFichinterSqlList).")";
391 }
392 } else {
393 if (!empty($searchCategoryFichinterSqlList)) {
394 $sql .= " AND (".implode(' AND ', $searchCategoryFichinterSqlList).")";
395 }
396 }
397}
398if ($search_status != '' && $search_status >= 0) {
399 $sql .= ' AND f.fk_statut = '.((int) ($search_status));
400}
401if ($search_signed_status != '' && $search_signed_status >= 0) {
402 $sql .= ' AND f.signed_status = '.((int) $search_signed_status);
403}
404if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') && $atleastonefieldinlines) {
405 if ($search_date_start) {
406 $sql .= " AND fd.date >= '".$db->idate($search_date_start)."'";
407 }
408 if ($search_date_end) {
409 $sql .= " AND fd.date <= '".$db->idate($search_date_end)."'";
410 }
411}
412if ($socid > 0) {
413 $sql .= " AND s.rowid = ".((int) $socid);
414}
415// Restriction on sale representative
416if (empty($user->socid) && !$permissiontoreadallthirdparty) {
417 $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).")";
418 if (getDolGlobalInt('MAIN_SEE_SUBORDINATES') && $userschilds) {
419 $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))."))";
420 }
421 $sql .= ")";
422}
423
424if ($search_all) {
425 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
426}
427// Search on sale representative
428/*
429if ($search_sale && $search_sale != '-1') {
430 if ($search_sale == -2) {
431 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc)";
432 } elseif ($search_sale > 0) {
433 $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).")";
434 }
435}*/
436// Add where from extra fields
437include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
438// Add where from hooks
439$parameters = array();
440$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
441$sql .= $hookmanager->resPrint;
442// Add GroupBy from hooks
443$parameters = array('search_all' => $search_all, 'fieldstosearchall' => $fieldstosearchall);
444$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
445$sql .= $hookmanager->resPrint;
446
447// Count total nb of records
448$nbtotalofrecords = '';
449if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
450 /* The fast and low memory method to get and count full list converts the sql into a sql count */
451 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
452 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
453 $resql = $db->query($sqlforcount);
454 if ($resql) {
455 $objforcount = $db->fetch_object($resql);
456 $nbtotalofrecords = $objforcount->nbtotalofrecords;
457 } else {
459 }
460
461 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
462 $page = 0;
463 $offset = 0;
464 }
465 $db->free($resql);
466}
467
468// Complete request and execute it with limit
469$sql .= $db->order($sortfield, $sortorder);
470if ($limit) {
471 $sql .= $db->plimit($limit + 1, $offset);
472}
473
474$resql = $db->query($sql);
475if (!$resql) {
477 exit;
478}
479
480$num = $db->num_rows($resql);
481
482
483// Direct jump if only one record found
484if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
485 $obj = $db->fetch_object($resql);
486 $id = $obj->rowid;
487 header("Location: ".dol_buildpath('/fichinter/card.php', 1).'?id='.$id);
488 exit;
489}
490
491
492// Output page
493// --------------------------------------------------------------------
494$paramsCat = '';
495foreach ($searchCategoryFichinterList as $searchCategoryFichinter) {
496 $paramsCat .= "&search_category_fichinter_list[]=".urlencode($searchCategoryFichinter);
497}
498
499llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist mod-fichinter page-list'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
500
501
502$arrayofselected = is_array($toselect) ? $toselect : array();
503
504if ($socid > 0) {
505 $soc = new Societe($db);
506 $soc->fetch($socid);
507 if (empty($search_company)) {
508 $search_company = $soc->name;
509 }
510}
511
512$param = '';
513if (!empty($mode)) {
514 $param .= '&mode='.urlencode($mode);
515}
516if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
517 $param .= '&contextpage='.urlencode($contextpage);
518}
519if ($limit > 0 && $limit != $conf->liste_limit) {
520 $param .= '&limit='.((int) $limit);
521}
522if ($search_all) {
523 $param .= "&search_all=".urlencode($search_all);
524}
525if ($socid) {
526 $param .= "&socid=".urlencode((string) ($socid));
527}
528if ($searchCategoryFichinterOperator == 1) {
529 $param .= "&search_category_fichinter_operator=".urlencode((string) $searchCategoryFichinterOperator);
530}
531foreach ($searchCategoryFichinterList as $searchCategoryFichinter) {
532 $param .= "&search_category_fichinter_list[]=".urlencode($searchCategoryFichinter);
533}
534if ($search_ref) {
535 $param .= "&search_ref=".urlencode($search_ref);
536}
537if ($search_ref_client) {
538 $param .= "&search_ref_client=".urlencode($search_ref_client);
539}
540if ($search_company) {
541 $param .= "&search_company=".urlencode($search_company);
542}
543if ($search_desc) {
544 $param .= "&search_desc=".urlencode($search_desc);
545}
546if ($search_projet_ref) {
547 $param .= "&search_projet_ref=".urlencode($search_projet_ref);
548}
549if ($search_contrat_ref) {
550 $param .= "&search_contrat_ref=".urlencode($search_contrat_ref);
551}
552if ($search_status != '' && $search_status > -1) {
553 $param .= "&search_status=".urlencode($search_status);
554}
555if ($search_signed_status != '' && $search_signed_status >= 0) {
556 $param .= '&search_signed_status='.urlencode($search_signed_status);
557}
558if ($search_date_startday > 0) {
559 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
560}
561if ($search_date_startmonth > 0) {
562 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
563}
564if ($search_date_startyear > 0) {
565 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
566}
567if ($search_date_endday > 0) {
568 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
569}
570if ($search_date_endmonth > 0) {
571 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
572}
573if ($search_date_endyear > 0) {
574 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
575}
576if ($show_files) {
577 $param .= '&show_files='.urlencode((string) ($show_files));
578}
579if ($optioncss != '') {
580 $param .= '&optioncss='.urlencode($optioncss);
581}
582// Add $param from extra fields
583include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
584// Add $param from hooks
585$parameters = array('param' => &$param);
586$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
587$param .= $hookmanager->resPrint;
588
589// List of mass actions available
590$arrayofmassactions = array(
591 'generate_doc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
592 'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
593 //'presend'=>$langs->trans("SendByMail"),
594);
595if (!empty($permissiontodelete)) {
596 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
597}
598if (isModEnabled('category') && $user->hasRight('categorie', 'creer')) {
599 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
600}
601if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) {
602 $arrayofmassactions = array();
603}
604$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
605
606
607print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
608if ($optioncss != '') {
609 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
610}
611print '<input type="hidden" name="token" value="'.newToken().'">';
612print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
613print '<input type="hidden" name="action" value="list">';
614print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
615print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
616print '<input type="hidden" name="page" value="'.$page.'">';
617print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
618print '<input type="hidden" name="page_y" value="">';
619print '<input type="hidden" name="mode" value="'.$mode.'">';
620
621$newcardbutton = '';
622$url = DOL_URL_ROOT.'/fichinter/card.php?action=create';
623if (!empty($socid)) {
624 $url .= '&socid='.$socid;
625}
626$newcardbutton = '';
627$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'));
628$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'));
629$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'));
630$newcardbutton .= dolGetButtonTitleSeparator();
631$newcardbutton .= dolGetButtonTitle($langs->trans('NewIntervention'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('ficheinter', 'creer'));
632
633print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
634
635$topicmail = "Information";
636$modelmail = "intervention";
637$objecttmp = new Fichinter($db);
638$trackid = 'int'.$object->id;
639include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
640
641if (!empty($catid)) {
642 print "<div id='ways'>";
643 $c = new Categorie($db);
644 $ways = $c->print_all_ways(' &gt; ', 'fichinter/list.php');
645 print " &gt; ".$ways[0]."<br>\n";
646 print "</div><br>";
647}
648
649if ($search_all) {
650 $setupstring = '';
651 foreach ($fieldstosearchall as $key => $val) {
652 $fieldstosearchall[$key] = $langs->trans($val);
653 $setupstring .= $key."=".$val.";";
654 }
655 print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
656 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
657}
658
659// Filter on categories
660$moreforfilter = '';
661if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
662 $formcategory = new FormCategory($db);
663 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_FICHINTER, $searchCategoryFichinterList, 'minwidth300', $searchCategoryFichinterOperator ? $searchCategoryFichinterOperator : 0);
664}
665$parameters = array();
666$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
667if (empty($reshook)) {
668 $moreforfilter .= $hookmanager->resPrint;
669} else {
670 $moreforfilter = $hookmanager->resPrint;
671}
672
673if (!empty($moreforfilter)) {
674 print '<div class="liste_titre liste_titre_bydiv centpercent">';
675 print $moreforfilter;
676 print '</div>';
677}
678
679$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
680$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
681$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
682$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
683
684print '<div class="div-table-responsive">';
685print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
686
687// Fields title search
688// --------------------------------------------------------------------
689print '<tr class="liste_titre_filter">';
690// Action column
691if ($conf->main_checkbox_left_column) {
692 print '<td class="liste_titre center maxwidthsearch">';
693 $searchpicto = $form->showFilterButtons('left');
694 print $searchpicto;
695 print '</td>';
696}
697if (!empty($arrayfields['f.ref']['checked'])) {
698 print '<td class="liste_titre">';
699 print '<input type="text" class="flat" name="search_ref" value="'.$search_ref.'" size="8">';
700 print '</td>';
701}
702if (!empty($arrayfields['f.ref_client']['checked'])) {
703 print '<td class="liste_titre">';
704 print '<input type="text" class="flat" name="search_ref_client" value="'.$search_ref_client.'" size="8">';
705 print '</td>';
706}
707if (!empty($arrayfields['s.nom']['checked'])) {
708 print '<td class="liste_titre">';
709 print '<input type="text" class="flat" name="search_company" value="'.$search_company.'" size="10">';
710 print '</td>';
711}
712if (!empty($arrayfields['pr.ref']['checked'])) {
713 print '<td class="liste_titre">';
714 print '<input type="text" class="flat" name="search_projet_ref" value="'.$search_projet_ref.'" size="8">';
715 print '</td>';
716}
717if (!empty($arrayfields['c.ref']['checked'])) {
718 print '<td class="liste_titre">';
719 print '<input type="text" class="flat" name="search_contrat_ref" value="'.$search_contrat_ref.'" size="8">';
720 print '</td>';
721}
722if (!empty($arrayfields['f.description']['checked'])) {
723 print '<td class="liste_titre">';
724 print '<input type="text" class="flat" name="search_desc" value="'.$search_desc.'" size="12">';
725 print '</td>';
726}
727// Extra fields
728include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
729
730// Fields from hook
731$parameters = array('arrayfields' => $arrayfields);
732$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
733print $hookmanager->resPrint;
734if (!empty($arrayfields['f.datec']['checked'])) {
735 // Date creation
736 print '<td class="liste_titre">';
737 print '</td>';
738}
739if (!empty($arrayfields['f.tms']['checked'])) {
740 // Date modification
741 print '<td class="liste_titre">';
742 print '</td>';
743}
744if (!empty($arrayfields['f.note_public']['checked'])) {
745 // Note public
746 print '<td class="liste_titre">';
747 print '</td>';
748}
749if (!empty($arrayfields['f.note_private']['checked'])) {
750 // Note private
751 print '<td class="liste_titre">';
752 print '</td>';
753}
754// Status
755if (!empty($arrayfields['f.fk_statut']['checked'])) {
756 print '<td class="liste_titre right parentonrightofpage">';
757 $liststatus = [
758 $object::STATUS_DRAFT => $langs->transnoentitiesnoconv('Draft'),
759 $object::STATUS_VALIDATED => $langs->transnoentitiesnoconv('Validated'),
760 $object::STATUS_BILLED => $langs->transnoentitiesnoconv('StatusInterInvoiced'),
761 $object::STATUS_CLOSED => $langs->transnoentitiesnoconv('Done'),
762 ];
763 if (!getDolGlobalString('FICHINTER_CLASSIFY_BILLED')) {
764 unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
765 }
766 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
767 print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1, 0, 0, '', 'search_status width100 onrightofpage');
768 print '</td>';
769}
770// Signed status
771if (!empty($arrayfields['f.signed_status']['checked'])) {
772 print '<td class="liste_titre center">';
773 $list_signed_status = $object->getSignedStatusLocalisedArray();
774 print $form->selectarray('search_signed_status', $list_signed_status, $search_signed_status, 1, 0, 0, '', 1, 0, 0, '', 'search_status');
775 print '</td>';
776}
777// Fields of detail line
778if (!empty($arrayfields['fd.description']['checked'])) {
779 print '<td class="liste_titre">&nbsp;</td>';
780}
781if (!empty($arrayfields['fd.date']['checked'])) {
782 print '<td class="liste_titre center">';
783 print '<div class="nowrapfordate">';
784 print $form->selectDate($search_date_start ?: -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
785 print '</div>';
786 print '<div class="nowrapfordate">';
787 print $form->selectDate($search_date_end ?: -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
788 print '</div>';
789 print '</td>';
790}
791if (!empty($arrayfields['fd.duree']['checked'])) {
792 print '<td class="liste_titre">&nbsp;</td>';
793}
794// Action column
795if (!$conf->main_checkbox_left_column) {
796 print '<td class="liste_titre center maxwidthsearch">';
797 $searchpicto = $form->showFilterButtons();
798 print $searchpicto;
799 print '</td>';
800}
801print '</tr>'."\n";
802
803$totalarray = array();
804$totalarray['nbfield'] = 0;
805
806// Fields title label
807// --------------------------------------------------------------------
808print '<tr class="liste_titre">';
809// Action column
810if ($conf->main_checkbox_left_column) {
811 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
812 $totalarray['nbfield']++;
813}
814if (!empty($arrayfields['f.ref']['checked'])) {
815 // @phan-suppress-next-line PhanTypeInvalidDimOffset
816 print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
817 $totalarray['nbfield']++;
818}
819if (!empty($arrayfields['f.ref_client']['checked'])) {
820 print_liste_field_titre($arrayfields['f.ref_client']['label'], $_SERVER["PHP_SELF"], "f.ref_client", "", $param, '', $sortfield, $sortorder);
821 $totalarray['nbfield']++;
822}
823if (!empty($arrayfields['s.nom']['checked'])) {
824 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
825 $totalarray['nbfield']++;
826}
827if (!empty($arrayfields['pr.ref']['checked'])) {
828 print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], "pr.ref", "", $param, '', $sortfield, $sortorder);
829 $totalarray['nbfield']++;
830}
831if (!empty($arrayfields['c.ref']['checked'])) {
832 print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder);
833 $totalarray['nbfield']++;
834}
835if (!empty($arrayfields['f.description']['checked'])) {
836 print_liste_field_titre($arrayfields['f.description']['label'], $_SERVER["PHP_SELF"], "f.description", "", $param, '', $sortfield, $sortorder);
837 $totalarray['nbfield']++;
838}
839// Extra fields
840include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
841// Hook fields
842$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
843$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
844print $hookmanager->resPrint;
845if (!empty($arrayfields['f.datec']['checked'])) {
846 print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
847 $totalarray['nbfield']++;
848}
849if (!empty($arrayfields['f.tms']['checked'])) {
850 print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
851 $totalarray['nbfield']++;
852}
853if (!empty($arrayfields['f.note_public']['checked'])) {
854 print_liste_field_titre($arrayfields['f.note_public']['label'], $_SERVER["PHP_SELF"], "f.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
855 $totalarray['nbfield']++;
856}
857if (!empty($arrayfields['f.note_private']['checked'])) {
858 print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
859 $totalarray['nbfield']++;
860}
861if (!empty($arrayfields['f.fk_statut']['checked'])) {
862 print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
863 $totalarray['nbfield']++;
864}
865if (!empty($arrayfields['f.signed_status']['checked'])) {
866 print_liste_field_titre($arrayfields['f.signed_status']['label'], $_SERVER["PHP_SELF"], "f.signed_status", "", $param, '', $sortfield, $sortorder, 'center ');
867 $totalarray['nbfield']++;
868}
869if (!empty($arrayfields['fd.description']['checked'])) {
870 print_liste_field_titre($arrayfields['fd.description']['label'], $_SERVER["PHP_SELF"], '');
871 $totalarray['nbfield']++;
872}
873if (!empty($arrayfields['fd.date']['checked'])) {
874 print_liste_field_titre($arrayfields['fd.date']['label'], $_SERVER["PHP_SELF"], "fd.date", "", $param, '', $sortfield, $sortorder, 'center ');
875 $totalarray['nbfield']++;
876}
877if (!empty($arrayfields['fd.duree']['checked'])) {
878 print_liste_field_titre($arrayfields['fd.duree']['label'], $_SERVER["PHP_SELF"], "fd.duree", "", $param, '', $sortfield, $sortorder, 'right ');
879 $totalarray['nbfield']++;
880}
881
882// Action column
883if (!$conf->main_checkbox_left_column) {
884 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
885 $totalarray['nbfield']++;
886}
887print "</tr>\n";
888
889
890// Loop on record
891// --------------------------------------------------------------------
892$i = 0;
893$savnbfield = $totalarray['nbfield'];
894$totalarray = array();
895$totalarray['nbfield'] = 0;
896$totalarray['val'] = array();
897$totalarray['val']['fd.duree'] = 0;
898$total = 0;
899$imaxinloop = ($limit ? min($num, $limit) : $num);
900while ($i < $imaxinloop) {
901 $obj = $db->fetch_object($resql);
902 if (empty($obj)) {
903 break; // Should not happen
904 }
905
906 // Store properties in $object
907 //$object->setVarsFromFetchObj($obj);
908
909 $objectstatic->id = $obj->rowid;
910 $objectstatic->ref = $obj->ref;
911 $objectstatic->ref_client = $obj->ref_client;
912 $objectstatic->statut = $obj->status; // deprecated
913 $objectstatic->status = $obj->status;
914 $objectstatic->signed_status = $obj->signed_status;
915
916 $companystatic->name = $obj->name;
917 $companystatic->id = $obj->socid;
918 $companystatic->client = $obj->client;
919 $companystatic->fournisseur = $obj->fournisseur;
920 $companystatic->email = $obj->email;
921 $companystatic->status = $obj->thirdpartystatus;
922
923 //mode kanban
924 if ($mode == 'kanban') {
925 if ($i == 0) {
926 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
927 print '<div class="box-flex-container kanban">';
928 }
929
930 // Output Kanban
931 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
932 $selected = 0;
933 if (in_array($object->id, $arrayofselected)) {
934 $selected = 1;
935 }
936 }
937
938 $objectstatic->duration = $obj->duree;
939 $arraydata = array();
940 $arraydata['thirdparty'] = $companystatic;
941 print $objectstatic->getKanbanView('', $arraydata);
942 if ($i == ($imaxinloop - 1)) {
943 print '</div>';
944 print '</td></tr>';
945 }
946 } else {
947 // Show here line of result
948 $j = 0;
949 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select">';
950 // Action column
951 if ($conf->main_checkbox_left_column) {
952 print '<td class="nowrap center">';
953 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
954 $selected = 0;
955 if (in_array($obj->rowid, $arrayofselected)) {
956 $selected = 1;
957 }
958 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
959 }
960 print '</td>';
961 if (!$i) {
962 $totalarray['nbfield']++;
963 }
964 }
965
966 // Picto + Ref
967 if (!empty($arrayfields['f.ref']['checked'])) {
968 print "<td>";
969
970 print '<table class="nobordernopadding"><tr class="nocellnopadd">';
971 print '<td class="nobordernopadding nowraponall">';
972 print $objectstatic->getNomUrl(1);
973 print '</td>';
974 // Warning
975 $warnornote = '';
976 //if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late"));
977 if (!empty($obj->note_private)) {
978 $warnornote .= ($warnornote ? ' ' : '');
979 $warnornote .= '<span class="note">';
980 $warnornote .= '<a href="note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>';
981 $warnornote .= '</span>';
982 }
983 if ($warnornote) {
984 print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
985 print $warnornote;
986 print '</td>';
987 }
988
989 // Other picto tool
990 print '<td width="16" class="right nobordernopadding hideonsmartphone">';
991 $filename = dol_sanitizeFileName($obj->ref);
992 $filedir = $conf->ficheinter->dir_output.'/'.dol_sanitizeFileName($obj->ref);
993 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
994 print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
995 print '</td></tr></table>';
996
997 print "</td>\n";
998 if (!$i) {
999 $totalarray['nbfield']++;
1000 }
1001 }
1002
1003 // Customer ref
1004 if (!empty($arrayfields['f.ref_client']['checked'])) {
1005 print '<td class="nowrap tdoverflowmax200">';
1006 print dol_escape_htmltag($obj->ref_client);
1007 print '</td>';
1008 if (!$i) {
1009 $totalarray['nbfield']++;
1010 }
1011 }
1012 // Third party
1013 if (!empty($arrayfields['s.nom']['checked'])) {
1014 print '<td class="tdoverflowmax125">';
1015 print $companystatic->getNomUrl(1, '', 44);
1016 print '</td>';
1017 if (!$i) {
1018 $totalarray['nbfield']++;
1019 }
1020 }
1021 // Project ref
1022 if (!empty($arrayfields['pr.ref']['checked']) && $projetstatic !== null) {
1023 print '<td class="tdoverflowmax150">';
1024 $projetstatic->id = $obj->projet_id;
1025 $projetstatic->ref = $obj->projet_ref;
1026 $projetstatic->title = $obj->projet_title;
1027 if ($projetstatic->id > 0) {
1028 print $projetstatic->getNomUrl(1, '');
1029 }
1030 print '</td>';
1031 if (!$i) {
1032 $totalarray['nbfield']++;
1033 }
1034 }
1035 // Contract
1036 if (!empty($arrayfields['c.ref']['checked']) && $contratstatic !== null) {
1037 print '<td class="tdoverflowmax150">';
1038 $contratstatic->id = $obj->contrat_id;
1039 $contratstatic->ref = $obj->contrat_ref;
1040 $contratstatic->ref_customer = $obj->contrat_ref_customer;
1041 $contratstatic->ref_supplier = $obj->contrat_ref_supplier;
1042 if ($contratstatic->id > 0) {
1043 print $contratstatic->getNomUrl(1, 0);
1044 print '</td>';
1045 }
1046 if (!$i) {
1047 $totalarray['nbfield']++;
1048 }
1049 }
1050 if (!empty($arrayfields['f.description']['checked'])) {
1051 print '<td>'.dol_trunc(dolGetFirstLineOfText(dol_string_nohtmltag($obj->description, 1)), 48).'</td>';
1052 if (!$i) {
1053 $totalarray['nbfield']++;
1054 }
1055 }
1056
1057 // Extra fields
1058 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1059 // Fields from hook
1060 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1061 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1062 print $hookmanager->resPrint;
1063 // Date creation
1064 if (!empty($arrayfields['f.datec']['checked'])) {
1065 print '<td class="center nowraponall">';
1066 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1067 print '</td>';
1068 if (!$i) {
1069 $totalarray['nbfield']++;
1070 }
1071 }
1072 // Date modification
1073 if (!empty($arrayfields['f.tms']['checked'])) {
1074 print '<td class="center nowraponall">';
1075 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser');
1076 print '</td>';
1077 if (!$i) {
1078 $totalarray['nbfield']++;
1079 }
1080 }
1081 // Note public
1082 if (!empty($arrayfields['f.note_public']['checked'])) {
1083 print '<td class="sensiblehtmlcontent center">';
1084 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_public, 5)).'</div>';
1085 print '</td>';
1086 if (!$i) {
1087 $totalarray['nbfield']++;
1088 }
1089 }
1090 // Note private
1091 if (!empty($arrayfields['f.note_private']['checked'])) {
1092 print '<td class="sensiblehtmlcontent center">';
1093 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_private, 5)).'</div>';
1094 print '</td>';
1095 if (!$i) {
1096 $totalarray['nbfield']++;
1097 }
1098 }
1099 // Status
1100 if (!empty($arrayfields['f.fk_statut']['checked'])) {
1101 print '<td class="center">'.$objectstatic->getLibStatut(5).'</td>';
1102 if (!$i) {
1103 $totalarray['nbfield']++;
1104 }
1105 }
1106 // Signed Status
1107 if (!empty($arrayfields['f.signed_status']['checked'])) {
1108 print '<td class="center">'.$objectstatic->getLibSignedStatus(5).'</td>';
1109 if (!$i) {
1110 $totalarray['nbfield']++;
1111 }
1112 }
1113 // Fields of detail of line
1114 if (!empty($arrayfields['fd.description']['checked'])) {
1115 $text = dolGetFirstLineOfText(dol_string_nohtmltag($obj->descriptiondetail, 1));
1116 print '<td>';
1117 print '<div class="classfortooltip tdoverflowmax250 small" title="'.dol_escape_htmltag($obj->descriptiondetail, 1, 1).'">';
1118 print dol_escape_htmltag($text);
1119 print '</div>';
1120 print '</td>';
1121 if (!$i) {
1122 $totalarray['nbfield']++;
1123 }
1124 }
1125 // Date line
1126 if (!empty($arrayfields['fd.date']['checked'])) {
1127 print '<td class="center nowraponall" title="'.dol_print_date($db->jdate($obj->dp), 'dayhour').'">'.dol_print_date($db->jdate($obj->dp), 'dayhour')."</td>\n";
1128 if (!$i) {
1129 $totalarray['nbfield']++;
1130 }
1131 }
1132 // Duration line
1133 if (!empty($arrayfields['fd.duree']['checked'])) {
1134 print '<td class="right">'.convertSecondToTime($obj->duree, 'allhourmin').'</td>';
1135 if (!$i) {
1136 $totalarray['nbfield']++;
1137 }
1138 if (!$i) {
1139 $totalarray['type'][$totalarray['nbfield']] = 'duration';
1140 }
1141 if (!$i) {
1142 $totalarray['pos'][$totalarray['nbfield']] = 'fd.duree';
1143 }
1144 $totalarray['val']['fd.duree'] += $obj->duree;
1145 }
1146 // Action column
1147 if (!$conf->main_checkbox_left_column) {
1148 print '<td class="nowrap center">';
1149 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1150 $selected = 0;
1151 if (in_array($obj->rowid, $arrayofselected)) {
1152 $selected = 1;
1153 }
1154 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1155 }
1156 print '</td>';
1157 if (!$i) {
1158 $totalarray['nbfield']++;
1159 }
1160 }
1161
1162 print '</tr>'."\n";
1163
1164 $total += (isset($obj->duree) ? $obj->duree : 0);
1165 }
1166 $i++;
1167}
1168
1169
1170// Show total line
1171include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1172
1173// If no record found
1174if ($num == 0) {
1175 $colspan = 1;
1176 foreach ($arrayfields as $key => $val) {
1177 if (!empty($val['checked'])) {
1178 $colspan++;
1179 }
1180 }
1181 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1182}
1183
1184$db->free($resql);
1185
1186$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1187$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1188print $hookmanager->resPrint;
1189
1190print '</table>'."\n";
1191print '</div>'."\n";
1192
1193print '</form>'."\n";
1194
1195if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
1196 $hidegeneratedfilelistifempty = 1;
1197 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1198 $hidegeneratedfilelistifempty = 0;
1199 }
1200
1201 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
1202 $formfile = new FormFile($db);
1203
1204 // Show list of available documents
1205 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1206 $urlsource .= str_replace('&amp;', '&', $param);
1207
1208 $filedir = $diroutputmassaction;
1209 $genallowed = $permissiontoread;
1210 $delallowed = $permissiontoadd;
1211
1212 print $formfile->showdocuments('massfilesarea_interventions', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1213}
1214
1215// End of page
1216llxFooter();
1217$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.
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...
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)
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.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_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.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
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).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
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...
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
buildzip.php
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.