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