dolibarr  x.y.z
job_list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
4  * Copyright (C) 2021 Greg Rastklan <greg.rastklan@atm-consulting.fr>
5  * Copyright (C) 2021 Jean-Pascal BOUDET <jean-pascal.boudet@atm-consulting.fr>
6  * Copyright (C) 2021 Grégory BLEMAND <gregory.blemand@atm-consulting.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
29 // Load Dolibarr environment
30 require '../main.inc.php';
31 
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
35 
36 // load hrm libraries
37 require_once __DIR__.'/class/job.class.php';
38 
39 // for other modules
40 //dol_include_once('/othermodule/class/otherobject.class.php');
41 
42 // Load translation files required by the page
43 $langs->loadLangs(array('hrm', 'other'));
44 
45 // Get Parameters
46 $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
47 $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
48 $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
49 $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
50 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
51 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
52 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'joblist'; // To manage different context of search
53 $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
54 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
55 
56 $id = GETPOST('id', 'int');
57 
58 // Load variable for pagination
59 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
60 $sortfield = GETPOST('sortfield', 'aZ09comma');
61 $sortorder = GETPOST('sortorder', 'aZ09comma');
62 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
63 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
64  // If $page is not defined, or '' or -1 or if we click on clear filters
65  $page = 0;
66 }
67 $offset = $limit * $page;
68 $pageprev = $page - 1;
69 $pagenext = $page + 1;
70 
71 // Initialize technical objects
72 $object = new Job($db);
73 $extrafields = new ExtraFields($db);
74 $diroutputmassaction = $conf->hrm->dir_output.'/temp/massgeneration/'.$user->id;
75 $hookmanager->initHooks(array('joblist')); // Note that conf->hooks_modules contains array
76 
77 // Fetch optionals attributes and labels
78 $extrafields->fetch_name_optionals_label($object->table_element);
79 //$extrafields->fetch_name_optionals_label($object->table_element_line);
80 
81 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
82 
83 // Default sort order (if not yet defined by previous GETPOST)
84 if (!$sortfield) {
85  reset($object->fields); // Reset is required to avoid key() to return null.
86  $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
87 }
88 if (!$sortorder) {
89  $sortorder = "ASC";
90 }
91 
92 // Initialize array of search criterias
93 $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
94 $search = array();
95 foreach ($object->fields as $key => $val) {
96  if (GETPOST('search_'.$key, 'alpha') !== '') {
97  $search[$key] = GETPOST('search_'.$key, 'alpha');
98  }
99  if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
100  $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
101  $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
102  }
103 }
104 
105 // List of fields to search into when doing a "search in all"
106 $fieldstosearchall = array();
107 foreach ($object->fields as $key => $val) {
108  if (!empty($val['searchall'])) {
109  $fieldstosearchall['t.'.$key] = $val['label'];
110  }
111 }
112 
113 // Definition of array of fields for columns
114 $arrayfields = array();
115 foreach ($object->fields as $key => $val) {
116  // If $val['visible']==0, then we never show the field
117  if (!empty($val['visible'])) {
118  $visible = (int) dol_eval($val['visible'], 1, 1, '1');
119  $arrayfields['t.'.$key] = array(
120  'label'=>$val['label'],
121  'checked'=>(($visible < 0) ? 0 : 1),
122  'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
123  'position'=>$val['position'],
124  'help'=> isset($val['help']) ? $val['help'] : ''
125  );
126  }
127 }
128 // Extra fields
129 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
130 
131 $object->fields = dol_sort_array($object->fields, 'position');
132 $arrayfields = dol_sort_array($arrayfields, 'position');
133 
134 // Permissions
135 $permissiontoread = $user->rights->hrm->all->read;
136 $permissiontoadd = $user->rights->hrm->all->write;
137 $permissiontodelete = $user->rights->hrm->all->delete;
138 
139 // Security check
140 if (empty($conf->hrm->enabled)) {
141  accessforbidden('Module not enabled');
142 }
143 
144 // Security check (enable the most restrictive one)
145 if ($user->socid > 0) accessforbidden();
146 //if ($user->socid > 0) accessforbidden();
147 //$socid = 0; if ($user->socid > 0) $socid = $user->socid;
148 //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
149 //restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
150 if (empty($conf->hrm->enabled)) accessforbidden();
151 if (!$permissiontoread) accessforbidden();
152 
153 
154 
155 /*
156  * Actions
157  */
158 
159 if (GETPOST('cancel', 'alpha')) {
160  $action = 'list';
161  $massaction = '';
162 }
163 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
164  $massaction = '';
165 }
166 
167 $parameters = array();
168 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
169 if ($reshook < 0) {
170  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
171 }
172 
173 if (empty($reshook)) {
174  // Selection of new fields
175  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
176 
177  // Purge search criteria
178  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
179  foreach ($object->fields as $key => $val) {
180  $search[$key] = '';
181  if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
182  $search[$key.'_dtstart'] = '';
183  $search[$key.'_dtend'] = '';
184  }
185  }
186  $toselect = array();
187  $search_array_options = array();
188  }
189  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
190  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
191  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
192  }
193 
194  // Mass actions
195  $objectclass = 'Job';
196  $objectlabel = 'Job';
197  $uploaddir = $conf->hrm->dir_output;
198  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
199 }
200 
201 
202 
203 /*
204  * View
205  */
206 
207 $form = new Form($db);
208 
209 $now = dol_now();
210 
211 //$help_url="EN:Module_Job|FR:Module_Job_FR|ES:Módulo_Job";
212 $help_url = '';
213 $title = $langs->trans("JobsPosition");
214 $morejs = array();
215 $morecss = array();
216 
217 
218 // Build and execute select
219 // --------------------------------------------------------------------
220 $sql = 'SELECT ';
221 $sql .= $object->getFieldList('t');
222 // Add fields from extrafields
223 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
224  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
225  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
226  }
227 }
228 // Add fields from hooks
229 $parameters = array();
230 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
231 $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
232 $sql = preg_replace('/,\s*$/', '', $sql);
233 $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
234 if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
235  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
236 }
237 // Add table from hooks
238 $parameters = array();
239 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
240 $sql .= $hookmanager->resPrint;
241 if ($object->ismultientitymanaged == 1) {
242  $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
243 } else {
244  $sql .= " WHERE 1 = 1";
245 }
246 foreach ($search as $key => $val) {
247  if (array_key_exists($key, $object->fields)) {
248  if ($key == 'status' && $search[$key] == -1) {
249  continue;
250  }
251  $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
252  if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
253  if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
254  $search[$key] = '';
255  }
256  $mode_search = 2;
257  }
258  if ($search[$key] != '') {
259  $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
260  }
261  } else {
262  if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
263  $columnName=preg_replace('/(_dtstart|_dtend)$/', '', $key);
264  if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
265  if (preg_match('/_dtstart$/', $key)) {
266  $sql .= " AND t." . $columnName . " >= '" . $db->idate($search[$key]) . "'";
267  }
268  if (preg_match('/_dtend$/', $key)) {
269  $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'";
270  }
271  }
272  }
273  }
274 }
275 if ($search_all) {
276  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
277 }
278 //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
279 // Add where from extra fields
280 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
281 // Add where from hooks
282 $parameters = array();
283 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
284 $sql .= $hookmanager->resPrint;
285 
286 /* If a group by is required
287 $sql .= " GROUP BY ";
288 foreach($object->fields as $key => $val) {
289  $sql .= "t.".$key.", ";
290 }
291 // Add fields from extrafields
292 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
293  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
294  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
295  }
296 }
297 // Add where from hooks
298 $parameters = array();
299 $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
300 $sql .= $hookmanager->resPrint;
301 $sql = preg_replace('/,\s*$/', '', $sql);
302 */
303 
304 $sql .= $db->order($sortfield, $sortorder);
305 
306 // Count total nb of records
307 $nbtotalofrecords = '';
308 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
309  $resql = $db->query($sql);
310  $nbtotalofrecords = $db->num_rows($resql);
311  if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
312  $page = 0;
313  $offset = 0;
314  }
315 }
316 // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
317 if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
318  $num = $nbtotalofrecords;
319 } else {
320  if ($limit) {
321  $sql .= $db->plimit($limit + 1, $offset);
322  }
323 
324  $resql = $db->query($sql);
325  if (!$resql) {
326  dol_print_error($db);
327  exit;
328  }
329 
330  $num = $db->num_rows($resql);
331 }
332 
333 // Direct jump if only one record found
334 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
335  $obj = $db->fetch_object($resql);
336  $id = $obj->rowid;
337  header("Location: ".dol_buildpath('/hrm/job_card.php', 1).'?id='.$id);
338  exit;
339 }
340 
341 
342 // Output page
343 // --------------------------------------------------------------------
344 
345 llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', '');
346 
347 // Example : Adding jquery code
348 // print '<script type="text/javascript" language="javascript">
349 // jQuery(document).ready(function() {
350 // function init_myfunc()
351 // {
352 // jQuery("#myid").removeAttr(\'disabled\');
353 // jQuery("#myid").attr(\'disabled\',\'disabled\');
354 // }
355 // init_myfunc();
356 // jQuery("#mybutton").click(function() {
357 // init_myfunc();
358 // });
359 // });
360 // </script>';
361 
362 $arrayofselected = is_array($toselect) ? $toselect : array();
363 
364 $param = '';
365 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
366  $param .= '&contextpage='.urlencode($contextpage);
367 }
368 if ($limit > 0 && $limit != $conf->liste_limit) {
369  $param .= '&limit='.urlencode($limit);
370 }
371 foreach ($search as $key => $val) {
372  if (is_array($search[$key]) && count($search[$key])) {
373  foreach ($search[$key] as $skey) {
374  $param .= '&search_'.$key.'[]='.urlencode($skey);
375  }
376  } else {
377  $param .= '&search_'.$key.'='.urlencode($search[$key]);
378  }
379 }
380 if ($optioncss != '') {
381  $param .= '&optioncss='.urlencode($optioncss);
382 }
383 // Add $param from extra fields
384 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
385 // Add $param from hooks
386 $parameters = array();
387 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
388 $param .= $hookmanager->resPrint;
389 
390 // List of mass actions available
391 $arrayofmassactions = array(
392  //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
393  //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
394  //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
395  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
396 );
397 if ($permissiontodelete) {
398  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
399 }
400 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
401  $arrayofmassactions = array();
402 }
403 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
404 
405 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
406 if ($optioncss != '') {
407  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
408 }
409 print '<input type="hidden" name="token" value="'.newToken().'">';
410 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
411 print '<input type="hidden" name="action" value="list">';
412 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
413 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
414 print '<input type="hidden" name="page" value="'.$page.'">';
415 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
416 
417 $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/hrm/job_card.php', 1).'?action=create', '', $permissiontoadd);
418 
419 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
420 
421 // Add code for pre mass action (confirmation or email presend form)
422 $topicmail = "SendJobRef";
423 $modelmail = "job";
424 $objecttmp = new Job($db);
425 $trackid = 'xxxx'.$object->id;
426 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
427 
428 if ($search_all) {
429  foreach ($fieldstosearchall as $key => $val) {
430  $fieldstosearchall[$key] = $langs->trans($val);
431  }
432  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
433 }
434 
435 $moreforfilter = '';
436 /*$moreforfilter.='<div class="divsearchfield">';
437 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
438 $moreforfilter.= '</div>';*/
439 
440 $parameters = array();
441 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
442 if (empty($reshook)) {
443  $moreforfilter .= $hookmanager->resPrint;
444 } else {
445  $moreforfilter = $hookmanager->resPrint;
446 }
447 
448 if (!empty($moreforfilter)) {
449  print '<div class="liste_titre liste_titre_bydiv centpercent">';
450  print $moreforfilter;
451  print '</div>';
452 }
453 
454 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
455 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
456 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
457 
458 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
459 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
460 
461 
462 // Fields title search
463 // --------------------------------------------------------------------
464 print '<tr class="liste_titre">';
465 foreach ($object->fields as $key => $val) {
466  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
467  if ($key == 'status') {
468  $cssforfield .= ($cssforfield ? ' ' : '').'center';
469  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
470  $cssforfield .= ($cssforfield ? ' ' : '').'center';
471  } elseif (in_array($val['type'], array('timestamp'))) {
472  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
473  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
474  $cssforfield .= ($cssforfield ? ' ' : '').'right';
475  }
476  if (!empty($arrayfields['t.'.$key]['checked'])) {
477  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
478  if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
479  print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
480  } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
481  print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1);
482  } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
483  print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
484  } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
485  print '<div class="nowrap">';
486  print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
487  print '</div>';
488  print '<div class="nowrap">';
489  print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
490  print '</div>';
491  }
492  print '</td>';
493  }
494 }
495 // Extra fields
496 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
497 
498 // Fields from hook
499 $parameters = array('arrayfields'=>$arrayfields);
500 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
501 print $hookmanager->resPrint;
502 // Action column
503 print '<td class="liste_titre maxwidthsearch">';
504 $searchpicto = $form->showFilterButtons();
505 print $searchpicto;
506 print '</td>';
507 print '</tr>'."\n";
508 
509 
510 // Fields title label
511 // --------------------------------------------------------------------
512 print '<tr class="liste_titre">';
513 foreach ($object->fields as $key => $val) {
514  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
515  if ($key == 'status') {
516  $cssforfield .= ($cssforfield ? ' ' : '').'center';
517  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
518  $cssforfield .= ($cssforfield ? ' ' : '').'center';
519  } elseif (in_array($val['type'], array('timestamp'))) {
520  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
521  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
522  $cssforfield .= ($cssforfield ? ' ' : '').'right';
523  }
524  if (!empty($arrayfields['t.'.$key]['checked'])) {
525  print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
526  }
527 }
528 // Extra fields
529 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
530 // Hook fields
531 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
532 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
533 print $hookmanager->resPrint;
534 // Action column
535 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
536 print '</tr>'."\n";
537 
538 
539 // Detect if we need a fetch on each output line
540 $needToFetchEachLine = 0;
541 if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
542  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
543  if (preg_match('/\$object/', $val)) {
544  $needToFetchEachLine++; // There is at least one compute field that use $object
545  }
546  }
547 }
548 
549 
550 // Loop on record
551 // --------------------------------------------------------------------
552 $i = 0;
553 $totalarray = array();
554 $totalarray['nbfield'] = 0;
555 while ($i < ($limit ? min($num, $limit) : $num)) {
556  $obj = $db->fetch_object($resql);
557  if (empty($obj)) {
558  break; // Should not happen
559  }
560 
561  // Store properties in $object
562  $object->setVarsFromFetchObj($obj);
563 
564  // Show here line of result
565  print '<tr class="oddeven">';
566  foreach ($object->fields as $key => $val) {
567  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
568  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
569  $cssforfield .= ($cssforfield ? ' ' : '').'center';
570  } elseif ($key == 'status') {
571  $cssforfield .= ($cssforfield ? ' ' : '').'center';
572  }
573 
574  if (in_array($val['type'], array('timestamp'))) {
575  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
576  } elseif ($key == 'ref') {
577  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
578  }
579 
580  if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
581  $cssforfield .= ($cssforfield ? ' ' : '').'right';
582  }
583  //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
584 
585  if (!empty($arrayfields['t.'.$key]['checked'])) {
586  print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
587  if ($key == 'status') {
588  print $object->getLibStatut(5);
589  } elseif ($key == 'rowid') {
590  print $object->showOutputField($val, $key, $object->id, '');
591  } elseif ($key == 'label') {
592  print $object->getNomUrl(1);
593  } else {
594  print $object->showOutputField($val, $key, $object->$key, '');
595  }
596  print '</td>';
597  if (!$i) {
598  $totalarray['nbfield']++;
599  }
600  if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
601  if (!$i) {
602  $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
603  }
604  if (!isset($totalarray['val'])) {
605  $totalarray['val'] = array();
606  }
607  if (!isset($totalarray['val']['t.'.$key])) {
608  $totalarray['val']['t.'.$key] = 0;
609  }
610  $totalarray['val']['t.'.$key] += $object->$key;
611  }
612  }
613  }
614  // Extra fields
615  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
616  // Fields from hook
617  $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
618  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
619  print $hookmanager->resPrint;
620  // Action column
621  print '<td class="nowrap center">';
622  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
623  $selected = 0;
624  if (in_array($object->id, $arrayofselected)) {
625  $selected = 1;
626  }
627  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
628  }
629  print '</td>';
630  if (!$i) {
631  $totalarray['nbfield']++;
632  }
633 
634  print '</tr>'."\n";
635 
636  $i++;
637 }
638 
639 // Show total line
640 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
641 
642 // If no record found
643 if ($num == 0) {
644  $colspan = 1;
645  foreach ($arrayfields as $key => $val) {
646  if (!empty($val['checked'])) {
647  $colspan++;
648  }
649  }
650  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
651 }
652 
653 
654 $db->free($resql);
655 
656 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
657 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
658 print $hookmanager->resPrint;
659 
660 print '</table>'."\n";
661 print '</div>'."\n";
662 
663 print '</form>'."\n";
664 
665 if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
666  $hidegeneratedfilelistifempty = 1;
667  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
668  $hidegeneratedfilelistifempty = 0;
669  }
670 
671  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
672  $formfile = new FormFile($db);
673 
674  // Show list of available documents
675  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
676  $urlsource .= str_replace('&amp;', '&', $param);
677 
678  $filedir = $diroutputmassaction;
679  $genallowed = $permissiontoread;
680  $delallowed = $permissiontoadd;
681 
682  print $formfile->showdocuments('massfilesarea_hrm', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
683 }
684 
685 // End of page
686 llxFooter();
687 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage standard extra fields.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class for Job.
Definition: job.class.php:37
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_now($mode='auto')
Return date for now.
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.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
$nbtotalofrecords
Count total nb of records.
Definition: list.php:329
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.