dolibarr  16.0.5
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 require '../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
37 
38 if (!empty($conf->categorie->enabled)) {
39  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
40  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
41 }
42 
43 // Load translation files required by the page
44 $langs->loadLangs(array('projects', 'companies', 'commercial'));
45 if (!empty($conf->eventorganization->enabled) && $conf->eventorganization->enabled) {
46  $langs->loadLangs(array('eventorganization'));
47 }
48 
49 $action = GETPOST('action', 'aZ09');
50 $massaction = GETPOST('massaction', 'alpha');
51 $show_files = GETPOST('show_files', 'int');
52 $confirm = GETPOST('confirm', 'alpha');
53 $toselect = GETPOST('toselect', 'array');
54 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'projectlist';
55 
56 $title = $langs->trans("Projects");
57 
58 // Security check
59 $socid = GETPOST('socid', 'int');
60 //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.
61 if ($socid > 0) {
62  $soc = new Societe($db);
63  $soc->fetch($socid);
64  $title .= ' (<a href="list.php">'.$soc->name.'</a>)';
65 }
66 if (!$user->rights->projet->lire) {
68 }
69 
70 $diroutputmassaction = $conf->project->dir_output.'/temp/massgeneration/'.$user->id;
71 
72 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
73 $sortfield = GETPOST('sortfield', 'aZ09comma');
74 $sortorder = GETPOST('sortorder', 'aZ09comma');
75 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
76 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
77  // If $page is not defined, or '' or -1 or if we click on clear filters
78  $page = 0;
79 }
80 if (!$sortfield) {
81  $sortfield = "p.ref";
82 }
83 if (!$sortorder) {
84  $sortorder = "ASC";
85 }
86 $offset = $limit * $page;
87 $pageprev = $page - 1;
88 $pagenext = $page + 1;
89 
90 $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
91 $search_ref = GETPOST("search_ref", 'alpha');
92 $search_label = GETPOST("search_label", 'alpha');
93 $search_societe = GETPOST("search_societe", 'alpha');
94 $search_status = GETPOST("search_status", 'int');
95 $search_opp_status = GETPOST("search_opp_status", 'alpha');
96 $search_opp_percent = GETPOST("search_opp_percent", 'alpha');
97 $search_opp_amount = GETPOST("search_opp_amount", 'alpha');
98 $search_budget_amount = GETPOST("search_budget_amount", 'alpha');
99 $search_public = GETPOST("search_public", 'int');
100 $search_project_user = GETPOST('search_project_user', 'int');
101 $search_project_contact = GETPOST('search_project_contact', 'int');
102 $search_sale = GETPOST('search_sale', 'int');
103 $search_usage_opportunity = GETPOST('search_usage_opportunity', 'int');
104 $search_usage_task = GETPOST('search_usage_task', 'int');
105 $search_usage_bill_time = GETPOST('search_usage_bill_time', 'int');
106 $search_usage_event_organization = GETPOST('search_usage_event_organization', 'int');
107 $search_accept_conference_suggestions = GETPOST('search_accept_conference_suggestions', 'int');
108 $search_accept_booth_suggestions = GETPOST('search_accept_booth_suggestions', 'int');
109 $search_price_registration = GETPOST("search_price_registration", 'alpha');
110 $search_price_booth = GETPOST("search_price_booth", 'alpha');
111 $optioncss = GETPOST('optioncss', 'alpha');
112 
113 $mine = ((GETPOST('mode') == 'mine') ? 1 : 0);
114 if ($mine) {
115  $search_project_user = $user->id; $mine = 0;
116 }
117 
118 $search_sday = GETPOST('search_sday', 'int');
119 $search_smonth = GETPOST('search_smonth', 'int');
120 $search_syear = GETPOST('search_syear', 'int');
121 $search_eday = GETPOST('search_eday', 'int');
122 $search_emonth = GETPOST('search_emonth', 'int');
123 $search_eyear = GETPOST('search_eyear', 'int');
124 
125 
126 $search_date_start_startmonth = GETPOST('search_date_start_startmonth', 'int');
127 $search_date_start_startyear = GETPOST('search_date_start_startyear', 'int');
128 $search_date_start_startday = GETPOST('search_date_start_startday', 'int');
129 $search_date_start_start = dol_mktime(0, 0, 0, $search_date_start_startmonth, $search_date_start_startday, $search_date_start_startyear); // Use tzserver
130 $search_date_start_endmonth = GETPOST('search_date_start_endmonth', 'int');
131 $search_date_start_endyear = GETPOST('search_date_start_endyear', 'int');
132 $search_date_start_endday = GETPOST('search_date_start_endday', 'int');
133 $search_date_start_end = dol_mktime(23, 59, 59, $search_date_start_endmonth, $search_date_start_endday, $search_date_start_endyear); // Use tzserver
134 
135 $search_date_end_startmonth = GETPOST('search_date_end_startmonth', 'int');
136 $search_date_end_startyear = GETPOST('search_date_end_startyear', 'int');
137 $search_date_end_startday = GETPOST('search_date_end_startday', 'int');
138 $search_date_end_start = dol_mktime(0, 0, 0, $search_date_end_startmonth, $search_date_end_startday, $search_date_end_startyear); // Use tzserver
139 $search_date_end_endmonth = GETPOST('search_date_end_endmonth', 'int');
140 $search_date_end_endyear = GETPOST('search_date_end_endyear', 'int');
141 $search_date_end_endday = GETPOST('search_date_end_endday', 'int');
142 $search_date_end_end = dol_mktime(23, 59, 59, $search_date_end_endmonth, $search_date_end_endday, $search_date_end_endyear); // Use tzserver
143 
144 
145 if ($search_status == '') {
146  $search_status = -1; // -1 or 1
147 }
148 
149 if (!empty($conf->categorie->enabled)) {
150  $search_category_array = GETPOST("search_category_".Categorie::TYPE_PROJECT."_list", "array");
151 }
152 
153 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
154 $object = new Project($db);
155 $hookmanager->initHooks(array('projectlist'));
156 $extrafields = new ExtraFields($db);
157 
158 // fetch optionals attributes and labels
159 $extrafields->fetch_name_optionals_label($object->table_element);
160 
161 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
162 
163 // List of fields to search into when doing a "search in all"
164 $fieldstosearchall = array();
165 foreach ($object->fields as $key => $val) {
166  if (empty($val['searchall'])) {
167  continue;
168  }
169 
170  // Don't allow search in private notes for external users when doing "search in all"
171  if (!empty($user->socid) && $key == "note_private") {
172  continue;
173  }
174 
175  $fieldstosearchall['p.'.$key] = $val['label'];
176 }
177 
178 // Add name object fields to "search in all"
179 $fieldstosearchall['s.nom'] = "ThirdPartyName";
180 
181 // Definition of array of fields for columns
182 $arrayfields = array();
183 foreach ($object->fields as $key => $val) {
184  // If $val['visible']==0, then we never show the field
185  if (!empty($val['visible'])) {
186  $visible = dol_eval($val['visible'], 1, 1, '1');
187  $arrayfields['p.'.$key] = array(
188  'label'=>$val['label'],
189  'checked'=>(($visible < 0) ? 0 : 1),
190  'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
191  'position'=>$val['position'],
192  'help'=> isset($val['help']) ? $val['help'] : ''
193  );
194  }
195 }
196 // Extra fields
197 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
198 
199 // Add non object fields to fields for list
200 $arrayfields['s.nom'] = array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>21, 'enabled'=>(empty($conf->societe->enabled) ? 0 : 1));
201 $arrayfields['commercial'] = array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>0, 'position'=>23);
202 $arrayfields['c.assigned'] = array('label'=>$langs->trans("AssignedTo"), 'checked'=>-1, 'position'=>120);
203 $arrayfields['opp_weighted_amount'] = array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'position'=> 116, 'enabled'=>(empty($conf->global->PROJECT_USE_OPPORTUNITIES) ? 0 : 1), 'position'=>106);
204 // Force some fields according to search_usage filter...
205 if (GETPOST('search_usage_opportunity')) {
206  //$arrayfields['p.usage_opportunity']['visible'] = 1; // Not require, filter on search_opp_status is enough
207  //$arrayfields['p.usage_opportunity']['checked'] = 1; // Not require, filter on search_opp_status is enough
208 }
209 if (GETPOST('search_usage_event_organization')) {
210  $arrayfields['p.fk_opp_status']['enabled'] = 0;
211  $arrayfields['p.opp_amount']['enabled'] = 0;
212  $arrayfields['p.opp_percent']['enabled'] = 0;
213  $arrayfields['opp_weighted_amount']['enabled'] = 0;
214  $arrayfields['p.usage_organize_event']['visible'] = 1;
215  $arrayfields['p.usage_organize_event']['checked'] = 1;
216 }
217 
218 $object->fields = dol_sort_array($object->fields, 'position');
219 $arrayfields = dol_sort_array($arrayfields, 'position');
220 
221 
222 /*
223  * Actions
224  */
225 
226 if (GETPOST('cancel', 'alpha')) {
227  $action = 'list';
228  $massaction = '';
229 }
230 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
231  $massaction = '';
232 }
233 
234 $parameters = array('socid'=>$socid);
235 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
236 if ($reshook < 0) {
237  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
238 }
239 
240 if (empty($reshook)) {
241  // Selection of new fields
242  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
243 
244  // Purge search criteria
245  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
246  $search_all = '';
247  $search_ref = "";
248  $search_label = "";
249  $search_societe = "";
250  $search_status = -1;
251  $search_opp_status = -1;
252  $search_opp_amount = '';
253  $search_opp_percent = '';
254  $search_budget_amount = '';
255  $search_public = "";
256  $search_sale = "";
257  $search_project_user = '';
258  $search_project_contact = '';
259  $search_sday = "";
260  $search_smonth = "";
261  $search_syear = "";
262  $search_eday = "";
263  $search_emonth = "";
264  $search_eyear = "";
265  $search_date_start_startmonth = "";
266  $search_date_start_startyear = "";
267  $search_date_start_startday = "";
268  $search_date_start_start = "";
269  $search_date_start_endmonth = "";
270  $search_date_start_endyear = "";
271  $search_date_start_endday = "";
272  $search_date_start_end = "";
273  $search_date_end_startmonth = "";
274  $search_date_end_startyear = "";
275  $search_date_end_startday = "";
276  $search_date_end_start = "";
277  $search_date_end_endmonth = "";
278  $search_date_end_endyear = "";
279  $search_date_end_endday = "";
280  $search_date_end_end = "";
281  $search_usage_opportunity = '';
282  $search_usage_task = '';
283  $search_usage_bill_time = '';
284  $search_usage_event_organization = '';
285  $search_accept_conference_suggestions = '';
286  $search_accept_booth_suggestions = '';
287  $search_price_registration = '';
288  $search_price_booth = '';
289  $toselect = array();
290  $search_array_options = array();
291  $search_category_array = array();
292  }
293 
294 
295  // Mass actions
296  $objectclass = 'Project';
297  $objectlabel = 'Project';
298  $permissiontoread = $user->rights->projet->lire;
299  $permissiontodelete = $user->rights->projet->supprimer;
300  $permissiontoadd = $user->rights->projet->creer;
301  $uploaddir = $conf->project->dir_output;
302  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
303 
304  // Close records
305  if (!$error && $massaction == 'close' && $user->rights->projet->creer) {
306  $db->begin();
307 
308  $objecttmp = new $objectclass($db);
309  $nbok = 0;
310  foreach ($toselect as $toselectid) {
311  $result = $objecttmp->fetch($toselectid);
312  if ($result > 0) {
313  $userWrite = $object->restrictedProjectArea($user, 'write');
314  if ($userWrite > 0 && $objecttmp->statut == 1) {
315  $result = $objecttmp->setClose($user);
316  if ($result <= 0) {
317  setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
318  $error++;
319  break;
320  } else {
321  $nbok++;
322  }
323  } elseif ($userWrite <= 0) {
324  setEventMessages($langs->trans("DontHavePermissionForCloseProject", $objecttmp->ref), null, 'warnings');
325  } else {
326  setEventMessages($langs->trans("DontHaveTheValidateStatus", $objecttmp->ref), null, 'warnings');
327  }
328  } else {
329  setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
330  $error++;
331  break;
332  }
333  }
334 
335  if (!$error) {
336  if ($nbok > 1) {
337  setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs');
338  } else {
339  setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs');
340  }
341  $db->commit();
342  } else {
343  $db->rollback();
344  }
345  }
346 }
347 
348 
349 /*
350  * View
351  */
352 
353 $form = new Form($db);
354 
355 $companystatic = new Societe($db);
356 $formother = new FormOther($db);
357 $formproject = new FormProjets($db);
358 
359 $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
360 $title = $langs->trans("LeadsOrProjects");
361 if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
362  $title = $langs->trans("Projects");
363 }
364 if (isset($conf->global->PROJECT_USE_OPPORTUNITIES) && $conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only
365  $title = $langs->trans("Leads");
366 }
367 $morejs = array();
368 $morecss = array();
369 
370 
371 // Get list of project id allowed to user (in a string list separated by comma)
372 $projectsListId = '';
373 if (empty($user->rights->projet->all->lire)) {
374  $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $socid);
375 }
376 
377 // Get id of types of contacts for projects (This list never contains a lot of elements)
378 $listofprojectcontacttype = array();
379 $listofprojectcontacttypeexternal = array();
380 $sql = "SELECT ctc.rowid, ctc.code, ctc.source FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
381 $sql .= " WHERE ctc.element = '".$db->escape($object->element)."'";
382 $resql = $db->query($sql);
383 if ($resql) {
384  while ($obj = $db->fetch_object($resql)) {
385  if ($obj->source == 'internal') $listofprojectcontacttype[$obj->rowid] = $obj->code;
386  else $listofprojectcontacttypeexternal[$obj->rowid] = $obj->code;
387  }
388 } else {
389  dol_print_error($db);
390 }
391 if (count($listofprojectcontacttype) == 0) {
392  $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found
393 }
394 if (count($listofprojectcontacttypeexternal) == 0) {
395  $listofprojectcontacttypeexternal[0] = '0'; // To avoid sql syntax error if not found
396 }
397 
398 $distinct = 'DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once.
399 $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,";
400 $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,";
401 $sql .= " p.usage_opportunity, p.usage_task, p.usage_bill_time, p.usage_organize_event,";
402 $sql .= " p.email_msgid,";
403 $sql .= " accept_conference_suggestions, accept_booth_suggestions, price_registration, price_booth,";
404 $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,";
405 $sql .= " country.code as country_code,";
406 $sql .= " cls.code as opp_status_code";
407 // Add fields from extrafields
408 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
409  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
410  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
411  }
412 }
413 // Add fields from hooks
414 $parameters = array();
415 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
416 $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
417 $sql = preg_replace('/,\s*$/', '', $sql);
418 $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as p";
419 if (!empty($conf->categorie->enabled)) {
420  $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_PROJECT, "p.rowid");
421 }
422 if (!empty($extrafields->attributes[$object->table_element]['label']) &&is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
423  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)";
424 }
425 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
426 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
427 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid";
428 // We'll need this table joined to the select in order to filter by sale
429 // No check is done on company permission because readability is managed by public status of project and assignement.
430 //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";
431 if ($search_sale > 0) {
432  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
433 }
434 if ($search_project_user > 0) {
435  $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp";
436 }
437 if ($search_project_contact > 0) {
438  $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp_contact";
439 }
440 $sql .= " WHERE p.entity IN (".getEntity('project').')';
441 if (!empty($conf->categorie->enabled)) {
442  $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_PROJECT, "p.rowid", $search_category_array);
443 }
444 if (empty($user->rights->projet->all->lire)) {
445  $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users
446 }
447 // No need to check if company is external user, as filtering of projects must be done by getProjectsAuthorizedForUser
448 if ($socid > 0) {
449  $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)
450 }
451 if ($search_ref) {
452  $sql .= natural_search('p.ref', $search_ref);
453 }
454 if ($search_label) {
455  $sql .= natural_search('p.title', $search_label);
456 }
457 if ($search_societe) {
458  $sql .= natural_search('s.nom', $search_societe);
459 }
460 if ($search_opp_amount) {
461  $sql .= natural_search('p.opp_amount', $search_opp_amount, 1);
462 }
463 if ($search_opp_percent) {
464  $sql .= natural_search('p.opp_percent', $search_opp_percent, 1);
465 }
466 $sql .= dolSqlDateFilter('p.dateo', $search_sday, $search_smonth, $search_syear);
467 $sql .= dolSqlDateFilter('p.datee', $search_eday, $search_emonth, $search_eyear);
468 
469 
470 if ($search_date_start_start) {
471  $sql .= " AND p.dateo >= '".$db->idate($search_date_start_start)."'";
472 }
473 if ($search_date_start_end) {
474  $sql .= " AND p.dateo <= '".$db->idate($search_date_start_end)."'";
475 }
476 
477 if ($search_date_end_start) {
478  $sql .= " AND p.datee >= '".$db->idate($search_date_end_start)."'";
479 }
480 if ($search_date_end_end) {
481  $sql .= " AND p.datee <= '".$db->idate($search_date_end_end)."'";
482 }
483 
484 if ($search_all) {
485  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
486 }
487 if ($search_status >= 0) {
488  if ($search_status == 99) {
489  $sql .= " AND p.fk_statut <> 2";
490  } else {
491  $sql .= " AND p.fk_statut = ".((int) $search_status);
492  }
493 }
494 if ($search_opp_status) {
495  if (is_numeric($search_opp_status) && $search_opp_status > 0) {
496  $sql .= " AND p.fk_opp_status = ".((int) $search_opp_status);
497  }
498  if ($search_opp_status == 'all') {
499  $sql .= " AND (p.fk_opp_status IS NOT NULL AND p.fk_opp_status <> -1)";
500  }
501  if ($search_opp_status == 'openedopp') {
502  $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'))";
503  }
504  if ($search_opp_status == 'notopenedopp') {
505  $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'))";
506  }
507  if ($search_opp_status == 'none') {
508  $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1)";
509  }
510 }
511 if ($search_public != '') {
512  $sql .= " AND p.public = ".((int) $search_public);
513 }
514 // For external user, no check is done on company permission because readability is managed by public status of project and assignement.
515 //if ($socid > 0) $sql.= " AND s.rowid = ".((int) $socid);
516 if ($search_sale > 0) {
517  $sql .= " AND sc.fk_user = ".((int) $search_sale);
518 }
519 // No check is done on company permission because readability is managed by public status of project and assignement.
520 //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))";
521 if ($search_project_user > 0) {
522  $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);
523 }
524 if ($search_project_contact > 0) {
525  $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);
526 }
527 if ($search_opp_amount != '') {
528  $sql .= natural_search('p.opp_amount', $search_opp_amount, 1);
529 }
530 if ($search_budget_amount != '') {
531  $sql .= natural_search('p.budget_amount', $search_budget_amount, 1);
532 }
533 if ($search_usage_opportunity != '' && $search_usage_opportunity >= 0) {
534  $sql .= natural_search('p.usage_opportunity', $search_usage_opportunity, 2);
535 }
536 if ($search_usage_task != '' && $search_usage_task >= 0) {
537  $sql .= natural_search('p.usage_task', $search_usage_task, 2);
538 }
539 if ($search_usage_bill_time != '' && $search_usage_bill_time >= 0) {
540  $sql .= natural_search('p.usage_bill_time', $search_usage_bill_time, 2);
541 }
542 if ($search_usage_event_organization != '' && $search_usage_event_organization >= 0) {
543  $sql .= natural_search('p.usage_organize_event', $search_usage_event_organization, 2);
544 }
545 if ($search_accept_conference_suggestions != '' && $search_accept_conference_suggestions >= 0) {
546  $sql .= natural_search('p.accept_conference_suggestions', $search_accept_conference_suggestions, 2);
547 }
548 if ($search_accept_booth_suggestions != '' && $search_accept_booth_suggestions >= 0) {
549  $sql .= natural_search('p.accept_booth_suggestions', $search_accept_booth_suggestions, 2);
550 }
551 if ($search_price_registration != '') {
552  $sql .= natural_search('p.price_registration', $search_price_registration, 1);
553 }
554 if ($search_price_booth != '') {
555  $sql .= natural_search('p.price_booth', $search_price_booth, 1);
556 }
557 // Add where from extra fields
558 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
559 // Add where from hooks
560 $parameters = array();
561 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
562 $sql .= $hookmanager->resPrint;
563 $sql .= $db->order($sortfield, $sortorder);
564 
565 // Count total nb of records
566 $nbtotalofrecords = '';
567 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
568  $resql = $db->query($sql);
569  $nbtotalofrecords = $db->num_rows($resql);
570  if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
571  $page = 0;
572  $offset = 0;
573  }
574 }
575 // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
576 if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
577  $num = $nbtotalofrecords;
578 } else {
579  if (!empty($limit)) {
580  $sql .= $db->plimit($limit + 1, $offset);
581  }
582 
583  $resql = $db->query($sql);
584  if (!$resql) {
585  dol_print_error($db);
586  exit;
587  }
588 
589  $num = $db->num_rows($resql);
590 }
591 
592 // Direct jump if only one record found
593 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) {
594  $obj = $db->fetch_object($resql);
595  header("Location: ".DOL_URL_ROOT.'/projet/card.php?id='.$obj->id);
596  exit;
597 }
598 
599 
600 // Output page
601 // --------------------------------------------------------------------
602 
603 dol_syslog("list allowed project", LOG_DEBUG);
604 
605 llxHeader('', $title, $help_url);
606 
607 $arrayofselected = is_array($toselect) ? $toselect : array();
608 
609 $param = '';
610 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
611  $param .= '&contextpage='.urlencode($contextpage);
612 }
613 if ($limit > 0 && $limit != $conf->liste_limit) {
614  $param .= '&limit='.urlencode($limit);
615 }
616 if ($search_all != '') {
617  $param .= '&search_all='.urlencode($search_all);
618 }
619 if ($search_sday) {
620  $param .= '&search_sday='.urlencode($search_sday);
621 }
622 if ($search_smonth) {
623  $param .= '&search_smonth='.urlencode($search_smonth);
624 }
625 if ($search_syear) {
626  $param .= '&search_syear='.urlencode($search_syear);
627 }
628 if ($search_eday) {
629  $param .= '&search_eday='.urlencode($search_eday);
630 }
631 if ($search_emonth) {
632  $param .= '&search_emonth='.urlencode($search_emonth);
633 }
634 if ($search_eyear) {
635  $param .= '&search_eyear='.urlencode($search_eyear);
636 }
637 if ($search_date_start_startmonth) {
638  $param .= '&search_date_start_startmonth='.urlencode($search_date_start_startmonth);
639 }
640 if ($search_date_start_startyear) {
641  $param .= '&search_date_start_startyear='.urlencode($search_date_start_startyear);
642 }
643 if ($search_date_start_startday) {
644  $param .= '&search_date_start_startday='.urlencode($search_date_start_startday);
645 }
646 if ($search_date_start_start) {
647  $param .= '&search_date_start_start='.urlencode($search_date_start_start);
648 }
649 if ($search_date_start_endmonth) {
650  $param .= '&search_date_start_endmonth='.urlencode($search_date_start_endmonth);
651 }
652 if ($search_date_start_endyear) {
653  $param .= '&search_date_start_endyear='.urlencode($search_date_start_endyear);
654 }
655 if ($search_date_start_endday) {
656  $param .= '&search_date_start_endday='.urlencode($search_date_start_endday);
657 }
658 if ($search_date_start_end) {
659  $param .= '&search_date_start_end='.urlencode($search_date_start_end);
660 }
661 if ($search_date_end_startmonth) {
662  $param .= '&search_date_end_startmonth='.urlencode($search_date_end_startmonth);
663 }
664 if ($search_date_end_startyear) {
665  $param .= '&search_date_end_startyear='.urlencode($search_date_end_startyear);
666 }
667 if ($search_date_end_startday) {
668  $param .= '&search_date_end_startday='.urlencode($search_date_end_startday);
669 }
670 if ($search_date_end_start) {
671  $param .= '&search_date_end_start='.urlencode($search_date_end_start);
672 }
673 if ($search_date_end_endmonth) {
674  $param .= '&search_date_end_endmonth='.urlencode($search_date_end_endmonth);
675 }
676 if ($search_date_end_endyear) {
677  $param .= '&search_date_end_endyear='.urlencode($search_date_end_endyear);
678 }
679 if ($search_date_end_endday) {
680  $param .= '&search_date_end_endday='.urlencode($search_date_end_endday);
681 }
682 if ($search_date_end_end) {
683  $param .= '&search_date_end_end=' . urlencode($search_date_end_end);
684 }
685 if ($socid) {
686  $param .= '&socid='.urlencode($socid);
687 }
688 if (!empty($search_categ)) {
689  $param .= '&search_categ='.urlencode($search_categ);
690 }
691 if ($search_ref != '') {
692  $param .= '&search_ref='.urlencode($search_ref);
693 }
694 if ($search_label != '') {
695  $param .= '&search_label='.urlencode($search_label);
696 }
697 if ($search_societe != '') {
698  $param .= '&search_societe='.urlencode($search_societe);
699 }
700 if ($search_status >= 0) {
701  $param .= '&search_status='.urlencode($search_status);
702 }
703 if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'openedopp', 'notopenedopp', 'none'))) {
704  $param .= '&search_opp_status='.urlencode($search_opp_status);
705 }
706 if ($search_opp_percent != '') {
707  $param .= '&search_opp_percent='.urlencode($search_opp_percent);
708 }
709 if ($search_public != '') {
710  $param .= '&search_public='.urlencode($search_public);
711 }
712 if ($search_project_user > 0) {
713  $param .= '&search_project_user='.urlencode($search_project_user);
714 }
715 if ($search_project_contact != '') {
716  $param .= '&search_project_user='.urlencode($search_project_contact);
717 }
718 if ($search_sale > 0) {
719  $param .= '&search_sale='.urlencode($search_sale);
720 }
721 if ($search_opp_amount != '') {
722  $param .= '&search_opp_amount='.urlencode($search_opp_amount);
723 }
724 if ($search_budget_amount != '') {
725  $param .= '&search_budget_amount='.urlencode($search_budget_amount);
726 }
727 if ($search_usage_task != '') {
728  $param .= '&search_usage_task='.urlencode($search_usage_task);
729 }
730 if ($search_usage_bill_time != '') {
731  $param .= '&search_usage_opportunity='.urlencode($search_usage_bill_time);
732 }
733 if ($search_usage_event_organization != '') {
734  $param .= '&search_usage_event_organization='.urlencode($search_usage_event_organization);
735 }
736 if ($search_accept_conference_suggestions != '') {
737  $param .= '&search_accept_conference_suggestions='.urlencode($search_accept_conference_suggestions);
738 }
739 if ($search_accept_booth_suggestions != '') {
740  $param .= '&search_accept_booth_suggestions='.urlencode($search_accept_booth_suggestions);
741 }
742 if ($search_price_registration != '') {
743  $param .= '&search_price_registration='.urlencode($search_price_registration);
744 }
745 if ($search_price_booth != '') {
746  $param .= '&search_price_booth='.urlencode($search_price_booth);
747 }
748 if ($optioncss != '') {
749  $param .= '&optioncss='.urlencode($optioncss);
750 }
751 // Add $param from extra fields
752 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
753 
754 // List of mass actions available
755 $arrayofmassactions = array(
756  'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
757  //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
758  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
759 );
760 //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
761 if ($user->rights->projet->creer) {
762  $arrayofmassactions['close'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Close");
763 }
764 if ($user->rights->projet->supprimer) {
765  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
766 }
767 if (isModEnabled('category') && $user->rights->projet->creer) {
768  $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
769 }
770 if (in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) {
771  $arrayofmassactions = array();
772 }
773 
774 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
775 
776 $url = DOL_URL_ROOT.'/projet/card.php?action=create';
777 if (!empty($socid)) {
778  $url .= '&socid='.$socid;
779 }
780 if ($search_usage_event_organization == 1) {
781  $url .= '&usage_organize_event=1';
782 }
783 $newcardbutton = dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', $url, '', $user->rights->projet->creer);
784 
785 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
786 if ($optioncss != '') {
787  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
788 }
789 print '<input type="hidden" name="token" value="'.newToken().'">';
790 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
791 print '<input type="hidden" name="action" value="list">';
792 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
793 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
794 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
795 
796 // Show description of content
797 $texthelp = '';
798 if ($search_project_user == $user->id) {
799  $texthelp .= $langs->trans("MyProjectsDesc");
800 } else {
801  if ($user->rights->projet->all->lire && !$socid) {
802  $texthelp .= $langs->trans("ProjectsDesc");
803  } else {
804  $texthelp .= $langs->trans("ProjectsPublicDesc");
805  }
806 }
807 
808 print_barre_liste($form->textwithpicto($title, $texthelp), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit, 0, 0, 1);
809 
810 
811 $topicmail = "Information";
812 $modelmail = "project";
813 $objecttmp = new Project($db);
814 $trackid = 'proj'.$object->id;
815 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
816 
817 if ($search_all) {
818  foreach ($fieldstosearchall as $key => $val) {
819  $fieldstosearchall[$key] = $langs->trans($val);
820  }
821  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
822 }
823 
824 $moreforfilter = '';
825 
826 // If the user can view user other than himself
827 $moreforfilter .= '<div class="divsearchfield">';
828 $tmptitle = $langs->trans('ProjectsWithThisUserAsContact');
829 //$includeonly = 'hierarchyme';
830 $includeonly = '';
831 if (empty($user->rights->user->user->lire)) {
832  $includeonly = array($user->id);
833 }
834 $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');
835 $moreforfilter .= '</div>';
836 
837 $moreforfilter .= '<div class="divsearchfield">';
838 $tmptitle = $langs->trans('ProjectsWithThisContact');
839 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->selectcontacts(0, $search_project_contact ? $search_project_contact : '', 'search_project_contact', $tmptitle, '', '', 0, 'maxwidth250 widthcentpercentminusx');
840 $moreforfilter .= '</div>';
841 
842 // If the user can view thirdparties other than his'
843 if ($user->rights->user->user->lire) {
844  $langs->load("commercial");
845  $moreforfilter .= '<div class="divsearchfield">';
846  $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
847  $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx');
848  $moreforfilter .= '</div>';
849 }
850 
851 // Filter on categories
852 if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
853  $formcategory = new FormCategory($db);
854  $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array);
855 }
856 
857 if (!empty($moreforfilter)) {
858  print '<div class="liste_titre liste_titre_bydiv centpercent">';
859  print $moreforfilter;
860  $parameters = array();
861  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
862  print $hookmanager->resPrint;
863  print '</div>';
864 }
865 
866 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
867 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
868 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
869 
870 
871 print '<div class="div-table-responsive">';
872 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
873 
874 // Fields title search
875 // --------------------------------------------------------------------
876 print '<tr class="liste_titre">';
877 // Action column
878 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
879  print '<td class="liste_titre maxwidthsearch">';
880  $searchpicto = $form->showFilterButtons('left');
881  print $searchpicto;
882  print '</td>';
883 }
884 // Project ref
885 if (!empty($arrayfields['p.ref']['checked'])) {
886  print '<td class="liste_titre">';
887  print '<input type="text" class="flat" name="search_ref" value="'.dol_escape_htmltag($search_ref).'" size="6">';
888  print '</td>';
889 }
890 // Project label
891 if (!empty($arrayfields['p.title']['checked'])) {
892  print '<td class="liste_titre">';
893  print '<input type="text" class="flat" name="search_label" size="8" value="'.dol_escape_htmltag($search_label).'">';
894  print '</td>';
895 }
896 // Third party
897 if (!empty($arrayfields['s.nom']['checked'])) {
898  print '<td class="liste_titre">';
899  if ($socid > 0) {
900  $tmpthirdparty = new Societe($db);
901  $tmpthirdparty->fetch($socid);
902  $search_societe = $tmpthirdparty->name;
903  }
904  print '<input type="text" class="flat" name="search_societe" size="8" value="'.dol_escape_htmltag($search_societe).'">';
905  print '</td>';
906 }
907 // Sale representative
908 if (!empty($arrayfields['commercial']['checked'])) {
909  print '<td class="liste_titre">&nbsp;</td>';
910 }
911 // Start date
912 if (!empty($arrayfields['p.dateo']['checked'])) {
913  print '<td class="liste_titre center nowraponall">';
914  /*if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
915  print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_sday" value="'.dol_escape_htmltag($search_sday).'">';
916  }
917  print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_smonth" value="'.dol_escape_htmltag($search_smonth).'">';
918  print $formother->selectyear($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');*/
919  print '<div class="nowrap">';
920  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'));
921  print '</div>';
922  print '<div class="nowrap">';
923  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'));
924  print '</div>';
925  print '</td>';
926 }
927 // End date
928 if (!empty($arrayfields['p.datee']['checked'])) {
929  print '<td class="liste_titre center nowraponall">';
930  /*if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
931  print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_eday" value="'.dol_escape_htmltag($search_eday).'">';
932  }
933  print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_emonth" value="'.dol_escape_htmltag($search_emonth).'">';
934  print $formother->selectyear($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');*/
935  print '<div class="nowrap">';
936  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'));
937  print '</div>';
938  print '<div class="nowrap">';
939  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'));
940  print '</div>';
941  print '</td>';
942 }
943 if (!empty($arrayfields['p.public']['checked'])) {
944  print '<td class="liste_titre center">';
945  $array = array(''=>'', 0 => $langs->trans("PrivateProject"), 1 => $langs->trans("SharedProject"));
946  print $form->selectarray('search_public', $array, $search_public);
947  print '</td>';
948 }
949 if (!empty($arrayfields['c.assigned']['checked'])) {
950  print '<td class="liste_titre center">';
951  print '</td>';
952 }
953 // Opp status
954 if (!empty($arrayfields['p.fk_opp_status']['checked'])) {
955  print '<td class="liste_titre nowrap center">';
956  print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 0, 1, 0, 'maxwidth100 nowrapoption', 1, 0);
957  print '</td>';
958 }
959 if (!empty($arrayfields['p.opp_amount']['checked'])) {
960  print '<td class="liste_titre nowrap right">';
961  print '<input type="text" class="flat" name="search_opp_amount" size="3" value="'.$search_opp_amount.'">';
962  print '</td>';
963 }
964 if (!empty($arrayfields['p.opp_percent']['checked'])) {
965  print '<td class="liste_titre nowrap right">';
966  print '<input type="text" class="flat" name="search_opp_percent" size="2" value="'.$search_opp_percent.'">';
967  print '</td>';
968 }
969 if (!empty($arrayfields['opp_weighted_amount']['checked'])) {
970  print '<td class="liste_titre nowrap right">';
971  print '</td>';
972 }
973 if (!empty($arrayfields['p.budget_amount']['checked'])) {
974  print '<td class="liste_titre nowrap right">';
975  print '<input type="text" class="flat" name="search_budget_amount" size="4" value="'.$search_budget_amount.'">';
976  print '</td>';
977 }
978 if (!empty($arrayfields['p.usage_opportunity']['checked'])) {
979  print '<td class="liste_titre nowrap right">';
980  print $form->selectyesno('search_usage_opportunity', $search_usage_opportunity, 1, false, 1);
981  print '';
982  print '</td>';
983 }
984 if (!empty($arrayfields['p.usage_task']['checked'])) {
985  print '<td class="liste_titre nowrap right">';
986  print $form->selectyesno('search_usage_task', $search_usage_task, 1, false, 1);
987  print '</td>';
988 }
989 if (!empty($arrayfields['p.usage_bill_time']['checked'])) {
990  print '<td class="liste_titre nowrap right">';
991  print $form->selectyesno('search_usage_bill_time', $search_usage_bill_time, 1, false, 1);
992  print '</td>';
993 }
994 if (!empty($arrayfields['p.usage_organize_event']['checked'])) {
995  print '<td class="liste_titre nowrap right">';
996  print $form->selectyesno('search_usage_event_organization', $search_usage_event_organization, 1, false, 1);
997  print '</td>';
998 }
999 if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) {
1000  print '<td class="liste_titre nowrap right">';
1001  print $form->selectyesno('search_accept_conference_suggestions', $search_accept_conference_suggestions, 1, false, 1);
1002  print '</td>';
1003 }
1004 if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) {
1005  print '<td class="liste_titre nowrap right">';
1006  print $form->selectyesno('search_accept_booth_suggestions', $search_accept_booth_suggestions, 1, false, 1);
1007  print '</td>';
1008 }
1009 if (!empty($arrayfields['p.price_registration']['checked'])) {
1010  print '<td class="liste_titre nowrap right">';
1011  print '<input type="text" class="flat" name="search_price_registration" size="4" value="'.$search_price_registration.'">';
1012  print '</td>';
1013 }
1014 if (!empty($arrayfields['p.price_booth']['checked'])) {
1015  print '<td class="liste_titre nowrap right">';
1016  print '<input type="text" class="flat" name="search_price_booth" size="4" value="'.$search_price_booth.'">';
1017  print '</td>';
1018 }
1019 // Extra fields
1020 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1021 
1022 // Fields from hook
1023 $parameters = array('arrayfields'=>$arrayfields);
1024 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
1025 print $hookmanager->resPrint;
1026 if (!empty($arrayfields['p.datec']['checked'])) {
1027  // Date creation
1028  print '<td class="liste_titre">';
1029  print '</td>';
1030 }
1031 if (!empty($arrayfields['p.tms']['checked'])) {
1032  // Date modification
1033  print '<td class="liste_titre">';
1034  print '</td>';
1035 }
1036 if (!empty($arrayfields['p.email_msgid']['checked'])) {
1037  // Email msg id
1038  print '<td class="liste_titre">';
1039  print '</td>';
1040 }
1041 if (!empty($arrayfields['p.fk_statut']['checked'])) {
1042  print '<td class="liste_titre nowrap right">';
1043  $arrayofstatus = array();
1044  foreach ($object->statuts_short as $key => $val) {
1045  $arrayofstatus[$key] = $langs->trans($val);
1046  }
1047  $arrayofstatus['99'] = $langs->trans("NotClosed").' ('.$langs->trans('Draft').' + '.$langs->trans('Opened').')';
1048  print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'minwidth75imp maxwidth125 selectarrowonleft');
1049  print ajax_combobox('search_status');
1050  print '</td>';
1051 }
1052 // Action column
1053 print '<td class="liste_titre maxwidthsearch">';
1054 $searchpicto = $form->showFilterButtons();
1055 print $searchpicto;
1056 print '</td>';
1057 
1058 print '</tr>'."\n";
1059 
1060 print '<tr class="liste_titre">';
1061 if (!empty($arrayfields['p.ref']['checked'])) {
1062  print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder);
1063 }
1064 if (!empty($arrayfields['p.title']['checked'])) {
1065  print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder);
1066 }
1067 if (!empty($arrayfields['s.nom']['checked'])) {
1068  print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
1069 }
1070 if (!empty($arrayfields['commercial']['checked'])) {
1071  print_liste_field_titre($arrayfields['commercial']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder, 'tdoverflowmax100imp ');
1072 }
1073 if (!empty($arrayfields['p.dateo']['checked'])) {
1074  print_liste_field_titre($arrayfields['p.dateo']['label'], $_SERVER["PHP_SELF"], "p.dateo", "", $param, '', $sortfield, $sortorder, 'center ');
1075 }
1076 if (!empty($arrayfields['p.datee']['checked'])) {
1077  print_liste_field_titre($arrayfields['p.datee']['label'], $_SERVER["PHP_SELF"], "p.datee", "", $param, '', $sortfield, $sortorder, 'center ');
1078 }
1079 if (!empty($arrayfields['p.public']['checked'])) {
1080  print_liste_field_titre($arrayfields['p.public']['label'], $_SERVER["PHP_SELF"], "p.public", "", $param, "", $sortfield, $sortorder, 'center ');
1081 }
1082 if (!empty($arrayfields['c.assigned']['checked'])) {
1083  print_liste_field_titre($arrayfields['c.assigned']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '');
1084 }
1085 if (!empty($arrayfields['p.fk_opp_status']['checked'])) {
1086  print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center ');
1087 }
1088 if (!empty($arrayfields['p.opp_amount']['checked'])) {
1089  print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right ');
1090 }
1091 if (!empty($arrayfields['p.opp_percent']['checked'])) {
1092  print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER['PHP_SELF'], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right ');
1093 }
1094 if (!empty($arrayfields['opp_weighted_amount']['checked'])) {
1095  print_liste_field_titre($arrayfields['opp_weighted_amount']['label'], $_SERVER['PHP_SELF'], 'opp_weighted_amount', '', $param, '', $sortfield, $sortorder, 'right ');
1096 }
1097 if (!empty($arrayfields['p.budget_amount']['checked'])) {
1098  print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right ');
1099 }
1100 if (!empty($arrayfields['p.usage_opportunity']['checked'])) {
1101  print_liste_field_titre($arrayfields['p.usage_opportunity']['label'], $_SERVER["PHP_SELF"], 'p.usage_opportunity', "", $param, '', $sortfield, $sortorder, 'right ');
1102 }
1103 if (!empty($arrayfields['p.usage_task']['checked'])) {
1104  print_liste_field_titre($arrayfields['p.usage_task']['label'], $_SERVER["PHP_SELF"], 'p.usage_task', "", $param, '', $sortfield, $sortorder, 'right ');
1105 }
1106 if (!empty($arrayfields['p.usage_bill_time']['checked'])) {
1107  print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right ');
1108 }
1109 if (!empty($arrayfields['p.usage_organize_event']['checked'])) {
1110  print_liste_field_titre($arrayfields['p.usage_organize_event']['label'], $_SERVER["PHP_SELF"], 'p.usage_organize_event', "", $param, '', $sortfield, $sortorder, 'right ');
1111 }
1112 if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) {
1113  print_liste_field_titre($arrayfields['p.accept_conference_suggestions']['label'], $_SERVER["PHP_SELF"], 'p.accept_conference_suggestions', "", $param, '', $sortfield, $sortorder, 'right ');
1114 }
1115 if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) {
1116  print_liste_field_titre($arrayfields['p.accept_booth_suggestions']['label'], $_SERVER["PHP_SELF"], 'p.accept_booth_suggestions', "", $param, '', $sortfield, $sortorder, 'right ');
1117 }
1118 if (!empty($arrayfields['p.price_registration']['checked'])) {
1119  print_liste_field_titre($arrayfields['p.price_registration']['label'], $_SERVER["PHP_SELF"], 'p.price_registration', "", $param, '', $sortfield, $sortorder, 'right ');
1120 }
1121 if (!empty($arrayfields['p.price_booth']['checked'])) {
1122  print_liste_field_titre($arrayfields['p.price_booth']['label'], $_SERVER["PHP_SELF"], 'p.price_booth', "", $param, '', $sortfield, $sortorder, 'right ');
1123 }
1124 // Extra fields
1125 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1126 // Hook fields
1127 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
1128 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1129 print $hookmanager->resPrint;
1130 if (!empty($arrayfields['p.datec']['checked'])) {
1131  print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1132 }
1133 if (!empty($arrayfields['p.tms']['checked'])) {
1134  print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1135 }
1136 if (!empty($arrayfields['p.email_msgid']['checked'])) {
1137  print_liste_field_titre($arrayfields['p.email_msgid']['label'], $_SERVER["PHP_SELF"], "p.email_msgid", "", $param, '', $sortfield, $sortorder, 'center ');
1138 }
1139 if (!empty($arrayfields['p.fk_statut']['checked'])) {
1140  print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
1141 }
1142 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1143 print "</tr>\n";
1144 
1145 $i = 0;
1146 $totalarray = array(
1147  'nbfield' => 0,
1148  'val' => array(),
1149 );
1150 $imaxinloop = ($limit ? min($num, $limit) : $num);
1151 while ($i < $imaxinloop) {
1152  $obj = $db->fetch_object($resql);
1153  if (empty($obj)) {
1154  break; // Should not happen
1155  }
1156 
1157  $object->id = $obj->id;
1158  $object->user_author_id = $obj->fk_user_creat;
1159  $object->public = $obj->public;
1160  $object->ref = $obj->ref;
1161  $object->datee = $db->jdate($obj->date_end);
1162  $object->statut = $obj->status; // deprecated
1163  $object->status = $obj->status;
1164  $object->public = $obj->public;
1165  $object->opp_status = $obj->fk_opp_status;
1166  $object->title = $obj->title;
1167 
1168  $userAccess = $object->restrictedProjectArea($user); // why this ?
1169  if ($userAccess >= 0) {
1170  $companystatic->id = $obj->socid;
1171  $companystatic->name = $obj->name;
1172  $companystatic->name_alias = $obj->alias;
1173  $companystatic->client = $obj->client;
1174  $companystatic->code_client = $obj->code_client;
1175  $companystatic->email = $obj->email;
1176  $companystatic->phone = $obj->phone;
1177  $companystatic->address = $obj->address;
1178  $companystatic->zip = $obj->zip;
1179  $companystatic->town = $obj->town;
1180  $companystatic->country_code = $obj->country_code;
1181 
1182  print '<tr class="oddeven">';
1183 
1184  // Project url
1185  if (!empty($arrayfields['p.ref']['checked'])) {
1186  print '<td class="nowraponall">';
1187  print $object->getNomUrl(1, (!empty(GETPOST('search_usage_event_organization', 'int'))?'eventorganization':''));
1188  if ($object->hasDelay()) {
1189  print img_warning($langs->trans('Late'));
1190  }
1191  print '</td>';
1192  if (!$i) {
1193  $totalarray['nbfield']++;
1194  }
1195  }
1196  // Title
1197  if (!empty($arrayfields['p.title']['checked'])) {
1198  print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->title).'">';
1199  print $obj->title;
1200  print '</td>';
1201  if (!$i) {
1202  $totalarray['nbfield']++;
1203  }
1204  }
1205  // Company
1206  if (!empty($arrayfields['s.nom']['checked'])) {
1207  print '<td class="tdoverflowmax100">';
1208  if ($obj->socid) {
1209  print $companystatic->getNomUrl(1);
1210  } else {
1211  print '&nbsp;';
1212  }
1213  print '</td>';
1214  if (!$i) {
1215  $totalarray['nbfield']++;
1216  }
1217  }
1218  // Sales Representatives
1219  if (!empty($arrayfields['commercial']['checked'])) {
1220  print '<td>';
1221  if ($obj->socid) {
1222  $companystatic->id = $obj->socid;
1223  $companystatic->name = $obj->name;
1224  $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
1225  $nbofsalesrepresentative = count($listsalesrepresentatives);
1226  if ($nbofsalesrepresentative > 6) {
1227  // We print only number
1228  print $nbofsalesrepresentative;
1229  } elseif ($nbofsalesrepresentative > 0) {
1230  $userstatic = new User($db);
1231  $j = 0;
1232  foreach ($listsalesrepresentatives as $val) {
1233  $userstatic->id = $val['id'];
1234  $userstatic->lastname = $val['lastname'];
1235  $userstatic->firstname = $val['firstname'];
1236  $userstatic->email = $val['email'];
1237  $userstatic->statut = $val['statut'];
1238  $userstatic->entity = $val['entity'];
1239  $userstatic->photo = $val['photo'];
1240  $userstatic->login = $val['login'];
1241  $userstatic->office_phone = $val['office_phone'];
1242  $userstatic->office_fax = $val['office_fax'];
1243  $userstatic->user_mobile = $val['user_mobile'];
1244  $userstatic->job = $val['job'];
1245  $userstatic->gender = $val['gender'];
1246  print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
1247  $j++;
1248  if ($j < $nbofsalesrepresentative) {
1249  print ' ';
1250  }
1251  }
1252  }
1253  //else print $langs->trans("NoSalesRepresentativeAffected");
1254  } else {
1255  print '&nbsp;';
1256  }
1257  print '</td>';
1258  if (!$i) {
1259  $totalarray['nbfield']++;
1260  }
1261  }
1262  // Date start
1263  if (!empty($arrayfields['p.dateo']['checked'])) {
1264  print '<td class="center">';
1265  print dol_print_date($db->jdate($obj->date_start), 'day');
1266  print '</td>';
1267  if (!$i) {
1268  $totalarray['nbfield']++;
1269  }
1270  }
1271  // Date end
1272  if (!empty($arrayfields['p.datee']['checked'])) {
1273  print '<td class="center">';
1274  print dol_print_date($db->jdate($obj->date_end), 'day');
1275  print '</td>';
1276  if (!$i) {
1277  $totalarray['nbfield']++;
1278  }
1279  }
1280  // Visibility
1281  if (!empty($arrayfields['p.public']['checked'])) {
1282  print '<td class="center">';
1283  if ($obj->public) {
1284  print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
1285  //print $langs->trans('SharedProject');
1286  } else {
1287  print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
1288  //print $langs->trans('PrivateProject');
1289  }
1290  print '</td>';
1291  if (!$i) {
1292  $totalarray['nbfield']++;
1293  }
1294  }
1295  // Contacts of project
1296  if (!empty($arrayfields['c.assigned']['checked'])) {
1297  print '<td class="center">';
1298  $ifisrt = 1;
1299  foreach (array('internal', 'external') as $source) {
1300  $tab = $object->liste_contact(-1, $source);
1301  $numcontact = count($tab);
1302  if (!empty($numcontact)) {
1303  foreach ($tab as $contactproject) {
1304  //var_dump($contacttask);
1305  if ($source == 'internal') {
1306  $c = new User($db);
1307  } else {
1308  $c = new Contact($db);
1309  }
1310  $c->fetch($contactproject['id']);
1311  if (!empty($c->photo)) {
1312  if (get_class($c) == 'User') {
1313  print $c->getNomUrl(-2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst'));
1314  } else {
1315  print $c->getNomUrl(-2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst'));
1316  }
1317  } else {
1318  if (get_class($c) == 'User') {
1319  print $c->getNomUrl(2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst'));
1320  } else {
1321  print $c->getNomUrl(2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst'));
1322  }
1323  }
1324  $ifisrt = 0;
1325  }
1326  }
1327  }
1328  print '</td>';
1329  }
1330  // Opp Status
1331  if (!empty($arrayfields['p.fk_opp_status']['checked'])) {
1332  print '<td class="center">';
1333  if ($obj->opp_status_code) {
1334  print $langs->trans("OppStatus".$obj->opp_status_code);
1335  }
1336  print '</td>';
1337  if (!$i) {
1338  $totalarray['nbfield']++;
1339  }
1340  }
1341  // Opp Amount
1342  if (!empty($arrayfields['p.opp_amount']['checked'])) {
1343  print '<td class="right">';
1344  //if ($obj->opp_status_code)
1345  if (strcmp($obj->opp_amount, '')) {
1346  print '<span class="amount">'.price($obj->opp_amount, 1, $langs, 1, -1, -1, '').'</span>';
1347  $totalarray['val']['p.opp_amount'] += $obj->opp_amount;
1348  }
1349  print '</td>';
1350  if (!$i) {
1351  $totalarray['nbfield']++;
1352  }
1353  if (!$i) {
1354  $totalarray['pos'][$totalarray['nbfield']] = 'p.opp_amount';
1355  }
1356  }
1357  // Opp percent
1358  if (!empty($arrayfields['p.opp_percent']['checked'])) {
1359  print '<td class="right">';
1360  if ($obj->opp_percent) {
1361  print price($obj->opp_percent, 1, $langs, 1, 0).'%';
1362  }
1363  print '</td>';
1364  if (!$i) {
1365  $totalarray['nbfield']++;
1366  }
1367  }
1368  // Opp weighted amount
1369  if (!empty($arrayfields['opp_weighted_amount']['checked'])) {
1370  if (!isset($totalarray['val']['opp_weighted_amount'])) {
1371  $totalarray['val']['opp_weighted_amount'] = 0;
1372  }
1373  print '<td align="right">';
1374  if ($obj->opp_weighted_amount) {
1375  print '<span class="amount">'.price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, '').'</span>';
1376  $totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount;
1377  }
1378  print '</td>';
1379  if (!$i) {
1380  $totalarray['nbfield']++;
1381  }
1382  if (!$i) {
1383  $totalarray['pos'][$totalarray['nbfield']] = 'opp_weighted_amount';
1384  }
1385  }
1386  // Budget
1387  if (!empty($arrayfields['p.budget_amount']['checked'])) {
1388  print '<td class="right">';
1389  if ($obj->budget_amount != '') {
1390  print '<span class="amount">'.price($obj->budget_amount, 1, $langs, 1, -1, -1).'</span>';
1391  $totalarray['val']['p.budget_amount'] += $obj->budget_amount;
1392  }
1393  print '</td>';
1394  if (!$i) {
1395  $totalarray['nbfield']++;
1396  }
1397  if (!$i) {
1398  $totalarray['pos'][$totalarray['nbfield']] = 'p.budget_amount';
1399  }
1400  }
1401  // Usage opportunity
1402  if (!empty($arrayfields['p.usage_opportunity']['checked'])) {
1403  print '<td class="right">';
1404  if ($obj->usage_opportunity) {
1405  print yn($obj->usage_opportunity);
1406  }
1407  print '</td>';
1408  if (!$i) {
1409  $totalarray['nbfield']++;
1410  }
1411  }
1412  // Usage task
1413  if (!empty($arrayfields['p.usage_task']['checked'])) {
1414  print '<td class="right">';
1415  if ($obj->usage_task) {
1416  print yn($obj->usage_task);
1417  }
1418  print '</td>';
1419  if (!$i) {
1420  $totalarray['nbfield']++;
1421  }
1422  }
1423  // Bill time
1424  if (!empty($arrayfields['p.usage_bill_time']['checked'])) {
1425  print '<td class="right">';
1426  if ($obj->usage_bill_time) {
1427  print yn($obj->usage_bill_time);
1428  }
1429  print '</td>';
1430  if (!$i) {
1431  $totalarray['nbfield']++;
1432  }
1433  }
1434  // Event Organization
1435  if (!empty($arrayfields['p.usage_organize_event']['checked'])) {
1436  print '<td class="right">';
1437  if ($obj->usage_organize_event) {
1438  print yn($obj->usage_organize_event);
1439  }
1440  print '</td>';
1441  if (!$i) {
1442  $totalarray['nbfield']++;
1443  }
1444  }
1445  // Allow unknown people to suggest conferences
1446  if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) {
1447  print '<td class="right">';
1448  if ($obj->accept_conference_suggestions) {
1449  print yn($obj->accept_conference_suggestions);
1450  }
1451  print '</td>';
1452  if (!$i) {
1453  $totalarray['nbfield']++;
1454  }
1455  }
1456  // Allow unknown people to suggest booth
1457  if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) {
1458  print '<td class="right">';
1459  if ($obj->accept_booth_suggestions) {
1460  print yn($obj->accept_booth_suggestions);
1461  }
1462  print '</td>';
1463  if (!$i) {
1464  $totalarray['nbfield']++;
1465  }
1466  }
1467  // Price of registration
1468  if (!empty($arrayfields['p.price_registration']['checked'])) {
1469  print '<td class="right">';
1470  if ($obj->price_registration != '') {
1471  print '<span class="amount">'.price($obj->price_registration, 1, $langs, 1, -1, -1).'</span>';
1472  $totalarray['val']['p.price_registration'] += $obj->price_registration;
1473  }
1474  print '</td>';
1475  if (!$i) {
1476  $totalarray['nbfield']++;
1477  }
1478  if (!$i) {
1479  $totalarray['pos'][$totalarray['nbfield']] = 'p.price_registration';
1480  }
1481  }
1482  // Price of booth
1483  if (!empty($arrayfields['p.price_booth']['checked'])) {
1484  print '<td class="right">';
1485  if ($obj->price_booth != '') {
1486  print '<span class="amount">'.price($obj->price_booth, 1, $langs, 1, -1, -1).'</span>';
1487  $totalarray['val']['p.price_booth'] += $obj->price_booth;
1488  }
1489  print '</td>';
1490  if (!$i) {
1491  $totalarray['nbfield']++;
1492  }
1493  if (!$i) {
1494  $totalarray['pos'][$totalarray['nbfield']] = 'p.price_booth';
1495  }
1496  }
1497  // Extra fields
1498  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1499  // Fields from hook
1500  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1501  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1502  print $hookmanager->resPrint;
1503  // Date creation
1504  if (!empty($arrayfields['p.datec']['checked'])) {
1505  print '<td class="center nowraponall">';
1506  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1507  print '</td>';
1508  if (!$i) {
1509  $totalarray['nbfield']++;
1510  }
1511  }
1512  // Date modification
1513  if (!empty($arrayfields['p.tms']['checked'])) {
1514  print '<td class="center nowraponall">';
1515  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1516  print '</td>';
1517  if (!$i) {
1518  $totalarray['nbfield']++;
1519  }
1520  }
1521  // Email MsgID
1522  if (!empty($arrayfields['p.email_msgid']['checked'])) {
1523  print '<td class="center">';
1524  print $obj->email_msgid;
1525  print '</td>';
1526  if (!$i) $totalarray['nbfield']++;
1527  }
1528  // Status
1529  if (!empty($arrayfields['p.fk_statut']['checked'])) {
1530  print '<td class="right">'.$object->getLibStatut(5).'</td>';
1531  if (!$i) {
1532  $totalarray['nbfield']++;
1533  }
1534  }
1535  // Action column
1536  if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1537  print '<td class="nowrap center">';
1538  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1539  $selected = 0;
1540  if (in_array($object->id, $arrayofselected)) {
1541  $selected = 1;
1542  }
1543  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
1544  }
1545  print '</td>';
1546  }
1547  if (!$i) {
1548  $totalarray['nbfield']++;
1549  }
1550 
1551  print "</tr>\n";
1552  }
1553 
1554  $i++;
1555 }
1556 
1557 // Show total line
1558 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1559 
1560 // If no record found
1561 if ($num == 0) {
1562  $colspan = 1;
1563  foreach ($arrayfields as $key => $val) {
1564  if (!empty($val['checked'])) {
1565  $colspan++;
1566  }
1567  }
1568  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1569 }
1570 
1571 $db->free($resql);
1572 
1573 $parameters = array('arrayfields'=>$arrayfields, 'sql' => $sql);
1574 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1575 print $hookmanager->resPrint;
1576 
1577 print "</table>\n";
1578 print '</div>';
1579 
1580 print "</form>\n";
1581 
1582 // End of page
1583 llxFooter();
1584 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
ajax_combobox
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:438
yn
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
Definition: functions.lib.php:6491
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
Project
Class to manage projects.
Definition: project.class.php:35
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
FormCategory
Class to manage forms for categories.
Definition: html.formcategory.class.php:30
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4521
FormProjets
Class to manage building of HTML components.
Definition: html.formprojet.class.php:30
$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
$help_url
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:116
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
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
Categorie\getFilterSelectQuery
static getFilterSelectQuery($type, $rowIdName, $searchList)
Return the addtional SQL SELECT query for filtering a list by a category.
Definition: categorie.class.php:2001
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_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
Contact
Class to manage contact/addresses.
Definition: contact.class.php:40
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
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
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
dol_eval
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
Definition: functions.lib.php:8611
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
$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
dolSqlDateFilter
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:334
price
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.
Definition: functions.lib.php:5541
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
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
Categorie\getFilterJoinQuery
static getFilterJoinQuery($type, $rowIdName)
Return the addtional SQL JOIN query for filtering a list by a category.
Definition: categorie.class.php:1984