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