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