dolibarr 24.0.0-beta
services_list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
6 * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
7 * Copyright (C) 2018-2026 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2019 Juanjo Menent <jmenent@2byte.es>
9 * Copyright (C) 2023-2024 William Mead <william.mead@manchenumerique.fr>
10 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
11 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 */
26
33require "../main.inc.php";
42require_once DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php";
43require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
44require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
45
46// Load translation files required by the page
47$langs->loadLangs(array('products', 'contracts', 'companies'));
48
49// Get parameters
50$massaction = GETPOST('massaction', 'alpha');
51$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
52$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
53$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
54$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')).$mode; // To manage different context of search
55
56// Load variable for pagination
57$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
58$sortfield = GETPOST('sortfield', 'aZ09comma');
59$sortorder = GETPOST('sortorder', 'aZ09comma');
60$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
61if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
62 // If $page is not defined, or '' or -1 or if we click on clear filters
63 $page = 0;
64}
65$offset = $limit * $page;
66$pageprev = $page - 1;
67$pagenext = $page + 1;
68if (!$sortfield) {
69 $sortfield = "c.rowid";
70}
71if (!$sortorder) {
72 $sortorder = "ASC";
73}
74
75$search_name = GETPOST("search_name", 'alpha');
76$search_subprice = GETPOST("search_subprice", 'alpha');
77$search_qty = GETPOST("search_qty", 'alpha');
78$search_total_ht = GETPOST("search_total_ht", 'alpha');
79$search_total_tva = GETPOST("search_total_tva", 'alpha');
80$search_total_ttc = GETPOST("search_total_ttc", 'alpha');
81$search_contract = GETPOST("search_contract", 'alpha');
82$search_service = GETPOST("search_service", 'alpha');
83$search_status = GETPOST("search_status", 'alpha');
84$search_option = GETPOST('search_option', 'alpha');
85$search_product_category = GETPOSTINT('search_product_category');
86
87// To support selection into combo list of status with detailed status '4&filter'
88$filter = '';
89if ($search_status == '4&filter=notexpired') {
90 $search_status = '4';
91 $filter = 'notexpired';
92}
93if ($search_status == '4&filter=expired') {
94 $search_status = '4';
95 $filter = 'expired';
96}
97
98$socid = GETPOSTINT('socid');
99
100$opouvertureprevuemonth = GETPOST('opouvertureprevuemonth');
101$opouvertureprevueday = GETPOST('opouvertureprevueday');
102$opouvertureprevueyear = GETPOST('opouvertureprevueyear');
103$filter_opouvertureprevue = GETPOST('filter_opouvertureprevue', 'alphawithlgt');
104
105$op1month = GETPOSTINT('op1month');
106$op1day = GETPOSTINT('op1day');
107$op1year = GETPOSTINT('op1year');
108$filter_op1 = GETPOST('filter_op1', 'alphawithlgt');
109
110$op2month = GETPOSTINT('op2month');
111$op2day = GETPOSTINT('op2day');
112$op2year = GETPOSTINT('op2year');
113$filter_op2 = GETPOST('filter_op2', 'alphawithlgt');
114
115$opcloturemonth = GETPOSTINT('opcloturemonth');
116$opclotureday = GETPOSTINT('opclotureday');
117$opclotureyear = GETPOSTINT('opclotureyear');
118$filter_opcloture = GETPOST('filter_opcloture', 'alphawithlgt');
119
120
121// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
123$hookmanager->initHooks(array('contractservicelist'));
124
125// fetch optionals attributes and labels
126$extrafields->fetch_name_optionals_label($object->table_element);
127
128$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
129
130// Security check
131$contratid = GETPOSTINT('id');
132if (!empty($user->socid)) {
133 $socid = $user->socid;
134}
135$result = restrictedArea($user, 'contrat', $contratid);
136
137$staticcontrat = new Contrat($db);
138$staticcontratligne = new ContratLigne($db);
139$companystatic = new Societe($db);
140
141$arrayfields = array(
142 'c.ref' => array('label' => "Contract", 'checked' => '1', 'position' => 80),
143 'p.description' => array('label' => "Service", 'checked' => '1', 'position' => 80),
144 's.nom' => array('label' => "ThirdParty", 'checked' => '1', 'position' => 90),
145 'cd.tva_tx' => array('label' => "VATRate", 'checked' => '-1', 'position' => 100),
146 'cd.subprice' => array('label' => "PriceUHT", 'checked' => '-1', 'position' => 105),
147 'cd.qty' => array('label' => "Qty", 'checked' => '1', 'position' => 108),
148 'cd.total_ht' => array('label' => "TotalHT", 'checked' => '-1', 'position' => 109, 'isameasure' => 1),
149 'cd.total_tva' => array('label' => "TotalVAT", 'checked' => '-1', 'position' => 110),
150 'cd.date_ouverture_prevue' => array('label' => "DateStartPlannedShort", 'checked' => '1', 'position' => 150),
151 'cd.date_ouverture' => array('label' => "DateStartRealShort", 'checked' => '1', 'position' => 160),
152 'cd.date_fin_validite' => array('label' => "DateEndPlannedShort", 'checked' => '1', 'position' => 170),
153 'cd.date_cloture' => array('label' => "DateEndRealShort", 'checked' => '1', 'position' => 180),
154 //'cd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
155 'cd.tms' => array('label' => "DateModificationShort", 'checked' => '0', 'position' => 500),
156 'status' => array('label' => "Status", 'checked' => '1', 'position' => 1000)
157);
158// Extra fields
159include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
160
161$object->fields = dol_sort_array($object->fields, 'position');
162$arrayfields = dol_sort_array($arrayfields, 'position');
163
164$permissiontoread = $user->hasRight('contrat', 'lire');
165$permissiontoadd = $user->hasRight('contrat', 'creer');
166$permissiontodelete = $user->hasRight('contrat', 'supprimer');
167
168$result = restrictedArea($user, 'contrat', 0);
169
170
171/*
172 * Actions
173 */
174
175if (GETPOST('cancel', 'alpha')) {
176 $action = 'list';
177 $massaction = '';
178}
179if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
180 $massaction = '';
181}
182
183$parameters = array('socid' => $socid);
184$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
185if ($reshook < 0) {
186 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
187}
188
189if (empty($reshook)) {
190 // Selection of new fields
191 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
192
193 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
194 $search_product_category = 0;
195 $search_name = "";
196 $search_subprice = "";
197 $search_qty = "";
198 $search_total_ht = "";
199 $search_total_tva = "";
200 $search_total_ttc = "";
201 $search_contract = "";
202 $search_service = "";
203 $search_status = "";
204 $search_option = '';
205 $opouvertureprevuemonth = "";
206 $opouvertureprevueday = "";
207 $opouvertureprevueyear = "";
208 $filter_opouvertureprevue = "";
209 $op1month = "";
210 $op1day = "";
211 $op1year = "";
212 $filter_op1 = "";
213 $op2month = "";
214 $op2day = "";
215 $op2year = "";
216 $filter_op2 = "";
217 $opcloturemonth = "";
218 $opclotureday = "";
219 $opclotureyear = "";
220 $filter_opcloture = "";
221 $filter = '';
222 $toselect = array();
223 $search_array_options = array();
224 }
225}
226
227
228/*
229 * View
230 */
231
232$form = new Form($db);
233
234$now = dol_now();
235
236$title = $langs->trans("ListOfServices");
237if ($search_status == "0") {
238 $title = $langs->trans("ListOfInactiveServices"); // Must use == "0"
239}
240if ($search_status == "4" && $filter != "expired") {
241 $title = $langs->trans("ListOfRunningServices");
242}
243if ($search_status == "4" && $filter == "expired") {
244 $title = $langs->trans("ListOfExpiredServices");
245}
246if ($search_status == "5") {
247 $title = $langs->trans("ListOfClosedServices");
248}
249$help_url = 'EN:Module_Contracts|FR:Module_Contrat|ES:Contratos_de_servicio';
250
251// Build and execute select
252// --------------------------------------------------------------------
253$sql = "SELECT c.rowid as cid, c.ref, c.statut as cstatut, c.ref_customer, c.ref_supplier,";
254$sql .= " s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur,";
255$sql .= " cd.rowid, cd.description, cd.statut, cd.product_type as type,";
256$sql .= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype, p.tobuy, p.tosell, p.barcode, p.entity as pentity,";
257if (!$user->hasRight('societe', 'client', 'voir')) {
258 $sql .= " sc.fk_soc, sc.fk_user,";
259}
260$sql .= " cd.date_ouverture_prevue,";
261$sql .= " cd.date_ouverture,";
262$sql .= " cd.date_fin_validite,";
263$sql .= " cd.date_cloture,";
264$sql .= " cd.qty,";
265$sql .= " cd.total_ht,";
266$sql .= " cd.total_tva,";
267$sql .= " cd.tva_tx,";
268$sql .= " cd.subprice,";
269//$sql.= " cd.date_c as date_creation,";
270$sql .= " cd.tms as date_modification";
271// Add fields from extrafields
272if (!empty($extrafields->attributes[$object->table_element]['label'])) {
273 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
274 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
275 }
276}
277// Add fields from hooks
278$parameters = array();
279$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
280$sql .= $hookmanager->resPrint;
281$sql .= " FROM ".MAIN_DB_PREFIX."contrat as c,";
282$sql .= " ".MAIN_DB_PREFIX."societe as s,";
283if (!$user->hasRight('societe', 'client', 'voir')) {
284 $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,";
285}
286$sql .= " ".MAIN_DB_PREFIX."contratdet as cd";
287if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
288 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cd.rowid = ef.fk_object)";
289}
290$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
291if ($search_product_category > 0) {
292 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product';
293}
294$sql .= " WHERE c.entity IN (".getEntity($object->element).")";
295$sql .= " AND c.rowid = cd.fk_contrat";
296if ($search_product_category > 0) {
297 $sql .= " AND cp.fk_categorie = ".((int) $search_product_category);
298}
299$sql .= " AND c.fk_soc = s.rowid";
300if (!$user->hasRight('societe', 'client', 'voir')) {
301 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
302}
303if ($search_status == "0") {
304 $sql .= " AND cd.statut = 0";
305}
306if ($search_status == "4") {
307 $sql .= " AND cd.statut = 4";
308}
309if ($search_status == "4&filter=expired" || ($search_status == '4' && $filter == 'expired')) {
310 $sql .= " AND cd.statut = 4 AND cd.date_fin_validite < '".$db->idate($now)."'";
311}
312if ($search_status == "4&filter=notexpired" || ($search_status == '4' && $filter == 'notexpired')) {
313 $sql .= " AND cd.statut = 4 AND cd.date_fin_validite >= '".$db->idate($now)."'";
314}
315if ($search_status == "5") {
316 $sql .= " AND cd.statut = 5";
317}
318if ($search_option == 'late' && $search_status != '0') {
319 $warning_date = $db->idate(dol_now() - $conf->contract->services->expires->warning_delay);
320 $sql .= " AND cd.date_fin_validite < '".addslashes($warning_date)."'";
321}
322if ($search_option == 'late' && $search_status == '0') {
323 $warning_date = $db->idate(dol_now() - $conf->contract->services->expires->warning_delay);
324 $sql .= " AND (cd.date_ouverture_prevue < '".addslashes($warning_date)."' OR cd.date_fin_validite < '".addslashes($warning_date)."')";
325}
326if ($search_subprice) {
327 $sql .= natural_search("cd.subprice", $search_subprice, 1);
328}
329if ($search_qty) {
330 $sql .= natural_search("cd.qty", $search_qty, 1);
331}
332if ($search_total_ht) {
333 $sql .= natural_search("cd.total_ht", $search_total_ht, 1);
334}
335if ($search_total_tva) {
336 $sql .= natural_search("cd.total_tva", $search_total_tva, 1);
337}
338if ($search_total_ttc) {
339 $sql .= natural_search("cd.total_ttc", $search_total_ttc, 1);
340}
341if ($search_name) {
342 $sql .= natural_search("s.nom", $search_name);
343}
344if ($search_contract) {
345 $sql .= natural_search("c.ref", $search_contract);
346}
347if ($search_service) {
348 $sql .= natural_search(array("p.ref", "p.description", "cd.description"), $search_service);
349}
350if ($socid > 0) {
351 $sql .= " AND s.rowid = ".((int) $socid);
352}
353
354$filter_dateouvertureprevue = '';
355$filter_date1 = '';
356$filter_date2 = '';
357$filter_opcloture = '';
358
359$filter_dateouvertureprevue_start = dol_mktime(0, 0, 0, (int) $opouvertureprevuemonth, (int) $opouvertureprevueday, (int) $opouvertureprevueyear);
360$filter_dateouvertureprevue_end = dol_mktime(23, 59, 59, (int) $opouvertureprevuemonth, (int) $opouvertureprevueday, (int) $opouvertureprevueyear);
361if ($filter_dateouvertureprevue_start != '' && $filter_opouvertureprevue == -1) {
362 $filter_opouvertureprevue = ' BETWEEN ';
363}
364
365$filter_date1_start = dol_mktime(0, 0, 0, (int) $op1month, (int) $op1day, (int) $op1year);
366$filter_date1_end = dol_mktime(23, 59, 59, (int) $op1month, (int) $op1day, (int) $op1year);
367if ($filter_date1_start != '' && $filter_op1 == -1) {
368 $filter_op1 = ' BETWEEN ';
369}
370
371$filter_date2_start = dol_mktime(0, 0, 0, (int) $op2month, (int) $op2day, (int) $op2year);
372$filter_date2_end = dol_mktime(23, 59, 59, (int) $op2month, (int) $op2day, (int) $op2year);
373if ($filter_date2_start != '' && $filter_op2 == -1) {
374 $filter_op2 = ' BETWEEN ';
375}
376
377$filter_datecloture_start = dol_mktime(0, 0, 0, (int) $opcloturemonth, (int) $opclotureday, (int) $opclotureyear);
378$filter_datecloture_end = dol_mktime(23, 59, 59, (int) $opcloturemonth, (int) $opclotureday, (int) $opclotureyear);
379if ($filter_datecloture_start != '' && $filter_opcloture == -1) {
380 $filter_opcloture = ' BETWEEN ';
381}
382
383if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_opouvertureprevue != ' BETWEEN ' && $filter_dateouvertureprevue_start != '') {
384 $sql .= " AND cd.date_ouverture_prevue ".preg_replace('/[^<>]/', '', $filter_opouvertureprevue)." '".$db->idate($filter_dateouvertureprevue_start)."'";
385}
386if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue == ' BETWEEN ') {
387 $sql .= " AND cd.date_ouverture_prevue ".$db->sanitize($filter_opouvertureprevue)." '".$db->idate($filter_dateouvertureprevue_start)."' AND '".$db->idate($filter_dateouvertureprevue_end)."'";
388}
389if (!empty($filter_op1) && $filter_op1 != -1 && $filter_op1 != ' BETWEEN ' && $filter_date1_start != '') {
390 $sql .= " AND cd.date_ouverture ".preg_replace('/[^<>]/', '', $filter_op1)." '".$db->idate($filter_date1_start)."'";
391}
392if (!empty($filter_op1) && $filter_op1 == ' BETWEEN ') {
393 $sql .= " AND cd.date_ouverture ".$db->sanitize($filter_op1)." '".$db->idate($filter_date1_start)."' AND '".$db->idate($filter_date1_end)."'";
394}
395if (!empty($filter_op2) && $filter_op2 != -1 && $filter_op2 != ' BETWEEN ' && $filter_date2_start != '') {
396 $sql .= " AND cd.date_fin_validite ".preg_replace('/[^<>]/', '', $filter_op2)." '".$db->idate($filter_date2_start)."'";
397}
398if (!empty($filter_op2) && $filter_op2 == ' BETWEEN ') {
399 $sql .= " AND cd.date_fin_validite ".$db->sanitize($filter_op2)." '".$db->idate($filter_date2_start)."' AND '".$db->idate($filter_date2_end)."'";
400}
401if (!empty($filter_opcloture) && $filter_opcloture != ' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start != '') {
402 $sql .= " AND cd.date_cloture ".preg_replace('/[^<>]/', '', $filter_opcloture)." '".$db->idate($filter_datecloture_start)."'";
403}
404if (!empty($filter_opcloture) && $filter_opcloture == ' BETWEEN ') {
405 $sql .= " AND cd.date_cloture ".$db->sanitize($filter_opcloture)." '".$db->idate($filter_datecloture_start)."' AND '".$db->idate($filter_datecloture_end)."'";
406}
407// Add where from extra fields
408include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
409
410// Add where from hooks
411$parameters = array();
412$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
413$sql .= $hookmanager->resPrint;
414
415// Count total nb of records
416$nbtotalofrecords = '';
417if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
418 $result = $db->query($sql);
419 $nbtotalofrecords = $db->num_rows($result);
420 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
421 $page = 0;
422 $offset = 0;
423 }
424}
425
426// Complete request and execute it with order and limit
427$sql .= $db->order($sortfield, $sortorder);
428if ($limit) {
429 $sql .= $db->plimit($limit + 1, $offset);
430}
431
432//print $sql;
433dol_syslog("contrat/services_list.php", LOG_DEBUG);
434$resql = $db->query($sql);
435if (!$resql) {
437 exit;
438}
439
440$num = $db->num_rows($resql);
441
442/*
443// Direct jump if only one record found
444if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
445 $obj = $db->fetch_object($resql);
446 $id = $obj->id;
447 header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$id.'&withprojet=1');
448 exit;
449}*/
450
451
452// Output page
453// --------------------------------------------------------------------
454
455llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-contrat page-list_services bodyforlist');
456
457$arrayofselected = is_array($toselect) ? $toselect : array();
458
459$param = '';
460if (!empty($mode)) {
461 $param .= '&mode='.urlencode($mode);
462}
463if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
464 $param .= '&contextpage='.urlencode($contextpage);
465}
466if ($limit > 0 && $limit != $conf->liste_limit) {
467 $param .= '&limit='.((int) $limit);
468}
469if ($optioncss != '') {
470 $param .= '&optioncss='.urlencode($optioncss);
471}
472if ($search_contract) {
473 $param .= '&amp;search_contract='.urlencode($search_contract);
474}
475if ($search_name) {
476 $param .= '&amp;search_name='.urlencode($search_name);
477}
478if ($search_subprice) {
479 $param .= '&amp;search_subprice='.urlencode($search_subprice);
480}
481if ($search_qty) {
482 $param .= '&amp;search_qty='.urlencode($search_qty);
483}
484if ($search_total_ht) {
485 $param .= '&amp;search_total_ht='.urlencode($search_total_ht);
486}
487if ($search_total_tva) {
488 $param .= '&amp;search_total_tva='.urlencode($search_total_tva);
489}
490if ($search_total_ttc) {
491 $param .= '&amp;search_total_ttc='.urlencode($search_total_ttc);
492}
493if ($search_service) {
494 $param .= '&amp;search_service='.urlencode($search_service);
495}
496if ($search_status != '') {
497 if ($filter == 'expired' || $filter == 'notexpired') {
498 $param .= '&amp;search_status='.urlencode($search_status.'&filter='.$filter);
499 } else {
500 $param .= '&amp;search_status='.urlencode($search_status);
501 }
502}
503if ($search_option) {
504 $param .= "&amp;search_option=".urlencode($search_option);
505}
506if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1) {
507 $param .= '&amp;filter_opouvertureprevue='.urlencode($filter_opouvertureprevue);
508}
509if (!empty($filter_op1) && $filter_op1 != -1) {
510 $param .= '&amp;filter_op1='.urlencode($filter_op1);
511}
512if (!empty($filter_op2) && $filter_op2 != -1) {
513 $param .= '&amp;filter_op2='.urlencode($filter_op2);
514}
515if (!empty($filter_opcloture) && $filter_opcloture != -1) {
516 $param .= '&amp;filter_opcloture='.urlencode($filter_opcloture);
517}
518if ($filter_dateouvertureprevue_start != '') {
519 $param .= '&amp;opouvertureprevueday='.((int) $opouvertureprevueday).'&amp;opouvertureprevuemonth='.((int) $opouvertureprevuemonth).'&amp;opouvertureprevueyear='.((int) $opouvertureprevueyear);
520}
521if ($filter_date1_start != '') {
522 $param .= '&amp;op1day='.((int) $op1day).'&amp;op1month='.((int) $op1month).'&amp;op1year='.((int) $op1year);
523}
524if ($filter_date2_start != '') {
525 $param .= '&amp;op2day='.((int) $op2day).'&amp;op2month='.((int) $op2month).'&amp;op2year='.((int) $op2year);
526}
527if ($filter_datecloture_start != '') {
528 $param .= '&amp;opclotureday='.((int) $op2day).'&amp;opcloturemonth='.((int) $op2month).'&amp;opclotureyear='.((int) $op2year);
529}
530// Add $param from extra fields
531include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
532// Add $param from hooks
533$parameters = array();
534$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
535$param .= $hookmanager->resPrint;
536
537// List of mass actions available
538$arrayofmassactions = array(
539 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
540 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
541);
542//if ($user->hasRight('contrat', 'supprimer')) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
543//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
544$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
545
546print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
547if ($optioncss != '') {
548 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
549}
550print '<input type="hidden" name="token" value="'.newToken().'">';
551print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
552print '<input type="hidden" name="action" value="list">';
553print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
554print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
555print '<input type="hidden" name="page" value="'.$page.'">';
556print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
557print '<input type="hidden" name="page_y" value="">';
558print '<input type="hidden" name="mode" value="'.$mode.'">';
559
560$newcardbutton = '';
561
562
563print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contract', 0, '', '', $limit);
564
565if (!empty($sall)) {
566 $fieldstosearchall = array();
567 foreach ($fieldstosearchall as $key => $val) { // @phan-suppress-current-line PhanEmptyForeach
568 $fieldstosearchall[$key] = $langs->trans($val);
569 }
570 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).implode(', ', $fieldstosearchall).'</div>';
571}
572
573$morefilter = '';
574$moreforfilter = '';
575
576// If the user can view categories of products
577if (isModEnabled('category') && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) {
578 include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
579 $moreforfilter .= '<div class="divsearchfield">';
580 $tmptitle = $langs->trans('IncludingProductWithTag');
581 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 0, 0, 1);
582 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, '', 'widthcentpercentminusx maxwidth300', 1);
583 $moreforfilter .= '</div>';
584}
585// alert on late date
586$moreforfilter .= '<div class="divsearchfield">';
587$moreforfilter .= '<label for="search_option">'.$langs->trans('Alert').'</label> <input type="checkbox" name="search_option" id="search_option" value="late"'.($search_option == 'late' ? ' checked' : '').'>';
588$moreforfilter .= '</div>';
589
590$parameters = array();
591$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
592if (empty($reshook)) {
593 $moreforfilter .= $hookmanager->resPrint;
594} else {
595 $moreforfilter = $hookmanager->resPrint;
596}
597
598
599if (!empty($moreforfilter)) {
600 print '<div class="liste_titre liste_titre_bydiv centpercent">';
601 print $moreforfilter;
602 print '</div>';
603}
604
605$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
606$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
607$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
608$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
609
610
611print '<div class="div-table-responsive">';
612print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
613
614// Fields title search
615// --------------------------------------------------------------------
616print '<tr class="liste_titre_filter">';
617// Action column
618if ($conf->main_checkbox_left_column) {
619 print '<td class="liste_titre center maxwidthsearch">';
620 $searchpicto = $form->showFilterButtons('left');
621 print $searchpicto;
622 print '</td>';
623}
624if (!empty($arrayfields['c.ref']['checked'])) {
625 print '<td class="liste_titre">';
626 print '<input type="hidden" name="mode" value="'.$mode.'">';
627 print '<input type="text" class="flat maxwidth75" name="search_contract" value="'.dol_escape_htmltag($search_contract).'">';
628 print '</td>';
629}
630// Service label
631if (!empty($arrayfields['p.description']['checked'])) {
632 print '<td class="liste_titre">';
633 print '<input type="text" class="flat maxwidth100" name="search_service" value="'.dol_escape_htmltag($search_service).'">';
634 print '</td>';
635}
636// detail lines
637if (!empty($arrayfields['cd.tva_tx']['checked'])) {
638 print '<td class="liste_titre">';
639 print '</td>';
640}
641if (!empty($arrayfields['cd.subprice']['checked'])) {
642 print '<td class="liste_titre right">';
643 print '<input type="text" class="flat maxwidth50 right" name="search_subprice" value="'.dol_escape_htmltag($search_subprice).'">';
644 print '</td>';
645}
646if (!empty($arrayfields['cd.qty']['checked'])) {
647 print '<td class="liste_titre right">';
648 print '<input type="text" class="flat maxwidth50 right" name="search_qty" value="'.dol_escape_htmltag($search_qty).'">';
649 print '</td>';
650}
651if (!empty($arrayfields['cd.total_ht']['checked'])) {
652 print '<td class="liste_titre right">';
653 print '<input type="text" class="flat maxwidth50" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).'">';
654 print '</td>';
655}
656if (!empty($arrayfields['cd.total_tva']['checked'])) {
657 print '<td class="liste_titre right">';
658 print '<input type="text" class="flat maxwidth50" name="search_total_tva" value="'.dol_escape_htmltag($search_total_tva).'">';
659 print '</td>';
660}
661// Third party
662if (!empty($arrayfields['s.nom']['checked'])) {
663 print '<td class="liste_titre">';
664 print '<input type="text" class="flat maxwidth100" name="search_name" value="'.dol_escape_htmltag($search_name).'">';
665 print '</td>';
666}
667
668if (!empty($arrayfields['cd.date_ouverture_prevue']['checked'])) {
669 print '<td class="liste_titre center">';
670 $arrayofoperators = array('<' => '<', '>' => '>');
671 print $form->selectarray('filter_opouvertureprevue', $arrayofoperators, $filter_opouvertureprevue, 1, 0, 0, '', 0, 0, 0, '', 'width50');
672 print ' ';
673 $filter_dateouvertureprevue = dol_mktime(0, 0, 0, (int) $opouvertureprevuemonth, (int) $opouvertureprevueday, (int) $opouvertureprevueyear);
674 print $form->selectDate($filter_dateouvertureprevue, 'opouvertureprevue', 0, 0, 1, '', 1, 0);
675 print '</td>';
676}
677if (!empty($arrayfields['cd.date_ouverture']['checked'])) {
678 print '<td class="liste_titre center">';
679 $arrayofoperators = array('<' => '<', '>' => '>');
680 print $form->selectarray('filter_op1', $arrayofoperators, $filter_op1, 1, 0, 0, '', 0, 0, 0, '', 'width50');
681 print ' ';
682 $filter_date1 = dol_mktime(0, 0, 0, (int) $op1month, (int) $op1day, (int) $op1year);
683 print $form->selectDate($filter_date1, 'op1', 0, 0, 1, '', 1, 0);
684 print '</td>';
685}
686if (!empty($arrayfields['cd.date_fin_validite']['checked'])) {
687 print '<td class="liste_titre center">';
688 $arrayofoperators = array('<' => '<', '>' => '>');
689 print $form->selectarray('filter_op2', $arrayofoperators, $filter_op2, 1, 0, 0, '', 0, 0, 0, '', 'width50');
690 print ' ';
691 $filter_date2 = dol_mktime(0, 0, 0, (int) $op2month, (int) $op2day, (int) $op2year);
692 print $form->selectDate($filter_date2, 'op2', 0, 0, 1, '', 1, 0);
693 print '</td>';
694}
695if (!empty($arrayfields['cd.date_cloture']['checked'])) {
696 print '<td class="liste_titre center">';
697 $arrayofoperators = array('<' => '<', '>' => '>');
698 print $form->selectarray('filter_opcloture', $arrayofoperators, $filter_opcloture, 1, 0, 0, '', 0, 0, 0, '', 'width50');
699 print ' ';
700 $filter_date_cloture = dol_mktime(0, 0, 0, (int) $opcloturemonth, (int) $opclotureday, (int) $opclotureyear);
701 print $form->selectDate($filter_date_cloture, 'opcloture', 0, 0, 1, '', 1, 0);
702 print '</td>';
703}
704// Extra fields
705include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
706
707// Fields from hook
708$parameters = array('arrayfields' => $arrayfields);
709$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
710print $hookmanager->resPrint;
711if (!empty($arrayfields['cd.datec']['checked'])) {
712 // Date creation
713 print '<td class="liste_titre">';
714 print '</td>';
715}
716if (!empty($arrayfields['cd.tms']['checked'])) {
717 // Date modification
718 print '<td class="liste_titre">';
719 print '</td>';
720}
721if (!empty($arrayfields['status']['checked'])) {
722 // Status
723 print '<td class="liste_titre right parentonrightofpage">';
724 $arrayofstatus = array(
725 '0' => $langs->trans("ServiceStatusInitial"),
726 '4' => $langs->trans("ServiceStatusRunning"),
727 '4&filter=notexpired' => $langs->trans("ServiceStatusNotLate"),
728 '4&filter=expired' => $langs->trans("ServiceStatusLate"),
729 '5' => $langs->trans("ServiceStatusClosed")
730 );
731 $search_status_new = GETPOST('search_status', 'alpha');
732 if ($filter == 'expired' && !preg_match('/expired/', $search_status_new)) {
733 $search_status_new .= '&filter=expired';
734 }
735 print $form->selectarray('search_status', $arrayofstatus, (strstr($search_status_new, ',') ? -1 : $search_status_new), 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage');
736 print '</td>';
737}
738// Action column
739if (!$conf->main_checkbox_left_column) {
740 print '<td class="liste_titre center maxwidthsearch">';
741 $searchpicto = $form->showFilterButtons();
742 print $searchpicto;
743 print '</td>';
744}
745print '</tr>'."\n";
746
747$totalarray = array();
748$totalarray['nbfield'] = 0;
749
750// Fields title label
751// --------------------------------------------------------------------
752print '<tr class="liste_titre">';
753// Action column
754if ($conf->main_checkbox_left_column) {
755 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
756 $totalarray['nbfield']++;
757}
758if (!empty($arrayfields['c.ref']['checked'])) {
759 // False positive @phan-suppress-next-line PhanTypeInvalidDimOffset
760 print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, "", $sortfield, $sortorder);
761}
762if (!empty($arrayfields['p.description']['checked'])) {
763 print_liste_field_titre($arrayfields['p.description']['label'], $_SERVER["PHP_SELF"], "p.description", "", $param, "", $sortfield, $sortorder);
764}
765if (!empty($arrayfields['cd.tva_tx']['checked'])) {
766 print_liste_field_titre($arrayfields['cd.tva_tx']['label'], $_SERVER["PHP_SELF"], "cd.tva_tx", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
767}
768if (!empty($arrayfields['cd.subprice']['checked'])) {
769 print_liste_field_titre($arrayfields['cd.subprice']['label'], $_SERVER["PHP_SELF"], "cd.subprice", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
770}
771if (!empty($arrayfields['cd.qty']['checked'])) {
772 print_liste_field_titre($arrayfields['cd.qty']['label'], $_SERVER["PHP_SELF"], "cd.qty", "", $param, '', $sortfield, $sortorder, 'right nowrap ');
773}
774if (!empty($arrayfields['cd.total_ht']['checked'])) {
775 print_liste_field_titre($arrayfields['cd.total_ht']['label'], $_SERVER["PHP_SELF"], "cd.total_ht", "", $param, '', $sortfield, $sortorder, 'right nowrap ');
776}
777if (!empty($arrayfields['cd.total_tva']['checked'])) {
778 print_liste_field_titre($arrayfields['cd.total_tva']['label'], $_SERVER["PHP_SELF"], "cd.total_tva", "", $param, '', $sortfield, $sortorder, 'right nowrap ');
779}
780if (!empty($arrayfields['s.nom']['checked'])) {
781 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
782}
783if (!empty($arrayfields['cd.date_ouverture_prevue']['checked'])) {
784 print_liste_field_titre($arrayfields['cd.date_ouverture_prevue']['label'], $_SERVER["PHP_SELF"], "cd.date_ouverture_prevue", "", $param, '', $sortfield, $sortorder, 'center ');
785}
786if (!empty($arrayfields['cd.date_ouverture']['checked'])) {
787 print_liste_field_titre($arrayfields['cd.date_ouverture']['label'], $_SERVER["PHP_SELF"], "cd.date_ouverture", "", $param, '', $sortfield, $sortorder, 'center ');
788}
789if (!empty($arrayfields['cd.date_fin_validite']['checked'])) {
790 print_liste_field_titre($arrayfields['cd.date_fin_validite']['label'], $_SERVER["PHP_SELF"], "cd.date_fin_validite", "", $param, '', $sortfield, $sortorder, 'center ');
791}
792if (!empty($arrayfields['cd.date_cloture']['checked'])) {
793 print_liste_field_titre($arrayfields['cd.date_cloture']['label'], $_SERVER["PHP_SELF"], "cd.date_cloture", "", $param, '', $sortfield, $sortorder, 'center ');
794}
795// Extra fields
796include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
797// Hook fields
798$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
799$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
800print $hookmanager->resPrint;
801if (!empty($arrayfields['cd.datec']['checked'])) {
802 print_liste_field_titre($arrayfields['cd.datec']['label'], $_SERVER["PHP_SELF"], "cd.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
803}
804if (!empty($arrayfields['cd.tms']['checked'])) {
805 print_liste_field_titre($arrayfields['cd.tms']['label'], $_SERVER["PHP_SELF"], "cd.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
806}
807if (!empty($arrayfields['status']['checked'])) {
808 print_liste_field_titre($arrayfields['status']['label'], $_SERVER["PHP_SELF"], "cd.statut,c.statut", "", $param, '', $sortfield, $sortorder, 'right ');
809}
810// Action column
811if (!$conf->main_checkbox_left_column) {
812 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
813 $totalarray['nbfield']++;
814}
815print '</tr>'."\n";
816
817
818// Loop on record
819// --------------------------------------------------------------------
820
821$contractstatic = new Contrat($db);
822$productstatic = new Product($db);
823
824$i = 0;
825$savnbfield = $totalarray['nbfield'];
826$totalarray = array('nbfield' => 0, 'val' => array('cd.qty' => 0, 'cd.total_ht' => 0, 'cd.total_tva' => 0));
827$imaxinloop = ($limit ? min($num, $limit) : $num);
828while ($i < $imaxinloop) {
829 $obj = $db->fetch_object($resql);
830 if (empty($obj)) {
831 break; // Should not happen
832 }
833
834 $contractstatic->id = $obj->cid;
835 $contractstatic->ref = $obj->ref ? $obj->ref : $obj->cid;
836 $contractstatic->ref_customer = $obj->ref_customer;
837 $contractstatic->ref_supplier = $obj->ref_supplier;
838
839 $companystatic->id = $obj->socid;
840 $companystatic->name = $obj->name;
841 $companystatic->email = $obj->email;
842 $companystatic->client = $obj->client;
843 $companystatic->fournisseur = $obj->fournisseur;
844
845 $productstatic->id = $obj->pid;
846 $productstatic->type = $obj->ptype;
847 $productstatic->ref = $obj->pref;
848 $productstatic->entity = $obj->pentity;
849 $productstatic->status = $obj->tosell;
850 $productstatic->status_buy = $obj->tobuy;
851 $productstatic->label = $obj->label;
852 $productstatic->description = $obj->description;
853 $productstatic->barcode = $obj->barcode;
854
855 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
856
857 // Action column
858 if ($conf->main_checkbox_left_column) {
859 print '<td class="nowrap center">';
860 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
861 $selected = 0;
862 if (in_array($obj->rowid, $arrayofselected)) {
863 $selected = 1;
864 }
865 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
866 }
867 print '</td>';
868 if (!$i) {
869 $totalarray['nbfield']++;
870 }
871 }
872 // Ref
873 if (!empty($arrayfields['c.ref']['checked'])) {
874 print '<td class="nowraponall">';
875 print $contractstatic->getNomUrl(1, 16);
876 print '</td>';
877 if (!$i) {
878 $totalarray['nbfield']++;
879 }
880 }
881 // Service
882 if (!empty($arrayfields['p.description']['checked'])) {
883 print '<td class="tdoverflowmax300">';
884 if ($obj->pid > 0) {
885 print $productstatic->getNomUrl(1, '', 24);
886 print $obj->label ? ' - '.dol_trunc($obj->label, 16) : '';
887 if (!empty($obj->description) && getDolGlobalString('PRODUCT_DESC_IN_LIST')) {
888 print '<br><div class="small lineheightsmall">'.dol_nl2br($obj->description).'</div>';
889 }
890 } else {
891 if ($obj->type == 0) {
892 print img_object($obj->description, 'product').' '.dol_trunc($obj->description, 24);
893 }
894 if ($obj->type == 1) {
895 print img_object($obj->description, 'service').' '.dol_trunc($obj->description, 24);
896 }
897 }
898 print '</td>';
899 if (!$i) {
900 $totalarray['nbfield']++;
901 }
902 }
903
904 if (!empty($arrayfields['cd.tva_tx']['checked'])) {
905 print '<td class="right nowraponall">';
906 print price2num($obj->tva_tx).'%';
907 print '</td>';
908 if (!$i) {
909 $totalarray['nbfield']++;
910 }
911 }
912 if (!empty($arrayfields['cd.subprice']['checked'])) {
913 print '<td class="right nowraponall">';
914 print price($obj->subprice);
915 print '</td>';
916 if (!$i) {
917 $totalarray['nbfield']++;
918 }
919 }
920 if (!empty($arrayfields['cd.qty']['checked'])) {
921 print '<td class="right nowraponall">';
922 print $obj->qty;
923 print '</td>';
924 if (!$i) {
925 $totalarray['nbfield']++;
926 }
927 if (!$i) {
928 $totalarray['pos'][$totalarray['nbfield']] = 'cd.qty';
929 }
930 $totalarray['val']['cd.qty'] += $obj->qty;
931 }
932 if (!empty($arrayfields['cd.total_ht']['checked'])) {
933 print '<td class="right nowraponall">';
934 print '<span class="amount">'.price($obj->total_ht).'</span>';
935 print '</td>';
936 if (!$i) {
937 $totalarray['nbfield']++;
938 }
939 if (!$i) {
940 $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_ht';
941 }
942 $totalarray['val']['cd.total_ht'] += $obj->total_ht;
943 }
944 if (!empty($arrayfields['cd.total_tva']['checked'])) {
945 print '<td class="right nowraponall">';
946 print '<span class="amount">'.price($obj->total_tva).'</span>';
947 print '</td>';
948 if (!$i) {
949 $totalarray['nbfield']++;
950 }
951 if (!$i) {
952 $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_tva';
953 }
954 $totalarray['val']['cd.total_tva'] += $obj->total_tva;
955 }
956
957 // Third party
958 if (!empty($arrayfields['s.nom']['checked'])) {
959 print '<td class="tdoverflowmax100">';
960 print $companystatic->getNomUrl(1, 'customer', 28);
961 print '</td>';
962 if (!$i) {
963 $totalarray['nbfield']++;
964 }
965 }
966
967 // Start date
968 if (!empty($arrayfields['cd.date_ouverture_prevue']['checked'])) {
969 print '<td class="center nowraponall">';
970 print($obj->date_ouverture_prevue ? dol_print_date($db->jdate($obj->date_ouverture_prevue), 'dayhour') : '&nbsp;');
971 if ($db->jdate($obj->date_ouverture_prevue) && ($db->jdate($obj->date_ouverture_prevue) < ($now - $conf->contrat->services->inactifs->warning_delay)) && $obj->statut == 0) {
972 print ' '.img_picto($langs->trans("Late"), "warning");
973 } else {
974 print '&nbsp;&nbsp;&nbsp;&nbsp;';
975 }
976 print '</td>';
977 if (!$i) {
978 $totalarray['nbfield']++;
979 }
980 }
981 if (!empty($arrayfields['cd.date_ouverture']['checked'])) {
982 print '<td class="center nowraponall">'.($obj->date_ouverture ? dol_print_date($db->jdate($obj->date_ouverture), 'dayhour') : '&nbsp;').'</td>';
983 if (!$i) {
984 $totalarray['nbfield']++;
985 }
986 }
987 // End date
988 if (!empty($arrayfields['cd.date_fin_validite']['checked'])) {
989 print '<td class="center nowraponall">'.($obj->date_fin_validite ? dol_print_date($db->jdate($obj->date_fin_validite), 'dayhour') : '&nbsp;');
990 if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) {
991 $warning_delay = $conf->contrat->services->expires->warning_delay / 3600 / 24;
992 $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days");
993 print img_warning($textlate);
994 } else {
995 print '&nbsp;&nbsp;&nbsp;&nbsp;';
996 }
997 print '</td>';
998 if (!$i) {
999 $totalarray['nbfield']++;
1000 }
1001 }
1002 // Close date (real end date)
1003 if (!empty($arrayfields['cd.date_cloture']['checked'])) {
1004 print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_cloture), 'dayhour').'</td>';
1005 if (!$i) {
1006 $totalarray['nbfield']++;
1007 }
1008 }
1009
1010 // Extra fields
1011 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1012 // Fields from hook
1013 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1014 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1015 print $hookmanager->resPrint;
1016 // Date creation
1017 if (!empty($arrayfields['cd.datec']['checked'])) {
1018 print '<td class="center">';
1019 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1020 print '</td>';
1021 if (!$i) {
1022 $totalarray['nbfield']++;
1023 }
1024 }
1025 // Date modification
1026 if (!empty($arrayfields['cd.tms']['checked'])) {
1027 print '<td class="center nowraponall">';
1028 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser');
1029 print '</td>';
1030 if (!$i) {
1031 $totalarray['nbfield']++;
1032 }
1033 }
1034 // Status
1035 if (!empty($arrayfields['status']['checked'])) {
1036 print '<td class="right">';
1037 if ($obj->cstatut == 0) {
1038 // If contract is draft, we say line is also draft
1039 //print $contractstatic->LibStatut(0, 5);
1040 print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0, '', ' - '.$langs->trans("Draft"));
1041 } else {
1042 print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0);
1043 }
1044 print '</td>';
1045 if (!$i) {
1046 $totalarray['nbfield']++;
1047 }
1048 }
1049 // Action column
1050 if (!$conf->main_checkbox_left_column) {
1051 print '<td class="nowrap center">';
1052 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1053 $selected = 0;
1054 if (in_array($obj->rowid, $arrayofselected)) {
1055 $selected = 1;
1056 }
1057 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1058 }
1059 print '</td>';
1060 if (!$i) {
1061 $totalarray['nbfield']++;
1062 }
1063 }
1064
1065 print '</tr>'."\n";
1066 $i++;
1067}
1068
1069// Show total line
1070include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1071
1072// If no record found
1073if ($num == 0) {
1074 $colspan = 1;
1075 foreach ($arrayfields as $key => $val) {
1076 if (!empty($val['checked'])) {
1077 $colspan++;
1078 }
1079 }
1080 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1081}
1082
1083$db->free($resql);
1084
1085$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1086$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1087print $hookmanager->resPrint;
1088
1089print '</table>'."\n";
1090print '</div>'."\n";
1091
1092print '</form>'."\n";
1093
1094
1095// End of page
1096llxFooter();
1097$db->close();
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
Class to manage lines of contracts.
Class to manage generation of HTML components Only common components must be here.
Class to manage products or services.
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)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
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...
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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.