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