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