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