dolibarr  13.0.2
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 require '../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
37 
38 if (!empty($conf->categorie->enabled))
39 {
40  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
41  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
42 }
43 
44 // Load translation files required by the page
45 $langs->loadLangs(array('projects', 'companies', 'commercial'));
46 
47 $action = GETPOST('action', 'aZ09');
48 $massaction = GETPOST('massaction', 'alpha');
49 $show_files = GETPOST('show_files', 'int');
50 $confirm = GETPOST('confirm', 'alpha');
51 $toselect = GETPOST('toselect', 'array');
52 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'projectlist';
53 
54 $title = $langs->trans("Projects");
55 
56 // Security check
57 $socid = (is_numeric($_GET["socid"]) ? $_GET["socid"] : 0);
58 //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.
59 if ($socid > 0)
60 {
61  $soc = new Societe($db);
62  $soc->fetch($socid);
63  $title .= ' (<a href="list.php">'.$soc->name.'</a>)';
64 }
65 if (!$user->rights->projet->lire) accessforbidden();
66 
67 $diroutputmassaction = $conf->projet->dir_output.'/temp/massgeneration/'.$user->id;
68 
69 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
70 $sortfield = GETPOST("sortfield", "aZ09comma");
71 $sortorder = GETPOST("sortorder", 'aZ09comma');
72 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
73 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters
74 if (!$sortfield) $sortfield = "p.ref";
75 if (!$sortorder) $sortorder = "ASC";
76 $offset = $limit * $page;
77 $pageprev = $page - 1;
78 $pagenext = $page + 1;
79 
80 $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
81 $search_ref = GETPOST("search_ref", 'alpha');
82 $search_label = GETPOST("search_label", 'alpha');
83 $search_societe = GETPOST("search_societe", 'alpha');
84 $search_status = GETPOST("search_status", 'int');
85 $search_opp_status = GETPOST("search_opp_status", 'alpha');
86 $search_opp_percent = GETPOST("search_opp_percent", 'alpha');
87 $search_opp_amount = GETPOST("search_opp_amount", 'alpha');
88 $search_budget_amount = GETPOST("search_budget_amount", 'alpha');
89 $search_public = GETPOST("search_public", 'int');
90 $search_project_user = GETPOST('search_project_user', 'int');
91 $search_sale = GETPOST('search_sale', 'int');
92 $search_usage_opportunity = GETPOST('search_usage_opportunity', 'int');
93 $search_usage_task = GETPOST('search_usage_task', 'int');
94 $search_usage_bill_time = GETPOST('search_usage_bill_time', 'int');
95 $optioncss = GETPOST('optioncss', 'alpha');
96 
97 $mine = $_REQUEST['mode'] == 'mine' ? 1 : 0;
98 if ($mine) { $search_project_user = $user->id; $mine = 0; }
99 
100 $search_sday = GETPOST('search_sday', 'int');
101 $search_smonth = GETPOST('search_smonth', 'int');
102 $search_syear = GETPOST('search_syear', 'int');
103 $search_eday = GETPOST('search_eday', 'int');
104 $search_emonth = GETPOST('search_emonth', 'int');
105 $search_eyear = GETPOST('search_eyear', 'int');
106 
107 if ($search_status == '') $search_status = -1; // -1 or 1
108 
109 if (!empty($conf->categorie->enabled))
110 {
111  $search_category_array = GETPOST("search_category_".Categorie::TYPE_PROJECT."_list", "array");
112 }
113 
114 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
115 $object = new Project($db);
116 $hookmanager->initHooks(array('projectlist'));
117 $extrafields = new ExtraFields($db);
118 
119 // fetch optionals attributes and labels
120 $extrafields->fetch_name_optionals_label($object->table_element);
121 
122 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
123 
124 // List of fields to search into when doing a "search in all"
125 $fieldstosearchall = array();
126 foreach ($object->fields as $key => $val) {
127  if (empty($val['searchall'])) {
128  continue;
129  }
130 
131  // Don't allow search in private notes for external users when doing "search in all"
132  if (!empty($user->socid) && $key == "note_private") {
133  continue;
134  }
135 
136  $fieldstosearchall['p.'.$key] = $val['label'];
137 }
138 
139 // Add name object fields to "search in all"
140 $fieldstosearchall['s.nom'] = "ThirdPartyName";
141 
142 // Definition of array of fields for columns
143 $arrayfields = array();
144 foreach ($object->fields as $key => $val) {
145  // If $val['visible']==0, then we never show the field
146  if (!empty($val['visible'])) {
147  $visible = dol_eval($val['visible'], 1);
148  $arrayfields['p.'.$key] = array(
149  'label'=>$val['label'],
150  'checked'=>(($visible < 0) ? 0 : 1),
151  'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
152  'position'=>$val['position'],
153  'help'=>$val['help']
154  );
155  }
156 }
157 // Extra fields
158 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
159 
160 // Add none object fields to fields for list
161 $arrayfields['s.nom'] = array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>21, 'enabled'=>(empty($conf->societe->enabled) ? 0 : 1));
162 $arrayfields['commercial'] = array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>0, 'position'=>23);
163 $arrayfields['opp_weighted_amount'] = array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'position'=> 116, 'enabled'=>(empty($conf->global->PROJECT_USE_OPPORTUNITIES) ? 0 : 1), 'position'=>106);
164 
165 $object->fields = dol_sort_array($object->fields, 'position');
166 $arrayfields = dol_sort_array($arrayfields, 'position');
167 
168 
169 
170 /*
171  * Actions
172  */
173 
174 if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
175 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; }
176 
177 $parameters = array('socid'=>$socid);
178 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
179 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
180 
181 if (empty($reshook))
182 {
183  // Selection of new fields
184  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
185 
186  // Purge search criteria
187  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
188  {
189  $search_all = '';
190  $search_ref = "";
191  $search_label = "";
192  $search_societe = "";
193  $search_status = -1;
194  $search_opp_status = -1;
195  $search_opp_amount = '';
196  $search_opp_percent = '';
197  $search_budget_amount = '';
198  $search_public = "";
199  $search_sale = "";
200  $search_project_user = '';
201  $search_sday = "";
202  $search_smonth = "";
203  $search_syear = "";
204  $search_eday = "";
205  $search_emonth = "";
206  $search_eyear = "";
207  $search_usage_opportunity = '';
208  $search_usage_task = '';
209  $search_usage_bill_time = '';
210  $toselect = '';
211  $search_array_options = array();
212  $search_category_array = array();
213  }
214 
215 
216  // Mass actions
217  $objectclass = 'Project';
218  $objectlabel = 'Project';
219  $permissiontoread = $user->rights->projet->lire;
220  $permissiontodelete = $user->rights->projet->supprimer;
221  $uploaddir = $conf->projet->dir_output;
222  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
223 
224  // Close records
225  if (!$error && $massaction == 'close' && $user->rights->projet->creer)
226  {
227  $db->begin();
228 
229  $objecttmp = new $objectclass($db);
230  $nbok = 0;
231  foreach ($toselect as $toselectid)
232  {
233  $result = $objecttmp->fetch($toselectid);
234  if ($result > 0)
235  {
236  $userWrite = $object->restrictedProjectArea($user, 'write');
237  if ($userWrite > 0 && $objecttmp->statut == 1) {
238  $result = $objecttmp->setClose($user);
239  if ($result <= 0) {
240  setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
241  $error++;
242  break;
243  } else $nbok++;
244  } elseif ($userWrite <= 0) {
245  setEventMessages($langs->trans("DontHavePermissionForCloseProject", $objecttmp->ref), null, 'warnings');
246  } else {
247  setEventMessages($langs->trans("DontHaveTheValidateStatus", $objecttmp->ref), null, 'warnings');
248  }
249  } else {
250  setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
251  $error++;
252  break;
253  }
254  }
255 
256  if (!$error)
257  {
258  if ($nbok > 1) setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs');
259  else setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs');
260  $db->commit();
261  } else {
262  $db->rollback();
263  }
264  }
265 }
266 
267 
268 /*
269  * View
270  */
271 
272 $socstatic = new Societe($db);
273 $form = new Form($db);
274 $formother = new FormOther($db);
275 $formproject = new FormProjets($db);
276 
277 $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
278 $title = $langs->trans("Projects");
279 
280 
281 // Get list of project id allowed to user (in a string list separated by comma)
282 $projectsListId = '';
283 if (!$user->rights->projet->all->lire) $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $socid);
284 
285 // Get id of types of contacts for projects (This list never contains a lot of elements)
286 $listofprojectcontacttype = array();
287 $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
288 $sql .= " WHERE ctc.element = '".$db->escape($object->element)."'";
289 $sql .= " AND ctc.source = 'internal'";
290 $resql = $db->query($sql);
291 if ($resql)
292 {
293  while ($obj = $db->fetch_object($resql))
294  {
295  $listofprojectcontacttype[$obj->rowid] = $obj->code;
296  }
297 } else dol_print_error($db);
298 if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found
299 
300 $distinct = 'DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once.
301 $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";
302 $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, p.usage_opportunity, p.usage_task, p.usage_bill_time";
303 $sql .= ", s.rowid as socid, s.nom as name, s.email";
304 $sql .= ", cls.code as opp_status_code";
305 // Add fields from extrafields
306 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
307  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
308 }
309 // Add fields from hooks
310 $parameters = array();
311 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
312 $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
313 $sql = preg_replace('/,\s*$/', '', $sql);
314 $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as p";
315 if (!empty($conf->categorie->enabled))
316 {
317  $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_PROJECT, "p.rowid");
318 }
319 if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)";
320 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
321 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid";
322 // We'll need this table joined to the select in order to filter by sale
323 // No check is done on company permission because readability is managed by public status of project and assignement.
324 //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";
325 if ($search_sale > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
326 if ($search_project_user > 0)
327 {
328  $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp";
329 }
330 $sql .= " WHERE p.entity IN (".getEntity('project').')';
331 if (!empty($conf->categorie->enabled))
332 {
333  $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_PROJECT, "p.rowid", $search_category_array);
334 }
335 if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users
336 // No need to check if company is external user, as filtering of projects must be done by getProjectsAuthorizedForUser
337 if ($socid > 0) $sql .= " AND (p.fk_soc = ".$socid.")"; // This filter if when we use a hard coded filter on company on url (not related to filter for external users)
338 if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
339 if ($search_label) $sql .= natural_search('p.title', $search_label);
340 if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
341 if ($search_opp_amount) $sql .= natural_search('p.opp_amount', $search_opp_amount, 1);
342 if ($search_opp_percent) $sql .= natural_search('p.opp_percent', $search_opp_percent, 1);
343 $sql .= dolSqlDateFilter('p.dateo', $search_sday, $search_smonth, $search_syear);
344 $sql .= dolSqlDateFilter('p.datee', $search_eday, $search_emonth, $search_eyear);
345 if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
346 if ($search_status >= 0)
347 {
348  if ($search_status == 99) $sql .= " AND p.fk_statut <> 2";
349  else $sql .= " AND p.fk_statut = ".$db->escape($search_status);
350 }
351 if ($search_opp_status)
352 {
353  if (is_numeric($search_opp_status) && $search_opp_status > 0) $sql .= " AND p.fk_opp_status = ".$db->escape($search_opp_status);
354  if ($search_opp_status == 'all') $sql .= " AND (p.fk_opp_status IS NOT NULL AND p.fk_opp_status <> -1)";
355  if ($search_opp_status == 'openedopp') $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'))";
356  if ($search_opp_status == 'notopenedopp') $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 IN ('WON')))";
357  if ($search_opp_status == 'none') $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1)";
358 }
359 if ($search_public != '') $sql .= " AND p.public = ".$db->escape($search_public);
360 // For external user, no check is done on company permission because readability is managed by public status of project and assignement.
361 //if ($socid > 0) $sql.= " AND s.rowid = ".$socid;
362 if ($search_sale > 0) $sql .= " AND sc.fk_user = ".$search_sale;
363 // No check is done on company permission because readability is managed by public status of project and assignement.
364 //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))";
365 if ($search_project_user > 0) $sql .= " AND ecp.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user;
366 if ($search_opp_amount != '') $sql .= natural_search('p.opp_amount', $search_opp_amount, 1);
367 if ($search_budget_amount != '') $sql .= natural_search('p.budget_amount', $search_budget_amount, 1);
368 if ($search_usage_opportunity != '' && $search_usage_opportunity >= 0) $sql .= natural_search('p.usage_opportunity', $search_usage_opportunity, 2);
369 if ($search_usage_task != '' && $search_usage_task >= 0) $sql .= natural_search('p.usage_task', $search_usage_task, 2);
370 if ($search_usage_bill_time != '' && $search_usage_bill_time >= 0) $sql .= natural_search('p.usage_bill_time', $search_usage_bill_time, 2);
371 // Add where from extra fields
372 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
373 // Add where from hooks
374 $parameters = array();
375 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
376 $sql .= $hookmanager->resPrint;
377 $sql .= $db->order($sortfield, $sortorder);
378 
379 // Count total nb of records
380 $nbtotalofrecords = '';
381 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
382  $resql = $db->query($sql);
383  $nbtotalofrecords = $db->num_rows($resql);
384  if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
385  $page = 0;
386  $offset = 0;
387  }
388 }
389 // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
390 if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
391  $num = $nbtotalofrecords;
392 } else {
393  if ($limit) $sql .= $db->plimit($limit + 1, $offset);
394 
395  $resql = $db->query($sql);
396  if (!$resql) {
397  dol_print_error($db);
398  exit;
399  }
400 
401  $num = $db->num_rows($resql);
402 }
403 
404 // Direct jump if only one record found
405 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
406 {
407  $obj = $db->fetch_object($resql);
408  header("Location: ".DOL_URL_ROOT.'/projet/card.php?id='.$obj->id);
409  exit;
410 }
411 
412 
413 // Output page
414 // --------------------------------------------------------------------
415 
416 dol_syslog("list allowed project", LOG_DEBUG);
417 
418 llxHeader('', $title, $help_url);
419 
420 $arrayofselected = is_array($toselect) ? $toselect : array();
421 
422 $param = '';
423 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
424 if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
425 if ($search_all != '') $param .= '&search_all='.urlencode($search_all);
426 if ($search_sday) $param .= '&search_sday='.urlencode($search_sday);
427 if ($search_smonth) $param .= '&search_smonth='.urlencode($search_smonth);
428 if ($search_syear) $param .= '&search_syear='.urlencode($search_syear);
429 if ($search_eday) $param .= '&search_eday='.urlencode($search_eday);
430 if ($search_emonth) $param .= '&search_emonth='.urlencode($search_emonth);
431 if ($search_eyear) $param .= '&search_eyear='.urlencode($search_eyear);
432 if ($socid) $param .= '&socid='.urlencode($socid);
433 if ($search_categ) $param .= '&search_categ='.urlencode($search_categ);
434 if ($search_ref != '') $param .= '&search_ref='.urlencode($search_ref);
435 if ($search_label != '') $param .= '&search_label='.urlencode($search_label);
436 if ($search_societe != '') $param .= '&search_societe='.urlencode($search_societe);
437 if ($search_status >= 0) $param .= '&search_status='.urlencode($search_status);
438 if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'openedopp', 'notopenedopp', 'none'))) $param .= '&search_opp_status='.urlencode($search_opp_status);
439 if ($search_opp_percent != '') $param .= '&search_opp_percent='.urlencode($search_opp_percent);
440 if ($search_public != '') $param .= '&search_public='.urlencode($search_public);
441 if ($search_project_user != '') $param .= '&search_project_user='.urlencode($search_project_user);
442 if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale);
443 if ($search_opp_amount != '') $param .= '&search_opp_amount='.urlencode($search_opp_amount);
444 if ($search_budget_amount != '') $param .= '&search_budget_amount='.urlencode($search_budget_amount);
445 if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
446 // Add $param from extra fields
447 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
448 
449 // List of mass actions available
450 $arrayofmassactions = array(
451  'generate_doc'=>$langs->trans("ReGeneratePDF"),
452  //'builddoc'=>$langs->trans("PDFMerge"),
453  //'presend'=>$langs->trans("SendByMail"),
454 );
455 //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
456 if ($user->rights->projet->creer) $arrayofmassactions['close'] = $langs->trans("Close");
457 if ($user->rights->projet->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
458 if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
459 
460 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
461 
462 $url = DOL_URL_ROOT.'/projet/card.php?action=create';
463 if (!empty($socid)) $url .= '&socid='.$socid;
464 $newcardbutton = dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', $url, '', $user->rights->projet->creer);
465 
466 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
467 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
468 print '<input type="hidden" name="token" value="'.newToken().'">';
469 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
470 print '<input type="hidden" name="action" value="list">';
471 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
472 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
473 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
474 
475 // Show description of content
476 $texthelp = '';
477 if ($search_project_user == $user->id) $texthelp .= $langs->trans("MyProjectsDesc");
478 else {
479  if ($user->rights->projet->all->lire && !$socid) $texthelp .= $langs->trans("ProjectsDesc");
480  else $texthelp .= $langs->trans("ProjectsPublicDesc");
481 }
482 
483 print_barre_liste($form->textwithpicto($title, $texthelp), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit, 0, 0, 1);
484 
485 
486 $topicmail = "Information";
487 $modelmail = "project";
488 $objecttmp = new Project($db);
489 $trackid = 'proj'.$object->id;
490 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
491 
492 if ($search_all)
493 {
494  foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
495  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
496 }
497 
498 $moreforfilter = '';
499 
500 // Filter on categories
501 if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire)
502 {
503  $formcategory = new FormCategory($db);
504  $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array);
505 }
506 
507 // If the user can view user other than himself
508 $moreforfilter .= '<div class="divsearchfield">';
509 $moreforfilter .= $langs->trans('ProjectsWithThisUserAsContact').': ';
510 //$includeonly = 'hierarchyme';
511 $includeonly = '';
512 if (empty($user->rights->user->user->lire)) $includeonly = array($user->id);
513 $moreforfilter .= $form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200');
514 $moreforfilter .= '</div>';
515 
516 // If the user can view thirdparties other than his'
517 if ($user->rights->societe->client->voir || $socid)
518 {
519  $langs->load("commercial");
520  $moreforfilter .= '<div class="divsearchfield">';
521  $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': ';
522  $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200');
523  $moreforfilter .= '</div>';
524 }
525 
526 if (!empty($moreforfilter))
527 {
528  print '<div class="liste_titre liste_titre_bydiv centpercent">';
529  print $moreforfilter;
530  $parameters = array();
531  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
532  print $hookmanager->resPrint;
533  print '</div>';
534 }
535 
536 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
537 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
538 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
539 
540 print '<div class="div-table-responsive">';
541 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
542 
543 // Fields title search
544 // --------------------------------------------------------------------
545 print '<tr class="liste_titre_filter">';
546 // Project ref
547 if (!empty($arrayfields['p.ref']['checked']))
548 {
549  print '<td class="liste_titre">';
550  print '<input type="text" class="flat" name="search_ref" value="'.dol_escape_htmltag($search_ref).'" size="6">';
551  print '</td>';
552 }
553 // Project label
554 if (!empty($arrayfields['p.title']['checked']))
555 {
556  print '<td class="liste_titre">';
557  print '<input type="text" class="flat" name="search_label" size="8" value="'.dol_escape_htmltag($search_label).'">';
558  print '</td>';
559 }
560 // Third party
561 if (!empty($arrayfields['s.nom']['checked']))
562 {
563  print '<td class="liste_titre">';
564  if ($socid > 0)
565  {
566  $tmpthirdparty = new Societe($db);
567  $tmpthirdparty->fetch($socid);
568  $search_societe = $tmpthirdparty->nom;
569  }
570  print '<input type="text" class="flat" name="search_societe" size="8" value="'.dol_escape_htmltag($search_societe).'">';
571  print '</td>';
572 }
573 // Sale representative
574 if (!empty($arrayfields['commercial']['checked']))
575 {
576  print '<td class="liste_titre">&nbsp;</td>';
577 }
578 // Start date
579 if (!empty($arrayfields['p.dateo']['checked']))
580 {
581  print '<td class="liste_titre center nowraponall">';
582  if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_sday" value="'.dol_escape_htmltag($search_sday).'">';
583  print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_smonth" value="'.dol_escape_htmltag($search_smonth).'">';
584  $formother->select_year($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');
585  print '</td>';
586 }
587 // End date
588 if (!empty($arrayfields['p.datee']['checked']))
589 {
590  print '<td class="liste_titre center nowraponall">';
591  if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_eday" value="'.dol_escape_htmltag($search_eday).'">';
592  print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_emonth" value="'.dol_escape_htmltag($search_emonth).'">';
593  $formother->select_year($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');
594  print '</td>';
595 }
596 if (!empty($arrayfields['p.public']['checked']))
597 {
598  print '<td class="liste_titre">';
599  $array = array(''=>'', 0 => $langs->trans("PrivateProject"), 1 => $langs->trans("SharedProject"));
600  print $form->selectarray('search_public', $array, $search_public);
601  print '</td>';
602 }
603 // Opp status
604 if (!empty($arrayfields['p.fk_opp_status']['checked']))
605 {
606  print '<td class="liste_titre nowrap center">';
607  print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 0, 1, 0, 'maxwidth100');
608  print '</td>';
609 }
610 if (!empty($arrayfields['p.opp_amount']['checked']))
611 {
612  print '<td class="liste_titre nowrap right">';
613  print '<input type="text" class="flat" name="search_opp_amount" size="3" value="'.$search_opp_amount.'">';
614  print '</td>';
615 }
616 if (!empty($arrayfields['p.opp_percent']['checked']))
617 {
618  print '<td class="liste_titre nowrap right">';
619  print '<input type="text" class="flat" name="search_opp_percent" size="2" value="'.$search_opp_percent.'">';
620  print '</td>';
621 }
622 if (!empty($arrayfields['opp_weighted_amount']['checked']))
623 {
624  print '<td class="liste_titre nowrap right">';
625  print '</td>';
626 }
627 if (!empty($arrayfields['p.budget_amount']['checked']))
628 {
629  print '<td class="liste_titre nowrap right">';
630  print '<input type="text" class="flat" name="search_budget_amount" size="4" value="'.$search_budget_amount.'">';
631  print '</td>';
632 }
633 if (!empty($arrayfields['p.usage_opportunity']['checked']))
634 {
635  print '<td class="liste_titre nowrap right">';
636  print $form->selectyesno('search_usage_opportunity', $search_usage_opportunity, 1, false, 1);
637  print '';
638  print '</td>';
639 }
640 if (!empty($arrayfields['p.usage_task']['checked']))
641 {
642  print '<td class="liste_titre nowrap right">';
643  print $form->selectyesno('search_usage_task', $search_usage_task, 1, false, 1);
644  print '</td>';
645 }
646 if (!empty($arrayfields['p.usage_bill_time']['checked']))
647 {
648  print '<td class="liste_titre nowrap right">';
649  print $form->selectyesno('search_usage_bill_time', $search_usage_bill_time, 1, false, 1);
650  print '</td>';
651 }
652 // Extra fields
653 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
654 
655 // Fields from hook
656 $parameters = array('arrayfields'=>$arrayfields);
657 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
658 print $hookmanager->resPrint;
659 if (!empty($arrayfields['p.datec']['checked']))
660 {
661  // Date creation
662  print '<td class="liste_titre">';
663  print '</td>';
664 }
665 if (!empty($arrayfields['p.tms']['checked']))
666 {
667  // Date modification
668  print '<td class="liste_titre">';
669  print '</td>';
670 }
671 if (!empty($arrayfields['p.fk_statut']['checked']))
672 {
673  print '<td class="liste_titre nowrap right">';
674  $arrayofstatus = array();
675  foreach ($object->statuts_short as $key => $val) $arrayofstatus[$key] = $langs->trans($val);
676  $arrayofstatus['99'] = $langs->trans("NotClosed").' ('.$langs->trans('Draft').' + '.$langs->trans('Opened').')';
677  print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'minwidth75imp maxwidth150 selectarrowonleft');
678  print ajax_combobox('search_status');
679  print '</td>';
680 }
681 // Action column
682 print '<td class="liste_titre maxwidthsearch">';
683 $searchpicto = $form->showFilterButtons();
684 print $searchpicto;
685 print '</td>';
686 
687 print '</tr>'."\n";
688 
689 print '<tr class="liste_titre">';
690 if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder);
691 if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder);
692 if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
693 if (!empty($arrayfields['commercial']['checked'])) print_liste_field_titre($arrayfields['commercial']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder, 'tdoverflowmax100imp ');
694 if (!empty($arrayfields['p.dateo']['checked'])) print_liste_field_titre($arrayfields['p.dateo']['label'], $_SERVER["PHP_SELF"], "p.dateo", "", $param, '', $sortfield, $sortorder, 'center ');
695 if (!empty($arrayfields['p.datee']['checked'])) print_liste_field_titre($arrayfields['p.datee']['label'], $_SERVER["PHP_SELF"], "p.datee", "", $param, '', $sortfield, $sortorder, 'center ');
696 if (!empty($arrayfields['p.public']['checked'])) print_liste_field_titre($arrayfields['p.public']['label'], $_SERVER["PHP_SELF"], "p.public", "", $param, "", $sortfield, $sortorder);
697 if (!empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center ');
698 if (!empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right ');
699 if (!empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER['PHP_SELF'], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right ');
700 if (!empty($arrayfields['opp_weighted_amount']['checked'])) print_liste_field_titre($arrayfields['opp_weighted_amount']['label'], $_SERVER['PHP_SELF'], 'opp_weighted_amount', '', $param, '', $sortfield, $sortorder, 'right ');
701 if (!empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right ');
702 if (!empty($arrayfields['p.usage_opportunity']['checked'])) print_liste_field_titre($arrayfields['p.usage_opportunity']['label'], $_SERVER["PHP_SELF"], 'p.usage_opportunity', "", $param, '', $sortfield, $sortorder, 'right ');
703 if (!empty($arrayfields['p.usage_task']['checked'])) print_liste_field_titre($arrayfields['p.usage_task']['label'], $_SERVER["PHP_SELF"], 'p.usage_task', "", $param, '', $sortfield, $sortorder, 'right ');
704 if (!empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right ');
705 // Extra fields
706 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
707 // Hook fields
708 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
709 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
710 print $hookmanager->resPrint;
711 if (!empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
712 if (!empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
713 if (!empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
714 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
715 print "</tr>\n";
716 
717 $i = 0;
718 $totalarray = array(
719  'nbfield' => 0,
720  'val' => array(),
721 );
722 while ($i < min($num, $limit))
723 {
724  $obj = $db->fetch_object($resql);
725 
726  $object->id = $obj->id;
727  $object->user_author_id = $obj->fk_user_creat;
728  $object->public = $obj->public;
729  $object->ref = $obj->ref;
730  $object->datee = $db->jdate($obj->date_end);
731  $object->statut = $obj->status; // deprecated
732  $object->status = $obj->status;
733  $object->public = $obj->public;
734  $object->opp_status = $obj->fk_opp_status;
735  $object->title = $obj->title;
736 
737  $userAccess = $object->restrictedProjectArea($user); // why this ?
738  if ($userAccess >= 0)
739  {
740  $socstatic->id = $obj->socid;
741  $socstatic->name = $obj->name;
742  $socstatic->email = $obj->email;
743 
744  print '<tr class="oddeven">';
745 
746  // Project url
747  if (!empty($arrayfields['p.ref']['checked']))
748  {
749  print '<td class="nowraponall">';
750  print $object->getNomUrl(1);
751  if ($object->hasDelay()) print img_warning($langs->trans('Late'));
752  print '</td>';
753  if (!$i) $totalarray['nbfield']++;
754  }
755  // Title
756  if (!empty($arrayfields['p.title']['checked']))
757  {
758  print '<td class="tdoverflowmax200">';
759  print dol_trunc($obj->title, 80);
760  print '</td>';
761  if (!$i) $totalarray['nbfield']++;
762  }
763  // Company
764  if (!empty($arrayfields['s.nom']['checked']))
765  {
766  print '<td class="tdoverflowmax100">';
767  if ($obj->socid)
768  {
769  print $socstatic->getNomUrl(1);
770  } else {
771  print '&nbsp;';
772  }
773  print '</td>';
774  if (!$i) $totalarray['nbfield']++;
775  }
776  // Sales Representatives
777  if (!empty($arrayfields['commercial']['checked']))
778  {
779  print '<td>';
780  if ($obj->socid)
781  {
782  $socstatic->id = $obj->socid;
783  $socstatic->name = $obj->name;
784  $listsalesrepresentatives = $socstatic->getSalesRepresentatives($user);
785  $nbofsalesrepresentative = count($listsalesrepresentatives);
786  if ($nbofsalesrepresentative > 3) // We print only number
787  {
788  print $nbofsalesrepresentative;
789  } elseif ($nbofsalesrepresentative > 0)
790  {
791  $userstatic = new User($db);
792  $j = 0;
793  foreach ($listsalesrepresentatives as $val)
794  {
795  $userstatic->id = $val['id'];
796  $userstatic->lastname = $val['lastname'];
797  $userstatic->firstname = $val['firstname'];
798  $userstatic->email = $val['email'];
799  $userstatic->statut = $val['statut'];
800  $userstatic->entity = $val['entity'];
801  $userstatic->photo = $val['photo'];
802  print $userstatic->getNomUrl(1, '', 0, 0, 12);
803  //print $userstatic->getNomUrl(-2);
804  $j++;
805  if ($j < $nbofsalesrepresentative) print ' ';
806  }
807  }
808  //else print $langs->trans("NoSalesRepresentativeAffected");
809  } else {
810  print '&nbsp';
811  }
812  print '</td>';
813  if (!$i) $totalarray['nbfield']++;
814  }
815  // Date start
816  if (!empty($arrayfields['p.dateo']['checked']))
817  {
818  print '<td class="center">';
819  print dol_print_date($db->jdate($obj->date_start), 'day');
820  print '</td>';
821  if (!$i) $totalarray['nbfield']++;
822  }
823  // Date end
824  if (!empty($arrayfields['p.datee']['checked']))
825  {
826  print '<td class="center">';
827  print dol_print_date($db->jdate($obj->date_end), 'day');
828  print '</td>';
829  if (!$i) $totalarray['nbfield']++;
830  }
831  // Visibility
832  if (!empty($arrayfields['p.public']['checked']))
833  {
834  print '<td class="left">';
835  if ($obj->public) print $langs->trans('SharedProject');
836  else print $langs->trans('PrivateProject');
837  print '</td>';
838  if (!$i) $totalarray['nbfield']++;
839  }
840  // Opp Status
841  if (!empty($arrayfields['p.fk_opp_status']['checked']))
842  {
843  print '<td class="center">';
844  if ($obj->opp_status_code) print $langs->trans("OppStatus".$obj->opp_status_code);
845  print '</td>';
846  if (!$i) $totalarray['nbfield']++;
847  }
848  // Opp Amount
849  if (!empty($arrayfields['p.opp_amount']['checked']))
850  {
851  print '<td class="right">';
852  //if ($obj->opp_status_code)
853  if (strcmp($obj->opp_amount, ''))
854  {
855  print price($obj->opp_amount, 1, $langs, 1, -1, -1, '');
856  $totalarray['val']['p.opp_amount'] += $obj->opp_amount;
857  }
858  print '</td>';
859  if (!$i) $totalarray['nbfield']++;
860  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.opp_amount';
861  }
862  // Opp percent
863  if (!empty($arrayfields['p.opp_percent']['checked']))
864  {
865  print '<td class="right">';
866  if ($obj->opp_percent) print price($obj->opp_percent, 1, $langs, 1, 0).'%';
867  print '</td>';
868  if (!$i) $totalarray['nbfield']++;
869  }
870  // Opp weighted amount
871  if (!empty($arrayfields['opp_weighted_amount']['checked']))
872  {
873  if (!isset($totalarray['val']['opp_weighted_amount'])) $totalarray['val']['opp_weighted_amount'] = 0;
874  print '<td align="right">';
875  if ($obj->opp_weighted_amount) {
876  print price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, '');
877  $totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount;
878  }
879  print '</td>';
880  if (!$i) $totalarray['nbfield']++;
881  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'opp_weighted_amount';
882  }
883  // Budget
884  if (!empty($arrayfields['p.budget_amount']['checked']))
885  {
886  print '<td class="right">';
887  if ($obj->budget_amount != '')
888  {
889  print price($obj->budget_amount, 1, $langs, 1, -1, -1);
890  $totalarray['val']['p.budget_amount'] += $obj->budget_amount;
891  }
892  print '</td>';
893  if (!$i) $totalarray['nbfield']++;
894  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.budget_amount';
895  }
896  // Usage opportunity
897  if (!empty($arrayfields['p.usage_opportunity']['checked']))
898  {
899  print '<td class="right">';
900  if ($obj->usage_opportunity)
901  {
902  print yn($obj->usage_opportunity);
903  }
904  print '</td>';
905  if (!$i) $totalarray['nbfield']++;
906  }
907  // Usage task
908  if (!empty($arrayfields['p.usage_task']['checked']))
909  {
910  print '<td class="right">';
911  if ($obj->usage_task)
912  {
913  print yn($obj->usage_task);
914  }
915  print '</td>';
916  if (!$i) $totalarray['nbfield']++;
917  }
918  // Bill time
919  if (!empty($arrayfields['p.usage_bill_time']['checked']))
920  {
921  print '<td class="right">';
922  if ($obj->usage_bill_time)
923  {
924  print yn($obj->usage_bill_time);
925  }
926  print '</td>';
927  if (!$i) $totalarray['nbfield']++;
928  }
929  // Extra fields
930  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
931  // Fields from hook
932  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
933  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
934  print $hookmanager->resPrint;
935  // Date creation
936  if (!empty($arrayfields['p.datec']['checked']))
937  {
938  print '<td class="center">';
939  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
940  print '</td>';
941  if (!$i) $totalarray['nbfield']++;
942  }
943  // Date modification
944  if (!empty($arrayfields['p.tms']['checked']))
945  {
946  print '<td class="center">';
947  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
948  print '</td>';
949  if (!$i) $totalarray['nbfield']++;
950  }
951  // Status
952  if (!empty($arrayfields['p.fk_statut']['checked']))
953  {
954  print '<td class="right">'.$object->getLibStatut(5).'</td>';
955  if (!$i) $totalarray['nbfield']++;
956  }
957  // Action column
958  print '<td class="nowrap center">';
959  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
960  {
961  $selected = 0;
962  if (in_array($obj->id, $arrayofselected)) $selected = 1;
963  print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
964  }
965  print '</td>';
966  if (!$i) $totalarray['nbfield']++;
967 
968  print "</tr>\n";
969  }
970 
971  $i++;
972 }
973 
974 // Show total line
975 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
976 
977 $db->free($resql);
978 
979 $parameters = array('sql' => $sql);
980 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
981 print $hookmanager->resPrint;
982 
983 print "</table>\n";
984 print '</div>';
985 print "</form>\n";
986 
987 // End of page
988 llxFooter();
989 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_eval($s, $returnvalue=0, $hideerrors=1)
Replace eval function to add more security.
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.
Class to manage Dolibarr users.
Definition: user.class.php:44
static getFilterSelectQuery($type, $rowIdName, $searchList)
Return the addtional SQL SELECT query for filtering a list by a category.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:391
static getFilterJoinQuery($type, $rowIdName)
Return the addtional SQL JOIN query for filtering a list by a category.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
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.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Class to manage projects.
Class to manage building of HTML components.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Classe permettant la generation de composants html autre Only common components are here...
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
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...
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0)
Generate a SQL string to make a filter into a range (for second of date until last second of date) ...
Definition: date.lib.php:281
print $_SERVER["PHP_SELF"]
Edit parameters.
Class to manage forms for categories.
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...
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding &#39;...&#39; if string larger than length.
llxFooter()
Empty footer.
Definition: wrapper.php:59