dolibarr  16.0.5
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
6  * Copyright (C) 2014-2019 Juanjo Menent <jmenent@2byte.es>
7  * Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
8  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
9  * Copyright (C) 2016-2018 Ferran Marcet <fmarcet@2byte.es>
10  * Copyright (C) 2019 Nicolas Zabouri <info@inovea-conseil.com>
11  * Copyright (C) 2021 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 require '../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
40 
41 // Load translation files required by the page
42 $langs->loadLangs(array('contracts', 'products', 'companies', 'compta'));
43 
44 $action = GETPOST('action', 'aZ09');
45 $massaction = GETPOST('massaction', 'alpha');
46 $show_files = GETPOST('show_files', 'int');
47 $confirm = GETPOST('confirm', 'alpha');
48 $toselect = GETPOST('toselect', 'array');
49 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'contractlist'; // To manage different context of search
50 
51 $search_name = GETPOST('search_name', 'alpha');
52 $search_email = GETPOST('search_email', 'alpha');
53 $search_town = GETPOST('search_town', 'alpha');
54 $search_zip = GETPOST('search_zip', 'alpha');
55 $search_state = GETPOST("search_state", 'alpha');
56 $search_country = GETPOST("search_country", 'int');
57 $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
58 $search_contract = GETPOST('search_contract', 'alpha');
59 $search_ref_customer = GETPOST('search_ref_customer', 'alpha');
60 $search_ref_supplier = GETPOST('search_ref_supplier', 'alpha');
61 $sall = (GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
62 $search_status = GETPOST('search_status', 'alpha');
63 $socid = GETPOST('socid', 'int');
64 $search_user = GETPOST('search_user', 'int');
65 $search_sale = GETPOST('search_sale', 'int');
66 $search_product_category = GETPOST('search_product_category', 'int');
67 $search_dfmonth = GETPOST('search_dfmonth', 'int');
68 $search_dfyear = GETPOST('search_dfyear', 'int');
69 $search_op2df = GETPOST('search_op2df', 'alpha');
70 $search_date_startday = GETPOST('search_date_startday', 'int');
71 $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
72 $search_date_startyear = GETPOST('search_date_startyear', 'int');
73 $search_date_endday = GETPOST('search_date_endday', 'int');
74 $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
75 $search_date_endyear = GETPOST('search_date_endyear', 'int');
76 $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
77 $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
78 
79 $optioncss = GETPOST('optioncss', 'alpha');
80 
81 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
82 $sortfield = GETPOST('sortfield', 'aZ09comma');
83 $sortorder = GETPOST('sortorder', 'aZ09comma');
84 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
85 if (empty($page) || $page == -1) {
86  $page = 0;
87 } // If $page is not defined, or '' or -1
88 $offset = $limit * $page;
89 $pageprev = $page - 1;
90 $pagenext = $page + 1;
91 if (!$sortfield) {
92  $sortfield = 'c.ref';
93 }
94 if (!$sortorder) {
95  $sortorder = 'DESC';
96 }
97 
98 // Security check
99 $id = GETPOST('id', 'int');
100 if ($user->socid) {
101  $socid = $user->socid;
102 }
103 $result = restrictedArea($user, 'contrat', $id);
104 
105 $diroutputmassaction = $conf->contrat->dir_output.'/temp/massgeneration/'.$user->id;
106 
107 $staticcontrat = new Contrat($db);
108 $staticcontratligne = new ContratLigne($db);
109 
110 if ($search_status == '') {
111  $search_status = 1;
112 }
113 
114 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
115 $object = new Contrat($db);
116 $hookmanager->initHooks(array('contractlist'));
117 $extrafields = new ExtraFields($db);
118 
119 // fetch optionals attributes and labels
120 $extrafields->fetch_name_optionals_label($object->table_element);
121 
122 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
123 // List of fields to search into when doing a "search in all"
124 $fieldstosearchall = array(
125  'c.ref'=>'Ref',
126  'c.ref_customer'=>'RefCustomer',
127  'c.ref_supplier'=>'RefSupplier',
128  's.nom'=>"ThirdParty",
129  'c.note_public'=>'NotePublic',
130 );
131 if (empty($user->socid)) {
132  $fieldstosearchall["c.note_private"] = "NotePrivate";
133 }
134 
135 $arrayfields = array(
136  'c.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1, 'position'=>10),
137  'c.ref_customer'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1, 'position'=>12),
138  'c.ref_supplier'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1, 'position'=>14),
139  's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>30),
140  's.email'=>array('label'=>$langs->trans("ThirdPartyEmail"), 'checked'=>0, 'position'=>30),
141  's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0, 'position'=>31),
142  's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1, 'position'=>32),
143  'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0, 'position'=>33),
144  'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0, 'position'=>34),
145  'sale_representative'=>array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>-1, 'position'=>80),
146  'c.date_contrat'=>array('label'=>$langs->trans("DateContract"), 'checked'=>1, 'position'=>45),
147  'c.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
148  'c.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
149  'lower_planned_end_date'=>array('label'=>$langs->trans("LowerDateEndPlannedShort"), 'checked'=>1, 'position'=>900, 'help'=>$langs->trans("LowerDateEndPlannedShort")),
150  'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
151 );
152 // Extra fields
153 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
154 
155 $object->fields = dol_sort_array($object->fields, 'position');
156 $arrayfields = dol_sort_array($arrayfields, 'position');
157 
158 
159 /*
160  * Action
161  */
162 
163 if (GETPOST('cancel', 'alpha')) {
164  $action = 'list'; $massaction = '';
165 }
166 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
167  $massaction = '';
168 }
169 
170 $parameters = array('socid'=>$socid);
171 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
172 if ($reshook < 0) {
173  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
174 }
175 
176 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
177 
178 // Purge search criteria
179 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
180  $search_dfmonth = '';
181  $search_dfyear = '';
182  $search_op2df = '';
183  $search_name = "";
184  $search_email = "";
185  $search_town = '';
186  $search_zip = "";
187  $search_state = "";
188  $search_type = '';
189  $search_country = '';
190  $search_contract = "";
191  $search_ref_customer = "";
192  $search_ref_supplier = "";
193  $search_user = '';
194  $search_sale = '';
195  $search_product_category = '';
196  $search_date_startday = '';
197  $search_date_startmonth = '';
198  $search_date_startyear = '';
199  $search_date_endday = '';
200  $search_date_endmonth = '';
201  $search_date_endyear = '';
202  $search_date_start = '';
203  $search_date_end = '';
204  $sall = "";
205  $search_status = "";
206  $toselect = array();
207  $search_type_thirdparty = '';
208  $search_array_options = array();
209 }
210 
211 if (empty($reshook)) {
212  $objectclass = 'Contrat';
213  $objectlabel = 'Contracts';
214  $permissiontoread = $user->rights->contrat->lire;
215  $permissiontodelete = $user->rights->contrat->supprimer;
216  $uploaddir = $conf->contrat->dir_output;
217  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
218 }
219 
220 
221 /*
222  * View
223  */
224 
225 $now = dol_now();
226 $form = new Form($db);
227 $formfile = new FormFile($db);
228 $formother = new FormOther($db);
229 $socstatic = new Societe($db);
230 $formcompany = new FormCompany($db);
231 $contracttmp = new Contrat($db);
232 $title = "";
233 
234 $sql = 'SELECT';
235 $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,";
236 $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,';
237 $sql .= " typent.code as typent_code,";
238 $sql .= " state.code_departement as state_code, state.nom as state_name,";
239 $sql .= " MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") as lower_planned_end_date,";
240 $sql .= " SUM(".$db->ifsql("cd.statut=0", 1, 0).') as nb_initial,';
241 $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,';
242 $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,';
243 $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,';
244 $sql .= " SUM(".$db->ifsql("cd.statut=5", 1, 0).') as nb_closed';
245 // Add fields from extrafields
246 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
247  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
248  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
249  }
250 }
251 // Add fields from hooks
252 $parameters = array();
253 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
254 $sql .= $hookmanager->resPrint;
255 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
256 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
257 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
258 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
259 if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
260  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
261 }
262 $sql .= ", ".MAIN_DB_PREFIX."contrat as c";
263 if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
264  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (c.rowid = ef.fk_object)";
265 }
266 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat";
267 if ($search_product_category > 0) {
268  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product';
269 }
270 if ($search_user > 0) {
271  $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
272  $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
273 }
274 $sql .= " WHERE c.fk_soc = s.rowid ";
275 $sql .= ' AND c.entity IN ('.getEntity('contract').')';
276 if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
277  $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
278 }
279 if ($search_product_category > 0) {
280  $sql .= " AND cp.fk_categorie = ".((int) $search_product_category);
281 }
282 if ($socid) {
283  $sql .= " AND s.rowid = ".((int) $socid);
284 }
285 if (empty($user->rights->societe->client->voir) && !$socid) {
286  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
287 }
288 if ($search_date_start) {
289  $sql .= " AND c.date_contrat >= '".$db->idate($search_date_start)."'";
290 }
291 if ($search_date_end) {
292  $sql .= " AND c.date_contrat <= '".$db->idate($search_date_end)."'";
293 }
294 if ($search_name) {
295  $sql .= natural_search('s.nom', $search_name);
296 }
297 if ($search_email) {
298  $sql .= natural_search('s.email', $search_email);
299 }
300 if ($search_contract) {
301  $sql .= natural_search(array('c.rowid', 'c.ref'), $search_contract);
302 }
303 if (!empty($search_ref_customer)) {
304  $sql .= natural_search(array('c.ref_customer'), $search_ref_customer);
305 }
306 if (!empty($search_ref_supplier)) {
307  $sql .= natural_search(array('c.ref_supplier'), $search_ref_supplier);
308 }
309 if ($search_zip) {
310  $sql .= natural_search(array('s.zip'), $search_zip);
311 }
312 if ($search_town) {
313  $sql .= natural_search(array('s.town'), $search_town);
314 }
315 if ($search_country && $search_country != '-1') {
316  $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
317 }
318 if ($search_sale > 0) {
319  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
320 }
321 if ($sall) {
322  $sql .= natural_search(array_keys($fieldstosearchall), $sall);
323 }
324 if ($search_user > 0) {
325  $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);
326 }
327 // Add where from extra fields
328 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
329 // Add where from hooks
330 $parameters = array();
331 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
332 $sql .= $hookmanager->resPrint;
333 $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,";
334 $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,';
335 $sql .= " typent.code,";
336 $sql .= " state.code_departement, state.nom";
337 // Add fields from extrafields
338 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
339  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
340  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : '');
341  }
342 }
343 // Add where from hooks
344 $parameters = array('search_dfyear' => $search_dfyear, 'search_op2df'=>$search_op2df);
345 $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
346 $sql .= $hookmanager->resPrint;
347 // Add HAVING from hooks
348 $parameters = array('search_dfyear' => $search_dfyear, 'search_op2df'=>$search_op2df);
349 $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook
350 if (empty($reshook)) {
351  if ($search_dfyear > 0 && $search_op2df) {
352  if ($search_op2df == '<=') {
353  $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."'";
354  } elseif ($search_op2df == '>=') {
355  $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'";
356  } else {
357  $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))."'";
358  }
359  }
360 }
361 $sql .= $hookmanager->resPrint;
362 
363 $nbtotalofrecords = '';
364 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
365  //$result = $db->query($sql);
366  //$nbtotalofrecords = $db->num_rows($result);
367 
368  if ($search_dfyear > 0 && $search_op2df) {
369  $resql = $db->query($sql, 0, 'auto', 1);
370  while ($db->fetch_object($resql)) {
371  if (empty($nbtotalofrecords)) {
372  $nbtotalofrecords = 1; // We can't make +1 because init value is ''
373  } else {
374  $nbtotalofrecords++;
375  }
376  }
377  } else {
378  $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
379  $sqlforcount = preg_replace('/LEFT JOIN '.MAIN_DB_PREFIX.'contratdet as cd ON c.rowid = cd.fk_contrat/', '', $sqlforcount);
380  $sqlforcount = preg_replace('/LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product/', '', $sqlforcount);
381  $sqlforcount = preg_replace('/AND cp.fk_categorie = '.((int) $search_product_category).'/', '', $sqlforcount);
382  $sqlforcount = preg_replace('/GROUP BY.*$/', '', $sqlforcount);
383 
384  $resql = $db->query($sqlforcount);
385  $objforcount = $db->fetch_object($resql);
386  $nbtotalofrecords = $objforcount->nbtotalofrecords;
387  }
388 
389  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
390  $page = 0;
391  $offset = 0;
392  }
393 }
394 
395 $sql .= $db->order($sortfield, $sortorder);
396 if ($limit) {
397  $sql .= $db->plimit($limit + 1, $offset);
398 }
399 
400 $resql = $db->query($sql);
401 if (!$resql) {
402  dol_print_error($db);
403  exit;
404 }
405 
406 $num = $db->num_rows($resql);
407 
408 // Direct jump if only one record found
409 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall && !$page) {
410  $obj = $db->fetch_object($resql);
411  $id = $obj->rowid;
412  header("Location: ".DOL_URL_ROOT.'/contrat/card.php?id='.$id);
413  exit;
414 }
415 
416 
417 // Output page
418 // --------------------------------------------------------------------
419 
420 llxHeader('', $langs->trans("Contracts"));
421 
422 $i = 0;
423 
424 $arrayofselected = is_array($toselect) ? $toselect : array();
425 
426 if ($socid > 0) {
427  $soc = new Societe($db);
428  $soc->fetch($socid);
429  if (empty($search_name)) {
430  $search_name = $soc->name;
431  }
432 }
433 
434 $param = '';
435 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
436  $param .= '&contextpage='.urlencode($contextpage);
437 }
438 if ($limit > 0 && $limit != $conf->liste_limit) {
439  $param .= '&limit='.urlencode($limit);
440 }
441 if ($sall != '') {
442  $param .= '&sall='.urlencode($sall);
443 }
444 if ($search_contract != '') {
445  $param .= '&search_contract='.urlencode($search_contract);
446 }
447 if ($search_name != '') {
448  $param .= '&search_name='.urlencode($search_name);
449 }
450 if ($search_email != '') {
451  $param .= '&search_email='.urlencode($search_email);
452 }
453 if ($search_ref_customer != '') {
454  $param .= '&search_ref_customer='.urlencode($search_ref_customer);
455 }
456 if ($search_ref_supplier != '') {
457  $param .= '&search_ref_supplier='.urlencode($search_ref_supplier);
458 }
459 if ($search_op2df != '') {
460  $param .= '&search_op2df='.urlencode($search_op2df);
461 }
462 if ($search_date_startday > 0) {
463  $param .= '&search_date_startday='.urlencode($search_date_startday);
464 }
465 if ($search_date_startmonth > 0) {
466  $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
467 }
468 if ($search_date_startyear > 0) {
469  $param .= '&search_date_startyear='.urlencode($search_date_startyear);
470 }
471 if ($search_date_endday > 0) {
472  $param .= '&search_date_endday='.urlencode($search_date_endday);
473 }
474 if ($search_date_endmonth > 0) {
475  $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
476 }
477 if ($search_date_endyear > 0) {
478  $param .= '&search_date_endyear='.urlencode($search_date_endyear);
479 }
480 if ($search_dfyear > 0) {
481  $param .= '&search_dfyear='.urlencode($search_dfyear);
482 }
483 if ($search_dfmonth > 0) {
484  $param .= '&search_dfmonth='.urlencode($search_dfmonth);
485 }
486 if ($search_sale > 0) {
487  $param .= '&search_sale='.urlencode($search_sale);
488 }
489 if ($search_user > 0) {
490  $param .= '&search_user='.urlencode($search_user);
491 }
492 if ($search_type_thirdparty > 0) {
493  $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
494 }
495 if ($search_country != '') {
496  $param .= "&search_country=".urlencode($search_country);
497 }
498 if ($search_product_category > 0) {
499  $param .= '&search_product_category='.urlencode($search_product_category);
500 }
501 if ($show_files) {
502  $param .= '&show_files='.urlencode($show_files);
503 }
504 if ($optioncss != '') {
505  $param .= '&optioncss='.urlencode($optioncss);
506 }
507 // Add $param from extra fields
508 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
509 
510 // List of mass actions available
511 $arrayofmassactions = array(
512  'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
513  'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
514  'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
515 );
516 if ($user->rights->contrat->supprimer) {
517  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
518 }
519 if (in_array($massaction, array('presend', 'predelete'))) {
520  $arrayofmassactions = array();
521 }
522 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
523 
524 $url = DOL_URL_ROOT.'/contrat/card.php?action=create';
525 if (!empty($socid)) {
526  $url .= '&socid='.((int) $socid);
527 }
528 $newcardbutton = dolGetButtonTitle($langs->trans('NewContractSubscription'), '', 'fa fa-plus-circle', $url, '', $user->rights->contrat->creer);
529 
530 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
531 if ($optioncss != '') {
532  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
533 }
534 print '<input type="hidden" name="token" value="'.newToken().'">';
535 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
536 print '<input type="hidden" name="action" value="list">';
537 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
538 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
539 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
540 
541 print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contract', 0, $newcardbutton, '', $limit, 0, 0, 1);
542 
543 $topicmail = "SendContractRef";
544 $modelmail = "contract";
545 $objecttmp = new Contrat($db);
546 $trackid = 'con'.$object->id;
547 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
548 
549 if ($sall) {
550  foreach ($fieldstosearchall as $key => $val) {
551  $fieldstosearchall[$key] = $langs->trans($val);
552  }
553  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
554 }
555 
556 $moreforfilter = '';
557 
558 // If the user can view prospects other than his'
559 if ($user->rights->user->user->lire) {
560  $langs->load("commercial");
561  $moreforfilter .= '<div class="divsearchfield">';
562  $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
563  $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'widthcentpercentminusx maxwidth300');
564  $moreforfilter .= '</div>';
565 }
566 // If the user can view other users
567 if ($user->rights->user->user->lire) {
568  $moreforfilter .= '<div class="divsearchfield">';
569  $tmptitle = $langs->trans('LinkedToSpecificUsers');
570  $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
571  $moreforfilter .= '</div>';
572 }
573 // If the user can view categories of products
574 if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) {
575  include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
576  $moreforfilter .= '<div class="divsearchfield">';
577  $tmptitle = $langs->trans('IncludingProductWithTag');
578  $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
579  $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);
580  $moreforfilter .= '</div>';
581 }
582 
583 $parameters = array();
584 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
585 if (empty($reshook)) {
586  $moreforfilter .= $hookmanager->resPrint;
587 } else {
588  $moreforfilter = $hookmanager->resPrint;
589 }
590 
591 if (!empty($moreforfilter)) {
592  print '<div class="liste_titre liste_titre_bydiv centpercent">';
593  print $moreforfilter;
594  print '</div>';
595 }
596 
597 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
598 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
599 if ($massactionbutton) {
600  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
601 }
602 
603 print '<div class="div-table-responsive">';
604 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
605 
606 print '<tr class="liste_titre_filter">';
607 if (!empty($arrayfields['c.ref']['checked'])) {
608  print '<td class="liste_titre">';
609  print '<input type="text" class="flat" size="3" name="search_contract" value="'.dol_escape_htmltag($search_contract).'">';
610  print '</td>';
611 }
612 if (!empty($arrayfields['c.ref_customer']['checked'])) {
613  print '<td class="liste_titre">';
614  print '<input type="text" class="flat" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).'">';
615  print '</td>';
616 }
617 if (!empty($arrayfields['c.ref_supplier']['checked'])) {
618  print '<td class="liste_titre">';
619  print '<input type="text" class="flat" size="6" name="search_ref_supplier" value="'.dol_escape_htmltag($search_ref_supplier).'">';
620  print '</td>';
621 }
622 if (!empty($arrayfields['s.nom']['checked'])) {
623  print '<td class="liste_titre">';
624  print '<input type="text" class="flat" size="8" name="search_name" value="'.dol_escape_htmltag($search_name).'">';
625  print '</td>';
626 }
627 if (!empty($arrayfields['s.email']['checked'])) {
628  print '<td class="liste_titre">';
629  print '<input type="text" class="flat" size="6" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
630  print '</td>';
631 }
632 // Town
633 if (!empty($arrayfields['s.town']['checked'])) {
634  print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
635 }
636 // Zip
637 if (!empty($arrayfields['s.zip']['checked'])) {
638  print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>';
639 }
640 // State
641 if (!empty($arrayfields['state.nom']['checked'])) {
642  print '<td class="liste_titre">';
643  print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
644  print '</td>';
645 }
646 // Country
647 if (!empty($arrayfields['country.code_iso']['checked'])) {
648  print '<td class="liste_titre center">';
649  print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
650  print '</td>';
651 }
652 // Company type
653 if (!empty($arrayfields['typent.code']['checked'])) {
654  print '<td class="liste_titre maxwidthonsmartphone center">';
655  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);
656  print '</td>';
657 }
658 if (!empty($arrayfields['sale_representative']['checked'])) {
659  print '<td class="liste_titre"></td>';
660 }
661 if (!empty($arrayfields['c.date_contrat']['checked'])) {
662  print '<td class="liste_titre center">';
663  print '<div class="nowrap">';
664  print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
665  print '</div>';
666  print '<div class="nowrap">';
667  print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
668  print '</div>';
669  print '</td>';
670 }
671 // Extra fields
672 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
673 
674 // Fields from hook
675 $parameters = array('arrayfields'=>$arrayfields);
676 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
677 print $hookmanager->resPrint;
678 // Date creation
679 if (!empty($arrayfields['c.datec']['checked'])) {
680  print '<td class="liste_titre">';
681  print '</td>';
682 }
683 // Date modification
684 if (!empty($arrayfields['c.tms']['checked'])) {
685  print '<td class="liste_titre">';
686  print '</td>';
687 }
688 // First end date
689 if (!empty($arrayfields['lower_planned_end_date']['checked'])) {
690  print '<td class="liste_titre nowraponall center">';
691  $arrayofoperators = array('0'=>'', '='=>'=', '<='=>'<=', '>='=>'>=');
692  print $form->selectarray('search_op2df', $arrayofoperators, $search_op2df, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth50imp');
693  print '</br>';
694  print $formother->select_month($search_dfmonth, 'search_dfmonth', 1, 0);
695  print ' ';
696  print $formother->selectyear($search_dfyear, 'search_dfyear', 1, 20, 5, 0, 0, '');
697  print '</td>';
698 }
699 // Status
700 if (!empty($arrayfields['status']['checked'])) {
701  print '<td class="liste_titre right" colspan="4"></td>';
702 }
703 print '<td class="liste_titre center">';
704 $searchpicto = $form->showFilterButtons();
705 print $searchpicto;
706 print '</td>';
707 print "</tr>\n";
708 
709 print '<tr class="liste_titre">';
710 if (!empty($arrayfields['c.ref']['checked'])) {
711  print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder);
712 }
713 if (!empty($arrayfields['c.ref_customer']['checked'])) {
714  print_liste_field_titre($arrayfields['c.ref_customer']['label'], $_SERVER["PHP_SELF"], "c.ref_customer", "", $param, '', $sortfield, $sortorder);
715 }
716 if (!empty($arrayfields['c.ref_supplier']['checked'])) {
717  print_liste_field_titre($arrayfields['c.ref_supplier']['label'], $_SERVER["PHP_SELF"], "c.ref_supplier", "", $param, '', $sortfield, $sortorder);
718 }
719 if (!empty($arrayfields['s.nom']['checked'])) {
720  print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
721 }
722 if (!empty($arrayfields['s.email']['checked'])) {
723  print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email", "", $param, '', $sortfield, $sortorder);
724 }
725 if (!empty($arrayfields['s.town']['checked'])) {
726  print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
727 }
728 if (!empty($arrayfields['s.zip']['checked'])) {
729  print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
730 }
731 if (!empty($arrayfields['state.nom']['checked'])) {
732  print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
733 }
734 if (!empty($arrayfields['country.code_iso']['checked'])) {
735  print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
736 }
737 if (!empty($arrayfields['typent.code']['checked'])) {
738  print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
739 }
740 if (!empty($arrayfields['sale_representative']['checked'])) {
741  print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder);
742 }
743 if (!empty($arrayfields['c.date_contrat']['checked'])) {
744  print_liste_field_titre($arrayfields['c.date_contrat']['label'], $_SERVER["PHP_SELF"], "c.date_contrat", "", $param, '', $sortfield, $sortorder, 'center ');
745 }
746 // Extra fields
747 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
748 // Hook fields
749 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
750 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
751 print $hookmanager->resPrint;
752 if (!empty($arrayfields['c.datec']['checked'])) {
753  print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
754 }
755 if (!empty($arrayfields['c.tms']['checked'])) {
756  print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
757 }
758 if (!empty($arrayfields['lower_planned_end_date']['checked'])) {
759  print_liste_field_titre($arrayfields['lower_planned_end_date']['label'], $_SERVER["PHP_SELF"], "lower_planned_end_date", "", $param, '', $sortfield, $sortorder, 'center ');
760 }
761 if (!empty($arrayfields['status']['checked'])) {
762  print_liste_field_titre($staticcontratligne->LibStatut(0, 3, -1, 'class="nochangebackground"'), '', '', '', '', 'width="16"');
763  print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 0, 'class="nochangebackground"'), '', '', '', '', 'width="16"');
764  print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 1, 'class="nochangebackground"'), '', '', '', '', 'width="16"');
765  print_liste_field_titre($staticcontratligne->LibStatut(5, 3, -1, 'class="nochangebackground"'), '', '', '', '', 'width="16"');
766 }
767 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
768 print "</tr>\n";
769 
770 $totalarray = array();
771 $totalarray['nbfield'] = 0;
772 $typenArray = array();
773 $cacheCountryIDCode = array();
774 
775 while ($i < min($num, $limit)) {
776  $obj = $db->fetch_object($resql);
777 
778  $contracttmp->ref = $obj->ref;
779  $contracttmp->id = $obj->rowid;
780  $contracttmp->ref_customer = $obj->ref_customer;
781  $contracttmp->ref_supplier = $obj->ref_supplier;
782 
783  if ($obj->socid > 0) {
784  $result = $socstatic->fetch($obj->socid);
785  }
786  /*$socstatic->id = $obj->socid;
787  $socstatic->name = $obj->name;
788  $socstatic->name_alias = $obj->name_alias;
789  $socstatic->email = $obj->email;
790  $socstatic->status = $obj->company_status;
791  $socstatic->logo = $obj->logo;
792  $socstatic->country_id = $obj->country_id;
793  $socstatic->country_code = '';
794  $socstatic->country = '';*/
795  if ($obj->country_id > 0) {
796  if (!isset($cacheCountryIDCode[$obj->country_id]['code'])) {
797  $tmparray = getCountry($obj->country_id, 'all');
798  $cacheCountryIDCode[$obj->country_id] = array('code'=> empty($tmparray['code']) ? '' : $tmparray['code'], 'label' => empty($tmparray['label']) ? '' : $tmparray['label']);
799  }
800  $socstatic->country_code = $cacheCountryIDCode[$obj->country_id]['code'];
801  $socstatic->country = $cacheCountryIDCode[$obj->country_id]['label'];
802  }
803 
804 
805  print '<tr class="oddeven">';
806 
807  // Ref
808  if (!empty($arrayfields['c.ref']['checked'])) {
809  print '<td class="nowraponall">';
810  print $contracttmp->getNomUrl(1);
811  if ($obj->nb_late) {
812  print img_warning($langs->trans("Late"));
813  }
814  if (!empty($obj->note_private) || !empty($obj->note_public)) {
815  print ' <span class="note">';
816  print '<a href="'.DOL_URL_ROOT.'/contrat/note.php?id='.$obj->rowid.'&save_lastsearch_values=1">'.img_picto($langs->trans("ViewPrivateNote"), 'note').'</a>';
817  print '</span>';
818  }
819 
820  $filename = dol_sanitizeFileName($obj->ref);
821  $filedir = $conf->contrat->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
822  $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
823  print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir);
824  print '</td>';
825 
826  print '</td>';
827  }
828 
829  // Ref thirdparty
830  if (!empty($arrayfields['c.ref_customer']['checked'])) {
831  print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag(dol_string_nohtmltag($contracttmp->getFormatedCustomerRef($obj->ref_customer))).'">'.$contracttmp->getFormatedCustomerRef($obj->ref_customer).'</td>';
832  }
833  if (!empty($arrayfields['c.ref_supplier']['checked'])) {
834  print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->ref_supplier).'">'.dol_escape_htmltag($obj->ref_supplier).'</td>';
835  }
836  if (!empty($arrayfields['s.nom']['checked'])) {
837  print '<td class="tdoverflowmax150">';
838  if ($obj->socid > 0) {
839  // TODO Use a cache for this string
840  print $socstatic->getNomUrl(1, '');
841  }
842  print '</td>';
843  }
844  // Email
845  if (!empty($arrayfields['s.email']['checked'])) {
846  print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->email).'">'.dol_print_email($obj->email, 0, $obj->socid, 0, 0, 1, 1).'</td>';
847  }
848  // Town
849  if (!empty($arrayfields['s.town']['checked'])) {
850  print '<td class="nocellnopadd">';
851  print $obj->town;
852  print '</td>';
853  if (!$i) {
854  $totalarray['nbfield']++;
855  }
856  }
857  // Zip
858  if (!empty($arrayfields['s.zip']['checked'])) {
859  print '<td class="nocellnopadd">';
860  print $obj->zip;
861  print '</td>';
862  if (!$i) {
863  $totalarray['nbfield']++;
864  }
865  }
866  // State
867  if (!empty($arrayfields['state.nom']['checked'])) {
868  print "<td>".$obj->state_name."</td>\n";
869  if (!$i) {
870  $totalarray['nbfield']++;
871  }
872  }
873  // Country
874  if (!empty($arrayfields['country.code_iso']['checked'])) {
875  print '<td class="center">';
876  print $socstatic->country;
877  print '</td>';
878  if (!$i) {
879  $totalarray['nbfield']++;
880  }
881  }
882  // Type ent
883  if (!empty($arrayfields['typent.code']['checked'])) {
884  print '<td class="center">';
885  if (count($typenArray) == 0) {
886  $typenArray = $formcompany->typent_array(1);
887  }
888  print $typenArray[$obj->typent_code];
889  print '</td>';
890  if (!$i) {
891  $totalarray['nbfield']++;
892  }
893  }
894  if (!empty($arrayfields['sale_representative']['checked'])) {
895  // Sales representatives
896  print '<td>';
897  if ($obj->socid > 0) {
898  $listsalesrepresentatives = $socstatic->getSalesRepresentatives($user);
899  if ($listsalesrepresentatives < 0) {
900  dol_print_error($db);
901  }
902  $nbofsalesrepresentative = count($listsalesrepresentatives);
903  if ($nbofsalesrepresentative > 6) {
904  // We print only number
905  print $nbofsalesrepresentative;
906  } elseif ($nbofsalesrepresentative > 0) {
907  $userstatic = new User($db);
908  $j = 0;
909  foreach ($listsalesrepresentatives as $val) {
910  $userstatic->id = $val['id'];
911  $userstatic->lastname = $val['lastname'];
912  $userstatic->firstname = $val['firstname'];
913  $userstatic->email = $val['email'];
914  $userstatic->statut = $val['statut'];
915  $userstatic->entity = $val['entity'];
916  $userstatic->photo = $val['photo'];
917  $userstatic->login = $val['login'];
918  $userstatic->phone = $val['phone'];
919  $userstatic->job = $val['job'];
920  $userstatic->gender = $val['gender'];
921 
922  //print '<div class="float">':
923  print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
924  $j++;
925  if ($j < $nbofsalesrepresentative) {
926  print ' ';
927  }
928  //print '</div>';
929  }
930  }
931  //else print $langs->trans("NoSalesRepresentativeAffected");
932  } else {
933  print '&nbsp;';
934  }
935  print '</td>';
936  }
937  // Date
938  if (!empty($arrayfields['c.date_contrat']['checked'])) {
939  print '<td class="center">'.dol_print_date($db->jdate($obj->date_contrat), 'day', 'tzserver').'</td>';
940  }
941  // Extra fields
942  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
943  // Fields from hook
944  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
945  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
946  print $hookmanager->resPrint;
947  // Date creation
948  if (!empty($arrayfields['c.datec']['checked'])) {
949  print '<td class="center nowrap">';
950  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
951  print '</td>';
952  if (!$i) {
953  $totalarray['nbfield']++;
954  }
955  }
956  // Date modification
957  if (!empty($arrayfields['c.tms']['checked'])) {
958  print '<td class="center nowrap">';
959  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
960  print '</td>';
961  if (!$i) {
962  $totalarray['nbfield']++;
963  }
964  }
965  // Date lower end date
966  if (!empty($arrayfields['lower_planned_end_date']['checked'])) {
967  print '<td class="center nowrapforall">';
968  print dol_print_date($db->jdate($obj->lower_planned_end_date), 'day', 'tzuser');
969  print '</td>';
970  if (!$i) {
971  $totalarray['nbfield']++;
972  }
973  }
974  // Status
975  if (!empty($arrayfields['status']['checked'])) {
976  print '<td class="center">'.($obj->nb_initial > 0 ? $obj->nb_initial : '').'</td>';
977  print '<td class="center">'.($obj->nb_running > 0 ? $obj->nb_running : '').'</td>';
978  print '<td class="center">'.($obj->nb_expired > 0 ? $obj->nb_expired : '').'</td>';
979  print '<td class="center">'.($obj->nb_closed > 0 ? $obj->nb_closed : '').'</td>';
980  }
981  // Action column
982  print '<td class="nowrap center">';
983  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
984  $selected = 0;
985  if (in_array($obj->rowid, $arrayofselected)) {
986  $selected = 1;
987  }
988  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
989  }
990  print '</td>';
991  if (!$i) {
992  $totalarray['nbfield']++;
993  }
994 
995  print "</tr>\n";
996  $i++;
997 }
998 
999 // If no record found
1000 if ($num == 0) {
1001  $colspan = 4; // Include the 4 columns of status
1002  foreach ($arrayfields as $key => $val) {
1003  if (!empty($val['checked'])) {
1004  $colspan++;
1005  }
1006  }
1007  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1008 }
1009 
1010 $db->free($resql);
1011 
1012 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1013 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
1014 print $hookmanager->resPrint;
1015 
1016 print '</table>';
1017 print '</div>';
1018 
1019 print '</form>';
1020 
1021 $hidegeneratedfilelistifempty = 1;
1022 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1023  $hidegeneratedfilelistifempty = 0;
1024 }
1025 
1026 // Show list of available documents
1027 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1028 $urlsource .= str_replace('&amp;', '&', $param);
1029 
1030 $filedir = $diroutputmassaction;
1031 $genallowed = $user->rights->contrat->lire;
1032 $delallowed = $user->rights->contrat->lire;
1033 
1034 print $formfile->showdocuments('massfilesarea_contract', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1035 
1036 
1037 llxFooter();
1038 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
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:1468
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
restrictedArea
restrictedArea($user, $features, $objectid=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:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
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:484
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:4844
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:8385
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4521
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
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:2514
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:3880
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:10605
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:6694
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:5257
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:551
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:570
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:386
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:5026
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:9420
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
ContratLigne
Class to manage lines of contracts.
Definition: contrat.class.php:2607
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:2960
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->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->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
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:489
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
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:2757
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59