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