dolibarr  17.0.4
position.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 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 
28 // Load Dolibarr environment
29 require '../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
31 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
32 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
33 require_once DOL_DOCUMENT_ROOT . '/hrm/class/position.class.php';
34 require_once DOL_DOCUMENT_ROOT . '/hrm/class/job.class.php';
35 require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm_position.lib.php';
36 require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm_job.lib.php';
37 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
38 require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
39 
40 
41 // Load translation files required by the page
42 $langs->loadLangs(array("hrm", "other", 'products'));
43 
44 $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
45 $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
46 $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
47 $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
48 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
49 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
50 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'jobpositionlist'; // To manage different context of search
51 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
52 $id = GETPOST('id', 'int');
53 $fk_job = GETPOST('fk_job', 'int');
54 
55 // Load variable for pagination
56 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
57 $sortfield = GETPOST('sortfield', 'aZ09comma');
58 $sortorder = GETPOST('sortorder', 'aZ09comma');
59 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
60 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
61  // If $page is not defined, or '' or -1 or if we click on clear filters
62  $page = 0;
63 }
64 $offset = $limit * $page;
65 $pageprev = $page - 1;
66 $pagenext = $page + 1;
67 
68 // Get parameters
69 $id = GETPOST('fk_job', 'int');
70 $ref = GETPOST('ref', 'alpha');
71 $fk_job = GETPOST('fk_job', 'int');
72 $fk_user = GETPOST('fk_user', 'int');
73 //$start_date = date('Y-m-d', GETPOST('date_startyear', 'int').'-'.GETPOST('date_startmonth', 'int').'-'.GETPOST('date_startday', 'int'));
74 $start_date = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
75 
76 $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
77 $backtopage = GETPOST('backtopage', 'alpha');
78 $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
79 $fk_job = GETPOST('fk_job', 'int');
80 
81 // Initialize technical objects
82 $object = new Job($db);
83 $objectposition = new Position($db);
84 
85 $extrafields = new ExtraFields($db);
86 
87 $diroutputmassaction = $conf->hrm->dir_output . '/temp/massgeneration/' . $user->id;
88 
89 $hookmanager->initHooks(array('jobpositionlist', 'globalcard')); // Note that conf->hooks_modules contains array
90 
91 
92 // Fetch optionals attributes and labels
93 $extrafields->fetch_name_optionals_label($objectposition->table_element);
94 //$extrafields->fetch_name_optionals_label($object->table_element_line);
95 
96 $search_array_options = $extrafields->getOptionalsFromPost($objectposition->table_element, '', 'search_');
97 
98 // Default sort order (if not yet defined by previous GETPOST)
99 if (!$sortfield) {
100  reset($objectposition->fields); // Reset is required to avoid key() to return null.
101  $sortfield = "t." . key($objectposition->fields); // Set here default search field. By default 1st field in definition.
102 }
103 if (!$sortorder) {
104  $sortorder = "ASC";
105 }
106 
107 // Initialize array of search criterias
108 $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
109 $search = array();
110 foreach ($objectposition->fields as $key => $val) {
111  if (GETPOST('search_' . $key, 'alpha') !== '') {
112  $search[$key] = GETPOST('search_' . $key, 'alpha');
113  }
114  if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
115  $search[$key . '_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_' . $key . '_dtstartmonth', 'int'), GETPOST('search_' . $key . '_dtstartday', 'int'), GETPOST('search_' . $key . '_dtstartyear', 'int'));
116  $search[$key . '_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_' . $key . '_dtendmonth', 'int'), GETPOST('search_' . $key . '_dtendday', 'int'), GETPOST('search_' . $key . '_dtendyear', 'int'));
117  }
118 }
119 
120 // List of fields to search into when doing a "search in all"
121 $fieldstosearchall = array();
122 foreach ($objectposition->fields as $key => $val) {
123  if (!empty($val['searchall'])) {
124  $fieldstosearchall['t.' . $key] = $val['label'];
125  }
126 }
127 
128 // Definition of array of fields for columns
129 $arrayfields = array();
130 foreach ($objectposition->fields as $key => $val) {
131  // If $val['visible']==0, then we never show the field
132  if (!empty($val['visible'])) {
133  $visible = (int) dol_eval($val['visible'], 1, 1, '1');
134  $arrayfields['t.' . $key] = array(
135  'label' => $val['label'],
136  'checked' => (($visible < 0) ? 0 : 1),
137  'enabled' => ($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
138  'position' => $val['position'],
139  'help' => isset($val['help']) ? $val['help'] : ''
140  );
141  }
142 }
143 // Extra fields
144 include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php';
145 
146 $objectposition->fields = dol_sort_array($objectposition->fields, 'position');
147 $arrayfields = dol_sort_array($arrayfields, 'position');
148 
149 
150 
151 
152 // Load object
153 include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
154 
155 // Permissions
156 $permissiontoread = $user->rights->hrm->all->read;
157 $permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
158 $permissiontodelete = $user->rights->hrm->all->delete;
159 $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1] . '/position';
160 
161 // Security check (enable the most restrictive one)
162 //if ($user->socid > 0) accessforbidden();
163 //if ($user->socid > 0) $socid = $user->socid;
164 //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
165 //restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
166 if (empty($conf->hrm->enabled)) accessforbidden();
167 if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) accessforbidden();
168 
169 
170 /*
171  * Actions
172  */
173 
174 $parameters = array();
175 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
176 if ($reshook < 0) {
177  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
178 }
179 
180 if (empty($reshook)) {
181  $error = 0;
182 
183  $backurlforlist = dol_buildpath('/hrm/position_list.php', 1);
184  //$backtopage = dol_buildpath('/hrm/position.php', 1) . '?fk_job=' . ($fk_job > 0 ? $fk_job : '__ID__');
185 
186  if (empty($backtopage) || ($cancel && $fk_job <= 0)) {
187  if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
188  if ($fk_job == -1 && (($action != 'add' && $action != 'create') || $cancel)) {
189  $backtopage = $backurlforlist;
190  } else {
191  if ($fk_job > 0) {
192  $backtopage = dol_buildpath('/hrm/position.php', 1) . '?fk_job=' . ($fk_job > 0 ? $fk_job : '__ID__');
193  } else {
194  $backtopage = dol_buildpath('/hrm/position_card.php', 1) . '?id=__ID__';
195  }
196  }
197  }
198  }
199 
200  $triggermodname = 'HRM_POSITION_MODIFY'; // Name of trigger action code to execute when we modify record
201 
202  // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
203  $job = $object;
204  $object = new Position($db);
205 
206  // Selection of new fields
207  include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php';
208 
209  // Purge search criteria
210  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
211  foreach ($object->fields as $key => $val) {
212  $search[$key] = '';
213  if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
214  $search[$key . '_dtstart'] = '';
215  $search[$key . '_dtend'] = '';
216  }
217  }
218  $toselect = array();
219  $search_array_options = array();
220  }
221  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
222  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
223  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
224  }
225 
226  // Mass actions
227  $objectclass = 'Position';
228  $objectlabel = 'Position';
229  $uploaddir = $conf->hrm->dir_output;
230  include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php';
231 
232  include DOL_DOCUMENT_ROOT . '/core/actions_addupdatedelete.inc.php';
233  $object = $job;
234 }
235 
236 /*
237  * View
238  */
239 
240 $title = $langs->trans("Position");
241 $help_url = '';
242 llxHeader('', $title, $help_url);
243 
244 $now = dol_now();
245 
246 // Part to create
247 if ($action == 'create') {
248  $object = new Position($db);
249  // Fetch optionals attributes and labels
250  $extrafields->fetch_name_optionals_label($object->table_element);
251  print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Position")), '', 'object_' . $object->picto);
252 
253  print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
254  print '<input type="hidden" name="token" value="' . newToken() . '">';
255  print '<input type="hidden" name="action" value="add">';
256  if ($backtopage) {
257  print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
258  }
259 
260  if ($backtopageforcancel) {
261  print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
262  }
263 
264  print dol_get_fiche_head(array(), '');
265 
266  print '<table class="border centpercent tableforfieldcreate">' . "\n";
267 
268  // Common attributes
269  include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php';
270 
271  // Other attributes
272  include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php';
273 
274  print '</table>' . "\n";
275 
276  print dol_get_fiche_end();
277 
278  print '<div class="center">';
279 
280  print '<input type="submit" class="button" name="add" value="' . dol_escape_htmltag($langs->trans("Create")) . '">';
281  print '&nbsp; ';
282  print '<input type="' . ($backtopage ? "submit" : "button") . '" class="button button-cancel" name="cancel" value="' . dol_escape_htmltag($langs->trans("Cancel")) . '"' . ($backtopage ? '' : ' onclick="javascript:history.go(-1)"') . '>'; // Cancel for create does not post form if we don't know the backtopage
283  print '</div>';
284 
285  print '</form>';
286 
287  //dol_set_focus('input[name="ref"]');
288 }
289 
290 if ($job->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
291  if ($backtopage) {
292  print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
293  }
294  if ($backtopageforcancel) {
295  print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
296  }
297 
298  // Part to show record
299 
300  $res = $object->fetch_optionals();
301 
302  $head = jobPrepareHead($object);
303 
304  print dol_get_fiche_head($head, 'position', $langs->trans("Workstation"), -1, $object->picto);
305 
306  // Object card
307  // ------------------------------------------------------------
308  $linkback = '<a href="' . dol_buildpath('/hrm/position_list.php', 1) . '?restore_lastsearch_values=1' . (!empty($fk_job) ? '&fk_job=' . $fk_job : '') . '">' . $langs->trans("BackToList") . '</a>';
309 
310  $morehtmlref = '<div class="refid">';
311  $morehtmlref.= $object->label;
312  $morehtmlref .= '</div>';
313 
314  dol_banner_tab($object, 'fk_job', $linkback, 1, 'rowid', 'rowid', $morehtmlref);
315 
316 
317  print '<div class="fichecenter">';
318  print '<div class="fichehalfleft">';
319  print '<div class="underbanner clearboth"></div>';
320  print '<table class="border centpercent tableforfield">' . "\n";
321 
322  // Common attributes
323  //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
324  //unset($object->fields['fk_project']); // Hide field already shown in banner
325  //unset($object->fields['fk_soc']); // Hide field already shown in banner
326  $object->fields['label']['visible']=0; // Already in banner
327  include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
328 
329  // Other attributes. Fields from hook formObjectOptions and Extrafields.
330  include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
331 
332  print '</table>';
333  print '</div>';
334  print '</div>';
335 
336  print '<div class="clearboth"></div>';
337 
338  print dol_get_fiche_end();
339 
340 
341  // List of positions
342 
343  $object = $objectposition;
344 
345 
346  //$help_url="EN:Module_Position|FR:Module_Position_FR|ES:MĂ³dulo_Position";
347  $help_url = '';
348  $title = $langs->trans("Positions");
349  $morejs = array();
350  $morecss = array();
351 
352 
353  // Build and execute select
354  // --------------------------------------------------------------------
355  $sql = 'SELECT ';
356  $sql .= $object->getFieldList('t');
357  // Add fields from extrafields
358  if (!empty($extrafields->attributes[$object->table_element]['label'])) {
359  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
360  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef." . $key . " as options_" . $key . ', ' : '');
361  }
362  }
363  // Add fields from hooks
364  $parameters = array();
365  $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
366  $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
367  $sql = preg_replace('/,\s*$/', '', $sql);
368  $sql .= " FROM " . MAIN_DB_PREFIX . $object->table_element . " as t";
369  if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
370  $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $object->table_element . "_extrafields as ef on (t.rowid = ef.fk_object)";
371  }
372  // Add table from hooks
373  $parameters = array();
374  $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
375  $sql .= $hookmanager->resPrint;
376  if ($object->ismultientitymanaged == 1) {
377  $sql .= " WHERE t.entity IN (" . getEntity($object->element) . ")";
378  } else {
379  $sql .= " WHERE 1 = 1";
380  }
381  $sql .= " AND t.fk_job = " . ((int) $fk_job) . " ";
382 
383  foreach ($search as $key => $val) {
384  if (array_key_exists($key, $object->fields)) {
385  if ($key == 'status' && $search[$key] == -1) {
386  continue;
387  }
388  $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
389  if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
390  if ($search[$key] == '-1' || $search[$key] === '0') {
391  $search[$key] = '';
392  }
393  $mode_search = 2;
394  }
395  if ($search[$key] != '') {
396  $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
397  }
398  } else {
399  if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
400  $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
401  if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
402  if (preg_match('/_dtstart$/', $key)) {
403  $sql .= " AND t." . $columnName . " >= '" . $db->idate($search[$key]) . "'";
404  }
405  if (preg_match('/_dtend$/', $key)) {
406  $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'";
407  }
408  }
409  }
410  }
411  }
412  if ($search_all) {
413  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
414  }
415  //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
416  // Add where from extra fields
417  include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php';
418  // Add where from hooks
419  $parameters = array();
420  $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
421  $sql .= $hookmanager->resPrint;
422 
423  $sql .= $db->order($sortfield, $sortorder);
424 
425  // Count total nb of records
426  $nbtotalofrecords = '';
427  if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
428  $resql = $db->query($sql);
429  $nbtotalofrecords = $db->num_rows($resql);
430  if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
431  $page = 0;
432  $offset = 0;
433  }
434  }
435  // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
436  if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
437  $num = $nbtotalofrecords;
438  } else {
439  if ($limit) {
440  $sql .= $db->plimit($limit + 1, $offset);
441  }
442 
443  $resql = $db->query($sql);
444  if (!$resql) {
445  dol_print_error($db);
446  exit;
447  }
448 
449  $num = $db->num_rows($resql);
450  }
451 
452  // Direct jump if only one record found
453  if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
454  $obj = $db->fetch_object($resql);
455  $id = $obj->rowid;
456  header("Location: " . dol_buildpath('/hrm/position.php', 1) . '?id=' . $id);
457  exit;
458  }
459 
460  $arrayofselected = is_array($toselect) ? $toselect : array();
461 
462  $param = 'fk_job=' . $fk_job;
463  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
464  $param .= '&contextpage=' . urlencode($contextpage);
465  }
466  if ($limit > 0 && $limit != $conf->liste_limit) {
467  $param .= '&limit=' . urlencode($limit);
468  }
469  foreach ($search as $key => $val) {
470  if (is_array($search[$key]) && count($search[$key])) {
471  foreach ($search[$key] as $skey) {
472  $param .= '&search_' . $key . '[]=' . urlencode($skey);
473  }
474  } else {
475  $param .= '&search_' . $key . '=' . urlencode($search[$key]);
476  }
477  }
478  if ($optioncss != '') {
479  $param .= '&optioncss=' . urlencode($optioncss);
480  }
481  // Add $param from extra fields
482  include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php';
483  // Add $param from hooks
484  $parameters = array();
485  $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
486  $param .= $hookmanager->resPrint;
487 
488  // List of mass actions available
489  $arrayofmassactions = array(
490  //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
491  //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
492  //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
493  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
494  );
495  if ($permissiontodelete) {
496  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"') . $langs->trans("Delete");
497  }
498  if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
499  $arrayofmassactions = array();
500  }
501  $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
502 
503  print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '?fk_job=' . $fk_job . '">' . "\n";
504  if ($optioncss != '') {
505  print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
506  }
507  print '<input type="hidden" name="token" value="' . newToken() . '">';
508  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
509  print '<input type="hidden" name="action" value="list">';
510  print '<input type="hidden" name="massaction" value="' . $massaction . '">';
511  print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
512  print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
513  print '<input type="hidden" name="page" value="' . $page . '">';
514  print '<input type="hidden" name="contextpage" value="' . $contextpage . '">';
515 
516  $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/hrm/position.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']).'&fk_job='.((int) $fk_job), '', $permissiontoadd);
517 
518  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_' . $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
519 
520  // Add code for pre mass action (confirmation or email presend form)
521  $topicmail = "SendPositionRef";
522  $modelmail = "position";
523  $objecttmp = new Position($db);
524  $trackid = 'xxxx' . $object->id;
525  include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php';
526 
527  if ($search_all) {
528  foreach ($fieldstosearchall as $key => $val) {
529  $fieldstosearchall[$key] = $langs->trans($val);
530  }
531  print '<div class="divsearchfieldfilter">' . $langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall) . '</div>';
532  }
533 
534  $moreforfilter = '';
535  /*$moreforfilter.='<div class="divsearchfield">';
536  $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
537  $moreforfilter.= '</div>';*/
538 
539  $parameters = array();
540  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
541  if (empty($reshook)) {
542  $moreforfilter .= $hookmanager->resPrint;
543  } else {
544  $moreforfilter = $hookmanager->resPrint;
545  }
546 
547  if (!empty($moreforfilter)) {
548  print '<div class="liste_titre liste_titre_bydiv centpercent">';
549  print $moreforfilter;
550  print '</div>';
551  }
552 
553  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
554  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
555  $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
556 
557  print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
558  print '<table class="tagtable nobottomiftotal liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n";
559 
560  // Fields title search
561  // --------------------------------------------------------------------
562  print '<tr class="liste_titre">';
563  foreach ($object->fields as $key => $val) {
564  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
565  if ($key == 'status') {
566  $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
567  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
568  $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
569  } elseif (in_array($val['type'], array('timestamp'))) {
570  $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
571  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
572  $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
573  }
574  if (!empty($arrayfields['t.' . $key]['checked'])) {
575  print '<td class="liste_titre' . ($cssforfield ? ' ' . $cssforfield : '') . '">';
576  if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
577  print $form->selectarray('search_' . $key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
578  } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
579  print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1);
580  } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
581  print '<input type="text" class="flat maxwidth75" name="search_' . $key . '" value="' . dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '') . '">';
582  } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
583  print '<div class="nowrap">';
584  print $form->selectDate($search[$key . '_dtstart'] ? $search[$key . '_dtstart'] : '', "search_" . $key . "_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
585  print '</div>';
586  print '<div class="nowrap">';
587  print $form->selectDate($search[$key . '_dtend'] ? $search[$key . '_dtend'] : '', "search_" . $key . "_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
588  print '</div>';
589  }
590  print '</td>';
591  }
592  }
593  // Extra fields
594  include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php';
595 
596  // Fields from hook
597  $parameters = array('arrayfields' => $arrayfields);
598  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
599  print $hookmanager->resPrint;
600  // Action column
601  print '<td class="liste_titre maxwidthsearch">';
602  $searchpicto = $form->showFilterButtons();
603  print $searchpicto;
604  print '</td>';
605  print '</tr>' . "\n";
606 
607 
608  // Fields title label
609  // --------------------------------------------------------------------
610  print '<tr class="liste_titre">';
611  foreach ($object->fields as $key => $val) {
612  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
613  if ($key == 'status') {
614  $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
615  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
616  $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
617  } elseif (in_array($val['type'], array('timestamp'))) {
618  $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
619  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
620  $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
621  }
622  if (!empty($arrayfields['t.' . $key]['checked'])) {
623  print getTitleFieldOfList($arrayfields['t.' . $key]['label'], 0, $_SERVER['PHP_SELF'], 't.' . $key, '', $param, ($cssforfield ? 'class="' . $cssforfield . '"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield . ' ' : '')) . "\n";
624  }
625  }
626  // Extra fields
627  include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php';
628  // Hook fields
629  $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
630  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
631  print $hookmanager->resPrint;
632  // Action column
633  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ') . "\n";
634  print '</tr>' . "\n";
635 
636  // Detect if we need a fetch on each output line
637  $needToFetchEachLine = 0;
638  if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
639  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
640  if (preg_match('/\$object/', $val)) {
641  $needToFetchEachLine++; // There is at least one compute field that use $object
642  }
643  }
644  }
645 
646 
647  // Loop on record
648  // --------------------------------------------------------------------
649  $i = 0;
650  $totalarray = array();
651  $totalarray['nbfield'] = 0;
652  while ($i < ($limit ? min($num, $limit) : $num)) {
653  $obj = $db->fetch_object($resql);
654  if (empty($obj)) {
655  break; // Should not happen
656  }
657 
658  // Store properties in $object
659  $object->setVarsFromFetchObj($obj);
660 
661  // Show here line of result
662  print '<tr class="oddeven">';
663  foreach ($object->fields as $key => $val) {
664  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
665  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
666  $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
667  } elseif ($key == 'status') {
668  $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
669  }
670 
671  if (in_array($val['type'], array('timestamp'))) {
672  $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
673  } elseif ($key == 'ref') {
674  $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
675  }
676 
677  if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
678  $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
679  }
680  //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
681 
682  if (!empty($arrayfields['t.' . $key]['checked'])) {
683  print '<td' . ($cssforfield ? ' class="' . $cssforfield . '"' : '') . '>';
684  if ($key == 'status') {
685  print $object->getLibStatut(5);
686  } elseif ($key == 'rowid') {
687  print $object->getNomUrl(1);
688  } else {
689  print $object->showOutputField($val, $key, $object->$key, '');
690  }
691  print '</td>';
692  if (!$i) {
693  $totalarray['nbfield']++;
694  }
695  if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
696  if (!$i) {
697  $totalarray['pos'][$totalarray['nbfield']] = 't.' . $key;
698  }
699  if (!isset($totalarray['val'])) {
700  $totalarray['val'] = array();
701  }
702  if (!isset($totalarray['val']['t.' . $key])) {
703  $totalarray['val']['t.' . $key] = 0;
704  }
705  $totalarray['val']['t.' . $key] += $object->$key;
706  }
707  }
708  }
709  // Extra fields
710  include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php';
711  // Fields from hook
712  $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
713  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
714  print $hookmanager->resPrint;
715  // Action column
716  print '<td class="nowrap center">';
717  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
718  $selected = 0;
719  if (in_array($object->id, $arrayofselected)) {
720  $selected = 1;
721  }
722  print '<input id="cb' . $object->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $object->id . '"' . ($selected ? ' checked="checked"' : '') . '>';
723  }
724  print '</td>';
725  if (!$i) {
726  $totalarray['nbfield']++;
727  }
728 
729  print '</tr>' . "\n";
730 
731  $i++;
732  }
733 
734  // Show total line
735  include DOL_DOCUMENT_ROOT . '/core/tpl/list_print_total.tpl.php';
736 
737  // If no record found
738  if ($num == 0) {
739  $colspan = 1;
740  foreach ($arrayfields as $key => $val) {
741  if (!empty($val['checked'])) {
742  $colspan++;
743  }
744  }
745  print '<tr><td colspan="' . $colspan . '" class="opacitymedium">' . $langs->trans("NoRecordFound") . '</td></tr>';
746  }
747 
748 
749  $db->free($resql);
750 
751  $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
752  $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
753  print $hookmanager->resPrint;
754 
755  print '</table>' . "\n";
756  print '</div>' . "\n";
757 
758  print '</form>' . "\n";
759 
760  if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
761  $hidegeneratedfilelistifempty = 1;
762  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
763  $hidegeneratedfilelistifempty = 0;
764  }
765 
766  require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
767  $formfile = new FormFile($db);
768 
769  // Show list of available documents
770  $urlsource = $_SERVER['PHP_SELF'] . '?sortfield=' . $sortfield . '&sortorder=' . $sortorder;
771  $urlsource .= str_replace('&amp;', '&', $param);
772 
773  $filedir = $diroutputmassaction;
774  $genallowed = $permissiontoread;
775  $delallowed = $permissiontoadd;
776 
777  print $formfile->showdocuments('massfilesarea_hrm', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
778  }
779 }
780 
781 
782 
783 
790 {
791  global $user, $langs, $db, $conf, $extrafields, $hookmanager, $permissiontoadd, $permissiontodelete;
792 
793  $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
794  $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
795  $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
796  $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
797  $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
798  $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
799  $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'positionlist'; // To manage different context of search
800  $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
801  $id = GETPOST('id', 'int');
802  $fk_job = GETPOST('fk_job', 'int');
803 
804  // Load variable for pagination
805  $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
806  $sortfield = GETPOST('sortfield', 'aZ09comma');
807  $sortorder = GETPOST('sortorder', 'aZ09comma');
808  $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
809  if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
810  // If $page is not defined, or '' or -1 or if we click on clear filters
811  $page = 0;
812  }
813  $offset = $limit * $page;
814  $pageprev = $page - 1;
815  $pagenext = $page + 1;
816 
817  // Initialize technical objects
818  $object = new Position($db);
819 
820  $extrafields = new ExtraFields($db);
821  $diroutputmassaction = $conf->hrm->dir_output . '/temp/massgeneration/' . $user->id;
822  $hookmanager->initHooks(array('positiontablist')); // Note that conf->hooks_modules contains array
823 
824  // Fetch optionals attributes and labels
825  $extrafields->fetch_name_optionals_label($object->table_element);
826  //$extrafields->fetch_name_optionals_label($object->table_element_line);
827 
828  $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
829 
830  // Default sort order (if not yet defined by previous GETPOST)
831  if (!$sortfield) {
832  reset($object->fields); // Reset is required to avoid key() to return null.
833  $sortfield = "t." . key($object->fields); // Set here default search field. By default 1st field in definition.
834  }
835  if (!$sortorder) {
836  $sortorder = "ASC";
837  }
838 
839  // Initialize array of search criterias
840  $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
841  $search = array();
842  foreach ($object->fields as $key => $val) {
843  if (GETPOST('search_' . $key, 'alpha') !== '') {
844  $search[$key] = GETPOST('search_' . $key, 'alpha');
845  }
846  if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
847  $search[$key . '_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_' . $key . '_dtstartmonth', 'int'), GETPOST('search_' . $key . '_dtstartday', 'int'), GETPOST('search_' . $key . '_dtstartyear', 'int'));
848  $search[$key . '_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_' . $key . '_dtendmonth', 'int'), GETPOST('search_' . $key . '_dtendday', 'int'), GETPOST('search_' . $key . '_dtendyear', 'int'));
849  }
850  }
851 
852  // List of fields to search into when doing a "search in all"
853  $fieldstosearchall = array();
854  foreach ($object->fields as $key => $val) {
855  if (!empty($val['searchall'])) {
856  $fieldstosearchall['t.' . $key] = $val['label'];
857  }
858  }
859 
860  // Definition of array of fields for columns
861  $arrayfields = array();
862  foreach ($object->fields as $key => $val) {
863  // If $val['visible']==0, then we never show the field
864  if (!empty($val['visible'])) {
865  $visible = (int) dol_eval($val['visible'], 1, 1, '1');
866  $arrayfields['t.' . $key] = array(
867  'label' => $val['label'],
868  'checked' => (($visible < 0) ? 0 : 1),
869  'enabled' => ($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
870  'position' => $val['position'],
871  'help' => isset($val['help']) ? $val['help'] : ''
872  );
873  }
874  }
875  // Extra fields
876  include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php';
877 
878  $object->fields = dol_sort_array($object->fields, 'position');
879  $arrayfields = dol_sort_array($arrayfields, 'position');
880 
881  // Security check
882  if (empty($conf->hrm->enabled)) {
883  accessforbidden('Module not enabled');
884  }
885 
886  // Security check (enable the most restrictive one)
887  if ($user->socid > 0) accessforbidden();
888  //if ($user->socid > 0) accessforbidden();
889  //$socid = 0; if ($user->socid > 0) $socid = $user->socid;
890  //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
891  //restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
892  //if (empty($conf->hrm->enabled)) accessforbidden();
893  //if (!$permissiontoread) accessforbidden();
894 
895 
896  // Build and execute select
897  // --------------------------------------------------------------------
898  $sql = 'SELECT ';
899  $sql .= $object->getFieldList('t');
900  // Add fields from extrafields
901  if (!empty($extrafields->attributes[$object->table_element]['label'])) {
902  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
903  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef." . $key . " as options_" . $key . ', ' : '');
904  }
905  }
906  // Add fields from hooks
907  $parameters = array();
908  $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
909  $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
910  $sql = preg_replace('/,\s*$/', '', $sql);
911  $sql .= " FROM " . MAIN_DB_PREFIX . $object->table_element . " as t";
912  if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
913  $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $object->table_element . "_extrafields as ef on (t.rowid = ef.fk_object)";
914  }
915  // Add table from hooks
916  $parameters = array();
917  $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
918  $sql .= $hookmanager->resPrint;
919  if ($object->ismultientitymanaged == 1) {
920  $sql .= " WHERE t.entity IN (" . getEntity($object->element) . ")";
921  } else {
922  $sql .= " WHERE 1 = 1";
923  }
924  $sql .= " AND t.fk_job = " . ((int) $fk_job) . " ";
925 
926  foreach ($search as $key => $val) {
927  if (array_key_exists($key, $object->fields)) {
928  if ($key == 'status' && $search[$key] == -1) {
929  continue;
930  }
931  $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
932  if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
933  if ($search[$key] == '-1' || $search[$key] === '0') {
934  $search[$key] = '';
935  }
936  $mode_search = 2;
937  }
938  if ($search[$key] != '') {
939  $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
940  }
941  } else {
942  if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
943  $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
944  if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
945  if (preg_match('/_dtstart$/', $key)) {
946  $sql .= " AND t." . $columnName . " >= '" . $db->idate($search[$key]) . "'";
947  }
948  if (preg_match('/_dtend$/', $key)) {
949  $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'";
950  }
951  }
952  }
953  }
954  }
955  if ($search_all) {
956  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
957  }
958  //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
959  // Add where from extra fields
960  include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php';
961  // Add where from hooks
962  $parameters = array();
963  $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
964  $sql .= $hookmanager->resPrint;
965 
966  /* If a group by is required
967  $sql .= " GROUP BY ";
968  foreach($object->fields as $key => $val) {
969  $sql .= "t.".$key.", ";
970  }
971  // Add fields from extrafields
972  if (!empty($extrafields->attributes[$object->table_element]['label'])) {
973  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
974  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
975  }
976  }
977  // Add where from hooks
978  $parameters = array();
979  $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
980  $sql .= $hookmanager->resPrint;
981  $sql = preg_replace('/,\s*$/', '', $sql);
982  */
983 
984  $sql .= $db->order($sortfield, $sortorder);
985 
986  // Count total nb of records
987  $nbtotalofrecords = '';
988  if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
989  $resql = $db->query($sql);
990  $nbtotalofrecords = $db->num_rows($resql);
991  if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
992  $page = 0;
993  $offset = 0;
994  }
995  }
996  // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
997  if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
998  $num = $nbtotalofrecords;
999  } else {
1000  if ($limit) {
1001  $sql .= $db->plimit($limit + 1, $offset);
1002  }
1003 
1004  $resql = $db->query($sql);
1005  if (!$resql) {
1006  dol_print_error($db);
1007  exit;
1008  }
1009 
1010  $num = $db->num_rows($resql);
1011  }
1012 
1013  // Direct jump if only one record found
1014  if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
1015  $obj = $db->fetch_object($resql);
1016  $id = $obj->rowid;
1017  header("Location: " . dol_buildpath('/hrm/position.php', 1) . '?id=' . $id);
1018  exit;
1019  }
1020 
1021  $arrayofselected = is_array($toselect) ? $toselect : array();
1022 
1023  $param = 'fk_job=' . $fk_job;
1024  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
1025  $param .= '&contextpage=' . urlencode($contextpage);
1026  }
1027  if ($limit > 0 && $limit != $conf->liste_limit) {
1028  $param .= '&limit=' . urlencode($limit);
1029  }
1030  foreach ($search as $key => $val) {
1031  if (is_array($search[$key]) && count($search[$key])) {
1032  foreach ($search[$key] as $skey) {
1033  $param .= '&search_' . $key . '[]=' . urlencode($skey);
1034  }
1035  } else {
1036  $param .= '&search_' . $key . '=' . urlencode($search[$key]);
1037  }
1038  }
1039  if ($optioncss != '') {
1040  $param .= '&optioncss=' . urlencode($optioncss);
1041  }
1042  // Add $param from extra fields
1043  include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php';
1044  // Add $param from hooks
1045  $parameters = array();
1046  $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
1047  $param .= $hookmanager->resPrint;
1048 
1049  // List of mass actions available
1050  $arrayofmassactions = array(
1051  //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
1052  //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
1053  //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
1054  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
1055  );
1056  if ($permissiontodelete) {
1057  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"') . $langs->trans("Delete");
1058  }
1059  if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
1060  $arrayofmassactions = array();
1061  }
1062  $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
1063 
1064  print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '?fk_job=' . $fk_job . '">' . "\n";
1065  if ($optioncss != '') {
1066  print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
1067  }
1068  print '<input type="hidden" name="token" value="' . newToken() . '">';
1069  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1070  print '<input type="hidden" name="action" value="list">';
1071  print '<input type="hidden" name="massaction" value="' . $massaction . '">';
1072  print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
1073  print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
1074  print '<input type="hidden" name="page" value="' . $page . '">';
1075  print '<input type="hidden" name="contextpage" value="' . $contextpage . '">';
1076 
1077  $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/hrm/position.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']).'&fk_job='.((int) $fk_job), '', $permissiontoadd);
1078 
1079  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_' . $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
1080 
1081  // Add code for pre mass action (confirmation or email presend form)
1082  $topicmail = "SendPositionRef";
1083  $modelmail = "position";
1084  $objecttmp = new Position($db);
1085  $trackid = 'xxxx' . $object->id;
1086  include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php';
1087 
1088  if ($search_all) {
1089  foreach ($fieldstosearchall as $key => $val) {
1090  $fieldstosearchall[$key] = $langs->trans($val);
1091  }
1092  print '<div class="divsearchfieldfilter">' . $langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall) . '</div>';
1093  }
1094 
1095  $moreforfilter = '';
1096  /*$moreforfilter.='<div class="divsearchfield">';
1097  $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
1098  $moreforfilter.= '</div>';*/
1099 
1100  $parameters = array();
1101  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
1102  if (empty($reshook)) {
1103  $moreforfilter .= $hookmanager->resPrint;
1104  } else {
1105  $moreforfilter = $hookmanager->resPrint;
1106  }
1107 
1108  if (!empty($moreforfilter)) {
1109  print '<div class="liste_titre liste_titre_bydiv centpercent">';
1110  print $moreforfilter;
1111  print '</div>';
1112  }
1113 
1114  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1115  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
1116  $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
1117 
1118  print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
1119  print '<table class="tagtable nobottomiftotal liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n";
1120 
1121 
1122  // Fields title search
1123  // --------------------------------------------------------------------
1124  print '<tr class="liste_titre">';
1125  foreach ($object->fields as $key => $val) {
1126  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
1127  if ($key == 'status') {
1128  $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
1129  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
1130  $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
1131  } elseif (in_array($val['type'], array('timestamp'))) {
1132  $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
1133  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
1134  $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
1135  }
1136  if (!empty($arrayfields['t.' . $key]['checked'])) {
1137  print '<td class="liste_titre' . ($cssforfield ? ' ' . $cssforfield : '') . '">';
1138  if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
1139  print $form->selectarray('search_' . $key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
1140  } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
1141  print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1);
1142  } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
1143  print '<input type="text" class="flat maxwidth75" name="search_' . $key . '" value="' . dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '') . '">';
1144  } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
1145  print '<div class="nowrap">';
1146  print $form->selectDate($search[$key . '_dtstart'] ? $search[$key . '_dtstart'] : '', "search_" . $key . "_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1147  print '</div>';
1148  print '<div class="nowrap">';
1149  print $form->selectDate($search[$key . '_dtend'] ? $search[$key . '_dtend'] : '', "search_" . $key . "_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1150  print '</div>';
1151  }
1152  print '</td>';
1153  }
1154  }
1155  // Extra fields
1156  include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php';
1157 
1158  // Fields from hook
1159  $parameters = array('arrayfields' => $arrayfields);
1160  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
1161  print $hookmanager->resPrint;
1162  // Action column
1163  print '<td class="liste_titre maxwidthsearch">';
1164  $searchpicto = $form->showFilterButtons();
1165  print $searchpicto;
1166  print '</td>';
1167  print '</tr>' . "\n";
1168 
1169 
1170  // Fields title label
1171  // --------------------------------------------------------------------
1172  print '<tr class="liste_titre">';
1173  foreach ($object->fields as $key => $val) {
1174  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
1175  if ($key == 'status') {
1176  $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
1177  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
1178  $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
1179  } elseif (in_array($val['type'], array('timestamp'))) {
1180  $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
1181  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
1182  $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
1183  }
1184  if (!empty($arrayfields['t.' . $key]['checked'])) {
1185  print getTitleFieldOfList($arrayfields['t.' . $key]['label'], 0, $_SERVER['PHP_SELF'], 't.' . $key, '', $param, ($cssforfield ? 'class="' . $cssforfield . '"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield . ' ' : '')) . "\n";
1186  }
1187  }
1188  // Extra fields
1189  include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php';
1190  // Hook fields
1191  $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
1192  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
1193  print $hookmanager->resPrint;
1194  // Action column
1195  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ') . "\n";
1196  print '</tr>' . "\n";
1197 
1198  // Detect if we need a fetch on each output line
1199  $needToFetchEachLine = 0;
1200  if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
1201  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
1202  if (preg_match('/\$object/', $val)) {
1203  $needToFetchEachLine++; // There is at least one compute field that use $object
1204  }
1205  }
1206  }
1207 
1208 
1209  // Loop on record
1210  // --------------------------------------------------------------------
1211  $i = 0;
1212  $totalarray = array();
1213  $totalarray['nbfield'] = 0;
1214  while ($i < ($limit ? min($num, $limit) : $num)) {
1215  $obj = $db->fetch_object($resql);
1216  if (empty($obj)) {
1217  break; // Should not happen
1218  }
1219 
1220  // Store properties in $object
1221  $object->setVarsFromFetchObj($obj);
1222 
1223  // Show here line of result
1224  print '<tr class="oddeven">';
1225  foreach ($object->fields as $key => $val) {
1226  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
1227  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
1228  $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
1229  } elseif ($key == 'status') {
1230  $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
1231  }
1232 
1233  if (in_array($val['type'], array('timestamp'))) {
1234  $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
1235  } elseif ($key == 'ref') {
1236  $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
1237  }
1238 
1239  if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
1240  $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
1241  }
1242  //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
1243 
1244  if (!empty($arrayfields['t.' . $key]['checked'])) {
1245  print '<td' . ($cssforfield ? ' class="' . $cssforfield . '"' : '') . '>';
1246  if ($key == 'status') {
1247  print $object->getLibStatut(5);
1248  } elseif ($key == 'rowid') {
1249  print $object->getNomUrl(1);
1250  } else {
1251  print $object->showOutputField($val, $key, $object->$key, '');
1252  }
1253  print '</td>';
1254  if (!$i) {
1255  $totalarray['nbfield']++;
1256  }
1257  if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
1258  if (!$i) {
1259  $totalarray['pos'][$totalarray['nbfield']] = 't.' . $key;
1260  }
1261  if (!isset($totalarray['val'])) {
1262  $totalarray['val'] = array();
1263  }
1264  if (!isset($totalarray['val']['t.' . $key])) {
1265  $totalarray['val']['t.' . $key] = 0;
1266  }
1267  $totalarray['val']['t.' . $key] += $object->$key;
1268  }
1269  }
1270  }
1271  // Extra fields
1272  include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php';
1273  // Fields from hook
1274  $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1275  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
1276  print $hookmanager->resPrint;
1277  // Action column
1278  print '<td class="nowrap center">';
1279  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1280  $selected = 0;
1281  if (in_array($object->id, $arrayofselected)) {
1282  $selected = 1;
1283  }
1284  print '<input id="cb' . $object->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $object->id . '"' . ($selected ? ' checked="checked"' : '') . '>';
1285  }
1286  print '</td>';
1287  if (!$i) {
1288  $totalarray['nbfield']++;
1289  }
1290 
1291  print '</tr>' . "\n";
1292 
1293  $i++;
1294  }
1295 
1296  // Show total line
1297  include DOL_DOCUMENT_ROOT . '/core/tpl/list_print_total.tpl.php';
1298 
1299  // If no record found
1300  if ($num == 0) {
1301  $colspan = 1;
1302  foreach ($arrayfields as $key => $val) {
1303  if (!empty($val['checked'])) {
1304  $colspan++;
1305  }
1306  }
1307  print '<tr><td colspan="' . $colspan . '" class="opacitymedium">' . $langs->trans("NoRecordFound") . '</td></tr>';
1308  }
1309 
1310 
1311  $db->free($resql);
1312 
1313  $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1314  $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
1315  print $hookmanager->resPrint;
1316 
1317  print '</table>' . "\n";
1318  print '</div>' . "\n";
1319 
1320  print '</form>' . "\n";
1321 
1322  if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
1323  $hidegeneratedfilelistifempty = 1;
1324  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
1325  $hidegeneratedfilelistifempty = 0;
1326  }
1327 
1328  require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
1329  $formfile = new FormFile($db);
1330 
1331  // Show list of available documents
1332  $urlsource = $_SERVER['PHP_SELF'] . '?sortfield=' . $sortfield . '&sortorder=' . $sortorder;
1333  $urlsource .= str_replace('&amp;', '&', $param);
1334 
1335  $filedir = $diroutputmassaction;
1336  $genallowed = $permissiontoread;
1337  $delallowed = $permissiontoadd;
1338 
1339  print $formfile->showdocuments('massfilesarea_hrm', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1340  }
1341 }
1342 
1343 // End of page
1344 llxFooter();
1345 $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 for Job.
Definition: job.class.php:37
Class for Position.
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_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
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...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
jobPrepareHead($object)
Prepare array of tabs for Job.
Definition: hrm_job.lib.php:33
if($action=='create') if($job->id > 0 &&(empty($action)||($action !='edit' && $action !='create'))) DisplayPositionList()
Show a list of positions for the current job.
Definition: position.php:789
$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.