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