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