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