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