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