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