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