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