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