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