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