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