dolibarr 24.0.0-beta
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 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
8 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30// Load Dolibarr environment
31require '../main.inc.php';
32require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
33require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
34require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
35require_once DOL_DOCUMENT_ROOT . '/hrm/class/position.class.php';
36require_once DOL_DOCUMENT_ROOT . '/hrm/class/job.class.php';
37require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm_position.lib.php';
38require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm_job.lib.php';
39require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
40require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
41
42
52// Load translation files required by the page
53$langs->loadLangs(array("hrm", "other", 'products'));
54
55$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
56$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
57$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
58$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
59$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
60$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
61$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'jobpositionlist'; // To manage different context of search
62$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
63$backtopage = GETPOST('backtopage', 'alpha');
64$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
65
66$id = GETPOSTINT('id');
67$ref = GETPOST('ref', 'alpha');
68$fk_job = (GETPOSTISSET('fk_job') ? GETPOSTINT('fk_job') : $id);
69$fk_user = GETPOSTINT('fk_user');
70//$start_date = date('Y-m-d', GETPOST('date_startyear', 'int').'-'.GETPOST('date_startmonth', 'int').'-'.GETPOST('date_startday', 'int'));
71$start_date = dol_mktime(0, 0, 0, GETPOSTINT('date_startmonth'), GETPOSTINT('date_startday'), GETPOSTINT('date_startyear'));
72
73
74// Load variable for pagination
75$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
76$sortfield = GETPOST('sortfield', 'aZ09comma');
77$sortorder = GETPOST('sortorder', 'aZ09comma');
78$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
79if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
80 // If $page is not defined, or '' or -1 or if we click on clear filters
81 $page = 0;
82}
83$offset = $limit * $page;
84$pageprev = $page - 1;
85$pagenext = $page + 1;
86
87
88// Initialize a technical objects
89$object = new Job($db);
90$objectposition = new Position($db);
91$extrafields = new ExtraFields($db);
92$diroutputmassaction = $conf->hrm->dir_output . '/temp/massgeneration/' . $user->id;
93$hookmanager->initHooks(array('jobpositioncard', 'globalcard')); // Note that conf->hooks_modules contains array
94
95
96// Fetch optionals attributes and labels
97$extrafields->fetch_name_optionals_label($objectposition->table_element);
98//$extrafields->fetch_name_optionals_label($object->table_element_line);
99
100$search_array_options = $extrafields->getOptionalsFromPost($objectposition->table_element, '', 'search_');
101
102// Default sort order (if not yet defined by previous GETPOST)
103if (!$sortfield) {
104 reset($objectposition->fields); // Reset is required to avoid key() to return null.
105 $sortfield = "t." . key($objectposition->fields); // Set here default search field. By default 1st field in definition.
106}
107if (!$sortorder) {
108 $sortorder = "ASC";
109}
110
111// Initialize array of search criteria
112$search_all = GETPOST('search_all', 'alphanohtml');
113$search = array();
114foreach ($objectposition->fields as $key => $val) {
115 if (GETPOST('search_' . $key, 'alpha') !== '') {
116 $search[$key] = GETPOST('search_' . $key, 'alpha');
117 }
118 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
119 $search[$key . '_dtstart'] = dol_mktime(0, 0, 0, GETPOSTINT('search_' . $key . '_dtstartmonth'), GETPOSTINT('search_' . $key . '_dtstartday'), GETPOSTINT('search_' . $key . '_dtstartyear'));
120 $search[$key . '_dtend'] = dol_mktime(23, 59, 59, GETPOSTINT('search_' . $key . '_dtendmonth'), GETPOSTINT('search_' . $key . '_dtendday'), GETPOSTINT('search_' . $key . '_dtendyear'));
121 }
122}
123
124// List of fields to search into when doing a "search in all"
125$fieldstosearchall = array();
126foreach ($objectposition->fields as $key => $val) {
127 if (!empty($val['searchall'])) {
128 $fieldstosearchall['t.' . $key] = $val['label'];
129 }
130}
131
132// Definition of array of fields for columns
133$arrayfields = array();
134foreach ($objectposition->fields as $key => $val) {
135 // If $val['visible']==0, then we never show the field
136 if (!empty($val['visible'])) {
137 $visible = (int) dol_eval((string) $val['visible'], 1, 1, '1');
138 $arrayfields['t.' . $key] = array(
139 'label' => $val['label'],
140 'checked' => (($visible < 0) ? 0 : 1),
141 'enabled' => (abs($visible) != 3 && (bool) dol_eval((string) $val['enabled'], 1)),
142 'position' => $val['position'],
143 'help' => isset($val['help']) ? $val['help'] : ''
144 );
145 }
146}
147// Extra fields
148include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php';
149
150$objectposition->fields = dol_sort_array($objectposition->fields, 'position');
151$arrayfields = dol_sort_array($arrayfields, 'position');
152
153
154
155
156// Load object
157include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
158
159// Permissions
160$permissiontoread = $user->hasRight('hrm', 'all', 'read');
161$permissiontoadd = $user->hasRight('hrm', 'all', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
162$permissiontodelete = $user->hasRight('hrm', 'all', 'delete');
163$upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1] . '/position';
164
165// Security check (enable the most restrictive one)
166//if ($user->socid > 0) accessforbidden();
167//if ($user->socid > 0) $socid = $user->socid;
168//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
169//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
170if (!isModEnabled('hrm')) {
172}
173if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) {
175}
176
177
178/*
179 * Actions
180 */
181
182$parameters = array();
183$job = null;
184$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
185if ($reshook < 0) {
186 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
187}
188if (empty($reshook)) {
189 $error = 0;
190
191 $backurlforlist = dol_buildpath('/hrm/position_list.php', 1);
192 $idBacktoPage = GETPOST('fk_job', 'aZ09');
193 if ($idBacktoPage > 0) {
194 $backtopage = dol_buildpath('/hrm/position.php', 1) . '?id=' . $idBacktoPage;
195 }
196 if (empty($backtopage) || ($cancel && empty($id))) {
197 if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
198 if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
199 $backtopage = $backurlforlist;
200 } else {
201 if ($fk_job > 0) {
202 $backtopage = dol_buildpath('/hrm/position.php', 1) . '?fk_job=' . ($fk_job > 0 ? $fk_job : '__ID__');
203 } else {
204 $backtopage = dol_buildpath('/hrm/position_card.php', 1) . '?id=__ID__';
205 }
206 }
207 }
208 }
209
210 $triggermodname = 'HRM_POSITION_MODIFY'; // Name of trigger action code to execute when we modify record
211
212 // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
213 $job = $object;
214 $object = new Position($db);
215
216 // Selection of new fields
217 include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php';
218
219 // Purge search criteria
220 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
221 foreach ($object->fields as $key => $val) {
222 $search[$key] = '';
223 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
224 $search[$key . '_dtstart'] = '';
225 $search[$key . '_dtend'] = '';
226 }
227 }
228 $toselect = array();
229 $search_array_options = array();
230 }
231 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
232 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
233 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
234 }
235
236 // Mass actions
237 $objectclass = 'Position';
238 $objectlabel = 'Position';
239 $uploaddir = $conf->hrm->dir_output;
240 include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php';
241
242 include DOL_DOCUMENT_ROOT . '/core/actions_addupdatedelete.inc.php';
243
244 $object = $job;
245}
246
247/*
248 * View
249 */
250
251$title = $langs->trans("Position");
252//$help_url="EN:Module_Position|FR:Module_Position_FR|ES:Módulo_Position";
253$help_url = '';
254
255llxHeader('', $title, $help_url);
256
257$now = dol_now();
258
259// Part to create
260if ($action == 'create') {
261 $object = new Position($db);
262 // Fetch optionals attributes and labels
263 $extrafields->fetch_name_optionals_label($object->table_element);
264 print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Position")), '', 'object_' . $object->picto);
265
266 print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
267 print '<input type="hidden" name="token" value="' . newToken() . '">';
268 print '<input type="hidden" name="action" value="add">';
269 if ($backtopage) {
270 print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
271 }
272 if ($backtopageforcancel) {
273 print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
274 }
275
276 print dol_get_fiche_head(array(), '');
277
278 print '<table class="border centpercent tableforfieldcreate">' . "\n";
279
280 // Common attributes
281 include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php';
282
283 // Other attributes
284 include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php';
285
286 print '</table>' . "\n";
287
288 print dol_get_fiche_end();
289
290 print $form->buttonsSaveCancel("Create");
291
292 print '</form>';
293
294 //dol_set_focus('input[name="ref"]');
295}
296if ($job !== null && $job->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
297 if ($backtopage) {
298 print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
299 }
300 if ($backtopageforcancel) {
301 print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
302 }
303
304 // Part to show record
305
306 $res = $object->fetch_optionals();
307
308 $head = jobPrepareHead($object);
309
310 print dol_get_fiche_head($head, 'position', $langs->trans("Workstation"), -1, $object->picto);
311
312 // Object card
313 // ------------------------------------------------------------
314 $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>';
315
316 $morehtmlref = '<div class="refid">';
317 $morehtmlref .= $object->label;
318 $morehtmlref .= '</div>';
319
320 dol_banner_tab($object, 'fk_job', $linkback, 1, 'rowid', 'rowid', $morehtmlref);
321
322
323 print '<div class="fichecenter">';
324 print '<div class="fichehalfleft">';
325 print '<div class="underbanner clearboth"></div>';
326 print '<table class="border centpercent tableforfield">' . "\n";
327
328 // Common attributes
329 //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
330 //unset($object->fields['fk_project']); // Hide field already shown in banner
331 //unset($object->fields['fk_soc']); // Hide field already shown in banner
332 $object->fields['label']['visible'] = 0; // Already in banner
333 include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
334
335 // Other attributes. Fields from hook formObjectOptions and Extrafields.
336 include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
337
338 print '</table>';
339 print '</div>';
340 print '</div>';
341
342 print '<div class="clearboth"></div>';
343
344 print dol_get_fiche_end();
345
346
347 // List of positions
348
349 $object = $objectposition;
350
351
352 // Build and execute select
353 // --------------------------------------------------------------------
354 $sql = 'SELECT ';
355 $sql .= $object->getFieldList('t');
356 // Add fields from extrafields
357 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
358 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
359 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef." . $key . " as options_" . $key . ', ' : '');
360 }
361 }
362 // Add fields from hooks
363 $parameters = array();
364 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
365 $sql .= $hookmanager->resPrint;
366 $sql = preg_replace('/,\s*$/', '', $sql);
367 $sql .= " FROM " . MAIN_DB_PREFIX . $object->table_element . " as t";
368 if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
369 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $object->table_element . "_extrafields as ef on (t.rowid = ef.fk_object)";
370 }
371 // Add table from hooks
372 $parameters = array();
373 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
374 $sql .= $hookmanager->resPrint;
375 if ($object->ismultientitymanaged == 1) {
376 $sql .= " WHERE t.entity IN (" . getEntity($object->element) . ")";
377 } else {
378 $sql .= " WHERE 1 = 1";
379 }
380 $sql .= " AND t.fk_job = " . ((int) $fk_job) . " ";
381
382 foreach ($search as $key => $val) {
383 if (array_key_exists($key, $object->fields)) {
384 if ($key == 'status' && $search[$key] == -1) {
385 continue;
386 }
387 $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
388 if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
389 if ($search[$key] == '-1' || $search[$key] === '0') {
390 $search[$key] = '';
391 }
392 $mode_search = 2;
393 }
394 if ($search[$key] != '') {
395 $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
396 }
397 } else {
398 if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
399 $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
400 if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
401 if (preg_match('/_dtstart$/', $key)) {
402 $sql .= " AND t." . $db->sanitize($columnName) . " >= '" . $db->idate($search[$key]) . "'";
403 }
404 if (preg_match('/_dtend$/', $key)) {
405 $sql .= " AND t." . $db->sanitize($columnName) . " <= '" . $db->idate($search[$key]) . "'";
406 }
407 }
408 }
409 }
410 }
411 if ($search_all) {
412 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
413 }
414 //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
415 // Add where from extra fields
416 include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php';
417 // Add where from hooks
418 $parameters = array();
419 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
420 $sql .= $hookmanager->resPrint;
421
422 $sql .= $db->order($sortfield, $sortorder);
423
424 // Count total nb of records
425 $nbtotalofrecords = '';
426 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
427 $resql = $db->query($sql);
428 $nbtotalofrecords = $db->num_rows($resql);
429 if (($page * $limit) > (int) $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
430 $page = 0;
431 $offset = 0;
432 }
433 }
434 // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
435 $resql = null;
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) {
446 exit;
447 }
448
449 $num = $db->num_rows($resql);
450 }
451
452 // Direct jump if only one record found
453 if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page && $resql !== null) {
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='.((int) $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('param' => &$param);
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 (GETPOSTINT('nomassaction') || 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 = '';
517 $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);
518
519 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_' . $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
520
521 // Add code for pre mass action (confirmation or email presend form)
522 $topicmail = "SendPositionRef";
523 $modelmail = "position";
524 $objecttmp = new Position($db);
525 $trackid = 'xxxx' . $object->id;
526 include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php';
527
528 if ($search_all) {
529 foreach ($fieldstosearchall as $key => $val) {
530 $fieldstosearchall[$key] = $langs->trans($val);
531 }
532 print '<div class="divsearchfieldfilter">' . $langs->trans("FilterOnInto", $search_all) . implode(', ', $fieldstosearchall) . '</div>';
533 }
534
535 $moreforfilter = '';
536 /*$moreforfilter.='<div class="divsearchfield">';
537 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
538 $moreforfilter.= '</div>';*/
539
540 $parameters = array();
541 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
542 if (empty($reshook)) {
543 $moreforfilter .= $hookmanager->resPrint;
544 } else {
545 $moreforfilter = $hookmanager->resPrint;
546 }
547
548 if (!empty($moreforfilter)) {
549 print '<div class="liste_titre liste_titre_bydiv centpercent">';
550 print $moreforfilter;
551 print '</div>';
552 }
553
554 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
555 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
556 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
557
558 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
559 print '<table class="tagtable nobottomiftotal liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n";
560
561 // Fields title search
562 // --------------------------------------------------------------------
563 print '<tr class="liste_titre">';
564 foreach ($object->fields as $key => $val) {
565 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
566 if ($key == 'status') {
567 $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
568 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
569 $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
570 } elseif (in_array($val['type'], array('timestamp'))) {
571 $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
572 } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
573 $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
574 }
575 if (!empty($arrayfields['t.' . $key]['checked'])) {
576 print '<td class="liste_titre' . ($cssforfield ? ' ' . $cssforfield : '') . '">';
577 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
578 print $form->selectarray('search_' . $key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
579 } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
580 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1);
581 } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
582 print '<input type="text" class="flat maxwidth75" name="search_' . $key . '" value="' . dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '') . '">';
583 } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
584 print '<div class="nowrap">';
585 print $form->selectDate($search[$key . '_dtstart'] ? $search[$key . '_dtstart'] : '', "search_" . $key . "_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
586 print '</div>';
587 print '<div class="nowrap">';
588 print $form->selectDate($search[$key . '_dtend'] ? $search[$key . '_dtend'] : '', "search_" . $key . "_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
589 print '</div>';
590 }
591 print '</td>';
592 }
593 }
594 // Extra fields
595 include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php';
596
597 // Fields from hook
598 $parameters = array('arrayfields' => $arrayfields);
599 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
600 print $hookmanager->resPrint;
601 // Action column
602 print '<td class="liste_titre maxwidthsearch">';
603 $searchpicto = $form->showFilterButtons();
604 print $searchpicto;
605 print '</td>';
606 print '</tr>' . "\n";
607
608
609 // Fields title label
610 // --------------------------------------------------------------------
611 print '<tr class="liste_titre">';
612 foreach ($object->fields as $key => $val) {
613 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
614 if ($key == 'status') {
615 $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
616 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
617 $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
618 } elseif (in_array($val['type'], array('timestamp'))) {
619 $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
620 } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
621 $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
622 }
623 if (!empty($arrayfields['t.' . $key]['checked'])) {
624 print getTitleFieldOfList($arrayfields['t.' . $key]['label'], 0, $_SERVER['PHP_SELF'], 't.' . $key, '', $param, ($cssforfield ? 'class="' . $cssforfield . '"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield . ' ' : '')) . "\n";
625 }
626 }
627 // Extra fields
628 include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php';
629 // Hook fields
630 $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
631 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
632 print $hookmanager->resPrint;
633 // Action column
634 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ') . "\n";
635 print '</tr>' . "\n";
636
637 // Detect if we need a fetch on each output line
638 $needToFetchEachLine = 0;
639 if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
640 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
641 if (!is_null($val) && preg_match('/\$object/', $val)) {
642 $needToFetchEachLine++; // There is at least one compute field that use $object
643 }
644 }
645 }
646
647
648 // Loop on record
649 // --------------------------------------------------------------------
650 $i = 0;
651 $totalarray = array();
652 $totalarray['nbfield'] = 0;
653 while ($i < ($limit ? min($num, $limit) : $num) && $resql !== null) {
654 $obj = $db->fetch_object($resql);
655 if (empty($obj)) {
656 break; // Should not happen
657 }
658
659 // Store properties in $object
660 $object->setVarsFromFetchObj($obj);
661
662 // Show here line of result
663 print '<tr class="oddeven">';
664 foreach ($object->fields as $key => $val) {
665 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
666 if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
667 $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
668 } elseif ($key == 'status') {
669 $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
670 }
671
672 if (in_array($val['type'], array('timestamp'))) {
673 $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
674 } elseif ($key == 'ref') {
675 $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
676 }
677
678 if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
679 $cssforfield .= ($cssforfield ? ' ' : '') . 'right';
680 }
681 //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
682
683 if (!empty($arrayfields['t.' . $key]['checked'])) {
684 print '<td' . ($cssforfield ? ' class="' . $cssforfield . '"' : '') . '>';
685 if ($key == 'status') {
686 print $object->getLibStatut(5);
687 } elseif ($key == 'rowid') {
688 print $object->getNomUrl(1);
689 } else {
690 print $object->showOutputField($val, $key, $object->$key, '');
691 }
692 print '</td>';
693 if (!$i) {
694 $totalarray['nbfield']++;
695 }
696 if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
697 if (!$i) {
698 $totalarray['pos'][$totalarray['nbfield']] = 't.' . $key;
699 }
700 if (!isset($totalarray['val'])) {
701 $totalarray['val'] = array();
702 }
703 if (!isset($totalarray['val']['t.' . $key])) {
704 $totalarray['val']['t.' . $key] = 0;
705 }
706 $totalarray['val']['t.' . $key] += $object->$key;
707 }
708 }
709 }
710 // Extra fields
711 include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php';
712 // Fields from hook
713 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
714 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
715 print $hookmanager->resPrint;
716 // Action column
717 print '<td class="nowrap center">';
718 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
719 $selected = 0;
720 if (in_array($object->id, $arrayofselected)) {
721 $selected = 1;
722 }
723 print '<input id="cb' . $object->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $object->id . '"' . ($selected ? ' checked="checked"' : '') . '>';
724 }
725 print '</td>';
726 if (!$i) {
727 $totalarray['nbfield']++;
728 }
729
730 print '</tr>' . "\n";
731
732 $i++;
733 }
734
735 // Show total line
736 include DOL_DOCUMENT_ROOT . '/core/tpl/list_print_total.tpl.php';
737
738 // If no record found
739 if ($num == 0) {
740 $colspan = 1;
741 foreach ($arrayfields as $key => $val) {
742 if (!empty($val['checked'])) {
743 $colspan++;
744 }
745 }
746 print '<tr><td colspan="' . $colspan . '"><span class="opacitymedium">' . $langs->trans("NoRecordFound") . '</span></td></tr>';
747 }
748
749
750 if ($resql !== null) {
751 $db->free($resql);
752 }
753
754 $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
755 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
756 print $hookmanager->resPrint;
757
758 print '</table>' . "\n";
759 print '</div>' . "\n";
760
761 print '</form>' . "\n";
762
763 if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
764 $hidegeneratedfilelistifempty = 1;
765 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
766 $hidegeneratedfilelistifempty = 0;
767 }
768
769 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
770 $formfile = new FormFile($db);
771
772 // Show list of available documents
773 $urlsource = $_SERVER['PHP_SELF'] . '?sortfield=' . $sortfield . '&sortorder=' . $sortorder;
774 $urlsource .= str_replace('&amp;', '&', $param);
775
776 $filedir = $diroutputmassaction;
777 $genallowed = $permissiontoread;
778 $delallowed = $permissiontoadd;
779
780 print $formfile->showdocuments('massfilesarea_hrm', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
781 }
782}
783
784// End of page
785llxFooter();
786$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:497
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage standard extra fields.
Class to offer components to list and upload files.
Class for Job.
Definition job.class.php:38
Class for Position.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
jobPrepareHead($object)
Prepare array of tabs for Job.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.