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