dolibarr 21.0.0-beta
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-2020 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
6 * Copyright (C) 2014-2019 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
8 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
9 * Copyright (C) 2016-2018 Ferran Marcet <fmarcet@2byte.es>
10 * Copyright (C) 2019 Nicolas Zabouri <info@inovea-conseil.com>
11 * Copyright (C) 2021-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
12 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
13 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
14 * Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.fr>
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program. If not, see <https://www.gnu.org/licenses/>.
28 */
29
36// Load Dolibarr environment
37require '../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
44if (isModEnabled("category")) {
45 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
46}
47
56// Load translation files required by the page
57$langs->loadLangs(array('contracts', 'products', 'companies', 'compta'));
58
59$action = GETPOST('action', 'aZ09');
60$massaction = GETPOST('massaction', 'alpha');
61$show_files = GETPOSTINT('show_files');
62$confirm = GETPOST('confirm', 'alpha');
63$toselect = GETPOST('toselect', 'array');
64$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'contractlist'; // To manage different context of search
65$optioncss = GETPOST('optioncss', 'alpha');
66$mode = GETPOST('mode', 'alpha');
67
68$socid = GETPOSTINT('socid');
69
70$search_name = GETPOST('search_name', 'alpha');
71$search_email = GETPOST('search_email', 'alpha');
72$search_town = GETPOST('search_town', 'alpha');
73$search_zip = GETPOST('search_zip', 'alpha');
74$search_state = GETPOST("search_state", 'alpha');
75$search_country = GETPOST("search_country", 'aZ09');
76$search_type_thirdparty = GETPOST("search_type_thirdparty", 'intcomma');
77$search_contract = GETPOST('search_contract', 'alpha');
78$search_ref_customer = GETPOST('search_ref_customer', 'alpha');
79$search_ref_supplier = GETPOST('search_ref_supplier', 'alpha');
80$search_all = GETPOST('search_all', 'alphanohtml');
81$search_status = GETPOST('search_status', 'alpha');
82$search_signed_status = GETPOST('search_signed_status', 'alpha');
83$search_user = GETPOST('search_user', 'intcomma');
84$search_sale = GETPOST('search_sale', 'intcomma');
85$search_product_category = GETPOST('search_product_category', 'intcomma');
86$search_dfmonth = GETPOSTINT('search_dfmonth');
87$search_dfyear = GETPOSTINT('search_dfyear');
88$search_op2df = GETPOST('search_op2df', 'alpha');
89$search_date_startday = GETPOSTINT('search_date_startday');
90$search_date_startmonth = GETPOSTINT('search_date_startmonth');
91$search_date_startyear = GETPOSTINT('search_date_startyear');
92$search_date_endday = GETPOSTINT('search_date_endday');
93$search_date_endmonth = GETPOSTINT('search_date_endmonth');
94$search_date_endyear = GETPOSTINT('search_date_endyear');
95$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
96$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
97$searchCategoryCustomerOperator = 0;
98if (GETPOSTISSET('formfilteraction')) {
99 $searchCategoryCustomerOperator = GETPOSTINT('search_category_customer_operator');
100} elseif (getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT')) {
101 $searchCategoryCustomerOperator = getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT');
102}
103$searchCategoryCustomerList = GETPOST('search_category_customer_list', 'array');
104
105$search_date_creation_startmonth = GETPOSTINT('search_date_creation_startmonth');
106$search_date_creation_startyear = GETPOSTINT('search_date_creation_startyear');
107$search_date_creation_startday = GETPOSTINT('search_date_creation_startday');
108$search_date_creation_start = dol_mktime(0, 0, 0, $search_date_creation_startmonth, $search_date_creation_startday, $search_date_creation_startyear); // Use tzserver
109$search_date_creation_endmonth = GETPOSTINT('search_date_creation_endmonth');
110$search_date_creation_endyear = GETPOSTINT('search_date_creation_endyear');
111$search_date_creation_endday = GETPOSTINT('search_date_creation_endday');
112$search_date_creation_end = dol_mktime(23, 59, 59, $search_date_creation_endmonth, $search_date_creation_endday, $search_date_creation_endyear); // Use tzserver
113
114$search_date_modif_startmonth = GETPOSTINT('search_date_modif_startmonth');
115$search_date_modif_startyear = GETPOSTINT('search_date_modif_startyear');
116$search_date_modif_startday = GETPOSTINT('search_date_modif_startday');
117$search_date_modif_start = dol_mktime(0, 0, 0, $search_date_modif_startmonth, $search_date_modif_startday, $search_date_modif_startyear); // Use tzserver
118$search_date_modif_endmonth = GETPOSTINT('search_date_modif_endmonth');
119$search_date_modif_endyear = GETPOSTINT('search_date_modif_endyear');
120$search_date_modif_endday = GETPOSTINT('search_date_modif_endday');
121$search_date_modif_end = dol_mktime(23, 59, 59, $search_date_modif_endmonth, $search_date_modif_endday, $search_date_modif_endyear); // Use tzserver
122
123// Load variable for pagination
124$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
125$sortfield = GETPOST('sortfield', 'aZ09comma');
126$sortorder = GETPOST('sortorder', 'aZ09comma');
127$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
128if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
129 // If $page is not defined, or '' or -1 or if we click on clear filters
130 $page = 0;
131}
132$offset = $limit * $page;
133$pageprev = $page - 1;
134$pagenext = $page + 1;
135if (!$sortfield) {
136 $sortfield = 'c.ref';
137}
138if (!$sortorder) {
139 $sortorder = 'DESC';
140}
141
142// Security check
143$id = GETPOSTINT('id');
144if ($user->socid > 0) {
145 $socid = $user->socid;
146}
147
148$hookmanager->initHooks(array('contractlist'));
149
150$result = restrictedArea($user, 'contrat', $id);
151
152$diroutputmassaction = $conf->contrat->dir_output.'/temp/massgeneration/'.$user->id;
153
154$staticcontrat = new Contrat($db);
155$staticcontratligne = new ContratLigne($db);
156
157if ($search_status == '') {
158 $search_status = 1;
159}
160
161// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
162$object = new Contrat($db);
163$extrafields = new ExtraFields($db);
164
165// fetch optionals attributes and labels
166$extrafields->fetch_name_optionals_label($object->table_element);
167
168$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
169// List of fields to search into when doing a "search in all"
170$fieldstosearchall = array();
171foreach ($object->fields as $key => $val) {
172 if (!empty($val['searchall'])) {
173 $fieldstosearchall['c.'.$key] = $val['label'];
174 }
175}
176$fieldstosearchall["s.nom"] = "ThirdParty";
177if (empty($user->socid)) {
178 $fieldstosearchall["c.note_private"] = "NotePrivate";
179}
180$parameters = array('fieldstosearchall' => $fieldstosearchall);
181$reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
182if ($reshook > 0) {
183 $fieldstosearchall = $hookmanager->resArray['fieldstosearchall'];
184} elseif ($reshook == 0) {
185 if (!empty($hookmanager->resArray['fieldstosearchall'])) {
186 $fieldstosearchall = array_merge($fieldstosearchall, $hookmanager->resArray['fieldstosearchall']);
187 }
188}
189
190$arrayfields = array(
191 'c.ref' => array('label' => $langs->trans("Ref"), 'checked' => 1, 'position' => 10),
192 'c.ref_customer' => array('label' => $langs->trans("RefCustomer"), 'checked' => 1, 'position' => 12),
193 'c.ref_supplier' => array('label' => $langs->trans("RefSupplier"), 'checked' => 1, 'position' => 14),
194 's.nom' => array('label' => $langs->trans("ThirdParty"), 'checked' => 1, 'position' => 30),
195 's.email' => array('label' => $langs->trans("ThirdPartyEmail"), 'checked' => 0, 'position' => 30),
196 's.town' => array('label' => $langs->trans("Town"), 'checked' => 0, 'position' => 31),
197 's.zip' => array('label' => $langs->trans("Zip"), 'checked' => 1, 'position' => 32),
198 'state.nom' => array('label' => $langs->trans("StateShort"), 'checked' => 0, 'position' => 33),
199 'country.code_iso' => array('label' => $langs->trans("Country"), 'checked' => 0, 'position' => 34),
200 'sale_representative' => array('label' => $langs->trans("SaleRepresentativesOfThirdParty"), 'checked' => -1, 'position' => 80),
201 'c.date_contrat' => array('label' => $langs->trans("DateContract"), 'checked' => 1, 'position' => 45),
202 'c.datec' => array('label' => $langs->trans("DateCreation"), 'checked' => 0, 'position' => 500),
203 'c.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => 0, 'position' => 500),
204 'lower_planned_end_date' => array('label' => $langs->trans("LowerDateEndPlannedShort"), 'checked' => 1, 'position' => 900, 'help' => $langs->trans("LowerDateEndPlannedShort")),
205 'status' => array('label' => $langs->trans("Status"), 'checked' => 1, 'position' => 1000),
206 'c.signed_status' => array('label' => $langs->trans('SignedStatus'), 'checked' => 0, 'position' => 1001),
207);
208// Extra fields
209include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
210
211$object->fields = dol_sort_array($object->fields, 'position');
212$arrayfields = dol_sort_array($arrayfields, 'position');
213'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
214
215if (!$user->hasRight('societe', 'client', 'voir')) {
216 $search_sale = $user->id;
217}
218
219$permissiontoread = $user->hasRight('contrat', 'lire');
220$permissiontoadd = $user->hasRight('contrat', 'creer');
221$permissiontodelete = $user->hasRight('contrat', 'supprimer');
222
223$result = restrictedArea($user, 'contrat', 0);
224
225
226
227/*
228 * Actions
229 */
230
231if (GETPOST('cancel', 'alpha')) {
232 $action = 'list';
233 $massaction = '';
234}
235if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
236 $massaction = '';
237}
238
239$parameters = array('socid' => $socid, 'arrayfields' => &$arrayfields);
240$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
241if ($reshook < 0) {
242 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
243}
244
245include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
246// Purge search criteria
247if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
248 $search_dfmonth = '';
249 $search_dfyear = '';
250 $search_op2df = '';
251 $search_name = "";
252 $search_email = "";
253 $search_town = '';
254 $search_zip = "";
255 $search_state = "";
256 $search_type = '';
257 $search_country = '';
258 $search_contract = "";
259 $search_ref_customer = "";
260 $search_ref_supplier = "";
261 $search_user = '';
262 $search_sale = '';
263 $search_product_category = '';
264 $search_date_startday = '';
265 $search_date_startmonth = '';
266 $search_date_startyear = '';
267 $search_date_endday = '';
268 $search_date_endmonth = '';
269 $search_date_endyear = '';
270 $search_date_start = '';
271 $search_date_end = '';
272 $search_all = "";
273 $search_date_creation_startmonth = "";
274 $search_date_creation_startyear = "";
275 $search_date_creation_startday = "";
276 $search_date_creation_start = "";
277 $search_date_creation_endmonth = "";
278 $search_date_creation_endyear = "";
279 $search_date_creation_endday = "";
280 $search_date_creation_end = "";
281 $search_date_modif_startmonth = "";
282 $search_date_modif_startyear = "";
283 $search_date_modif_startday = "";
284 $search_date_modif_start = "";
285 $search_date_modif_endmonth = "";
286 $search_date_modif_endyear = "";
287 $search_date_modif_endday = "";
288 $search_date_modif_end = "";
289 $search_status = "";
290 $search_signed_status = '';
291 $toselect = array();
292 $search_type_thirdparty = '';
293 $searchCategoryCustomerList = array();
294 $search_array_options = array();
295}
296
297if (empty($reshook)) {
298 $objectclass = 'Contrat';
299 $objectlabel = 'Contracts';
300 $uploaddir = $conf->contrat->dir_output;
301 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
302}
303
304
305/*
306 * View
307 */
308
309$form = new Form($db);
310$formfile = new FormFile($db);
311$formother = new FormOther($db);
312$socstatic = new Societe($db);
313$formcompany = new FormCompany($db);
314$contracttmp = new Contrat($db);
315
316$now = dol_now();
317
318$title = "";
319
320$sql = 'SELECT';
321$sql .= " c.rowid, c.ref, c.datec as date_creation, c.tms as date_modification, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public, c.entity, c.signed_status,";
322$sql .= ' s.rowid as socid, s.nom as name, s.name_alias, s.email, s.town, s.zip, s.fk_pays as country_id, s.client, s.code_client, s.status as company_status, s.logo as company_logo,';
323$sql .= " typent.code as typent_code,";
324$sql .= " state.code_departement as state_code, state.nom as state_name,";
325// TODO Add a denormalized field "denormalized_lower_planned_end_date" so we can remove the HAVING and then,
326// remove completely the SUM and GROUP BY (faster). Status of each service can be read into the loop that build the list.
327$sql .= " MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") as lower_planned_end_date,"; // lowest expiration date among open service lines
328$sql .= " SUM(".$db->ifsql("cd.statut=0", 1, 0).') as nb_initial,';
329$sql .= " SUM(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now)."')", 1, 0).') as nb_running,';
330$sql .= " SUM(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')", 1, 0).') as nb_expired,';
331$sql .= " SUM(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now - $conf->contrat->services->expires->warning_delay)."')", 1, 0).') as nb_late,';
332$sql .= " SUM(".$db->ifsql("cd.statut=5", 1, 0).') as nb_closed';
333// Add fields from extrafields
334if (!empty($extrafields->attributes[$object->table_element]['label'])) {
335 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
336 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
337 }
338}
339// Add fields from hooks
340$parameters = array();
341$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
342$sql .= $hookmanager->resPrint;
343$sql = preg_replace('/,\s*$/', '', $sql);
344
345$sqlfields = $sql; // $sql fields to remove for count total
346
347$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
348$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
349$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
350$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
351$sql .= ", ".MAIN_DB_PREFIX."contrat as c";
352if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
353 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (c.rowid = ef.fk_object)";
354}
355$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat";
356if ($search_user > 0) {
357 $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
358 $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
359}
360$sql .= " WHERE c.fk_soc = s.rowid ";
361$sql .= ' AND c.entity IN ('.getEntity('contract').')';
362if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
363 $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
364}
365if ($socid > 0) {
366 $sql .= " AND s.rowid = ".((int) $socid);
367}
368if ($search_date_start) {
369 $sql .= " AND c.date_contrat >= '".$db->idate($search_date_start)."'";
370}
371if ($search_date_end) {
372 $sql .= " AND c.date_contrat <= '".$db->idate($search_date_end)."'";
373}
374if ($search_name) {
375 $sql .= natural_search('s.nom', $search_name);
376}
377if ($search_email) {
378 $sql .= natural_search('s.email', $search_email);
379}
380if ($search_contract) {
381 $sql .= natural_search(array('c.rowid', 'c.ref'), $search_contract);
382}
383if (!empty($search_ref_customer)) {
384 $sql .= natural_search(array('c.ref_customer'), $search_ref_customer);
385}
386if (!empty($search_ref_supplier)) {
387 $sql .= natural_search(array('c.ref_supplier'), $search_ref_supplier);
388}
389if ($search_zip) {
390 $sql .= natural_search(array('s.zip'), $search_zip);
391}
392if ($search_town) {
393 $sql .= natural_search(array('s.town'), $search_town);
394}
395if ($search_country && $search_country != '-1') {
396 $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
397}
398/*if ($search_sale > 0) {
399 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
400}*/
401if ($search_all) {
402 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
403}
404if ($search_user > 0) {
405 $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='contrat' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user);
406}
407// Search on sale representative
408if ($search_sale && $search_sale != '-1') {
409 if ($search_sale == -2) {
410 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc)";
411 } elseif ($search_sale > 0) {
412 $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
413 }
414}
415// Search for tag/category ($searchCategoryProductList is an array of ID)
416$searchCategoryProductOperator = -1;
417$searchCategoryProductList = array($search_product_category);
418if (!empty($searchCategoryProductList)) {
419 $searchCategoryProductSqlList = array();
420 $listofcategoryid = '';
421 foreach ($searchCategoryProductList as $searchCategoryProduct) {
422 if (intval($searchCategoryProduct) == -2) {
423 $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."contratdet as cd WHERE cd.fk_contrat = c.rowid AND cd.fk_product = ck.fk_product)";
424 } elseif (intval($searchCategoryProduct) > 0) {
425 if ($searchCategoryProductOperator == 0) {
426 $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."contratdet as cd WHERE cd.fk_contrat = c.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")";
427 } else {
428 $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
429 }
430 }
431 }
432 if ($listofcategoryid) {
433 $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."contratdet as cd WHERE cd.fk_contrat = c.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
434 }
435 if ($searchCategoryProductOperator == 1) {
436 if (!empty($searchCategoryProductSqlList)) {
437 $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
438 }
439 } else {
440 if (!empty($searchCategoryProductSqlList)) {
441 $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
442 }
443 }
444}
445$searchCategoryCustomerSqlList = array();
446if ($searchCategoryCustomerOperator == 1) {
447 $existsCategoryCustomerList = array();
448 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
449 if (intval($searchCategoryCustomer) == -2) {
450 $sqlCategoryCustomerNotExists = " NOT EXISTS (";
451 $sqlCategoryCustomerNotExists .= " SELECT cat_cus.fk_soc";
452 $sqlCategoryCustomerNotExists .= " FROM ".$db->prefix()."categorie_societe AS cat_cus";
453 $sqlCategoryCustomerNotExists .= " WHERE cat_cus.fk_soc = s.rowid";
454 $sqlCategoryCustomerNotExists .= " )";
455 $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists;
456 } elseif (intval($searchCategoryCustomer) > 0) {
457 $existsCategoryCustomerList[] = $db->escape($searchCategoryCustomer);
458 }
459 }
460 if (!empty($existsCategoryCustomerList)) {
461 $sqlCategoryCustomerExists = " EXISTS (";
462 $sqlCategoryCustomerExists .= " SELECT cat_cus.fk_soc";
463 $sqlCategoryCustomerExists .= " FROM ".$db->prefix()."categorie_societe AS cat_cus";
464 $sqlCategoryCustomerExists .= " WHERE cat_cus.fk_soc = s.rowid";
465 $sqlCategoryCustomerExists .= " AND cat_cus.fk_categorie IN (".$db->sanitize(implode(',', $existsCategoryCustomerList)).")";
466 $sqlCategoryCustomerExists .= " )";
467 $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerExists;
468 }
469 if (!empty($searchCategoryCustomerSqlList)) {
470 $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")";
471 }
472} else {
473 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
474 if (intval($searchCategoryCustomer) == -2) {
475 $sqlCategoryCustomerNotExists = " NOT EXISTS (";
476 $sqlCategoryCustomerNotExists .= " SELECT cat_cus.fk_soc";
477 $sqlCategoryCustomerNotExists .= " FROM ".$db->prefix()."categorie_societe AS cat_cus";
478 $sqlCategoryCustomerNotExists .= " WHERE cat_cus.fk_soc = s.rowid";
479 $sqlCategoryCustomerNotExists .= " )";
480 $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists;
481 } elseif (intval($searchCategoryCustomer) > 0) {
482 $searchCategoryCustomerSqlList[] = "s.rowid IN (SELECT fk_soc FROM ".$db->prefix()."categorie_societe WHERE fk_categorie = ".((int) $searchCategoryCustomer).")";
483 }
484 }
485 if (!empty($searchCategoryCustomerSqlList)) {
486 $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")";
487 }
488}
489
490if ($search_date_creation_start) {
491 $sql .= " AND c.datec >= '".$db->idate($search_date_creation_start)."'";
492}
493if ($search_date_creation_end) {
494 $sql .= " AND c.datec <= '".$db->idate($search_date_creation_end)."'";
495}
496
497if ($search_date_modif_start) {
498 $sql .= " AND c.tms >= '".$db->idate($search_date_modif_start)."'";
499}
500if ($search_date_modif_end) {
501 $sql .= " AND c.tms <= '".$db->idate($search_date_modif_end)."'";
502}
503if ($search_signed_status != '' && $search_signed_status >= 0) {
504 $sql .= ' AND c.signed_status = '.urlencode($search_signed_status);
505}
506
507// Add where from extra fields
508include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
509// Add where from hooks
510$parameters = array();
511$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
512$sql .= $hookmanager->resPrint;
513$sql .= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public, c.entity, c.signed_status,";
514$sql .= ' s.rowid, s.nom, s.name_alias, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.status, s.logo,';
515$sql .= " typent.code,";
516$sql .= " state.code_departement, state.nom";
517// Add fields from extrafields
518if (!empty($extrafields->attributes[$object->table_element]['label'])) {
519 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
520 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : '');
521 }
522}
523// Add where from hooks
524$parameters = array('search_dfyear' => $search_dfyear, 'search_op2df' => $search_op2df);
525$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
526$sql .= $hookmanager->resPrint;
527// Add HAVING from hooks
528$parameters = array('search_dfyear' => $search_dfyear, 'search_op2df' => $search_op2df);
529$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
530if (empty($reshook)) {
531 if ($search_dfyear > 0 && $search_op2df) {
532 if ($search_op2df == '<=') {
533 $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."'";
534 } elseif ($search_op2df == '>=') {
535 $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'";
536 } else {
537 $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."' AND MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'";
538 }
539 }
540}
541$sql .= $hookmanager->resPrint;
542
543// Count total nb of records
544$nbtotalofrecords = '';
545if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
546 //$result = $db->query($sql);
547 //$nbtotalofrecords = $db->num_rows($result);
548
549 if ($search_dfyear > 0 && $search_op2df) {
550 $resql = $db->query($sql, 0, 'auto', 1);
551 while ($db->fetch_object($resql)) {
552 if (empty($nbtotalofrecords)) {
553 $nbtotalofrecords = 1; // We can't make +1 because init value is ''
554 } else {
555 $nbtotalofrecords++;
556 }
557 }
558 } else {
559 /* The fast and low memory method to get and count full list converts the sql into a sql count */
560 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
561
562 $sqlforcount = str_replace('LEFT JOIN '.MAIN_DB_PREFIX.'c_country as country on (country.rowid = s.fk_pays)', '', $sqlforcount);
563 $sqlforcount = str_replace('LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as typent on (typent.id = s.fk_typent)', '', $sqlforcount);
564 $sqlforcount = str_replace('LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as state on (state.rowid = s.fk_departement)', '', $sqlforcount);
565 $sqlforcount = str_replace('LEFT JOIN '.MAIN_DB_PREFIX.'contratdet as cd ON c.rowid = cd.fk_contrat', '', $sqlforcount);
566 //$sqlforcount = str_replace('LEFT JOIN '.MAIN_DB_PREFIX.'contrat_extrafields as ef on (c.rowid = ef.fk_object)', '', $sqlforcount); // We my need this if there is filters on extrafields
567 $sqlforcount = preg_replace('/GROUP BY.*$/', '', $sqlforcount);
568
569 $resql = $db->query($sqlforcount);
570 if ($resql) {
571 $objforcount = $db->fetch_object($resql);
572 $nbtotalofrecords = $objforcount->nbtotalofrecords;
573 } else {
574 dol_print_error($db);
575 }
576 }
577
578 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
579 $page = 0;
580 $offset = 0;
581 }
582 $db->free($resql);
583}
584
585// Complete request and execute it with limit
586$sql .= $db->order($sortfield, $sortorder);
587if ($limit) {
588 $sql .= $db->plimit($limit + 1, $offset);
589}
590
591$resql = $db->query($sql);
592if (!$resql) {
593 dol_print_error($db);
594 exit;
595}
596
597$num = $db->num_rows($resql);
598
599// Direct jump if only one record found
600if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
601 $obj = $db->fetch_object($resql);
602 $id = $obj->rowid;
603 header("Location: ".DOL_URL_ROOT.'/contrat/card.php?id='.$id);
604 exit;
605}
606
607
608// Output page
609// --------------------------------------------------------------------
610$title = $langs->trans("Contracts");
611$help_url = 'EN:Module_Contracts|FR:Module_Contrat|ES:Contratos_de_servicio';
612
613llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-contrat page-list bodyforlist');
614
615$i = 0;
616
617$arrayofselected = is_array($toselect) ? $toselect : array();
618
619if ($socid > 0) {
620 $soc = new Societe($db);
621 $soc->fetch($socid);
622 if (empty($search_name)) {
623 $search_name = $soc->name;
624 }
625}
626
627$param = '';
628if (!empty($mode)) {
629 $param .= '&mode='.urlencode($mode);
630}
631if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
632 $param .= '&contextpage='.urlencode($contextpage);
633}
634if ($limit > 0 && $limit != $conf->liste_limit) {
635 $param .= '&limit='.((int) $limit);
636}
637if ($search_all != '') {
638 $param .= '&search_all='.urlencode($search_all);
639}
640if ($search_contract != '') {
641 $param .= '&search_contract='.urlencode($search_contract);
642}
643if ($search_name != '') {
644 $param .= '&search_name='.urlencode($search_name);
645}
646if ($search_email != '') {
647 $param .= '&search_email='.urlencode($search_email);
648}
649if ($search_ref_customer != '') {
650 $param .= '&search_ref_customer='.urlencode($search_ref_customer);
651}
652if ($search_ref_supplier != '') {
653 $param .= '&search_ref_supplier='.urlencode($search_ref_supplier);
654}
655if ($search_op2df != '') {
656 $param .= '&search_op2df='.urlencode($search_op2df);
657}
658if ($search_date_creation_startmonth) {
659 $param .= '&search_date_creation_startmonth='.urlencode((string) ($search_date_creation_startmonth));
660}
661if ($search_date_creation_startyear) {
662 $param .= '&search_date_creation_startyear='.urlencode((string) ($search_date_creation_startyear));
663}
664if ($search_date_creation_startday) {
665 $param .= '&search_date_creation_startday='.urlencode((string) ($search_date_creation_startday));
666}
667if ($search_date_creation_start) {
668 $param .= '&search_date_creation_start='.urlencode($search_date_creation_start);
669}
670if ($search_date_creation_endmonth) {
671 $param .= '&search_date_creation_endmonth='.urlencode((string) ($search_date_creation_endmonth));
672}
673if ($search_date_creation_endyear) {
674 $param .= '&search_date_creation_endyear='.urlencode((string) ($search_date_creation_endyear));
675}
676if ($search_date_creation_endday) {
677 $param .= '&search_date_creation_endday='.urlencode((string) ($search_date_creation_endday));
678}
679if ($search_date_creation_end) {
680 $param .= '&search_date_creation_end='.urlencode($search_date_creation_end);
681}
682if ($search_date_modif_startmonth) {
683 $param .= '&search_date_modif_startmonth='.urlencode((string) ($search_date_modif_startmonth));
684}
685if ($search_date_modif_startyear) {
686 $param .= '&search_date_modif_startyear='.urlencode((string) ($search_date_modif_startyear));
687}
688if ($search_date_modif_startday) {
689 $param .= '&search_date_modif_startday='.urlencode((string) ($search_date_modif_startday));
690}
691if ($search_date_modif_start) {
692 $param .= '&search_date_modif_start='.urlencode($search_date_modif_start);
693}
694if ($search_date_modif_endmonth) {
695 $param .= '&search_date_modif_endmonth='.urlencode((string) ($search_date_modif_endmonth));
696}
697if ($search_date_modif_endyear) {
698 $param .= '&search_date_modif_endyear='.urlencode((string) ($search_date_modif_endyear));
699}
700if ($search_date_modif_endday) {
701 $param .= '&search_date_modif_endday='.urlencode((string) ($search_date_modif_endday));
702}
703if ($search_date_modif_end) {
704 $param .= '&search_date_modif_end=' . urlencode($search_date_modif_end);
705}
706if ($search_date_startday > 0) {
707 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
708}
709if ($search_date_startmonth > 0) {
710 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
711}
712if ($search_date_startyear > 0) {
713 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
714}
715if ($search_date_endday > 0) {
716 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
717}
718if ($search_date_endmonth > 0) {
719 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
720}
721if ($search_date_endyear > 0) {
722 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
723}
724if ($search_dfyear > 0) {
725 $param .= '&search_dfyear='.urlencode((string) ($search_dfyear));
726}
727if ($search_dfmonth > 0) {
728 $param .= '&search_dfmonth='.urlencode((string) ($search_dfmonth));
729}
730if ($search_signed_status != '' && $search_signed_status >= 0) {
731 $param .= '&search_signed_status='.urlencode($search_signed_status);
732}
733if ($search_sale > 0) {
734 $param .= '&search_sale='.urlencode($search_sale);
735}
736if ($search_user > 0) {
737 $param .= '&search_user='.urlencode((string) ($search_user));
738}
739if ($search_type_thirdparty > 0) {
740 $param .= '&search_type_thirdparty='.urlencode((string) ($search_type_thirdparty));
741}
742if ($search_country != '') {
743 $param .= "&search_country=".urlencode($search_country);
744}
745if ($search_product_category > 0) {
746 $param .= '&search_product_category='.urlencode((string) ($search_product_category));
747}
748if ($show_files) {
749 $param .= '&show_files='.urlencode((string) ($show_files));
750}
751if ($optioncss != '') {
752 $param .= '&optioncss='.urlencode($optioncss);
753}
754foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
755 $param .= "&search_category_customer_list[]=".urlencode($searchCategoryCustomer);
756}
757// Add $param from extra fields
758include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
759
760// List of mass actions available
761$arrayofmassactions = array(
762 'generate_doc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
763 'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
764 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
765);
766if (!empty($permissiontodelete)) {
767 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
768}
769if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
770 $arrayofmassactions = array();
771}
772$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
773
774$url = DOL_URL_ROOT.'/contrat/card.php?action=create';
775if (!empty($socid)) {
776 $url .= '&socid='.((int) $socid);
777}
778$newcardbutton = '';
779$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition'));
780$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition'));
781$newcardbutton .= dolGetButtonTitleSeparator();
782$newcardbutton .= dolGetButtonTitle($langs->trans('NewContractSubscription'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('contrat', 'creer'));
783
784print '<form method="POST" id="searchFormList" action="'.$_SERVER['PHP_SELF'].'">'."\n";
785if ($optioncss != '') {
786 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
787}
788print '<input type="hidden" name="token" value="'.newToken().'">';
789print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
790print '<input type="hidden" name="action" value="list">';
791print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
792print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
793print '<input type="hidden" name="page" value="'.$page.'">';
794print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
795print '<input type="hidden" name="page_y" value="">';
796print '<input type="hidden" name="mode" value="'.$mode.'">';
797
798// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
799print_barre_liste($langs->trans("Contracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contract', 0, $newcardbutton, '', $limit, 0, 0, 1);
800
801$topicmail = "SendContractRef";
802$modelmail = "contract";
803$objecttmp = new Contrat($db);
804$trackid = 'con'.$object->id;
805include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
806
807if ($search_all) {
808 $setupstring = '';
809 foreach ($fieldstosearchall as $key => $val) {
810 $fieldstosearchall[$key] = $langs->trans($val);
811 $setupstring .= $key."=".$val.";";
812 }
813 print '<!-- Search done like if CONTRACT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
814 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'."\n";
815}
816
817$moreforfilter = '';
818
819// If the user can view prospects other than his'
820if ($user->hasRight('user', 'user', 'lire')) {
821 $langs->load("commercial");
822 $moreforfilter .= '<div class="divsearchfield">';
823 $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
824 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'widthcentpercentminusx maxwidth300');
825 $moreforfilter .= '</div>';
826}
827// If the user can view other users
828if ($user->hasRight('user', 'user', 'lire')) {
829 $moreforfilter .= '<div class="divsearchfield">';
830 $tmptitle = $langs->trans('LinkedToSpecificUsers');
831 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
832 $moreforfilter .= '</div>';
833}
834// If the user can view categories of products
835if (isModEnabled('category') && $user->hasRight('categorie', 'lire') && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) {
836 include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
837 $moreforfilter .= '<div class="divsearchfield">';
838 $tmptitle = $langs->trans('IncludingProductWithTag');
839 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 2);
840 $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);
841 $moreforfilter .= '</div>';
842}
843// Filter on customer categories
844if (getDolGlobalString('MAIN_SEARCH_CATEGORY_CUSTOMER_ON_CONTRACT_LIST') && isModEnabled("category") && $user->hasRight('categorie', 'lire')) {
845 $moreforfilter .= '<div class="divsearchfield">';
846 $tmptitle = $langs->transnoentities('CustomersProspectsCategoriesShort');
847 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
848 $categoriesArr = $form->select_all_categories(Categorie::TYPE_CUSTOMER, '', '', 64, 0, 2);
849 $categoriesArr[-2] = '- '.$langs->trans('NotCategorized').' -';
850 $moreforfilter .= Form::multiselectarray('search_category_customer_list', $categoriesArr, $searchCategoryCustomerList, 0, 0, 'minwidth300', 0, 0, '', 'category', $tmptitle);
851 $moreforfilter .= ' <input type="checkbox" class="valignmiddle" id="search_category_customer_operator" name="search_category_customer_operator" value="1"'.($searchCategoryCustomerOperator == 1 ? ' checked="checked"' : '').'/>';
852 $moreforfilter .= $form->textwithpicto('', $langs->trans('UseOrOperatorForCategories') . ' : ' . $tmptitle, 1, 'help', '', 0, 2, 'tooltip_cat_cus'); // Tooltip on click
853 $moreforfilter .= '</div>';
854}
855
856$parameters = array();
857$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
858if (empty($reshook)) {
859 $moreforfilter .= $hookmanager->resPrint;
860} else {
861 $moreforfilter = $hookmanager->resPrint;
862}
863
864if (!empty($moreforfilter)) {
865 print '<div class="liste_titre liste_titre_bydiv centpercent">';
866 print $moreforfilter;
867 print '</div>';
868}
869
870$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
871$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
872if ($massactionbutton) {
873 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
874}
875
876print '<div class="div-table-responsive">';
877print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
878
879// Fields title search
880// --------------------------------------------------------------------
881print '<tr class="liste_titre_filter">';
882// Action column
883if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
884 print '<td class="liste_titre maxwidthsearch center">';
885 $searchpicto = $form->showFilterButtons('left');
886 print $searchpicto;
887 print '</td>';
888}
889if (!empty($arrayfields['c.ref']['checked'])) {
890 print '<td class="liste_titre">';
891 print '<input type="text" class="flat" size="3" name="search_contract" value="'.dol_escape_htmltag($search_contract).'">';
892 print '</td>';
893}
894if (!empty($arrayfields['c.ref_customer']['checked'])) {
895 print '<td class="liste_titre">';
896 print '<input type="text" class="flat" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).'">';
897 print '</td>';
898}
899if (!empty($arrayfields['c.ref_supplier']['checked'])) {
900 print '<td class="liste_titre">';
901 print '<input type="text" class="flat" size="6" name="search_ref_supplier" value="'.dol_escape_htmltag($search_ref_supplier).'">';
902 print '</td>';
903}
904if (!empty($arrayfields['s.nom']['checked'])) {
905 print '<td class="liste_titre">';
906 print '<input type="text" class="flat" size="8" name="search_name" value="'.dol_escape_htmltag($search_name).'">';
907 print '</td>';
908}
909if (!empty($arrayfields['s.email']['checked'])) {
910 print '<td class="liste_titre">';
911 print '<input type="text" class="flat" size="6" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
912 print '</td>';
913}
914// Town
915if (!empty($arrayfields['s.town']['checked'])) {
916 print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
917}
918// Zip
919if (!empty($arrayfields['s.zip']['checked'])) {
920 print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>';
921}
922// State
923if (!empty($arrayfields['state.nom']['checked'])) {
924 print '<td class="liste_titre">';
925 print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
926 print '</td>';
927}
928// Country
929if (!empty($arrayfields['country.code_iso']['checked'])) {
930 print '<td class="liste_titre center">';
931 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
932 print '</td>';
933}
934// Company type
935if (!empty($arrayfields['typent.code']['checked'])) {
936 print '<td class="liste_titre maxwidthonsmartphone center">';
937 print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (!getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
938 print '</td>';
939}
940if (!empty($arrayfields['sale_representative']['checked'])) {
941 print '<td class="liste_titre"></td>';
942}
943if (!empty($arrayfields['c.date_contrat']['checked'])) {
944 print '<td class="liste_titre center">';
945 print '<div class="nowrapfordate">';
946 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
947 print '</div>';
948 print '<div class="nowrapfordate">';
949 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
950 print '</div>';
951 print '</td>';
952}
953// Signed status
954if (!empty($arrayfields['c.signed_status']['checked'])) {
955 print '<td class="liste_titre center">';
956 $list_signed_status = $object->getSignedStatusLocalisedArray();
957 print $form->selectarray('search_signed_status', $list_signed_status, $search_signed_status, 1, 0, 0, '', 1, 0, 0, '', 'search_status');
958 print '</td>';
959}
960// Extra fields
961include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
962
963// Fields from hook
964$parameters = array('arrayfields' => $arrayfields);
965$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
966print $hookmanager->resPrint;
967// Creation date
968if (!empty($arrayfields['c.datec']['checked'])) {
969 print '<td class="liste_titre center nowraponall">';
970 print '<div class="nowrapfordate">';
971 print $form->selectDate($search_date_creation_start ? $search_date_creation_start : -1, 'search_date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
972 print '</div>';
973 print '<div class="nowrapfordate">';
974 print $form->selectDate($search_date_creation_end ? $search_date_creation_end : -1, 'search_date_creation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
975 print '</div>';
976 print '</td>';
977}
978// Modification date
979if (!empty($arrayfields['c.tms']['checked'])) {
980 print '<td class="liste_titre center nowraponall">';
981 print '<div class="nowrapfordate">';
982 print $form->selectDate($search_date_modif_start ? $search_date_modif_start : -1, 'search_date_modif_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
983 print '</div>';
984 print '<div class="nowrapfordate">';
985 print $form->selectDate($search_date_modif_end ? $search_date_modif_end : -1, 'search_date_modif_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
986 print '</div>';
987 print '</td>';
988}
989// First end date
990if (!empty($arrayfields['lower_planned_end_date']['checked'])) {
991 print '<td class="liste_titre nowraponall center">';
992 $arrayofoperators = array('0' => '', '=' => '=', '<=' => '<=', '>=' => '>=');
993 print $form->selectarray('search_op2df', $arrayofoperators, $search_op2df, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth50imp');
994 print '</br>';
995 print $formother->select_month($search_dfmonth, 'search_dfmonth', 1, 0);
996 print ' ';
997 print $formother->selectyear($search_dfyear, 'search_dfyear', 1, 20, 5, 0, 0, '');
998 print '</td>';
999}
1000// Status
1001if (!empty($arrayfields['status']['checked'])) {
1002 print '<td class="liste_titre right" colspan="4"></td>';
1003}
1004
1005// Action column
1006if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1007 print '<td class="liste_titre center">';
1008 $searchpicto = $form->showFilterButtons();
1009 print $searchpicto;
1010 print '</td>';
1011}
1012print '</tr>'."\n";
1013
1014$totalarray = array();
1015$totalarray['nbfield'] = 0;
1016
1017// Fields title label
1018// --------------------------------------------------------------------
1019print '<tr class="liste_titre">';
1020if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1021 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1022 $totalarray['nbfield']++; // For the column action
1023}
1024if (!empty($arrayfields['c.ref']['checked'])) {
1025 // False positive @phan-suppress-next-line PhanTypeInvalidDimOffset
1026 print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder);
1027 $totalarray['nbfield']++; // For the column action
1028}
1029if (!empty($arrayfields['c.ref_customer']['checked'])) {
1030 print_liste_field_titre($arrayfields['c.ref_customer']['label'], $_SERVER["PHP_SELF"], "c.ref_customer", "", $param, '', $sortfield, $sortorder);
1031 $totalarray['nbfield']++; // For the column action
1032}
1033if (!empty($arrayfields['c.ref_supplier']['checked'])) {
1034 print_liste_field_titre($arrayfields['c.ref_supplier']['label'], $_SERVER["PHP_SELF"], "c.ref_supplier", "", $param, '', $sortfield, $sortorder);
1035 $totalarray['nbfield']++; // For the column action
1036}
1037if (!empty($arrayfields['s.nom']['checked'])) {
1038 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
1039 $totalarray['nbfield']++; // For the column action
1040}
1041if (!empty($arrayfields['s.email']['checked'])) {
1042 print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email", "", $param, '', $sortfield, $sortorder);
1043 $totalarray['nbfield']++; // For the column action
1044}
1045if (!empty($arrayfields['s.town']['checked'])) {
1046 print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
1047 $totalarray['nbfield']++; // For the column action
1048}
1049if (!empty($arrayfields['s.zip']['checked'])) {
1050 print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
1051 $totalarray['nbfield']++; // For the column action
1052}
1053if (!empty($arrayfields['state.nom']['checked'])) {
1054 print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1055 $totalarray['nbfield']++; // For the column action
1056}
1057if (!empty($arrayfields['country.code_iso']['checked'])) {
1058 print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1059 $totalarray['nbfield']++; // For the column action
1060}
1061if (!empty($arrayfields['typent.code']['checked'])) {
1062 print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
1063 $totalarray['nbfield']++; // For the column action
1064}
1065if (!empty($arrayfields['sale_representative']['checked'])) {
1066 print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder);
1067 $totalarray['nbfield']++; // For the column action
1068}
1069if (!empty($arrayfields['c.date_contrat']['checked'])) {
1070 print_liste_field_titre($arrayfields['c.date_contrat']['label'], $_SERVER["PHP_SELF"], "c.date_contrat", "", $param, '', $sortfield, $sortorder, 'center ');
1071 $totalarray['nbfield']++; // For the column action
1072}
1073if (!empty($arrayfields['c.signed_status']['checked'])) {
1074 print_liste_field_titre($arrayfields['c.signed_status']['label'], $_SERVER["PHP_SELF"], "c.signed_status", "", $param, '', $sortfield, $sortorder, 'center ');
1075 $totalarray['nbfield']++;
1076}
1077// Extra fields
1078include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1079// Hook fields
1080$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
1081$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1082print $hookmanager->resPrint;
1083if (!empty($arrayfields['c.datec']['checked'])) {
1084 print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1085 $totalarray['nbfield']++; // For the column action
1086}
1087if (!empty($arrayfields['c.tms']['checked'])) {
1088 print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1089 $totalarray['nbfield']++; // For the column action
1090}
1091if (!empty($arrayfields['lower_planned_end_date']['checked'])) {
1092 print_liste_field_titre($arrayfields['lower_planned_end_date']['label'], $_SERVER["PHP_SELF"], "lower_planned_end_date", "", $param, '', $sortfield, $sortorder, 'center ');
1093 $totalarray['nbfield']++; // For the column action
1094}
1095if (!empty($arrayfields['status']['checked'])) {
1096 print_liste_field_titre($staticcontratligne->LibStatut(0, 3, -1, 'class="nochangebackground"'), '', '', '', '', 'width="16"');
1097 $totalarray['nbfield']++; // For the column action
1098 print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 0, 'class="nochangebackground"'), '', '', '', '', 'width="16"');
1099 $totalarray['nbfield']++; // For the column action
1100 print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 1, 'class="nochangebackground"'), '', '', '', '', 'width="16"');
1101 $totalarray['nbfield']++; // For the column action
1102 print_liste_field_titre($staticcontratligne->LibStatut(5, 3, -1, 'class="nochangebackground"'), '', '', '', '', 'width="16"');
1103 $totalarray['nbfield']++; // For the column action
1104}
1105if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1106 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1107 $totalarray['nbfield']++; // For the column action
1108}
1109print "</tr>\n";
1110
1111// Loop on record
1112// --------------------------------------------------------------------
1113$i = 0;
1114$savnbfield = $totalarray['nbfield'];
1115$totalarray = array();
1116$totalarray['nbfield'] = 0;
1117$typenArray = array();
1118$cacheCountryIDCode = array();
1119$imaxinloop = ($limit ? min($num, $limit) : $num);
1120while ($i < $imaxinloop) {
1121 $obj = $db->fetch_object($resql);
1122 if (empty($obj)) {
1123 break; // Should not happen
1124 }
1125
1126 $contracttmp->ref = $obj->ref;
1127 $contracttmp->id = $obj->rowid;
1128 $contracttmp->ref_customer = $obj->ref_customer;
1129 $contracttmp->ref_supplier = $obj->ref_supplier;
1130
1131 $contracttmp->nbofserviceswait = $obj->nb_initial;
1132 $contracttmp->nbofservicesopened = $obj->nb_running;
1133 $contracttmp->nbofservicesexpired = $obj->nb_expired;
1134 $contracttmp->nbofservicesclosed = $obj->nb_closed;
1135 $contracttmp->signed_status = $obj->signed_status;
1136
1137 $socstatic->id = $obj->socid;
1138 $socstatic->name = $obj->name;
1139 $socstatic->name_alias = $obj->name_alias;
1140 $socstatic->email = $obj->email;
1141 $socstatic->status = $obj->company_status;
1142 $socstatic->logo = $obj->company_logo;
1143 $socstatic->country_id = $obj->country_id;
1144 $socstatic->country_code = '';
1145 $socstatic->country = '';
1146
1147 if ($obj->country_id > 0) {
1148 if (!isset($cacheCountryIDCode[$obj->country_id]['code'])) {
1149 $tmparray = getCountry($obj->country_id, 'all');
1150 $cacheCountryIDCode[$obj->country_id] = array('code' => empty($tmparray['code']) ? '' : $tmparray['code'], 'label' => empty($tmparray['label']) ? '' : $tmparray['label']);
1151 }
1152 $socstatic->country_code = $cacheCountryIDCode[$obj->country_id]['code'];
1153 $socstatic->country = $cacheCountryIDCode[$obj->country_id]['label'];
1154 }
1155
1156 if ($mode == 'kanban') {
1157 if ($i == 0) {
1158 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1159 print '<div class="box-flex-container kanban">';
1160 }
1161 // Output Kanban
1162 $arraydata = array();
1163 $arraydata['thirdparty'] = $socstatic;
1164 $arraydata['selected'] = in_array($obj->rowid, $arrayofselected);
1165 $contracttmp->date_contrat = $obj->date_contrat;
1166 print $contracttmp->getKanbanView('', $arraydata);
1167 if ($i == ($imaxinloop - 1)) {
1168 print '</div>';
1169 print '</td></tr>';
1170 }
1171 } else {
1172 // Show here line of result
1173 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
1174 // Action column
1175 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1176 print '<td class="nowrap center">';
1177 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1178 $selected = 0;
1179 if (in_array($obj->rowid, $arrayofselected)) {
1180 $selected = 1;
1181 }
1182 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1183 }
1184 print '</td>';
1185 if (!$i) {
1186 $totalarray['nbfield']++;
1187 }
1188 }
1189 // Ref
1190 if (!empty($arrayfields['c.ref']['checked'])) {
1191 print '<td class="nowraponall">';
1192 print $contracttmp->getNomUrl(1);
1193 if ($obj->nb_late) {
1194 print img_warning($langs->trans("Late"));
1195 }
1196 if (!empty($obj->note_private) || !empty($obj->note_public)) {
1197 print ' <span class="note">';
1198 print '<a href="'.DOL_URL_ROOT.'/contrat/note.php?id='.$obj->rowid.'&save_lastsearch_values=1">'.img_picto($langs->trans("ViewPrivateNote"), 'note').'</a>';
1199 print '</span>';
1200 }
1201
1202 $filename = dol_sanitizeFileName($obj->ref);
1203 $filedir = $conf->contrat->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
1204 $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
1205 print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir);
1206 print '</td>';
1207
1208 print '</td>';
1209 if (!$i) {
1210 $totalarray['nbfield']++;
1211 }
1212 }
1213
1214 // Ref thirdparty
1215 if (!empty($arrayfields['c.ref_customer']['checked'])) {
1216 print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag(dol_string_nohtmltag($contracttmp->getFormatedCustomerRef($obj->ref_customer))).'">'.$contracttmp->getFormatedCustomerRef($obj->ref_customer).'</td>';
1217 if (!$i) {
1218 $totalarray['nbfield']++;
1219 }
1220 }
1221 if (!empty($arrayfields['c.ref_supplier']['checked'])) {
1222 print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->ref_supplier).'">'.dol_escape_htmltag($obj->ref_supplier).'</td>';
1223 }
1224 if (!empty($arrayfields['s.nom']['checked'])) {
1225 print '<td class="tdoverflowmax150">';
1226 if ($obj->socid > 0) {
1227 // TODO Use a cache for this string
1228 print $socstatic->getNomUrl(1, '');
1229 }
1230 print '</td>';
1231 }
1232 // Email
1233 if (!empty($arrayfields['s.email']['checked'])) {
1234 print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->email).'">'.dol_print_email($obj->email, 0, $obj->socid, 1, 0, 1, 1).'</td>';
1235 }
1236 // Town
1237 if (!empty($arrayfields['s.town']['checked'])) {
1238 print '<td class="nocellnopadd">';
1239 print $obj->town;
1240 print '</td>';
1241 if (!$i) {
1242 $totalarray['nbfield']++;
1243 }
1244 }
1245 // Zip
1246 if (!empty($arrayfields['s.zip']['checked'])) {
1247 print '<td class="center nocellnopadd">';
1248 print $obj->zip;
1249 print '</td>';
1250 if (!$i) {
1251 $totalarray['nbfield']++;
1252 }
1253 }
1254 // State
1255 if (!empty($arrayfields['state.nom']['checked'])) {
1256 print "<td>".$obj->state_name."</td>\n";
1257 if (!$i) {
1258 $totalarray['nbfield']++;
1259 }
1260 }
1261 // Country
1262 if (!empty($arrayfields['country.code_iso']['checked'])) {
1263 print '<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($socstatic->country).'">';
1264 print dol_escape_htmltag($socstatic->country);
1265 print '</td>';
1266 if (!$i) {
1267 $totalarray['nbfield']++;
1268 }
1269 }
1270 // Type ent
1271 if (!empty($arrayfields['typent.code']['checked'])) {
1272 print '<td class="center">';
1273 if (count($typenArray) == 0) {
1274 $typenArray = $formcompany->typent_array(1);
1275 }
1276 print $typenArray[$obj->typent_code];
1277 print '</td>';
1278 if (!$i) {
1279 $totalarray['nbfield']++;
1280 }
1281 }
1282 if (!empty($arrayfields['sale_representative']['checked'])) {
1283 // Sales representatives
1284 print '<td>';
1285 if ($obj->socid > 0) {
1286 $listsalesrepresentatives = $socstatic->getSalesRepresentatives($user);
1287 if ($listsalesrepresentatives < 0) {
1288 dol_print_error($db);
1289 }
1290 $nbofsalesrepresentative = count($listsalesrepresentatives);
1291 if ($nbofsalesrepresentative > 6) {
1292 // We print only number
1293 print $nbofsalesrepresentative;
1294 } elseif ($nbofsalesrepresentative > 0) {
1295 $userstatic = new User($db);
1296 $j = 0;
1297 foreach ($listsalesrepresentatives as $val) {
1298 $userstatic->id = $val['id'];
1299 $userstatic->lastname = $val['lastname'];
1300 $userstatic->firstname = $val['firstname'];
1301 $userstatic->email = $val['email'];
1302 $userstatic->status = $val['statut'];
1303 $userstatic->entity = $val['entity'];
1304 $userstatic->photo = $val['photo'];
1305 $userstatic->login = $val['login'];
1306 $userstatic->phone = $val['phone'];
1307 $userstatic->job = $val['job'];
1308 $userstatic->gender = $val['gender'];
1309
1310 //print '<div class="float">':
1311 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
1312 $j++;
1313 if ($j < $nbofsalesrepresentative) {
1314 print ' ';
1315 }
1316 //print '</div>';
1317 }
1318 }
1319 //else print $langs->trans("NoSalesRepresentativeAffected");
1320 } else {
1321 print '&nbsp;';
1322 }
1323 print '</td>';
1324 }
1325 // Date
1326 if (!empty($arrayfields['c.date_contrat']['checked'])) {
1327 print '<td class="center">'.dol_print_date($db->jdate($obj->date_contrat), 'day', 'tzserver').'</td>';
1328 }
1329 // Signed Status
1330 if (!empty($arrayfields['c.signed_status']['checked'])) {
1331 print '<td class="center">'.$contracttmp->getLibSignedStatus(5).'</td>';
1332 if (!$i) {
1333 $totalarray['nbfield']++;
1334 }
1335 }
1336 // Extra fields
1337 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1338 // Fields from hook
1339 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1340 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1341 print $hookmanager->resPrint;
1342 // Date creation
1343 if (!empty($arrayfields['c.datec']['checked'])) {
1344 print '<td class="center nowrap">';
1345 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1346 print '</td>';
1347 if (!$i) {
1348 $totalarray['nbfield']++;
1349 }
1350 }
1351 // Date modification
1352 if (!empty($arrayfields['c.tms']['checked'])) {
1353 print '<td class="center nowrap">';
1354 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser');
1355 print '</td>';
1356 if (!$i) {
1357 $totalarray['nbfield']++;
1358 }
1359 }
1360 // Date lower end date
1361 if (!empty($arrayfields['lower_planned_end_date']['checked'])) {
1362 print '<td class="center nowrapforall">';
1363 print dol_print_date($db->jdate($obj->lower_planned_end_date), 'day', 'tzuser');
1364 print '</td>';
1365 if (!$i) {
1366 $totalarray['nbfield']++;
1367 }
1368 }
1369 // Status
1370 if (!empty($arrayfields['status']['checked'])) {
1371 print '<td class="center">'.($obj->nb_initial > 0 ? $obj->nb_initial : '').'</td>';
1372 print '<td class="center">'.($obj->nb_running > 0 ? $obj->nb_running : '').'</td>';
1373 print '<td class="center">'.($obj->nb_expired > 0 ? $obj->nb_expired : '').'</td>';
1374 print '<td class="center">'.($obj->nb_closed > 0 ? $obj->nb_closed : '').'</td>';
1375 if (!$i) {
1376 $totalarray['nbfield']++;
1377 $totalarray['nbfield']++;
1378 $totalarray['nbfield']++;
1379 $totalarray['nbfield']++;
1380 }
1381 }
1382 // Action column
1383 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1384 print '<td class="nowrap center">';
1385 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1386 $selected = 0;
1387 if (in_array($obj->rowid, $arrayofselected)) {
1388 $selected = 1;
1389 }
1390 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1391 }
1392 print '</td>';
1393 if (!$i) {
1394 $totalarray['nbfield']++;
1395 }
1396 }
1397
1398 print '</tr>'."\n";
1399 }
1400 $i++;
1401}
1402
1403// If no record found
1404if ($num == 0) {
1405 $colspan = 4; // Include the 4 columns of status
1406 foreach ($arrayfields as $key => $val) {
1407 if (!empty($val['checked'])) {
1408 $colspan++;
1409 }
1410 }
1411 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1412}
1413
1414$db->free($resql);
1415
1416$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1417$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1418print $hookmanager->resPrint;
1419
1420print '</table>'."\n";
1421print '</div>'."\n";
1422
1423print '</form>'."\n";
1424
1425$hidegeneratedfilelistifempty = 1;
1426if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1427 $hidegeneratedfilelistifempty = 0;
1428}
1429
1430// Show list of available documents
1431$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1432$urlsource .= str_replace('&amp;', '&', $param);
1433
1434$filedir = $diroutputmassaction;
1435$genallowed = $permissiontoread;
1436$delallowed = $permissiontoadd;
1437
1438print $formfile->showdocuments('massfilesarea_contract', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1439
1440
1441llxFooter();
1442$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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:71
Class to manage lines of contracts.
Class to manage standard extra fields.
Class to build HTML component for third parties management Only common components are here.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
static multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $morecss='', $translate=0, $width=0, $moreattrib='', $elemtype='', $placeholder='', $addjscombo=-1)
Show a multiselect form from an array.
Class permettant la generation de composants html autre Only common components are here.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition date.lib.php:600
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition date.lib.php:619
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
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...
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.
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0, $morecss='paddingrightonly')
Show EMail link formatted for HTML output.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.