dolibarr 24.0.1
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', we offer the filter assigned to
1372// TODO This must be moved on the dedicated column "Assigned to".
1373if ($user->hasRight('user', 'user', 'lire')) {
1374 $langs->load("commercial");
1375 $moreforfilter .= '<div class="divsearchfield">';
1376 $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
1377 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth300 widthcentpercentminusx');
1378 $moreforfilter .= '</div>';
1379}
1380
1381// Filter on project categories
1382if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
1383 $formcategory = new FormCategory($db);
1384 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array, 'minwidth200imp minwidth200 widthcentpercentminusx', -1, 1, 1, $langs->transnoentitiesnoconv("ProjectsCategoryShort"));
1385}
1386
1387// Filter on customer categories
1388if (getDolGlobalString('MAIN_SEARCH_CATEGORY_CUSTOMER_ON_PROJECT_LIST') && isModEnabled("category") && $user->hasRight('categorie', 'lire')) {
1389 $formcategory = new FormCategory($db);
1390 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_CUSTOMER, $searchCategoryCustomerList, 'minwidth200imp minwidth200 widthcentpercentminusx', $searchCategoryCustomerList ? $searchCategoryCustomerList : 0);
1391}
1392
1393// alert on late date
1394$moreforfilter .= '<div class="divsearchfield">';
1395$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' : '').'>';
1396$moreforfilter .= '</div>';
1397
1398if (getDolGlobalInt('PROJECT_ENABLE_SUB_PROJECT')) {
1399 //Checkbox for omitting child projects filter
1400 $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"' : '').'"> ';
1401}
1402
1403if (!empty($moreforfilter)) {
1404 print '<div class="liste_titre liste_titre_bydiv centpercent">';
1405 print $moreforfilter;
1406 $parameters = array();
1407 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1408 print $hookmanager->resPrint;
1409 print '</div>';
1410}
1411
1412$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1413$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
1414$selectedfields = (($mode != 'kanban' && $mode != 'kanbangroupby') ? $htmlofselectarray : '');
1415$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
1416
1417
1418print '<div class="div-table-responsive">';
1419print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1420
1421// Fields title search
1422// --------------------------------------------------------------------
1423print '<thead>';
1424print '<tr class="liste_titre_filter">';
1425// Action column left
1426if ($conf->main_checkbox_left_column) {
1427 print '<td class="liste_titre center maxwidthsearch" id="action_column_left">';
1428 $searchpicto = $form->showFilterButtons('left');
1429 print $searchpicto;
1430 print '</td>';
1431}
1432// Project ID
1433if (!empty($arrayfields['p.rowid']['checked'])) {
1434 print '<td class="liste_titre" id="search_id">';
1435 print '<input type="text" class="flat width50" name="search_id" value="'.dol_escape_htmltag($search_id).'">';
1436 print '</td>';
1437}
1438// Project ref
1439if (!empty($arrayfields['p.ref']['checked'])) {
1440 print '<td class="liste_titre" id="search_ref">';
1441 print '<input type="text" class="flat width75" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
1442 print '</td>';
1443}
1444// Project label
1445if (!empty($arrayfields['p.title']['checked'])) {
1446 print '<td class="liste_titre" id="search_label">';
1447 print '<input type="text" class="flat width100" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
1448 print '</td>';
1449}
1450
1451// Parent project
1452if (!empty($arrayfields['p.fk_project']['checked'])) {
1453 print '<td class="liste_titre" id="parent_project">';
1454 print '<div class="nowrap">';
1455 $ref_placeholder = $langs->trans('Ref');
1456 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).'">';
1457 print '</div>';
1458 print '<div class="nowrap">';
1459 $label_placeholder = $langs->trans('Label');
1460 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).'">';
1461 print '</div>';
1462 print '</td>';
1463}
1464
1465// Third party
1466if (!empty($arrayfields['s.nom']['checked'])) {
1467 print '<td class="liste_titre" id="search_societe">';
1468 if ($socid > 0) {
1469 $tmpthirdparty = new Societe($db);
1470 $tmpthirdparty->fetch($socid);
1471 $search_societe = $tmpthirdparty->name;
1472 }
1473 print '<input type="text" class="flat width100" name="search_societe" value="'.dol_escape_htmltag((string) $search_societe).'">';
1474 print '</td>';
1475}
1476
1477// Alias
1478if (!empty($arrayfields['s.name_alias']['checked'])) {
1479 print '<td class="liste_titre" id="search_societe_alias">';
1480 if ($socid > 0) {
1481 $tmpthirdparty = new Societe($db);
1482 $tmpthirdparty->fetch($socid);
1483 $search_societe_alias = $tmpthirdparty->name_alias;
1484 }
1485 print '<input type="text" class="flat width100" name="search_societe_alias" value="'.dol_escape_htmltag($search_societe_alias).'">';
1486 print '</td>';
1487}
1488
1489// Ref customer
1490if (!empty($arrayfields['s.code_client']['checked'])) {
1491 print '<td class="liste_titre" id="search_societe_ref_customer">';
1492 print '<input type="text" class="flat width75" name="search_societe_ref_customer" value="'.dol_escape_htmltag($search_societe_ref_customer).'">';
1493 print '</td>';
1494}
1495// Ref supplier
1496if (!empty($arrayfields['s.code_fournisseur']['checked'])) {
1497 print '<td class="liste_titre" id="search_societe_ref_supplier">';
1498 print '<input type="text" class="flat width75" name="search_societe_ref_supplier" value="'.dol_escape_htmltag($search_societe_ref_supplier).'">';
1499 print '</td>';
1500}
1501
1502// Country of thirdparty
1503if (!empty($arrayfields['co.country_code']['checked'])) {
1504 print '<td class="liste_titre" id="search_societe_country">';
1505 print '<input type="text" class="flat width50" name="search_societe_country" value="'.dol_escape_htmltag($search_societe_country).'">';
1506 print '</td>';
1507}
1508// Sale representative
1509if (!empty($arrayfields['commercial']['checked'])) {
1510 print '<td class="liste_titre" id="sale_representative">&nbsp;</td>';
1511}
1512// Start date
1513if (!empty($arrayfields['p.dateo']['checked'])) {
1514 print '<td class="liste_titre center" id="search_date_start">';
1515 print '<div class="nowrapfordate">';
1516 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'));
1517 print '</div>';
1518 print '<div class="nowrapfordate">';
1519 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'));
1520 print '</div>';
1521 print '</td>';
1522}
1523// End date
1524if (!empty($arrayfields['p.datee']['checked'])) {
1525 print '<td class="liste_titre center" id="search_date_end">';
1526 print '<div class="nowrapfordate">';
1527 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'));
1528 print '</div>';
1529 print '<div class="nowrapfordate">';
1530 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'));
1531 print '</div>';
1532 print '</td>';
1533}
1534// Visibility
1535if (!empty($arrayfields['p.public']['checked'])) {
1536 print '<td class="liste_titre center">';
1537 $array = array('' => '', 0 => $langs->trans("PrivateProject"), 1 => $langs->trans("SharedProject"));
1538 print $form->selectarray('search_public', $array, $search_public, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth75');
1539 print '</td>';
1540}
1541if (!empty($arrayfields['c.assigned']['checked'])) {
1542 print '<td class="liste_titre center">';
1543 print '</td>';
1544}
1545// Opp status
1546if (!empty($arrayfields['p.fk_opp_status']['checked'])) {
1547 print '<td class="liste_titre nowrap center">';
1548 print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 1, 1, 0, 'maxwidth125 nowrapoption', 1, 1);
1549 print '</td>';
1550}
1551if (!empty($arrayfields['p.opp_amount']['checked'])) {
1552 print '<td class="liste_titre nowrap right" id="search_opp_amount">';
1553 print '<input type="text" class="flat" name="search_opp_amount" size="3" value="'.$search_opp_amount.'">';
1554 print '</td>';
1555}
1556if (!empty($arrayfields['p.opp_percent']['checked'])) {
1557 print '<td class="liste_titre nowrap right" id="search_opp_percent">';
1558 print '<input type="text" class="flat" name="search_opp_percent" size="2" value="'.$search_opp_percent.'">';
1559 print '</td>';
1560}
1561if (!empty($arrayfields['opp_weighted_amount']['checked'])) {
1562 print '<td class="liste_titre nowrap right">';
1563 print '</td>';
1564}
1565if (!empty($arrayfields['p.budget_amount']['checked'])) {
1566 print '<td class="liste_titre nowrap right" id="search_budget_amount">';
1567 print '<input type="text" class="flat" name="search_budget_amount" size="4" value="'.$search_budget_amount.'">';
1568 print '</td>';
1569}
1570if (!empty($arrayfields['p.usage_opportunity']['checked'])) {
1571 print '<td class="liste_titre nowrap">';
1572 print $form->selectyesno('search_usage_opportunity', $search_usage_opportunity, 1, false, 1, 1);
1573 print '';
1574 print '</td>';
1575}
1576if (!empty($arrayfields['p.usage_task']['checked'])) {
1577 print '<td class="liste_titre nowrap">';
1578 print $form->selectyesno('search_usage_task', $search_usage_task, 1, false, 1, 1);
1579 print '</td>';
1580}
1581if (!empty($arrayfields['p.usage_bill_time']['checked'])) {
1582 print '<td class="liste_titre nowrap">';
1583 print $form->selectyesno('search_usage_bill_time', $search_usage_bill_time, 1, false, 1, 1);
1584 print '</td>';
1585}
1586if (!empty($arrayfields['p.usage_organize_event']['checked'])) {
1587 print '<td class="liste_titre nowrap">';
1588 print $form->selectyesno('search_usage_event_organization', $search_usage_event_organization, 1, false, 1, 1);
1589 print '</td>';
1590}
1591if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) {
1592 print '<td class="liste_titre nowrap">';
1593 print $form->selectyesno('search_accept_conference_suggestions', $search_accept_conference_suggestions, 1, false, 1, 1);
1594 print '</td>';
1595}
1596if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) {
1597 print '<td class="liste_titre nowrap">';
1598 print $form->selectyesno('search_accept_booth_suggestions', $search_accept_booth_suggestions, 1, false, 1, 1);
1599 print '</td>';
1600}
1601if (!empty($arrayfields['p.price_registration']['checked'])) {
1602 print '<td class="liste_titre nowrap right" id="search_price_registration">';
1603 print '<input type="text" class="flat" name="search_price_registration" size="4" value="'.dol_escape_htmltag($search_price_registration).'">';
1604 print '</td>';
1605}
1606if (!empty($arrayfields['p.price_booth']['checked'])) {
1607 print '<td class="liste_titre nowrap right" id="search_price_booth">';
1608 print '<input type="text" class="flat" name="search_price_booth" size="4" value="'.dol_escape_htmltag($search_price_booth).'">';
1609 print '</td>';
1610}
1611if (!empty($arrayfields['u.login']['checked'])) {
1612 // Author
1613 print '<td class="liste_titre" align="center" id="search_login">';
1614 print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
1615 print '</td>';
1616}
1617// Extra fields
1618include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1619
1620// Fields from hook
1621$parameters = array('arrayfields' => $arrayfields);
1622$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
1623print $hookmanager->resPrint;
1624// Creation date
1625if (!empty($arrayfields['p.datec']['checked'])) {
1626 print '<td class="liste_titre center" id="search_date_creation">';
1627 print '<div class="nowrapfordate">';
1628 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'));
1629 print '</div>';
1630 print '<div class="nowrapfordate">';
1631 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'));
1632 print '</div>';
1633 print '</td>';
1634}
1635// Modification date
1636if (!empty($arrayfields['p.tms']['checked'])) {
1637 print '<td class="liste_titre center" id="search_date_modif">';
1638 print '<div class="nowrapfordate">';
1639 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'));
1640 print '</div>';
1641 print '<div class="nowrapfordate">';
1642 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'));
1643 print '</div>';
1644 print '</td>';
1645}
1646if (!empty($arrayfields['p.email_msgid']['checked'])) {
1647 // Email msg id
1648 print '<td class="liste_titre">';
1649 print '</td>';
1650}
1651if (!empty($arrayfields['p.import_key']['checked'])) {
1652 // Import key
1653 print '<td class="liste_titre" id="search_import_key">';
1654 print '<input class="flat width75" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
1655 print '</td>';
1656}
1657// Status - if you insert id here it doesn't work the way it should - so we don't
1658if (!empty($arrayfields['p.fk_statut']['checked'])) {
1659 print '<td class="liste_titre center parentonrightofpage">';
1660 $formproject->selectProjectsStatus($search_status, 1, 'search_status');
1661 print '</td>';
1662}
1663// Action column right
1664if (!$conf->main_checkbox_left_column) {
1665 print '<td class="liste_titre maxwidthsearch" id="action_column_right">';
1666 $searchpicto = $form->showFilterButtons();
1667 print $searchpicto;
1668 print '</td>';
1669}
1670print '</tr>'."\n";
1671
1672$totalarray = array();
1673$totalarray['nbfield'] = 0;
1674
1675// Fields title label
1676// --------------------------------------------------------------------
1677print '<tr class="liste_titre">';
1678if ($conf->main_checkbox_left_column) {
1679 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1680 $totalarray['nbfield']++;
1681}
1682if (!empty($arrayfields['p.rowid']['checked'])) {
1683 print_liste_field_titre($arrayfields['p.rowid']['label'], $_SERVER["PHP_SELF"], "p.rowid", "", $param, "", $sortfield, $sortorder);
1684 $totalarray['nbfield']++;
1685}
1686if (!empty($arrayfields['p.ref']['checked'])) {
1687 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder);
1688 $totalarray['nbfield']++;
1689}
1690if (!empty($arrayfields['p.title']['checked'])) {
1691 print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder);
1692 $totalarray['nbfield']++;
1693}
1694if (!empty($arrayfields['p.fk_project']['checked'])) {
1695 print_liste_field_titre($arrayfields['p.fk_project']['label'], $_SERVER["PHP_SELF"], "p.fk_project", "", $param, "", $sortfield, $sortorder);
1696 $totalarray['nbfield']++;
1697}
1698if (!empty($arrayfields['s.nom']['checked'])) {
1699 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
1700 $totalarray['nbfield']++;
1701}
1702if (!empty($arrayfields['s.name_alias']['checked'])) {
1703 // @phan-suppress-next-line PhanTypeInvalidDimOffset
1704 print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder);
1705 $totalarray['nbfield']++;
1706}
1707if (!empty($arrayfields['s.code_client']['checked'])) {
1708 print_liste_field_titre($arrayfields['s.code_client']['label'], $_SERVER["PHP_SELF"], "s.code_client", "", $param, "", $sortfield, $sortorder);
1709 $totalarray['nbfield']++;
1710}
1711if (!empty($arrayfields['s.code_fournisseur']['checked'])) {
1712 print_liste_field_titre($arrayfields['s.code_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $param, "", $sortfield, $sortorder);
1713 $totalarray['nbfield']++;
1714}
1715if (!empty($arrayfields['co.country_code']['checked'])) {
1716 print_liste_field_titre($arrayfields['co.country_code']['label'], $_SERVER["PHP_SELF"], "country.code", "", $param, "", $sortfield, $sortorder, 'center ');
1717 $totalarray['nbfield']++;
1718}
1719if (!empty($arrayfields['commercial']['checked'])) {
1720 print_liste_field_titre($arrayfields['commercial']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder, 'tdoverflowmax100imp ');
1721 $totalarray['nbfield']++;
1722}
1723if (!empty($arrayfields['p.dateo']['checked'])) {
1724 print_liste_field_titre($arrayfields['p.dateo']['label'], $_SERVER["PHP_SELF"], "p.dateo", "", $param, '', $sortfield, $sortorder, 'center ');
1725 $totalarray['nbfield']++;
1726}
1727if (!empty($arrayfields['p.datee']['checked'])) {
1728 print_liste_field_titre($arrayfields['p.datee']['label'], $_SERVER["PHP_SELF"], "p.datee", "", $param, '', $sortfield, $sortorder, 'center ');
1729 $totalarray['nbfield']++;
1730}
1731if (!empty($arrayfields['p.public']['checked'])) {
1732 print_liste_field_titre($arrayfields['p.public']['label'], $_SERVER["PHP_SELF"], "p.public", "", $param, "", $sortfield, $sortorder, 'center ');
1733 $totalarray['nbfield']++;
1734}
1735if (!empty($arrayfields['c.assigned']['checked'])) {
1736 print_liste_field_titre($arrayfields['c.assigned']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '');
1737 $totalarray['nbfield']++;
1738}
1739if (!empty($arrayfields['p.fk_opp_status']['checked'])) {
1740 // @phan-suppress-next-line PhanTypeInvalidDimOffset
1741 print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center ');
1742 $totalarray['nbfield']++;
1743}
1744if (!empty($arrayfields['p.opp_amount']['checked'])) {
1745 // @phan-suppress-next-line PhanTypeInvalidDimOffset
1746 print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right ');
1747 $totalarray['nbfield']++;
1748}
1749if (!empty($arrayfields['p.opp_percent']['checked'])) {
1750 // @phan-suppress-next-line PhanTypeInvalidDimOffset
1751 print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER['PHP_SELF'], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right ');
1752 $totalarray['nbfield']++;
1753}
1754if (!empty($arrayfields['opp_weighted_amount']['checked'])) {
1755 print_liste_field_titre($arrayfields['opp_weighted_amount']['label'], $_SERVER['PHP_SELF'], 'opp_weighted_amount', '', $param, '', $sortfield, $sortorder, 'right ');
1756 $totalarray['nbfield']++;
1757}
1758if (!empty($arrayfields['p.budget_amount']['checked'])) {
1759 print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right ');
1760 $totalarray['nbfield']++;
1761}
1762if (!empty($arrayfields['p.usage_opportunity']['checked'])) {
1763 print_liste_field_titre($arrayfields['p.usage_opportunity']['label'], $_SERVER["PHP_SELF"], 'p.usage_opportunity', "", $param, '', $sortfield, $sortorder, '');
1764 $totalarray['nbfield']++;
1765}
1766if (!empty($arrayfields['p.usage_task']['checked'])) {
1767 print_liste_field_titre($arrayfields['p.usage_task']['label'], $_SERVER["PHP_SELF"], 'p.usage_task', "", $param, '', $sortfield, $sortorder, '');
1768 $totalarray['nbfield']++;
1769}
1770if (!empty($arrayfields['p.usage_bill_time']['checked'])) {
1771 print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, '');
1772 $totalarray['nbfield']++;
1773}
1774if (!empty($arrayfields['p.usage_organize_event']['checked'])) {
1775 // @phan-suppress-next-line PhanTypeInvalidDimOffset
1776 print_liste_field_titre($arrayfields['p.usage_organize_event']['label'], $_SERVER["PHP_SELF"], 'p.usage_organize_event', "", $param, '', $sortfield, $sortorder, '');
1777 $totalarray['nbfield']++;
1778}
1779if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) {
1780 print_liste_field_titre($arrayfields['p.accept_conference_suggestions']['label'], $_SERVER["PHP_SELF"], 'p.accept_conference_suggestions', "", $param, '', $sortfield, $sortorder, '');
1781 $totalarray['nbfield']++;
1782}
1783if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) {
1784 print_liste_field_titre($arrayfields['p.accept_booth_suggestions']['label'], $_SERVER["PHP_SELF"], 'p.accept_booth_suggestions', "", $param, '', $sortfield, $sortorder, '');
1785 $totalarray['nbfield']++;
1786}
1787if (!empty($arrayfields['p.price_registration']['checked'])) {
1788 print_liste_field_titre($arrayfields['p.price_registration']['label'], $_SERVER["PHP_SELF"], 'p.price_registration', "", $param, '', $sortfield, $sortorder, 'right ');
1789 $totalarray['nbfield']++;
1790}
1791if (!empty($arrayfields['p.price_booth']['checked'])) {
1792 print_liste_field_titre($arrayfields['p.price_booth']['label'], $_SERVER["PHP_SELF"], 'p.price_booth', "", $param, '', $sortfield, $sortorder, 'right ');
1793 $totalarray['nbfield']++;
1794}
1795if (!empty($arrayfields['u.login']['checked'])) {
1796 print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder);
1797 $totalarray['nbfield']++;
1798}
1799// Extra fields
1800include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1801// Hook fields
1802$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
1803$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1804print $hookmanager->resPrint;
1805if (!empty($arrayfields['p.datec']['checked'])) {
1806 print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1807 $totalarray['nbfield']++;
1808}
1809if (!empty($arrayfields['p.tms']['checked'])) {
1810 print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1811 $totalarray['nbfield']++;
1812}
1813if (!empty($arrayfields['p.email_msgid']['checked'])) {
1814 print_liste_field_titre($arrayfields['p.email_msgid']['label'], $_SERVER["PHP_SELF"], "p.email_msgid", "", $param, '', $sortfield, $sortorder, 'center ');
1815 $totalarray['nbfield']++;
1816}
1817if (!empty($arrayfields['p.import_key']['checked'])) {
1818 print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, '');
1819 $totalarray['nbfield']++;
1820}
1821if (!empty($arrayfields['p.fk_statut']['checked'])) {
1822 print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
1823 $totalarray['nbfield']++;
1824}
1825// Action column
1826if (!$conf->main_checkbox_left_column) {
1827 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
1828 $totalarray['nbfield']++;
1829}
1830print '</tr></thead>'."\n";
1831
1832
1833$i = 0;
1834$savnbfield = $totalarray['nbfield'];
1835$totalarray = array(
1836 'nbfield' => 0,
1837 'val' => array()
1838);
1839$imaxinloop = ($limit ? min($num, $limit) : $num);
1840while ($i < $imaxinloop) {
1841 $obj = $db->fetch_object($resql);
1842 if (empty($obj)) {
1843 break; // Should not happen
1844 }
1845
1846 // Thirdparty
1847 $companystatic->id = $obj->socid;
1848 $companystatic->name = $obj->name;
1849 $companystatic->name_alias = $obj->alias;
1850 $companystatic->client = $obj->client;
1851 $companystatic->code_client = $obj->code_client;
1852 $companystatic->code_fournisseur = $obj->code_fournisseur;
1853 $companystatic->email = $obj->email;
1854 $companystatic->phone = $obj->phone;
1855 $companystatic->address = $obj->address;
1856 $companystatic->zip = $obj->zip;
1857 $companystatic->town = $obj->town;
1858 $companystatic->country_code = $obj->country_code;
1859
1860 // Project
1861 $object->id = $obj->id;
1862 $object->ref = $obj->ref;
1863 $object->title = $obj->title;
1864 $object->fk_project = $obj->fk_project;
1865 $object->fk_opp_status = $obj->fk_opp_status;
1866 $object->user_author_id = $obj->fk_user_creat;
1867 $object->date_creation = $db->jdate($obj->date_creation);
1868 $object->date_start = $db->jdate($obj->date_start);
1869 $object->date_end = $db->jdate($obj->date_end);
1870 $object->status = $obj->status;
1871 $object->public = $obj->public;
1872 $object->opp_percent = $obj->opp_percent;
1873 $object->opp_status = $obj->fk_opp_status;
1874 $object->opp_status_code = $obj->opp_status_code;
1875 $object->opp_amount = !empty($obj->opp_amount) ? $obj->opp_amount : "";
1876 $object->opp_weighted_amount = $obj->opp_weighted_amount;
1877 $object->budget_amount = $obj->budget_amount;
1878 $object->usage_opportunity = $obj->usage_opportunity;
1879 $object->usage_task = $obj->usage_task;
1880 $object->usage_bill_time = $obj->usage_bill_time;
1881 $object->usage_organize_event = $obj->usage_organize_event;
1882 $object->email_msgid = $obj->email_msgid;
1883 $object->import_key = $obj->import_key;
1884 $object->thirdparty = $companystatic;
1885
1886 //$userAccess = $object->restrictedProjectArea($user); // disabled, permission on project must be done by the select
1887
1888 $stringassignedusers = '';
1889
1890 if (!empty($arrayfields['c.assigned']['checked'])) {
1891 $ifisrt = 1;
1892 foreach (array('internal', 'external') as $source) {
1893 $tab = $object->liste_contact(-1, $source, 0, '', 1);
1894 $numcontact = count($tab);
1895 if (!empty($numcontact)) {
1896 foreach ($tab as $contactproject) {
1897 //var_dump($contacttask);
1898 if ($source == 'internal') {
1899 if (!empty($conf->cache['user'][$contactproject['id']])) {
1900 $c = $conf->cache['user'][$contactproject['id']];
1901 } else {
1902 $c = new User($db);
1903 $c->fetch($contactproject['id']);
1904 $conf->cache['user'][$contactproject['id']] = $c;
1905 }
1906 } else {
1907 if (!empty($conf->cache['contact'][$contactproject['id']])) {
1908 $c = $conf->cache['contact'][$contactproject['id']];
1909 } else {
1910 $c = new Contact($db);
1911 $c->fetch($contactproject['id']);
1912 $conf->cache['contact'][$contactproject['id']] = $c;
1913 }
1914 }
1915 if (get_class($c) == 'User') {
1916 $stringassignedusers .= $c->getNomUrl(-2, '', 0, 0, 24, 1, '', 'valignmiddle'.($ifisrt ? '' : ' notfirst'));
1917 } else {
1918 $stringassignedusers .= $c->getNomUrl(-2, '', 0, 0, -1, 0, 'valignmiddle'.($ifisrt ? '' : ' notfirst'));
1919 }
1920 $ifisrt = 0;
1921 }
1922 }
1923 }
1924 }
1925
1926 if ($mode == 'kanban' || $mode == 'kanbangroupby') {
1927 if ($i == 0) {
1928 print '<tr class="trkanban'.(empty($groupby) ? '' : ' trkanbangroupby').'"><td colspan="'.$savnbfield.'">';
1929 }
1930
1931 $groupbyvalue = 'unset';
1932 $groupbyfield = 'unsetfield';
1933 //var_dump($groupbyvalues);
1934
1935 if (!empty($groupby)) {
1936 $groupbyfield = preg_replace('/^[a-z]+\./', '', $groupby);
1937 // $groupbyold will be the value after the first pass to find break on the next pass.
1938 //var_dump("groupby=$groupby groupbyvalue=$groupbyvalue groupbyfield=$groupbyfield");
1939
1940 if (is_null($groupbyold)) {
1941 print '<div class="box-flex-container-columns kanban">'; // Start div for all kanban columns
1942 }
1943 // Start kanban column
1944 if (is_null($obj->$groupbyfield)) {
1945 $groupbyvalue = 'undefined';
1946 // We found a null value, we add an undefined value in dictionary of values $groupbyvalues
1947 $groupbyvalues[0] = array('id' => '0', 'label' => 'Undefined');
1948 } else {
1949 $groupbyvalue = $obj->$groupbyfield;
1950 }
1951
1952 if ($groupbyold !== $groupbyvalue) { // We found a break on a new column
1953 if (!is_null($groupbyold)) {
1954 print '</div>'; // We need a new kanban column - end box-flex-container
1955 }
1956
1957 $indexofgroupbyvalue = null;
1958
1959 // We show column that we must show before the first current record
1960 //var_dump("groupbyold=".$groupbyold.", current record to show has group value groupbyvalue=".$groupbyvalue);
1961 foreach ($groupbyvalues as $tmpcursor => $tmpgroupbyvalue) { // $tmpcursor is a i index like 0, 1, 2, ...
1962 // Is $tmpcursor a key before, equal or after the $groupbyvalue into the $groupbyvalues
1963 foreach ($groupbyvalues as $tmpcursor2 => $tmpgroupbyvalue2) {
1964 if ($tmpgroupbyvalue2['id'] == $groupbyvalue) { // We found the index of $groupbyvalue
1965 $indexofgroupbyvalue = $tmpcursor2;
1966 break;
1967 }
1968 }
1969 //var_dump('indexofgroupbyvalue='.$indexofgroupbyvalue);
1970
1971 if (!is_null($groupbyold)) {
1972 $indexofgroupbyold = null;
1973 foreach ($groupbyvalues as $tmpcursor2 => $tmpgroupbyvalue2) {
1974 if ($tmpgroupbyvalue2['id'] == $groupbyold) { // We found the index of $groupbyold
1975 $indexofgroupbyold = $tmpcursor2;
1976 break;
1977 }
1978 }
1979 //var_dump('indexofgroupbyold='.$indexofgroupbyold);
1980
1981 if ($tmpcursor <= $indexofgroupbyold) {
1982 continue;
1983 }
1984 }
1985 if ($tmpcursor >= $indexofgroupbyvalue) { // We reach the column to show, so we stop
1986 continue;
1987 }
1988
1989 // We found a possible column with no value, we output the empty column
1990 print '<!-- empty column before column of fetched value --><div class="box-flex-container-column kanban column';
1991 if (array_key_exists($tmpcursor, $groupofcollpasedvalues)) {
1992 print ' kanbancollapsed';
1993 }
1994 print '" data-groupbyid="'.preg_replace('/[^a-z0-9]/', '', $tmpgroupbyvalue['id']).'" data-groupbyfield="'.$groupbyfield.'">';
1995 print '<div class="kanbanlabel">'.$langs->trans($tmpgroupbyvalue['label']).'</div>';
1996 print '</div>'; // Start and end the new column
1997 }
1998
1999 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
2000 print '<div class="kanbanlabel">'.$langs->trans((is_null($indexofgroupbyvalue) || empty($groupbyvalues[$indexofgroupbyvalue]['label'])) ? 'Undefined' : $groupbyvalues[$indexofgroupbyvalue]['label']).'</div>';
2001 }
2002 $groupbyold = $groupbyvalue;
2003 } elseif ($i == 0) {
2004 print '<div class="box-flex-container kanban">';
2005 }
2006
2007 // Output Kanban
2008 $selected = -1;
2009 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2010 $selected = 0;
2011 if (in_array($object->id, $arrayofselected)) {
2012 $selected = 1;
2013 }
2014 }
2015 $arrayofdata = array('assignedusers' => $stringassignedusers, 'thirdparty' => $companystatic, 'selected' => $selected, 'mode' => $mode);
2016
2017 print $object->getKanbanView('', $arrayofdata, ($groupby ? 'small' : ''));
2018
2019 // if no more elements to show
2020 if ($i == ($imaxinloop - 1)) {
2021 // Close kanban column
2022 if (!empty($groupby)) {
2023 print '</div>'; // end box-flex-container
2024
2025 // We show column that we must show after the last current record
2026 //var_dump("groupbyold=".$groupbyold.", current record to show has group value groupbyvalue=".$groupbyvalue);
2027 foreach ($groupbyvalues as $tmpcursor => $tmpgroupbyvalue) {
2028 // Is $tmpcursor a key before, equal or after the $groupbyvalue into the $groupbyvalues
2029 $indexofgroupbyvalue = null;
2030 foreach ($groupbyvalues as $tmpcursor2 => $tmpgroupbyvalue2) {
2031 if ($tmpgroupbyvalue2['id'] == $groupbyvalue) { // We found the index of $groupbyvalue
2032 $indexofgroupbyvalue = $tmpcursor2;
2033 break;
2034 }
2035 }
2036 //var_dump('indexofgroupbyvalue='.$indexofgroupbyvalue);
2037
2038 if (!is_null($groupbyold)) {
2039 $indexofgroupbyold = null;
2040 foreach ($groupbyvalues as $tmpcursor2 => $tmpgroupbyvalue2) {
2041 if ($tmpgroupbyvalue2['id'] == $groupbyold) { // We found the index of $groupbyold
2042 $indexofgroupbyold = $tmpcursor2;
2043 break;
2044 }
2045 }
2046 //var_dump('indexofgroupbyold='.$indexofgroupbyold);
2047 }
2048
2049 //var_dump("tmpcursor=".$tmpcursor." groupbyold=".$groupbyold." groupbyvalue=".$groupbyvalue);
2050 if ($tmpcursor <= $indexofgroupbyvalue) {
2051 continue;
2052 }
2053 // We found a possible column with no value, we output the empty column
2054 print '<!-- empty column after column of fetched value --><div class="box-flex-container-column kanban column';
2055 if (array_key_exists($tmpcursor, $groupofcollpasedvalues)) {
2056 print ' kanbancollapsed';
2057 }
2058 print '" data-groupbyid="'.preg_replace('/[^a-z0-9]/', '', $tmpgroupbyvalue['id']).'" data-groupbyfield="'.$groupbyfield.'">';
2059 print '<div class="kanbanlabel">'.$langs->trans(empty($tmpgroupbyvalue['label']) ? 'Undefined' : $tmpgroupbyvalue['label']).'</div>';
2060 print '</div>'; // Start and end the new column
2061 }
2062 print '</div>'; // end box-flex-container-columns
2063 } else {
2064 print '</div>'; // end box-flex-container
2065 }
2066
2067 print '</td></tr>';
2068 }
2069 } else {
2070 // Author
2071 $userstatic->id = $obj->fk_user_creat;
2072 $userstatic->login = $obj->login;
2073 $userstatic->lastname = $obj->lastname;
2074 $userstatic->firstname = $obj->firstname;
2075 $userstatic->email = $obj->user_email;
2076 $userstatic->status = $obj->user_statut;
2077 $userstatic->entity = $obj->entity;
2078 $userstatic->photo = $obj->photo;
2079 $userstatic->office_phone = $obj->office_phone;
2080 $userstatic->office_fax = $obj->office_fax;
2081 $userstatic->user_mobile = $obj->user_mobile;
2082 $userstatic->job = $obj->job;
2083 $userstatic->gender = $obj->gender;
2084
2085 // Show here line of result
2086 $j = 0;
2087 print '<tr data-rowid="'.$object->id.'" class="oddeven row-with-select '.((getDolGlobalInt('MAIN_FINISHED_LINES_OPACITY') == 1 && $object->status > 1) ? 'opacitymedium' : '').'">';
2088 // Action column
2089 if ($conf->main_checkbox_left_column) {
2090 print '<td class="nowrap center">';
2091 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2092 $selected = 0;
2093 if (in_array($object->id, $arrayofselected)) {
2094 $selected = 1;
2095 }
2096 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
2097 }
2098 print '</td>';
2099 if (!$i) {
2100 $totalarray['nbfield']++;
2101 }
2102 }
2103 // Project ID
2104 if (!empty($arrayfields['p.rowid']['checked'])) {
2105 print '<td class="nowraponall">';
2106 print $object->id;
2107 print '</td>';
2108 if (!$i) {
2109 $totalarray['nbfield']++;
2110 }
2111 }
2112 // Project ref url
2113 if (!empty($arrayfields['p.ref']['checked'])) {
2114 print '<td class="nowraponall tdoverflowmax200">';
2115 print $object->getNomUrl(1, (!empty(GETPOSTINT('search_usage_event_organization')) ? 'eventorganization' : ''));
2116 if ($object->hasDelay()) {
2117 print img_warning($langs->trans('Late'));
2118 }
2119 print '</td>';
2120 if (!$i) {
2121 $totalarray['nbfield']++;
2122 }
2123 }
2124 // Project title
2125 if (!empty($arrayfields['p.title']['checked'])) {
2126 print '<td class="" title="'.dolPrintHTMLForAttribute($obj->title).'">';
2127 print '<div class="twolinesmax-normallineheight minwidth200onall spantitle">';
2128 print dolPrintHTML($obj->title);
2129 print '</div>';
2130 print '</td>';
2131 if (!$i) {
2132 $totalarray['nbfield']++;
2133 }
2134 }
2135 // Parent Project
2136 if (!empty($arrayfields['p.fk_project']['checked'])) {
2137 print '<td class="nowraponall">';
2138 if ($object->fk_project) {
2139 $parent_object = new Project($db);
2140 $parent_result = $parent_object->fetch($object->fk_project);
2141 if ($parent_result > 0) {
2142 $accessallowed = checkUserAccessToObject($user, array('projet'), $parent_object, 'projet&project', '', '', 'rowid', '');
2143 if ($accessallowed) {
2144 print $parent_object->getNomUrl(-1);
2145 } else {
2146 $parent_url = DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project;
2147 print '<a href="'.$parent_url.'">';
2148 print img_picto('', 'warning', 'class="pictofixedwidth error"');
2149 print '<del title="You do not have access to see parent project">ACCESS DENIED!</del>';
2150 print img_picto('', 'warning', 'class="pictofixedwidth error"');
2151 print '</a>';
2152 }
2153 } else {
2154 print((int) $object->fk_project);
2155 }
2156 }
2157
2158 print '</td>';
2159 if (!$i) {
2160 $totalarray['nbfield']++;
2161 }
2162 }
2163
2164 // Company
2165 if (!empty($arrayfields['s.nom']['checked'])) {
2166 print '<td class="tdoverflowmax125">';
2167 if ($obj->socid) {
2168 print $companystatic->getNomUrl(1, '', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
2169 } else {
2170 print '&nbsp;';
2171 }
2172 print '</td>';
2173 if (!$i) {
2174 $totalarray['nbfield']++;
2175 }
2176 }
2177 // Alias
2178 if (!empty($arrayfields['s.name_alias']['checked'])) {
2179 print '<td class="tdoverflowmax100">';
2180 if ($obj->socid) {
2181 print $companystatic->name_alias;
2182 } else {
2183 print '&nbsp;';
2184 }
2185 print '</td>';
2186 if (!$i) {
2187 $totalarray['nbfield']++;
2188 }
2189 }
2190 // Ref customer
2191 if (!empty($arrayfields['s.code_client']['checked'])) {
2192 print '<td class="tdoverflowmax100">';
2193 if ($obj->socid) {
2194 print $companystatic->code_client;
2195 } else {
2196 print '&nbsp;';
2197 }
2198 print '</td>';
2199 if (!$i) {
2200 $totalarray['nbfield']++;
2201 }
2202 }
2203 // Ref supplier
2204 if (!empty($arrayfields['s.code_fournisseur']['checked'])) {
2205 print '<td class="tdoverflowmax100">';
2206 if ($obj->socid) {
2207 print $companystatic->code_fournisseur;
2208 } else {
2209 print '&nbsp;';
2210 }
2211 print '</td>';
2212 if (!$i) {
2213 $totalarray['nbfield']++;
2214 }
2215 }
2216 // Country code
2217 if (!empty($arrayfields['co.country_code']['checked'])) {
2218 print '<td class="tdoverflowmax125 center">';
2219 print $obj->country_code;
2220 print '</td>';
2221 if (!$i) {
2222 $totalarray['nbfield']++;
2223 }
2224 }
2225 // Sales Representatives
2226 if (!empty($arrayfields['commercial']['checked'])) {
2227 print '<td class="tdoverflowmax150">';
2228 if ($obj->socid) {
2229 $PROJECT_MAX_SALES_TO_SHOW_IN_LIST = getDolGlobalInt('PROJECT_MAX_SALES_TO_SHOW_IN_LIST', 5);
2230 $companystatic->id = $obj->socid;
2231 $companystatic->name = $obj->name;
2232 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
2233 $nbofsalesrepresentative = count($listsalesrepresentatives);
2234 if ($nbofsalesrepresentative > $PROJECT_MAX_SALES_TO_SHOW_IN_LIST) {
2235 // We print only number
2236 print $nbofsalesrepresentative;
2237 } elseif ($nbofsalesrepresentative > 0) {
2238 $userstatic = new User($db);
2239 $j = 0;
2240 foreach ($listsalesrepresentatives as $val) {
2241 $userstatic->id = $val['id'];
2242 $userstatic->lastname = $val['lastname'];
2243 $userstatic->firstname = $val['firstname'];
2244 $userstatic->email = $val['email'];
2245 $userstatic->status = $val['statut'];
2246 $userstatic->entity = $val['entity'];
2247 $userstatic->photo = $val['photo'];
2248 $userstatic->login = $val['login'];
2249 $userstatic->office_phone = $val['office_phone'];
2250 $userstatic->office_fax = $val['office_fax'];
2251 $userstatic->user_mobile = $val['user_mobile'];
2252 $userstatic->job = $val['job'];
2253 $userstatic->gender = $val['gender'];
2254 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
2255 $j++;
2256 if ($j < $nbofsalesrepresentative) {
2257 print ' ';
2258 }
2259 }
2260 }
2261 //else print $langs->trans("NoSalesRepresentativeAffected");
2262 } else {
2263 print '&nbsp;';
2264 }
2265 print '</td>';
2266 if (!$i) {
2267 $totalarray['nbfield']++;
2268 }
2269 }
2270
2271 // Date start project
2272 if (!empty($arrayfields['p.dateo']['checked'])) {
2273 print '<td class="center">';
2274 print dol_print_date($db->jdate($obj->date_start), 'day');
2275 print '</td>';
2276 if (!$i) {
2277 $totalarray['nbfield']++;
2278 }
2279 }
2280 // Date end project
2281 if (!empty($arrayfields['p.datee']['checked'])) {
2282 print '<td class="center">';
2283 print dol_print_date($db->jdate($obj->date_end), 'day');
2284 print '</td>';
2285 if (!$i) {
2286 $totalarray['nbfield']++;
2287 }
2288 }
2289
2290 // Visibility
2291 if (!empty($arrayfields['p.public']['checked'])) {
2292 print '<td class="center">';
2293 if ($obj->public) {
2294 print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
2295 //print $langs->trans('SharedProject');
2296 } else {
2297 print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
2298 //print $langs->trans('PrivateProject');
2299 }
2300 print '</td>';
2301 if (!$i) {
2302 $totalarray['nbfield']++;
2303 }
2304 }
2305 // Assigned contacts of project
2306 if (!empty($arrayfields['c.assigned']['checked'])) {
2307 print '<td class="center nowraponall tdoverflowmax150">';
2308 print $stringassignedusers;
2309 print '</td>';
2310 if (!$i) {
2311 $totalarray['nbfield']++;
2312 }
2313 }
2314 // Opp Status
2315 if (!empty($arrayfields['p.fk_opp_status']['checked'])) {
2316 $s = '';
2317 if ($obj->opp_status_code) {
2318 $s = $langs->trans("OppStatus".$obj->opp_status_code);
2319 if (empty($arrayfields['p.opp_percent']['checked']) && $obj->opp_percent) {
2320 $s .= ' ('.dol_escape_htmltag(price2num($obj->opp_percent, 1)).'%)';
2321 }
2322 }
2323 print '<td class="center tdoverflowmax150" title="'.$s.'">';
2324 print $s;
2325 print '</td>';
2326 if (!$i) {
2327 $totalarray['nbfield']++;
2328 }
2329 }
2330 // Opp Amount
2331 if (!empty($arrayfields['p.opp_amount']['checked'])) {
2332 print '<td class="right">';
2333 //if ($obj->opp_status_code)
2334 if (isset($obj->opp_amount) && strcmp($obj->opp_amount, '')) {
2335 print '<span class="amount">'.price($obj->opp_amount, 1, $langs, 1, -1, -1, '').'</span>';
2336 if (!isset($totalarray['val']['p.opp_amount'])) {
2337 $totalarray['val']['p.opp_amount'] = $obj->opp_amount;
2338 } else {
2339 $totalarray['val']['p.opp_amount'] += $obj->opp_amount;
2340 }
2341 }
2342 print '</td>';
2343 if (!$i) {
2344 $totalarray['nbfield']++;
2345 }
2346 if (!$i) {
2347 $totalarray['pos'][$totalarray['nbfield']] = 'p.opp_amount';
2348 }
2349 }
2350 // Opp percent
2351 if (!empty($arrayfields['p.opp_percent']['checked'])) {
2352 print '<td class="right">';
2353 if ($obj->opp_percent) {
2354 print price($obj->opp_percent, 1, $langs, 1, 0).'%';
2355 }
2356 print '</td>';
2357 if (!$i) {
2358 $totalarray['nbfield']++;
2359 }
2360 }
2361 // Opp weighted amount
2362 if (!empty($arrayfields['opp_weighted_amount']['checked'])) {
2363 if (!isset($totalarray['val']['opp_weighted_amount'])) {
2364 $totalarray['val']['opp_weighted_amount'] = 0;
2365 }
2366 print '<td align="right">';
2367 if ($obj->opp_weighted_amount) {
2368 print '<span class="amount">'.price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, '').'</span>';
2369 $totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount;
2370 }
2371 print '</td>';
2372 if (!$i) {
2373 $totalarray['nbfield']++;
2374 $totalarray['pos'][$totalarray['nbfield']] = 'opp_weighted_amount';
2375 }
2376 }
2377 // Budget
2378 if (!empty($arrayfields['p.budget_amount']['checked'])) {
2379 print '<td class="right">';
2380 if ($obj->budget_amount != '') {
2381 print '<span class="amount">'.price($obj->budget_amount, 1, $langs, 1, -1, -1).'</span>';
2382 if (!isset($totalarray['val']['p.budget_amount'])) {
2383 $totalarray['val']['p.budget_amount'] = $obj->budget_amount;
2384 } else {
2385 $totalarray['val']['p.budget_amount'] += $obj->budget_amount;
2386 }
2387 }
2388 print '</td>';
2389 if (!$i) {
2390 $totalarray['nbfield']++;
2391 $totalarray['pos'][$totalarray['nbfield']] = 'p.budget_amount';
2392 }
2393 }
2394 // Usage opportunity
2395 if (!empty($arrayfields['p.usage_opportunity']['checked'])) {
2396 print '<td class="center">';
2397 if ($obj->usage_opportunity) {
2398 print yn($obj->usage_opportunity, 4);
2399 }
2400 print '</td>';
2401 if (!$i) {
2402 $totalarray['nbfield']++;
2403 }
2404 }
2405 // Usage task
2406 if (!empty($arrayfields['p.usage_task']['checked'])) {
2407 print '<td class="center">';
2408 if ($obj->usage_task) {
2409 print yn($obj->usage_task, 4);
2410 }
2411 print '</td>';
2412 if (!$i) {
2413 $totalarray['nbfield']++;
2414 }
2415 }
2416 // Usage bill time
2417 if (!empty($arrayfields['p.usage_bill_time']['checked'])) {
2418 print '<td class="center">';
2419 if ($obj->usage_bill_time) {
2420 print yn($obj->usage_bill_time, 4);
2421 }
2422 print '</td>';
2423 if (!$i) {
2424 $totalarray['nbfield']++;
2425 }
2426 }
2427 // Usage event organization
2428 if (!empty($arrayfields['p.usage_organize_event']['checked'])) {
2429 print '<td class="center">';
2430 if ($obj->usage_organize_event) {
2431 print yn($obj->usage_organize_event, 4);
2432 }
2433 print '</td>';
2434 if (!$i) {
2435 $totalarray['nbfield']++;
2436 }
2437 }
2438 // Allow unknown people to suggest conferences
2439 if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) {
2440 print '<td class="center">';
2441 if ($obj->accept_conference_suggestions) {
2442 print yn($obj->accept_conference_suggestions);
2443 }
2444 print '</td>';
2445 if (!$i) {
2446 $totalarray['nbfield']++;
2447 }
2448 }
2449 // Allow unknown people to suggest booth
2450 if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) {
2451 print '<td class="">';
2452 if ($obj->accept_booth_suggestions) {
2453 print yn($obj->accept_booth_suggestions);
2454 }
2455 print '</td>';
2456 if (!$i) {
2457 $totalarray['nbfield']++;
2458 }
2459 }
2460 // Price of registration
2461 if (!empty($arrayfields['p.price_registration']['checked'])) {
2462 print '<td class="right">';
2463 if ($obj->price_registration != '') {
2464 print '<span class="amount">'.price($obj->price_registration, 1, $langs, 1, -1, -1).'</span>';
2465 $totalarray['val']['p.price_registration'] += $obj->price_registration;
2466 }
2467 print '</td>';
2468 if (!$i) {
2469 $totalarray['nbfield']++;
2470 }
2471 if (!$i) {
2472 $totalarray['pos'][$totalarray['nbfield']] = 'p.price_registration';
2473 }
2474 }
2475 // Price of booth
2476 if (!empty($arrayfields['p.price_booth']['checked'])) {
2477 print '<td class="right">';
2478 if ($obj->price_booth != '') {
2479 print '<span class="amount">'.price($obj->price_booth, 1, $langs, 1, -1, -1).'</span>';
2480 $totalarray['val']['p.price_booth'] += $obj->price_booth;
2481 }
2482 print '</td>';
2483 if (!$i) {
2484 $totalarray['nbfield']++;
2485 }
2486 if (!$i) {
2487 $totalarray['pos'][$totalarray['nbfield']] = 'p.price_booth';
2488 }
2489 }
2490 // Author
2491 if (!empty($arrayfields['u.login']['checked'])) {
2492 print '<td class="center tdoverflowmax150">';
2493 if ($userstatic->id) {
2494 print $userstatic->getNomUrl(-1);
2495 }
2496 print "</td>\n";
2497 if (!$i) {
2498 $totalarray['nbfield']++;
2499 }
2500 }
2501 // Extra fields
2502 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
2503 // Fields from hook
2504 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
2505 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2506 print $hookmanager->resPrint;
2507 // Date creation
2508 if (!empty($arrayfields['p.datec']['checked'])) {
2509 print '<td class="center nowraponall">';
2510 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
2511 print '</td>';
2512 if (!$i) {
2513 $totalarray['nbfield']++;
2514 }
2515 }
2516 // Date modification
2517 if (!empty($arrayfields['p.tms']['checked'])) {
2518 print '<td class="center nowraponall">';
2519 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser');
2520 print '</td>';
2521 if (!$i) {
2522 $totalarray['nbfield']++;
2523 }
2524 }
2525 // Email MsgID
2526 if (!empty($arrayfields['p.email_msgid']['checked'])) {
2527 print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($obj->email_msgid).'">';
2528 print dol_escape_htmltag($obj->email_msgid);
2529 print '</td>';
2530 if (!$i) {
2531 $totalarray['nbfield']++;
2532 }
2533 }
2534 // Import key
2535 if (!empty($arrayfields['p.import_key']['checked'])) {
2536 print '<td class="right">'.dol_escape_htmltag($obj->import_key).'</td>';
2537 if (!$i) {
2538 $totalarray['nbfield']++;
2539 }
2540 }
2541 // Status
2542 if (!empty($arrayfields['p.fk_statut']['checked'])) {
2543 print '<td class="center">'.$object->getLibStatut(5).'</td>';
2544 if (!$i) {
2545 $totalarray['nbfield']++;
2546 }
2547 }
2548 // Action column
2549 if (!$conf->main_checkbox_left_column) {
2550 print '<td class="nowrap center">';
2551 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2552 $selected = 0;
2553 if (in_array($object->id, $arrayofselected)) {
2554 $selected = 1;
2555 }
2556 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
2557 }
2558 print '</td>';
2559 if (!$i) {
2560 $totalarray['nbfield']++;
2561 }
2562 }
2563
2564 print '</tr>'."\n";
2565 }
2566
2567 $i++;
2568}
2569
2570// Show total line
2571include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
2572
2573// If no record found
2574if ($num == 0) {
2575 $colspan = 1;
2576 foreach ($arrayfields as $key => $val) {
2577 if (!empty($val['checked'])) {
2578 $colspan++;
2579 }
2580 }
2581 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
2582}
2583
2584$db->free($resql);
2585
2586$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
2587$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2588print $hookmanager->resPrint;
2589
2590print '</table>'."\n";
2591print '</div>'."\n";
2592
2593print '</form>'."\n";
2594
2595if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
2596 $hidegeneratedfilelistifempty = 1;
2597 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
2598 $hidegeneratedfilelistifempty = 0;
2599 }
2600
2601 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
2602 $formfile = new FormFile($db);
2603
2604 // Show list of available documents
2605 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
2606 $urlsource .= str_replace('&amp;', '&', $param);
2607
2608 $filedir = $diroutputmassaction;
2609 $genallowed = $permissiontoread;
2610 $delallowed = $permissiontoadd;
2611
2612 print $formfile->showdocuments('massfilesarea_'.$object->module, '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
2613}
2614
2615// End of page
2616llxFooter();
2617$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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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.
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.
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).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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
buildzip.php
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.