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