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