dolibarr  17.0.4
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005 Marc Bariley / Ocebo <marc@ocebo.com>
5  * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
7  * Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
8  * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
9  * Copyright (C) 2019 Juanjo Menent <jmenent@2byte.es>
10  * Copyright (C) 2020 Tobias Sean <tobias.sekan@startmail.com>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <https://www.gnu.org/licenses/>.
24  */
25 
32 // Load Dolibarr environment
33 require '../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
40 
41 if (isModEnabled('categorie')) {
42  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
43  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
44 }
45 
46 // Load translation files required by the page
47 $langs->loadLangs(array('projects', 'companies', 'commercial'));
48 if (isModEnabled('eventorganization') && $conf->eventorganization->enabled) {
49  $langs->loadLangs(array('eventorganization'));
50 }
51 
52 $action = GETPOST('action', 'aZ09');
53 $massaction = GETPOST('massaction', 'alpha');
54 $show_files = GETPOST('show_files', 'int');
55 $confirm = GETPOST('confirm', 'alpha');
56 $toselect = GETPOST('toselect', 'array');
57 $optioncss = GETPOST('optioncss', 'alpha');
58 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'projectlist';
59 
60 $title = $langs->trans("Projects");
61 
62 // Security check
63 $socid = GETPOST('socid', 'int');
64 //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement.
65 if ($socid > 0) {
66  $soc = new Societe($db);
67  $soc->fetch($socid);
68  $title .= ' (<a href="list.php">'.$soc->name.'</a>)';
69 }
70 if (!$user->rights->projet->lire) {
72 }
73 
74 $diroutputmassaction = $conf->project->dir_output.'/temp/massgeneration/'.$user->id;
75 
76 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
77 $sortfield = GETPOST('sortfield', 'aZ09comma');
78 $sortorder = GETPOST('sortorder', 'aZ09comma');
79 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
80 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
81  // If $page is not defined, or '' or -1 or if we click on clear filters
82  $page = 0;
83 }
84 if (!$sortfield) {
85  $sortfield = "p.ref";
86 }
87 if (!$sortorder) {
88  $sortorder = "ASC";
89 }
90 $offset = $limit * $page;
91 $pageprev = $page - 1;
92 $pagenext = $page + 1;
93 
94 $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
95 $search_ref = GETPOST("search_ref", 'alpha');
96 $search_label = GETPOST("search_label", 'alpha');
97 $search_societe = GETPOST("search_societe", 'alpha');
98 $search_societe_alias = GETPOST("search_societe_alias", 'alpha');
99 $search_status = GETPOST("search_status", 'int');
100 $search_opp_status = GETPOST("search_opp_status", 'alpha');
101 $search_opp_percent = GETPOST("search_opp_percent", 'alpha');
102 $search_opp_amount = GETPOST("search_opp_amount", 'alpha');
103 $search_budget_amount = GETPOST("search_budget_amount", 'alpha');
104 $search_public = GETPOST("search_public", 'int');
105 $search_project_user = GETPOST('search_project_user', 'int');
106 $search_project_contact = GETPOST('search_project_contact', 'int');
107 $search_sale = GETPOST('search_sale', 'int');
108 $search_usage_opportunity = GETPOST('search_usage_opportunity', 'int');
109 $search_usage_task = GETPOST('search_usage_task', 'int');
110 $search_usage_bill_time = GETPOST('search_usage_bill_time', 'int');
111 $search_usage_event_organization = GETPOST('search_usage_event_organization', 'int');
112 $search_accept_conference_suggestions = GETPOST('search_accept_conference_suggestions', 'int');
113 $search_accept_booth_suggestions = GETPOST('search_accept_booth_suggestions', 'int');
114 $search_price_registration = GETPOST("search_price_registration", 'alpha');
115 $search_price_booth = GETPOST("search_price_booth", 'alpha');
116 $search_login = GETPOST('search_login', 'alpha');
117 $search_import_key = GETPOST('search_import_key', 'alpha');
118 $searchCategoryCustomerOperator = 0;
119 if (GETPOSTISSET('formfilteraction')) {
120  $searchCategoryCustomerOperator = GETPOST('search_category_customer_operator', 'int');
121 } elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) {
122  $searchCategoryCustomerOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT;
123 }
124 $searchCategoryCustomerList = GETPOST('search_category_customer_list', 'array');
125 
126 
127 $mine = ((GETPOST('mode') == 'mine') ? 1 : 0);
128 if ($mine) {
129  $search_project_user = $user->id; $mine = 0;
130 }
131 
132 $search_sday = GETPOST('search_sday', 'int');
133 $search_smonth = GETPOST('search_smonth', 'int');
134 $search_syear = GETPOST('search_syear', 'int');
135 $search_eday = GETPOST('search_eday', 'int');
136 $search_emonth = GETPOST('search_emonth', 'int');
137 $search_eyear = GETPOST('search_eyear', 'int');
138 
139 $search_date_start_startmonth = GETPOST('search_date_start_startmonth', 'int');
140 $search_date_start_startyear = GETPOST('search_date_start_startyear', 'int');
141 $search_date_start_startday = GETPOST('search_date_start_startday', 'int');
142 $search_date_start_start = dol_mktime(0, 0, 0, $search_date_start_startmonth, $search_date_start_startday, $search_date_start_startyear); // Use tzserver
143 $search_date_start_endmonth = GETPOST('search_date_start_endmonth', 'int');
144 $search_date_start_endyear = GETPOST('search_date_start_endyear', 'int');
145 $search_date_start_endday = GETPOST('search_date_start_endday', 'int');
146 $search_date_start_end = dol_mktime(23, 59, 59, $search_date_start_endmonth, $search_date_start_endday, $search_date_start_endyear); // Use tzserver
147 
148 $search_date_end_startmonth = GETPOST('search_date_end_startmonth', 'int');
149 $search_date_end_startyear = GETPOST('search_date_end_startyear', 'int');
150 $search_date_end_startday = GETPOST('search_date_end_startday', 'int');
151 $search_date_end_start = dol_mktime(0, 0, 0, $search_date_end_startmonth, $search_date_end_startday, $search_date_end_startyear); // Use tzserver
152 $search_date_end_endmonth = GETPOST('search_date_end_endmonth', 'int');
153 $search_date_end_endyear = GETPOST('search_date_end_endyear', 'int');
154 $search_date_end_endday = GETPOST('search_date_end_endday', 'int');
155 $search_date_end_end = dol_mktime(23, 59, 59, $search_date_end_endmonth, $search_date_end_endday, $search_date_end_endyear); // Use tzserver
156 
157 if (isModEnabled('categorie')) {
158  $search_category_array = GETPOST("search_category_".Categorie::TYPE_PROJECT."_list", "array");
159 }
160 
161 if ($search_status == '') {
162  $search_status = -1; // -1 or 1
163 }
164 
165 
166 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
167 $object = new Project($db);
168 $hookmanager->initHooks(array('projectlist'));
169 $extrafields = new ExtraFields($db);
170 
171 // fetch optionals attributes and labels
172 $extrafields->fetch_name_optionals_label($object->table_element);
173 
174 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
175 
176 // List of fields to search into when doing a "search in all"
177 $fieldstosearchall = array();
178 foreach ($object->fields as $key => $val) {
179  if (empty($val['searchall'])) {
180  continue;
181  }
182 
183  // Don't allow search in private notes for external users when doing "search in all"
184  if (!empty($user->socid) && $key == "note_private") {
185  continue;
186  }
187 
188  $fieldstosearchall['p.'.$key] = $val['label'];
189 }
190 
191 // Add name object fields to "search in all"
192 $fieldstosearchall['s.nom'] = "ThirdPartyName";
193 
194 // Definition of array of fields for columns
195 $arrayfields = array();
196 foreach ($object->fields as $key => $val) {
197  // If $val['visible']==0, then we never show the field
198  if (!empty($val['visible'])) {
199  $visible = dol_eval($val['visible'], 1, 1, '1');
200  $arrayfields['p.'.$key] = array(
201  'label'=>$val['label'],
202  'checked'=>(($visible < 0) ? 0 : 1),
203  'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
204  'position'=>$val['position'],
205  'help'=> isset($val['help']) ? $val['help'] : ''
206  );
207  }
208 }
209 // Extra fields
210 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
211 
212 // Add non object fields to fields for list
213 $arrayfields['s.nom'] = array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>21, 'enabled'=>(!isModEnabled('societe') ? 0 : 1));
214 $arrayfields['s.name_alias'] = array('label'=>"AliasNameShort", 'checked'=>0, 'position'=>22);
215 $arrayfields['commercial'] = array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>0, 'position'=>23);
216 $arrayfields['c.assigned'] = array('label'=>$langs->trans("AssignedTo"), 'checked'=>1, 'position'=>120);
217 $arrayfields['opp_weighted_amount'] = array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'enabled'=>(empty($conf->global->PROJECT_USE_OPPORTUNITIES) ? 0 : 1), 'position'=>106);
218 $arrayfields['u.login'] = array('label'=>"Author", 'checked'=>-1, 'position'=>165);
219 // Force some fields according to search_usage filter...
220 if (GETPOST('search_usage_opportunity')) {
221  //$arrayfields['p.usage_opportunity']['visible'] = 1; // Not require, filter on search_opp_status is enough
222  //$arrayfields['p.usage_opportunity']['checked'] = 1; // Not require, filter on search_opp_status is enough
223 }
224 if (GETPOST('search_usage_event_organization')) {
225  $arrayfields['p.fk_opp_status']['enabled'] = 0;
226  $arrayfields['p.opp_amount']['enabled'] = 0;
227  $arrayfields['p.opp_percent']['enabled'] = 0;
228  $arrayfields['opp_weighted_amount']['enabled'] = 0;
229  $arrayfields['p.usage_organize_event']['visible'] = 1;
230  $arrayfields['p.usage_organize_event']['checked'] = 1;
231 }
232 
233 $object->fields = dol_sort_array($object->fields, 'position');
234 $arrayfields = dol_sort_array($arrayfields, 'position');
235 
236 
237 /*
238  * Actions
239  */
240 
241 if (GETPOST('cancel', 'alpha')) {
242  $action = 'list';
243  $massaction = '';
244 }
245 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
246  $massaction = '';
247 }
248 
249 $parameters = array('socid'=>$socid);
250 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
251 if ($reshook < 0) {
252  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
253 }
254 
255 if (empty($reshook)) {
256  // Selection of new fields
257  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
258 
259  // Purge search criteria
260  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
261  $search_all = '';
262  $search_ref = "";
263  $search_label = "";
264  $search_societe = "";
265  $search_societe_alias = '';
266  $search_status = -1;
267  $search_opp_status = -1;
268  $search_opp_amount = '';
269  $search_opp_percent = '';
270  $search_budget_amount = '';
271  $search_public = "";
272  $search_sale = "";
273  $search_project_user = '';
274  $search_project_contact = '';
275  $search_sday = "";
276  $search_smonth = "";
277  $search_syear = "";
278  $search_eday = "";
279  $search_emonth = "";
280  $search_eyear = "";
281  $search_date_start_startmonth = "";
282  $search_date_start_startyear = "";
283  $search_date_start_startday = "";
284  $search_date_start_start = "";
285  $search_date_start_endmonth = "";
286  $search_date_start_endyear = "";
287  $search_date_start_endday = "";
288  $search_date_start_end = "";
289  $search_date_end_startmonth = "";
290  $search_date_end_startyear = "";
291  $search_date_end_startday = "";
292  $search_date_end_start = "";
293  $search_date_end_endmonth = "";
294  $search_date_end_endyear = "";
295  $search_date_end_endday = "";
296  $search_date_end_end = "";
297  $search_usage_opportunity = '';
298  $search_usage_task = '';
299  $search_usage_bill_time = '';
300  $search_usage_event_organization = '';
301  $search_accept_conference_suggestions = '';
302  $search_accept_booth_suggestions = '';
303  $search_price_registration = '';
304  $search_price_booth = '';
305  $search_login = '';
306  $search_import_key = '';
307  $toselect = array();
308  $search_array_options = array();
309  $search_category_array = array();
310  }
311 
312 
313  // Mass actions
314  $objectclass = 'Project';
315  $objectlabel = 'Project';
316  $permissiontoread = $user->rights->projet->lire;
317  $permissiontodelete = $user->rights->projet->supprimer;
318  $permissiontoadd = $user->rights->projet->creer;
319  $uploaddir = $conf->project->dir_output;
320  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
321 
322  // Close records
323  if (!$error && $massaction == 'close' && $user->rights->projet->creer) {
324  $db->begin();
325 
326  $objecttmp = new $objectclass($db);
327  $nbok = 0;
328  foreach ($toselect as $toselectid) {
329  $result = $objecttmp->fetch($toselectid);
330  if ($result > 0) {
331  $userWrite = $object->restrictedProjectArea($user, 'write');
332  if ($userWrite > 0 && $objecttmp->statut == 1) {
333  $result = $objecttmp->setClose($user);
334  if ($result <= 0) {
335  setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
336  $error++;
337  break;
338  } else {
339  $nbok++;
340  }
341  } elseif ($userWrite <= 0) {
342  setEventMessages($langs->trans("DontHavePermissionForCloseProject", $objecttmp->ref), null, 'warnings');
343  } else {
344  setEventMessages($langs->trans("DontHaveTheValidateStatus", $objecttmp->ref), null, 'warnings');
345  }
346  } else {
347  setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
348  $error++;
349  break;
350  }
351  }
352 
353  if (!$error) {
354  if ($nbok > 1) {
355  setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs');
356  } else {
357  setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs');
358  }
359  $db->commit();
360  } else {
361  $db->rollback();
362  }
363  }
364 }
365 
366 
367 /*
368  * View
369  */
370 
371 $form = new Form($db);
372 $formcompany = new FormCompany($db);
373 
374 $now = dol_now();
375 
376 $companystatic = new Societe($db);
377 $taskstatic = new Task($db);
378 $formother = new FormOther($db);
379 $formproject = new FormProjets($db);
380 
381 $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
382 $title = $langs->trans("LeadsOrProjects");
383 if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
384  $title = $langs->trans("Projects");
385 }
386 if (isset($conf->global->PROJECT_USE_OPPORTUNITIES) && $conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only
387  $title = $langs->trans("Leads");
388 }
389 $morejs = array();
390 $morecss = array();
391 
392 
393 // Get list of project id allowed to user (in a string list separated by comma)
394 $projectsListId = '';
395 if (empty($user->rights->projet->all->lire)) {
396  $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $socid);
397 }
398 
399 // Get id of types of contacts for projects (This list never contains a lot of elements)
400 $listofprojectcontacttype = array();
401 $listofprojectcontacttypeexternal = array();
402 $sql = "SELECT ctc.rowid, ctc.code, ctc.source FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
403 $sql .= " WHERE ctc.element = '".$db->escape($object->element)."'";
404 $resql = $db->query($sql);
405 if ($resql) {
406  while ($obj = $db->fetch_object($resql)) {
407  if ($obj->source == 'internal') $listofprojectcontacttype[$obj->rowid] = $obj->code;
408  else $listofprojectcontacttypeexternal[$obj->rowid] = $obj->code;
409  }
410 } else {
411  dol_print_error($db);
412 }
413 if (count($listofprojectcontacttype) == 0) {
414  $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found
415 }
416 if (count($listofprojectcontacttypeexternal) == 0) {
417  $listofprojectcontacttypeexternal[0] = '0'; // To avoid sql syntax error if not found
418 }
419 
420 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
421 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
422 
423 $distinct = 'DISTINCT'; // We add distinct until we have added a protection to be sure a contact of a project and task is only once.
424 $sql = "SELECT ".$distinct." p.rowid as id, p.ref, p.title, p.fk_statut as status, p.fk_opp_status, p.public, p.fk_user_creat,";
425 $sql .= " p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, (p.opp_amount*p.opp_percent/100) as opp_weighted_amount, p.tms as date_update, p.budget_amount,";
426 $sql .= " p.usage_opportunity, p.usage_task, p.usage_bill_time, p.usage_organize_event,";
427 $sql .= " p.email_msgid, p.import_key,";
428 $sql .= " p.accept_conference_suggestions, p.accept_booth_suggestions, p.price_registration, p.price_booth,";
429 $sql .= " s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.code_client,";
430 $sql .= " country.code as country_code,";
431 $sql .= " cls.code as opp_status_code,";
432 $sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender';
433 // Add fields from extrafields
434 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
435  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
436  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
437  }
438 }
439 // Add fields from hooks
440 $parameters = array();
441 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
442 $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
443 $sql = preg_replace('/,\s*$/', '', $sql);
444 
445 $sqlfields = $sql; // $sql fields to remove for count total
446 
447 $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as p";
448 if (!empty($extrafields->attributes[$object->table_element]['label']) &&is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
449  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)";
450 }
451 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
452 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
453 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid";
454 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user AS u ON p.fk_user_creat = u.rowid';
455 // We'll need this table joined to the select in order to filter by sale
456 // No check is done on company permission because readability is managed by public status of project and assignement.
457 //if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
458 if ($search_sale > 0) {
459  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
460 }
461 if ($search_project_user > 0) {
462  $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp";
463 }
464 if ($search_project_contact > 0) {
465  $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp_contact";
466 }
467 
468 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
469 $sql .= $hookmanager->resPrint;
470 
471 $sql .= " WHERE p.entity IN (".getEntity('project').')';
472 if (empty($user->rights->projet->all->lire)) {
473  $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users
474 }
475 // No need to check if company is external user, as filtering of projects must be done by getProjectsAuthorizedForUser
476 if ($socid > 0) {
477  $sql .= " AND (p.fk_soc = ".((int) $socid).")"; // This filter if when we use a hard coded filter on company on url (not related to filter for external users)
478 }
479 if ($search_ref) {
480  $sql .= natural_search('p.ref', $search_ref);
481 }
482 if ($search_label) {
483  $sql .= natural_search('p.title', $search_label);
484 }
485 if (empty($arrayfields['s.name_alias']['checked']) && $search_societe) {
486  $sql .= natural_search(array("s.nom", "s.name_alias"), $search_societe);
487 } else {
488  if ($search_societe) {
489  $sql .= natural_search('s.nom', $search_societe);
490  }
491  if ($search_societe_alias) {
492  $sql .= natural_search('s.name_alias', $search_societe_alias);
493  }
494 }
495 if ($search_opp_amount) {
496  $sql .= natural_search('p.opp_amount', $search_opp_amount, 1);
497 }
498 if ($search_opp_percent) {
499  $sql .= natural_search('p.opp_percent', $search_opp_percent, 1);
500 }
501 $sql .= dolSqlDateFilter('p.dateo', $search_sday, $search_smonth, $search_syear);
502 $sql .= dolSqlDateFilter('p.datee', $search_eday, $search_emonth, $search_eyear);
503 
504 if ($search_date_start_start) {
505  $sql .= " AND p.dateo >= '".$db->idate($search_date_start_start)."'";
506 }
507 if ($search_date_start_end) {
508  $sql .= " AND p.dateo <= '".$db->idate($search_date_start_end)."'";
509 }
510 
511 if ($search_date_end_start) {
512  $sql .= " AND p.datee >= '".$db->idate($search_date_end_start)."'";
513 }
514 if ($search_date_end_end) {
515  $sql .= " AND p.datee <= '".$db->idate($search_date_end_end)."'";
516 }
517 
518 if ($search_all) {
519  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
520 }
521 if ($search_status >= 0) {
522  if ($search_status == 99) {
523  $sql .= " AND p.fk_statut <> 2";
524  } else {
525  $sql .= " AND p.fk_statut = ".((int) $search_status);
526  }
527 }
528 if ($search_opp_status) {
529  if (is_numeric($search_opp_status) && $search_opp_status > 0) {
530  $sql .= " AND p.fk_opp_status = ".((int) $search_opp_status);
531  }
532  if ($search_opp_status == 'all') {
533  $sql .= " AND (p.fk_opp_status IS NOT NULL AND p.fk_opp_status <> -1)";
534  }
535  if ($search_opp_status == 'openedopp') {
536  $sql .= " AND p.fk_opp_status IS NOT NULL AND p.fk_opp_status <> -1 AND p.fk_opp_status NOT IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON','LOST'))";
537  }
538  if ($search_opp_status == 'notopenedopp') {
539  $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1 OR p.fk_opp_status IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code = 'WON'))";
540  }
541  if ($search_opp_status == 'none') {
542  $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1)";
543  }
544 }
545 if ($search_public != '') {
546  $sql .= " AND p.public = ".((int) $search_public);
547 }
548 // For external user, no check is done on company permission because readability is managed by public status of project and assignement.
549 //if ($socid > 0) $sql.= " AND s.rowid = ".((int) $socid);
550 if ($search_sale > 0) {
551  $sql .= " AND sc.fk_user = ".((int) $search_sale);
552 }
553 // No check is done on company permission because readability is managed by public status of project and assignement.
554 //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id).") OR (s.rowid IS NULL))";
555 if ($search_project_user > 0) {
556  // TODO Replace this with a EXISTS and remove the link to table + DISTINCT
557  $sql .= " AND ecp.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listofprojectcontacttype))).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".((int) $search_project_user);
558 }
559 if ($search_project_contact > 0) {
560  // TODO Replace this with a EXISTS and remove the link to table + DISTINCT
561  $sql .= " AND ecp_contact.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listofprojectcontacttypeexternal))).") AND ecp_contact.element_id = p.rowid AND ecp_contact.fk_socpeople = ".((int) $search_project_contact);
562 }
563 if ($search_opp_amount != '') {
564  $sql .= natural_search('p.opp_amount', $search_opp_amount, 1);
565 }
566 if ($search_budget_amount != '') {
567  $sql .= natural_search('p.budget_amount', $search_budget_amount, 1);
568 }
569 if ($search_usage_opportunity != '' && $search_usage_opportunity >= 0) {
570  $sql .= natural_search('p.usage_opportunity', $search_usage_opportunity, 2);
571 }
572 if ($search_usage_task != '' && $search_usage_task >= 0) {
573  $sql .= natural_search('p.usage_task', $search_usage_task, 2);
574 }
575 if ($search_usage_bill_time != '' && $search_usage_bill_time >= 0) {
576  $sql .= natural_search('p.usage_bill_time', $search_usage_bill_time, 2);
577 }
578 if ($search_usage_event_organization != '' && $search_usage_event_organization >= 0) {
579  $sql .= natural_search('p.usage_organize_event', $search_usage_event_organization, 2);
580 }
581 if ($search_accept_conference_suggestions != '' && $search_accept_conference_suggestions >= 0) {
582  $sql .= natural_search('p.accept_conference_suggestions', $search_accept_conference_suggestions, 2);
583 }
584 if ($search_accept_booth_suggestions != '' && $search_accept_booth_suggestions >= 0) {
585  $sql .= natural_search('p.accept_booth_suggestions', $search_accept_booth_suggestions, 2);
586 }
587 if ($search_price_registration != '') {
588  $sql .= natural_search('p.price_registration', $search_price_registration, 1);
589 }
590 if ($search_price_booth != '') {
591  $sql .= natural_search('p.price_booth', $search_price_booth, 1);
592 }
593 if ($search_login) {
594  $sql .= natural_search(array('u.login', 'u.firstname', 'u.lastname'), $search_login);
595 }
596 if ($search_import_key) {
597  $sql .= natural_search(array('p.import_key'), $search_import_key);
598 }
599 // Search for tag/category ($searchCategoryProjectList is an array of ID)
600 $searchCategoryProjectList = $search_category_array;
601 $searchCategoryProjectOperator = 0;
602 if (!empty($searchCategoryProjectList)) {
603  $searchCategoryProjectSqlList = array();
604  $listofcategoryid = '';
605  foreach ($searchCategoryProjectList as $searchCategoryProject) {
606  if (intval($searchCategoryProject) == -2) {
607  $searchCategoryProjectSqlList[] = "NOT EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project)";
608  } elseif (intval($searchCategoryProject) > 0) {
609  if ($searchCategoryProjectOperator == 0) {
610  $searchCategoryProjectSqlList[] = " EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project AND ck.fk_categorie = ".((int) $searchCategoryProject).")";
611  } else {
612  $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject);
613  }
614  }
615  }
616  if ($listofcategoryid) {
617  $searchCategoryProjectSqlList[] = " EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
618  }
619  if ($searchCategoryProjectOperator == 1) {
620  if (!empty($searchCategoryProjectSqlList)) {
621  $sql .= " AND (".implode(' OR ', $searchCategoryProjectSqlList).")";
622  }
623  } else {
624  if (!empty($searchCategoryProjectSqlList)) {
625  $sql .= " AND (".implode(' AND ', $searchCategoryProjectSqlList).")";
626  }
627  }
628 }
629 $searchCategoryCustomerSqlList = array();
630 if ($searchCategoryCustomerOperator == 1) {
631  $existsCategoryCustomerList = array();
632  foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
633  if (intval($searchCategoryCustomer) == -2) {
634  $sqlCategoryCustomerNotExists = " NOT EXISTS (";
635  $sqlCategoryCustomerNotExists .= " SELECT cat_cus.fk_soc";
636  $sqlCategoryCustomerNotExists .= " FROM ".$db->prefix()."categorie_societe AS cat_cus";
637  $sqlCategoryCustomerNotExists .= " WHERE cat_cus.fk_soc = p.fk_soc";
638  $sqlCategoryCustomerNotExists .= " )";
639  $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists;
640  } elseif (intval($searchCategoryCustomer) > 0) {
641  $existsCategoryCustomerList[] = $db->escape($searchCategoryCustomer);
642  }
643  }
644  if (!empty($existsCategoryCustomerList)) {
645  $sqlCategoryCustomerExists = " EXISTS (";
646  $sqlCategoryCustomerExists .= " SELECT cat_cus.fk_soc";
647  $sqlCategoryCustomerExists .= " FROM ".$db->prefix()."categorie_societe AS cat_cus";
648  $sqlCategoryCustomerExists .= " WHERE cat_cus.fk_soc = p.fk_soc";
649  $sqlCategoryCustomerExists .= " AND cat_cus.fk_categorie IN (".$db->sanitize(implode(',', $existsCategoryCustomerList)).")";
650  $sqlCategoryCustomerExists .= " )";
651  $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerExists;
652  }
653  if (!empty($searchCategoryCustomerSqlList)) {
654  $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")";
655  }
656 } else {
657  foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
658  if (intval($searchCategoryCustomer) == -2) {
659  $sqlCategoryCustomerNotExists = " NOT EXISTS (";
660  $sqlCategoryCustomerNotExists .= " SELECT cat_cus.fk_soc";
661  $sqlCategoryCustomerNotExists .= " FROM ".$db->prefix()."categorie_societe AS cat_cus";
662  $sqlCategoryCustomerNotExists .= " WHERE cat_cus.fk_soc = p.fk_soc";
663  $sqlCategoryCustomerNotExists .= " )";
664  $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists;
665  } elseif (intval($searchCategoryCustomer) > 0) {
666  $searchCategoryCustomerSqlList[] = "p.fk_soc IN (SELECT fk_soc FROM ".$db->prefix()."categorie_societe WHERE fk_categorie = ".((int) $searchCategoryCustomer).")";
667  }
668  }
669  if (!empty($searchCategoryCustomerSqlList)) {
670  $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")";
671  }
672 }
673 // Add where from extra fields
674 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
675 // Add where from hooks
676 $parameters = array();
677 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
678 $sql .= $hookmanager->resPrint;
679 //print $sql;
680 
681 // Count total nb of records
682 $nbtotalofrecords = '';
683 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
684  /* The fast and low memory method to get and count full list converts the sql into a sql count */
685  $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
686  $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
687  $resql = $db->query($sqlforcount);
688  if ($resql) {
689  $objforcount = $db->fetch_object($resql);
690  $nbtotalofrecords = $objforcount->nbtotalofrecords;
691  } else {
692  dol_print_error($db);
693  }
694 
695  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
696  $page = 0;
697  $offset = 0;
698  }
699  $db->free($resql);
700 }
701 
702 // Complete request and execute it with limit
703 $sql .= $db->order($sortfield, $sortorder);
704 if ($limit) {
705  $sql .= $db->plimit($limit + 1, $offset);
706 }
707 
708 $resql = $db->query($sql);
709 if (!$resql) {
710  dol_print_error($db);
711  exit;
712 }
713 
714 $num = $db->num_rows($resql);
715 
716 // Direct jump if only one record found
717 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
718  $obj = $db->fetch_object($resql);
719  header("Location: ".DOL_URL_ROOT.'/projet/card.php?id='.$obj->id);
720  exit;
721 }
722 
723 
724 // Output page
725 // --------------------------------------------------------------------
726 
727 llxHeader('', $title, $help_url);
728 
729 $arrayofselected = is_array($toselect) ? $toselect : array();
730 
731 $param = '';
732 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
733  $param .= '&contextpage='.urlencode($contextpage);
734 }
735 if ($limit > 0 && $limit != $conf->liste_limit) {
736  $param .= '&limit='.((int) $limit);
737 }
738 if ($search_all != '') {
739  $param .= '&search_all='.urlencode($search_all);
740 }
741 if ($search_sday) {
742  $param .= '&search_sday='.urlencode($search_sday);
743 }
744 if ($search_smonth) {
745  $param .= '&search_smonth='.urlencode($search_smonth);
746 }
747 if ($search_syear) {
748  $param .= '&search_syear='.urlencode($search_syear);
749 }
750 if ($search_eday) {
751  $param .= '&search_eday='.urlencode($search_eday);
752 }
753 if ($search_emonth) {
754  $param .= '&search_emonth='.urlencode($search_emonth);
755 }
756 if ($search_eyear) {
757  $param .= '&search_eyear='.urlencode($search_eyear);
758 }
759 if ($search_date_start_startmonth) {
760  $param .= '&search_date_start_startmonth='.urlencode($search_date_start_startmonth);
761 }
762 if ($search_date_start_startyear) {
763  $param .= '&search_date_start_startyear='.urlencode($search_date_start_startyear);
764 }
765 if ($search_date_start_startday) {
766  $param .= '&search_date_start_startday='.urlencode($search_date_start_startday);
767 }
768 if ($search_date_start_start) {
769  $param .= '&search_date_start_start='.urlencode($search_date_start_start);
770 }
771 if ($search_date_start_endmonth) {
772  $param .= '&search_date_start_endmonth='.urlencode($search_date_start_endmonth);
773 }
774 if ($search_date_start_endyear) {
775  $param .= '&search_date_start_endyear='.urlencode($search_date_start_endyear);
776 }
777 if ($search_date_start_endday) {
778  $param .= '&search_date_start_endday='.urlencode($search_date_start_endday);
779 }
780 if ($search_date_start_end) {
781  $param .= '&search_date_start_end='.urlencode($search_date_start_end);
782 }
783 if ($search_date_end_startmonth) {
784  $param .= '&search_date_end_startmonth='.urlencode($search_date_end_startmonth);
785 }
786 if ($search_date_end_startyear) {
787  $param .= '&search_date_end_startyear='.urlencode($search_date_end_startyear);
788 }
789 if ($search_date_end_startday) {
790  $param .= '&search_date_end_startday='.urlencode($search_date_end_startday);
791 }
792 if ($search_date_end_start) {
793  $param .= '&search_date_end_start='.urlencode($search_date_end_start);
794 }
795 if ($search_date_end_endmonth) {
796  $param .= '&search_date_end_endmonth='.urlencode($search_date_end_endmonth);
797 }
798 if ($search_date_end_endyear) {
799  $param .= '&search_date_end_endyear='.urlencode($search_date_end_endyear);
800 }
801 if ($search_date_end_endday) {
802  $param .= '&search_date_end_endday='.urlencode($search_date_end_endday);
803 }
804 if ($search_date_end_end) {
805  $param .= '&search_date_end_end=' . urlencode($search_date_end_end);
806 }
807 if ($socid) {
808  $param .= '&socid='.urlencode($socid);
809 }
810 if ($search_ref != '') {
811  $param .= '&search_ref='.urlencode($search_ref);
812 }
813 if ($search_label != '') {
814  $param .= '&search_label='.urlencode($search_label);
815 }
816 if ($search_societe != '') {
817  $param .= '&search_societe='.urlencode($search_societe);
818 }
819 if ($search_societe_alias != '') {
820  $param .= '&search_societe_alias='.urlencode($search_societe_alias);
821 }
822 if ($search_status >= 0) {
823  $param .= '&search_status='.urlencode($search_status);
824 }
825 if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'openedopp', 'notopenedopp', 'none'))) {
826  $param .= '&search_opp_status='.urlencode($search_opp_status);
827 }
828 if ($search_opp_percent != '') {
829  $param .= '&search_opp_percent='.urlencode($search_opp_percent);
830 }
831 if ($search_public != '') {
832  $param .= '&search_public='.urlencode($search_public);
833 }
834 if ($search_project_user > 0) {
835  $param .= '&search_project_user='.urlencode($search_project_user);
836 }
837 if ($search_project_contact != '') {
838  $param .= '&search_project_contact='.urlencode($search_project_contact);
839 }
840 if ($search_sale > 0) {
841  $param .= '&search_sale='.urlencode($search_sale);
842 }
843 if ($search_opp_amount != '') {
844  $param .= '&search_opp_amount='.urlencode($search_opp_amount);
845 }
846 if ($search_budget_amount != '') {
847  $param .= '&search_budget_amount='.urlencode($search_budget_amount);
848 }
849 if ($search_usage_task != '') {
850  $param .= '&search_usage_task='.urlencode($search_usage_task);
851 }
852 if ($search_usage_bill_time != '') {
853  $param .= '&search_usage_opportunity='.urlencode($search_usage_bill_time);
854 }
855 if ($search_usage_event_organization != '') {
856  $param .= '&search_usage_event_organization='.urlencode($search_usage_event_organization);
857 }
858 if ($search_accept_conference_suggestions != '') {
859  $param .= '&search_accept_conference_suggestions='.urlencode($search_accept_conference_suggestions);
860 }
861 if ($search_accept_booth_suggestions != '') {
862  $param .= '&search_accept_booth_suggestions='.urlencode($search_accept_booth_suggestions);
863 }
864 if ($search_price_registration != '') {
865  $param .= '&search_price_registration='.urlencode($search_price_registration);
866 }
867 if ($search_price_booth != '') {
868  $param .= '&search_price_booth='.urlencode($search_price_booth);
869 }
870 if ($search_login) {
871  $param .= '&search_login='.urlencode($search_login);
872 }
873 if ($search_import_key) {
874  $param .= '&search_import_key='.urlencode($search_import_key);
875 }
876 if ($optioncss != '') {
877  $param .= '&optioncss='.urlencode($optioncss);
878 }
879 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
880  $param .= "&search_category_customer_list[]=".urlencode($searchCategoryCustomer);
881 }
882 // Add $param from extra fields
883 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
884 
885 // List of mass actions available
886 $arrayofmassactions = array(
887  'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
888  'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
889  //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
890  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
891 );
892 //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
893 if ($user->rights->projet->creer) {
894  $arrayofmassactions['close'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Close");
895  $arrayofmassactions['preaffectuser'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("AffectUser");
896 }
897 if ($user->rights->projet->supprimer) {
898  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
899 }
900 if (isModEnabled('category') && $user->rights->projet->creer) {
901  $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
902 }
903 if (in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preaffectuser'))) {
904  $arrayofmassactions = array();
905 }
906 
907 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
908 
909 $url = DOL_URL_ROOT.'/projet/card.php?action=create';
910 if (!empty($socid)) {
911  $url .= '&socid='.$socid;
912 }
913 if ($search_usage_event_organization == 1) {
914  $url .= '&usage_organize_event=1';
915 }
916 $newcardbutton = dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', $url, '', $user->rights->projet->creer);
917 
918 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
919 if ($optioncss != '') {
920  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
921 }
922 print '<input type="hidden" name="token" value="'.newToken().'">';
923 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
924 print '<input type="hidden" name="action" value="list">';
925 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
926 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
927 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
928 
929 // Show description of content
930 $texthelp = '';
931 if ($search_project_user == $user->id) {
932  $texthelp .= $langs->trans("MyProjectsDesc");
933 } else {
934  if ($user->rights->projet->all->lire && !$socid) {
935  $texthelp .= $langs->trans("ProjectsDesc");
936  } else {
937  $texthelp .= $langs->trans("ProjectsPublicDesc");
938  }
939 }
940 
941 print_barre_liste($form->textwithpicto($title, $texthelp), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit, 0, 0, 1);
942 
943 
944 $topicmail = "Information";
945 $modelmail = "project";
946 $objecttmp = new Project($db);
947 $trackid = 'proj'.$object->id;
948 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
949 
950 if ($search_all) {
951  foreach ($fieldstosearchall as $key => $val) {
952  $fieldstosearchall[$key] = $langs->trans($val);
953  }
954  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
955 }
956 
957 $moreforfilter = '';
958 
959 // If the user can view user other than himself
960 $moreforfilter .= '<div class="divsearchfield">';
961 $tmptitle = $langs->trans('ProjectsWithThisUserAsContact');
962 //$includeonly = 'hierarchyme';
963 $includeonly = '';
964 if (empty($user->rights->user->user->lire)) {
965  $includeonly = array($user->id);
966 }
967 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
968 $moreforfilter .= '</div>';
969 
970 $moreforfilter .= '<div class="divsearchfield">';
971 $tmptitle = $langs->trans('ProjectsWithThisContact');
972 $moreforfilter .= img_picto($tmptitle, 'contact', 'class="pictofixedwidth"').$form->selectcontacts(0, $search_project_contact ? $search_project_contact : '', 'search_project_contact', $tmptitle, '', '', 0, 'maxwidth250 widthcentpercentminusx');
973 $moreforfilter .= '</div>';
974 
975 // If the user can view thirdparties other than his'
976 if ($user->rights->user->user->lire) {
977  $langs->load("commercial");
978  $moreforfilter .= '<div class="divsearchfield">';
979  $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
980  $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx');
981  $moreforfilter .= '</div>';
982 }
983 
984 // Filter on categories
985 if (isModEnabled('categorie') && $user->rights->categorie->lire) {
986  $formcategory = new FormCategory($db);
987  $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array);
988 }
989 // Filter on customer categories
990 if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_PROJECT_LIST) && !empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
991  $moreforfilter .= '<div class="divsearchfield">';
992  $tmptitle = $langs->transnoentities('CustomersProspectsCategoriesShort');
993  $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
994  $categoriesArr = $form->select_all_categories(Categorie::TYPE_CUSTOMER, '', '', 64, 0, 1);
995  $categoriesArr[-2] = '- '.$langs->trans('NotCategorized').' -';
996  $moreforfilter .= Form::multiselectarray('search_category_customer_list', $categoriesArr, $searchCategoryCustomerList, 0, 0, 'minwidth300', 0, 0, '', 'category', $tmptitle);
997  $moreforfilter .= ' <input type="checkbox" class="valignmiddle" id="search_category_customer_operator" name="search_category_customer_operator" value="1"'.($searchCategoryCustomerOperator == 1 ? ' checked="checked"' : '').'/>';
998  $moreforfilter .= $form->textwithpicto('', $langs->trans('UseOrOperatorForCategories') . ' : ' . $tmptitle, 1, 'help', '', 0, 2, 'tooltip_cat_cus'); // Tooltip on click
999  $moreforfilter .= '</div>';
1000 }
1001 
1002 if (!empty($moreforfilter)) {
1003  print '<div class="liste_titre liste_titre_bydiv centpercent">';
1004  print $moreforfilter;
1005  $parameters = array();
1006  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
1007  print $hookmanager->resPrint;
1008  print '</div>';
1009 }
1010 
1011 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1012 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
1013 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
1014 
1015 
1016 print '<div class="div-table-responsive">';
1017 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1018 
1019 // Fields title search
1020 // --------------------------------------------------------------------
1021 print '<tr class="liste_titre_filter">';
1022 // Action column
1023 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1024  print '<td class="liste_titre maxwidthsearch">';
1025  $searchpicto = $form->showFilterButtons('left');
1026  print $searchpicto;
1027  print '</td>';
1028 }
1029 // Project ref
1030 if (!empty($arrayfields['p.ref']['checked'])) {
1031  print '<td class="liste_titre">';
1032  print '<input type="text" class="flat" name="search_ref" value="'.dol_escape_htmltag($search_ref).'" size="6">';
1033  print '</td>';
1034 }
1035 // Project label
1036 if (!empty($arrayfields['p.title']['checked'])) {
1037  print '<td class="liste_titre">';
1038  print '<input type="text" class="flat" name="search_label" size="8" value="'.dol_escape_htmltag($search_label).'">';
1039  print '</td>';
1040 }
1041 // Third party
1042 if (!empty($arrayfields['s.nom']['checked'])) {
1043  print '<td class="liste_titre">';
1044  if ($socid > 0) {
1045  $tmpthirdparty = new Societe($db);
1046  $tmpthirdparty->fetch($socid);
1047  $search_societe = $tmpthirdparty->name;
1048  }
1049  print '<input type="text" class="flat" name="search_societe" size="8" value="'.dol_escape_htmltag($search_societe).'">';
1050  print '</td>';
1051 }
1052 
1053 // Alias
1054 if (!empty($arrayfields['s.name_alias']['checked'])) {
1055  print '<td class="liste_titre">';
1056  if ($socid > 0) {
1057  $tmpthirdparty = new Societe($db);
1058  $tmpthirdparty->fetch($socid);
1059  $search_societe_alias = $tmpthirdparty->name_alias;
1060  }
1061  print '<input type="text" class="flat" name="search_societe_alias" size="8" value="'.dol_escape_htmltag($search_societe_alias).'">';
1062  print '</td>';
1063 }
1064 // Sale representative
1065 if (!empty($arrayfields['commercial']['checked'])) {
1066  print '<td class="liste_titre">&nbsp;</td>';
1067 }
1068 // Start date
1069 if (!empty($arrayfields['p.dateo']['checked'])) {
1070  print '<td class="liste_titre center nowraponall">';
1071  /*if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
1072  print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_sday" value="'.dol_escape_htmltag($search_sday).'">';
1073  }
1074  print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_smonth" value="'.dol_escape_htmltag($search_smonth).'">';
1075  print $formother->selectyear($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');*/
1076  print '<div class="nowrap">';
1077  print $form->selectDate($search_date_start_start ? $search_date_start_start : -1, 'search_date_start_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1078  print '</div>';
1079  print '<div class="nowrap">';
1080  print $form->selectDate($search_date_start_end ? $search_date_start_end : -1, 'search_date_start_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1081  print '</div>';
1082  print '</td>';
1083 }
1084 // End date
1085 if (!empty($arrayfields['p.datee']['checked'])) {
1086  print '<td class="liste_titre center nowraponall">';
1087  /*if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
1088  print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_eday" value="'.dol_escape_htmltag($search_eday).'">';
1089  }
1090  print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_emonth" value="'.dol_escape_htmltag($search_emonth).'">';
1091  print $formother->selectyear($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');*/
1092  print '<div class="nowrap">';
1093  print $form->selectDate($search_date_end_start ? $search_date_end_start : -1, 'search_date_end_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1094  print '</div>';
1095  print '<div class="nowrap">';
1096  print $form->selectDate($search_date_end_end ? $search_date_end_end : -1, 'search_date_end_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1097  print '</div>';
1098  print '</td>';
1099 }
1100 // Visibility
1101 if (!empty($arrayfields['p.public']['checked'])) {
1102  print '<td class="liste_titre center">';
1103  $array = array(''=>'', 0 => $langs->trans("PrivateProject"), 1 => $langs->trans("SharedProject"));
1104  print $form->selectarray('search_public', $array, $search_public, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth75');
1105  print '</td>';
1106 }
1107 if (!empty($arrayfields['c.assigned']['checked'])) {
1108  print '<td class="liste_titre center">';
1109  print '</td>';
1110 }
1111 // Opp status
1112 if (!empty($arrayfields['p.fk_opp_status']['checked'])) {
1113  print '<td class="liste_titre nowrap center">';
1114  print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 1, 1, 0, 'maxwidth125 nowrapoption', 1, 1);
1115  print '</td>';
1116 }
1117 if (!empty($arrayfields['p.opp_amount']['checked'])) {
1118  print '<td class="liste_titre nowrap right">';
1119  print '<input type="text" class="flat" name="search_opp_amount" size="3" value="'.$search_opp_amount.'">';
1120  print '</td>';
1121 }
1122 if (!empty($arrayfields['p.opp_percent']['checked'])) {
1123  print '<td class="liste_titre nowrap right">';
1124  print '<input type="text" class="flat" name="search_opp_percent" size="2" value="'.$search_opp_percent.'">';
1125  print '</td>';
1126 }
1127 if (!empty($arrayfields['opp_weighted_amount']['checked'])) {
1128  print '<td class="liste_titre nowrap right">';
1129  print '</td>';
1130 }
1131 if (!empty($arrayfields['p.budget_amount']['checked'])) {
1132  print '<td class="liste_titre nowrap right">';
1133  print '<input type="text" class="flat" name="search_budget_amount" size="4" value="'.$search_budget_amount.'">';
1134  print '</td>';
1135 }
1136 if (!empty($arrayfields['p.usage_opportunity']['checked'])) {
1137  print '<td class="liste_titre nowrap right">';
1138  print $form->selectyesno('search_usage_opportunity', $search_usage_opportunity, 1, false, 1);
1139  print '';
1140  print '</td>';
1141 }
1142 if (!empty($arrayfields['p.usage_task']['checked'])) {
1143  print '<td class="liste_titre nowrap right">';
1144  print $form->selectyesno('search_usage_task', $search_usage_task, 1, false, 1);
1145  print '</td>';
1146 }
1147 if (!empty($arrayfields['p.usage_bill_time']['checked'])) {
1148  print '<td class="liste_titre nowrap right">';
1149  print $form->selectyesno('search_usage_bill_time', $search_usage_bill_time, 1, false, 1);
1150  print '</td>';
1151 }
1152 if (!empty($arrayfields['p.usage_organize_event']['checked'])) {
1153  print '<td class="liste_titre nowrap right">';
1154  print $form->selectyesno('search_usage_event_organization', $search_usage_event_organization, 1, false, 1);
1155  print '</td>';
1156 }
1157 if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) {
1158  print '<td class="liste_titre nowrap right">';
1159  print $form->selectyesno('search_accept_conference_suggestions', $search_accept_conference_suggestions, 1, false, 1);
1160  print '</td>';
1161 }
1162 if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) {
1163  print '<td class="liste_titre nowrap right">';
1164  print $form->selectyesno('search_accept_booth_suggestions', $search_accept_booth_suggestions, 1, false, 1);
1165  print '</td>';
1166 }
1167 if (!empty($arrayfields['p.price_registration']['checked'])) {
1168  print '<td class="liste_titre nowrap right">';
1169  print '<input type="text" class="flat" name="search_price_registration" size="4" value="'.$search_price_registration.'">';
1170  print '</td>';
1171 }
1172 if (!empty($arrayfields['p.price_booth']['checked'])) {
1173  print '<td class="liste_titre nowrap right">';
1174  print '<input type="text" class="flat" name="search_price_booth" size="4" value="'.$search_price_booth.'">';
1175  print '</td>';
1176 }
1177 if (!empty($arrayfields['u.login']['checked'])) {
1178  // Author
1179  print '<td class="liste_titre" align="center">';
1180  print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
1181  print '</td>';
1182 }
1183 // Extra fields
1184 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1185 
1186 // Fields from hook
1187 $parameters = array('arrayfields'=>$arrayfields);
1188 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
1189 print $hookmanager->resPrint;
1190 if (!empty($arrayfields['p.datec']['checked'])) {
1191  // Date creation
1192  print '<td class="liste_titre">';
1193  print '</td>';
1194 }
1195 if (!empty($arrayfields['p.tms']['checked'])) {
1196  // Date modification
1197  print '<td class="liste_titre">';
1198  print '</td>';
1199 }
1200 if (!empty($arrayfields['p.email_msgid']['checked'])) {
1201  // Email msg id
1202  print '<td class="liste_titre">';
1203  print '</td>';
1204 }
1205 if (!empty($arrayfields['p.import_key']['checked'])) {
1206  // Import key
1207  print '<td class="liste_titre">';
1208  print '<input class="flat width75" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
1209  print '</td>';
1210 }
1211 if (!empty($arrayfields['p.fk_statut']['checked'])) {
1212  print '<td class="liste_titre center parentonrightofpage">';
1213  $arrayofstatus = array();
1214  foreach ($object->statuts_short as $key => $val) {
1215  $arrayofstatus[$key] = $langs->trans($val);
1216  }
1217  $arrayofstatus['99'] = $langs->trans("NotClosed").' ('.$langs->trans('Draft').' + '.$langs->trans('Opened').')';
1218  print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1);
1219  print '</td>';
1220 }
1221 // Action column
1222 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1223  print '<td class="liste_titre maxwidthsearch">';
1224  $searchpicto = $form->showFilterButtons();
1225  print $searchpicto;
1226  print '</td>';
1227 }
1228 print '</tr>'."\n";
1229 
1230 print '<tr class="liste_titre">';
1231 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1232  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1233 }
1234 if (!empty($arrayfields['p.ref']['checked'])) {
1235  print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder);
1236 }
1237 if (!empty($arrayfields['p.title']['checked'])) {
1238  print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder);
1239 }
1240 if (!empty($arrayfields['s.nom']['checked'])) {
1241  print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
1242 }
1243 if (!empty($arrayfields['s.name_alias']['checked'])) {
1244  print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder);
1245 }
1246 if (!empty($arrayfields['commercial']['checked'])) {
1247  print_liste_field_titre($arrayfields['commercial']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder, 'tdoverflowmax100imp ');
1248 }
1249 if (!empty($arrayfields['p.dateo']['checked'])) {
1250  print_liste_field_titre($arrayfields['p.dateo']['label'], $_SERVER["PHP_SELF"], "p.dateo", "", $param, '', $sortfield, $sortorder, 'center ');
1251 }
1252 if (!empty($arrayfields['p.datee']['checked'])) {
1253  print_liste_field_titre($arrayfields['p.datee']['label'], $_SERVER["PHP_SELF"], "p.datee", "", $param, '', $sortfield, $sortorder, 'center ');
1254 }
1255 if (!empty($arrayfields['p.public']['checked'])) {
1256  print_liste_field_titre($arrayfields['p.public']['label'], $_SERVER["PHP_SELF"], "p.public", "", $param, "", $sortfield, $sortorder, 'center ');
1257 }
1258 if (!empty($arrayfields['c.assigned']['checked'])) {
1259  print_liste_field_titre($arrayfields['c.assigned']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '');
1260 }
1261 if (!empty($arrayfields['p.fk_opp_status']['checked'])) {
1262  print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center ');
1263 }
1264 if (!empty($arrayfields['p.opp_amount']['checked'])) {
1265  print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right ');
1266 }
1267 if (!empty($arrayfields['p.opp_percent']['checked'])) {
1268  print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER['PHP_SELF'], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right ');
1269 }
1270 if (!empty($arrayfields['opp_weighted_amount']['checked'])) {
1271  print_liste_field_titre($arrayfields['opp_weighted_amount']['label'], $_SERVER['PHP_SELF'], 'opp_weighted_amount', '', $param, '', $sortfield, $sortorder, 'right ');
1272 }
1273 if (!empty($arrayfields['p.budget_amount']['checked'])) {
1274  print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right ');
1275 }
1276 if (!empty($arrayfields['p.usage_opportunity']['checked'])) {
1277  print_liste_field_titre($arrayfields['p.usage_opportunity']['label'], $_SERVER["PHP_SELF"], 'p.usage_opportunity', "", $param, '', $sortfield, $sortorder, 'right ');
1278 }
1279 if (!empty($arrayfields['p.usage_task']['checked'])) {
1280  print_liste_field_titre($arrayfields['p.usage_task']['label'], $_SERVER["PHP_SELF"], 'p.usage_task', "", $param, '', $sortfield, $sortorder, 'right ');
1281 }
1282 if (!empty($arrayfields['p.usage_bill_time']['checked'])) {
1283  print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right ');
1284 }
1285 if (!empty($arrayfields['p.usage_organize_event']['checked'])) {
1286  print_liste_field_titre($arrayfields['p.usage_organize_event']['label'], $_SERVER["PHP_SELF"], 'p.usage_organize_event', "", $param, '', $sortfield, $sortorder, 'right ');
1287 }
1288 if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) {
1289  print_liste_field_titre($arrayfields['p.accept_conference_suggestions']['label'], $_SERVER["PHP_SELF"], 'p.accept_conference_suggestions', "", $param, '', $sortfield, $sortorder, 'right ');
1290 }
1291 if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) {
1292  print_liste_field_titre($arrayfields['p.accept_booth_suggestions']['label'], $_SERVER["PHP_SELF"], 'p.accept_booth_suggestions', "", $param, '', $sortfield, $sortorder, 'right ');
1293 }
1294 if (!empty($arrayfields['p.price_registration']['checked'])) {
1295  print_liste_field_titre($arrayfields['p.price_registration']['label'], $_SERVER["PHP_SELF"], 'p.price_registration', "", $param, '', $sortfield, $sortorder, 'right ');
1296 }
1297 if (!empty($arrayfields['p.price_booth']['checked'])) {
1298  print_liste_field_titre($arrayfields['p.price_booth']['label'], $_SERVER["PHP_SELF"], 'p.price_booth', "", $param, '', $sortfield, $sortorder, 'right ');
1299 }
1300 if (!empty($arrayfields['u.login']['checked'])) {
1301  print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder);
1302 }
1303 // Extra fields
1304 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1305 // Hook fields
1306 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
1307 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1308 print $hookmanager->resPrint;
1309 if (!empty($arrayfields['p.datec']['checked'])) {
1310  print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1311 }
1312 if (!empty($arrayfields['p.tms']['checked'])) {
1313  print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1314 }
1315 if (!empty($arrayfields['p.email_msgid']['checked'])) {
1316  print_liste_field_titre($arrayfields['p.email_msgid']['label'], $_SERVER["PHP_SELF"], "p.email_msgid", "", $param, '', $sortfield, $sortorder, 'center ');
1317 }
1318 if (!empty($arrayfields['p.import_key']['checked'])) {
1319  print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, '');
1320 }
1321 if (!empty($arrayfields['p.fk_statut']['checked'])) {
1322  print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
1323 }
1324 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1325  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1326 }
1327 print "</tr>\n";
1328 
1329 $userstatic = new User($db);
1330 
1331 $i = 0;
1332 $totalarray = array(
1333  'nbfield' => 0,
1334  'val' => array(),
1335 );
1336 $imaxinloop = ($limit ? min($num, $limit) : $num);
1337 while ($i < $imaxinloop) {
1338  $obj = $db->fetch_object($resql);
1339  if (empty($obj)) {
1340  break; // Should not happen
1341  }
1342 
1343  $object->id = $obj->id;
1344  $object->user_author_id = $obj->fk_user_creat;
1345  $object->public = $obj->public;
1346  $object->ref = $obj->ref;
1347  $object->datee = $db->jdate($obj->date_end);
1348  $object->statut = $obj->status; // deprecated
1349  $object->status = $obj->status;
1350  $object->public = $obj->public;
1351  $object->opp_status = $obj->fk_opp_status;
1352  $object->title = $obj->title;
1353 
1354  $userAccess = $object->restrictedProjectArea($user); // why this ?
1355  if ($userAccess >= 0) {
1356  // Thirdparty
1357  $companystatic->id = $obj->socid;
1358  $companystatic->name = $obj->name;
1359  $companystatic->name_alias = $obj->alias;
1360  $companystatic->client = $obj->client;
1361  $companystatic->code_client = $obj->code_client;
1362  $companystatic->email = $obj->email;
1363  $companystatic->phone = $obj->phone;
1364  $companystatic->address = $obj->address;
1365  $companystatic->zip = $obj->zip;
1366  $companystatic->town = $obj->town;
1367  $companystatic->country_code = $obj->country_code;
1368 
1369  // Author
1370  $userstatic->id = $obj->fk_user_creat;
1371  $userstatic->login = $obj->login;
1372  $userstatic->lastname = $obj->lastname;
1373  $userstatic->firstname = $obj->firstname;
1374  $userstatic->email = $obj->user_email;
1375  $userstatic->statut = $obj->user_statut;
1376  $userstatic->entity = $obj->entity;
1377  $userstatic->photo = $obj->photo;
1378  $userstatic->office_phone = $obj->office_phone;
1379  $userstatic->office_fax = $obj->office_fax;
1380  $userstatic->user_mobile = $obj->user_mobile;
1381  $userstatic->job = $obj->job;
1382  $userstatic->gender = $obj->gender;
1383 
1384  print '<tr class="oddeven">';
1385 
1386  // Action column
1387  if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1388  print '<td class="nowrap center">';
1389  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1390  $selected = 0;
1391  if (in_array($obj->id, $arrayofselected)) {
1392  $selected = 1;
1393  }
1394  print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
1395  }
1396  print '</td>';
1397  if (!$i) {
1398  $totalarray['nbfield']++;
1399  }
1400  }
1401  // Project url
1402  if (!empty($arrayfields['p.ref']['checked'])) {
1403  print '<td class="nowraponall tdoverflowmax200" title="'.dol_escape_htmltag($object->ref).'">';
1404  print $object->getNomUrl(1, (!empty(GETPOST('search_usage_event_organization', 'int'))?'eventorganization':''));
1405  if ($object->hasDelay()) {
1406  print img_warning($langs->trans('Late'));
1407  }
1408  print '</td>';
1409  if (!$i) {
1410  $totalarray['nbfield']++;
1411  }
1412  }
1413  // Title
1414  if (!empty($arrayfields['p.title']['checked'])) {
1415  print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->title).'">';
1416  print $obj->title;
1417  print '</td>';
1418  if (!$i) {
1419  $totalarray['nbfield']++;
1420  }
1421  }
1422  // Company
1423  if (!empty($arrayfields['s.nom']['checked'])) {
1424  print '<td class="tdoverflowmax100">';
1425  if ($obj->socid) {
1426  print $companystatic->getNomUrl(1, '', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
1427  } else {
1428  print '&nbsp;';
1429  }
1430  print '</td>';
1431  if (!$i) {
1432  $totalarray['nbfield']++;
1433  }
1434  }
1435  // Alias
1436  if (!empty($arrayfields['s.name_alias']['checked'])) {
1437  print '<td class="tdoverflowmax100">';
1438  if ($obj->socid) {
1439  print $companystatic->name_alias;
1440  } else {
1441  print '&nbsp;';
1442  }
1443  print '</td>';
1444  if (!$i) {
1445  $totalarray['nbfield']++;
1446  }
1447  }
1448  // Sales Representatives
1449  if (!empty($arrayfields['commercial']['checked'])) {
1450  print '<td class="tdoverflowmax150">';
1451  if ($obj->socid) {
1452  $companystatic->id = $obj->socid;
1453  $companystatic->name = $obj->name;
1454  $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
1455  $nbofsalesrepresentative = count($listsalesrepresentatives);
1456  if ($nbofsalesrepresentative > 6) {
1457  // We print only number
1458  print $nbofsalesrepresentative;
1459  } elseif ($nbofsalesrepresentative > 0) {
1460  $userstatic = new User($db);
1461  $j = 0;
1462  foreach ($listsalesrepresentatives as $val) {
1463  $userstatic->id = $val['id'];
1464  $userstatic->lastname = $val['lastname'];
1465  $userstatic->firstname = $val['firstname'];
1466  $userstatic->email = $val['email'];
1467  $userstatic->statut = $val['statut'];
1468  $userstatic->entity = $val['entity'];
1469  $userstatic->photo = $val['photo'];
1470  $userstatic->login = $val['login'];
1471  $userstatic->office_phone = $val['office_phone'];
1472  $userstatic->office_fax = $val['office_fax'];
1473  $userstatic->user_mobile = $val['user_mobile'];
1474  $userstatic->job = $val['job'];
1475  $userstatic->gender = $val['gender'];
1476  print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
1477  $j++;
1478  if ($j < $nbofsalesrepresentative) {
1479  print ' ';
1480  }
1481  }
1482  }
1483  //else print $langs->trans("NoSalesRepresentativeAffected");
1484  } else {
1485  print '&nbsp;';
1486  }
1487  print '</td>';
1488  if (!$i) {
1489  $totalarray['nbfield']++;
1490  }
1491  }
1492 
1493  // Date start project
1494  if (!empty($arrayfields['p.dateo']['checked'])) {
1495  print '<td class="center">';
1496  print dol_print_date($db->jdate($obj->date_start), 'day');
1497  print '</td>';
1498  if (!$i) {
1499  $totalarray['nbfield']++;
1500  }
1501  }
1502  // Date end project
1503  if (!empty($arrayfields['p.datee']['checked'])) {
1504  print '<td class="center">';
1505  print dol_print_date($db->jdate($obj->date_end), 'day');
1506  print '</td>';
1507  if (!$i) {
1508  $totalarray['nbfield']++;
1509  }
1510  }
1511 
1512  // Visibility
1513  if (!empty($arrayfields['p.public']['checked'])) {
1514  print '<td class="center">';
1515  if ($obj->public) {
1516  print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
1517  //print $langs->trans('SharedProject');
1518  } else {
1519  print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
1520  //print $langs->trans('PrivateProject');
1521  }
1522  print '</td>';
1523  if (!$i) {
1524  $totalarray['nbfield']++;
1525  }
1526  }
1527  // Contacts of project
1528  if (!empty($arrayfields['c.assigned']['checked'])) {
1529  print '<td class="center nowraponall tdoverflowmax200">';
1530  $ifisrt = 1;
1531  foreach (array('internal', 'external') as $source) {
1532  $tab = $object->liste_contact(-1, $source, 0, '', 1);
1533  $numcontact = count($tab);
1534  if (!empty($numcontact)) {
1535  foreach ($tab as $contactproject) {
1536  //var_dump($contacttask);
1537  $cid = $contactproject['id'];
1538  if ($source == 'internal') {
1539  if (empty($conf->cache['user'][$cid])) {
1540  $c = new User($db);
1541  $c->fetch($cid);
1542  $conf->cache['user'][$cid] = $c;
1543  } else {
1544  $c = $conf->cache['user'][$cid];
1545  }
1546  } else {
1547  if (empty($conf->cache['contact'][$cid])) {
1548  $c = new Contact($db);
1549  $c->fetch($cid);
1550  $conf->cache['contact'][$cid] = $c;
1551  } else {
1552  $c = $conf->cache['contact'][$cid];
1553  }
1554  }
1555 
1556  if (!empty($c->photo)) {
1557  if (get_class($c) == 'User') {
1558  print $c->getNomUrl(-2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst'));
1559  } else {
1560  print $c->getNomUrl(-2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst'));
1561  }
1562  } else {
1563  if (get_class($c) == 'User') {
1564  print $c->getNomUrl(2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst'));
1565  } else {
1566  print $c->getNomUrl(2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst'));
1567  }
1568  }
1569  $ifisrt = 0;
1570  }
1571  }
1572  }
1573  print '</td>';
1574  if (!$i) {
1575  $totalarray['nbfield']++;
1576  }
1577  }
1578  // Opp Status
1579  if (!empty($arrayfields['p.fk_opp_status']['checked'])) {
1580  print '<td class="center">';
1581  if ($obj->opp_status_code) {
1582  print $langs->trans("OppStatus".$obj->opp_status_code);
1583  }
1584  print '</td>';
1585  if (!$i) {
1586  $totalarray['nbfield']++;
1587  }
1588  }
1589  // Opp Amount
1590  if (!empty($arrayfields['p.opp_amount']['checked'])) {
1591  print '<td class="right">';
1592  //if ($obj->opp_status_code)
1593  if (strcmp($obj->opp_amount, '')) {
1594  print '<span class="amount">'.price($obj->opp_amount, 1, $langs, 1, -1, -1, '').'</span>';
1595  if (empty($totalarray['val']['p.opp_amount'])) {
1596  $totalarray['val']['p.opp_amount'] = $obj->opp_amount;
1597  } else {
1598  $totalarray['val']['p.opp_amount'] += $obj->opp_amount;
1599  }
1600  }
1601  print '</td>';
1602  if (!$i) {
1603  $totalarray['nbfield']++;
1604  }
1605  if (!$i) {
1606  $totalarray['pos'][$totalarray['nbfield']] = 'p.opp_amount';
1607  }
1608  }
1609  // Opp percent
1610  if (!empty($arrayfields['p.opp_percent']['checked'])) {
1611  print '<td class="right">';
1612  if ($obj->opp_percent) {
1613  print price($obj->opp_percent, 1, $langs, 1, 0).'%';
1614  }
1615  print '</td>';
1616  if (!$i) {
1617  $totalarray['nbfield']++;
1618  }
1619  }
1620  // Opp weighted amount
1621  if (!empty($arrayfields['opp_weighted_amount']['checked'])) {
1622  if (!isset($totalarray['val']['opp_weighted_amount'])) {
1623  $totalarray['val']['opp_weighted_amount'] = 0;
1624  }
1625  print '<td align="right">';
1626  if ($obj->opp_weighted_amount) {
1627  print '<span class="amount">'.price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, '').'</span>';
1628  if (empty($totalarray['val']['opp_weighted_amount'])) {
1629  $totalarray['val']['opp_weighted_amount'] = $obj->opp_weighted_amount;
1630  } else {
1631  $totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount;
1632  }
1633  }
1634  print '</td>';
1635  if (!$i) {
1636  $totalarray['nbfield']++;
1637  }
1638  if (!$i) {
1639  $totalarray['pos'][$totalarray['nbfield']] = 'opp_weighted_amount';
1640  }
1641  }
1642  // Budget
1643  if (!empty($arrayfields['p.budget_amount']['checked'])) {
1644  print '<td class="right">';
1645  if ($obj->budget_amount != '') {
1646  print '<span class="amount">'.price($obj->budget_amount, 1, $langs, 1, -1, -1).'</span>';
1647  if (empty($totalarray['val']['p.budget_amount'])) {
1648  $totalarray['val']['p.budget_amount'] = $obj->budget_amount;
1649  } else {
1650  $totalarray['val']['p.budget_amount'] += $obj->budget_amount;
1651  }
1652  }
1653  print '</td>';
1654  if (!$i) {
1655  $totalarray['nbfield']++;
1656  }
1657  if (!$i) {
1658  $totalarray['pos'][$totalarray['nbfield']] = 'p.budget_amount';
1659  }
1660  }
1661  // Usage opportunity
1662  if (!empty($arrayfields['p.usage_opportunity']['checked'])) {
1663  print '<td class="right">';
1664  if ($obj->usage_opportunity) {
1665  print yn($obj->usage_opportunity);
1666  }
1667  print '</td>';
1668  if (!$i) {
1669  $totalarray['nbfield']++;
1670  }
1671  }
1672  // Usage task
1673  if (!empty($arrayfields['p.usage_task']['checked'])) {
1674  print '<td class="right">';
1675  if ($obj->usage_task) {
1676  print yn($obj->usage_task);
1677  }
1678  print '</td>';
1679  if (!$i) {
1680  $totalarray['nbfield']++;
1681  }
1682  }
1683  // Bill time
1684  if (!empty($arrayfields['p.usage_bill_time']['checked'])) {
1685  print '<td class="right">';
1686  if ($obj->usage_bill_time) {
1687  print yn($obj->usage_bill_time);
1688  }
1689  print '</td>';
1690  if (!$i) {
1691  $totalarray['nbfield']++;
1692  }
1693  }
1694  // Event Organization
1695  if (!empty($arrayfields['p.usage_organize_event']['checked'])) {
1696  print '<td class="right">';
1697  if ($obj->usage_organize_event) {
1698  print yn($obj->usage_organize_event);
1699  }
1700  print '</td>';
1701  if (!$i) {
1702  $totalarray['nbfield']++;
1703  }
1704  }
1705  // Allow unknown people to suggest conferences
1706  if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) {
1707  print '<td class="right">';
1708  if ($obj->accept_conference_suggestions) {
1709  print yn($obj->accept_conference_suggestions);
1710  }
1711  print '</td>';
1712  if (!$i) {
1713  $totalarray['nbfield']++;
1714  }
1715  }
1716  // Allow unknown people to suggest booth
1717  if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) {
1718  print '<td class="right">';
1719  if ($obj->accept_booth_suggestions) {
1720  print yn($obj->accept_booth_suggestions);
1721  }
1722  print '</td>';
1723  if (!$i) {
1724  $totalarray['nbfield']++;
1725  }
1726  }
1727  // Price of registration
1728  if (!empty($arrayfields['p.price_registration']['checked'])) {
1729  print '<td class="right">';
1730  if ($obj->price_registration != '') {
1731  print '<span class="amount">'.price($obj->price_registration, 1, $langs, 1, -1, -1).'</span>';
1732  $totalarray['val']['p.price_registration'] += $obj->price_registration;
1733  }
1734  print '</td>';
1735  if (!$i) {
1736  $totalarray['nbfield']++;
1737  }
1738  if (!$i) {
1739  $totalarray['pos'][$totalarray['nbfield']] = 'p.price_registration';
1740  }
1741  }
1742  // Price of booth
1743  if (!empty($arrayfields['p.price_booth']['checked'])) {
1744  print '<td class="right">';
1745  if ($obj->price_booth != '') {
1746  print '<span class="amount">'.price($obj->price_booth, 1, $langs, 1, -1, -1).'</span>';
1747  $totalarray['val']['p.price_booth'] += $obj->price_booth;
1748  }
1749  print '</td>';
1750  if (!$i) {
1751  $totalarray['nbfield']++;
1752  }
1753  if (!$i) {
1754  $totalarray['pos'][$totalarray['nbfield']] = 'p.price_booth';
1755  }
1756  }
1757 
1758  if (!empty($arrayfields['u.login']['checked'])) {
1759  print '<td class="center tdoverflowmax150">';
1760  if ($userstatic->id) {
1761  print $userstatic->getNomUrl(-1);
1762  } else {
1763  print '&nbsp;';
1764  }
1765  print "</td>\n";
1766  if (!$i) {
1767  $totalarray['nbfield']++;
1768  }
1769  }
1770  // Extra fields
1771  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1772  // Fields from hook
1773  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1774  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1775  print $hookmanager->resPrint;
1776  // Date creation
1777  if (!empty($arrayfields['p.datec']['checked'])) {
1778  print '<td class="center nowraponall">';
1779  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1780  print '</td>';
1781  if (!$i) {
1782  $totalarray['nbfield']++;
1783  }
1784  }
1785  // Date modification
1786  if (!empty($arrayfields['p.tms']['checked'])) {
1787  print '<td class="center nowraponall">';
1788  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1789  print '</td>';
1790  if (!$i) {
1791  $totalarray['nbfield']++;
1792  }
1793  }
1794  // Email MsgID
1795  if (!empty($arrayfields['p.email_msgid']['checked'])) {
1796  print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($obj->email_msgid).'">';
1797  print dol_escape_htmltag($obj->email_msgid);
1798  print '</td>';
1799  if (!$i) {
1800  $totalarray['nbfield']++;
1801  }
1802  }
1803  // Import key
1804  if (!empty($arrayfields['p.import_key']['checked'])) {
1805  print '<td class="right">'.dol_escape_htmltag($obj->import_key).'</td>';
1806  if (!$i) {
1807  $totalarray['nbfield']++;
1808  }
1809  }
1810  // Status
1811  if (!empty($arrayfields['p.fk_statut']['checked'])) {
1812  print '<td class="center">'.$object->getLibStatut(5).'</td>';
1813  if (!$i) {
1814  $totalarray['nbfield']++;
1815  }
1816  }
1817  // Action column
1818  if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1819  print '<td class="nowrap center">';
1820  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1821  $selected = 0;
1822  if (in_array($obj->id, $arrayofselected)) {
1823  $selected = 1;
1824  }
1825  print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
1826  }
1827  print '</td>';
1828  if (!$i) {
1829  $totalarray['nbfield']++;
1830  }
1831  }
1832 
1833  print "</tr>\n";
1834  }
1835 
1836  $i++;
1837 }
1838 
1839 // Show total line
1840 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1841 
1842 // If no record found
1843 if ($num == 0) {
1844  $colspan = 1;
1845  foreach ($arrayfields as $key => $val) {
1846  if (!empty($val['checked'])) {
1847  $colspan++;
1848  }
1849  }
1850  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1851 }
1852 
1853 $db->free($resql);
1854 
1855 $parameters = array('arrayfields'=>$arrayfields, 'sql' => $sql);
1856 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1857 print $hookmanager->resPrint;
1858 
1859 print "</table>\n";
1860 print '</div>';
1861 
1862 print "</form>\n";
1863 
1864 // End of page
1865 llxFooter();
1866 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
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
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage contact/addresses.
Class to manage standard extra fields.
Class to manage forms for categories.
Class to build HTML component for third parties management Only common components are here.
Class to manage generation of HTML components Only common components must be here.
static multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $morecss='', $translate=0, $width=0, $moreattrib='', $elemtype='', $placeholder='', $addjscombo=-1)
Show a multiselect form from an array.
Classe permettant la generation de composants html autre Only common components are here.
Class to manage building of HTML components.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage tasks.
Definition: task.class.php:38
Class to manage Dolibarr users.
Definition: user.class.php:47
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)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
Definition: date.lib.php:358
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_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.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
$nbtotalofrecords
Count total nb of records.
Definition: list.php:329
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.