dolibarr 25.0.0-alpha
recruitmentjobposition_list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2025-2026 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Load Dolibarr environment
27require_once '../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentjobposition.lib.php';
29require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php';
33
42// Load translation files required by the page
43$langs->loadLangs(array("recruitment", "other"));
44
45$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
46$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
47$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
48$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
49$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
50$toselect = GETPOST('toselect', 'array:int'); // Array of ids of elements selected into a list
51$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'recruitmentjobpositionlist'; // To manage different context of search
52$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
53$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
54$mode = GETPOST('mode', 'aZ');
55
56$id = GETPOSTINT('id');
57
58// Load variable for pagination
59$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
60$sortfield = GETPOST('sortfield', 'aZ09comma');
61$sortorder = GETPOST('sortorder', 'aZ09comma');
62$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
63if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
64 // If $page is not defined, or '' or -1 or if we click on clear filters
65 $page = 0;
66}
67$offset = $limit * $page;
68$pageprev = $page - 1;
69$pagenext = $page + 1;
70
71// Initialize a technical objects
73$extrafields = new ExtraFields($db);
74$diroutputmassaction = $conf->recruitment->dir_output.'/temp/massgeneration/'.$user->id;
75$hookmanager->initHooks(array('recruitmentjobpositionlist')); // Note that conf->hooks_modules contains array
76
77// Fetch optionals attributes and labels
78$extrafields->fetch_name_optionals_label($object->table_element);
79//$extrafields->fetch_name_optionals_label($object->table_element_line);
80
81$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
82
83// Default sort order (if not yet defined by previous GETPOST)
84if (!$sortfield) {
85 $sortfield = "t.ref";
86}
87if (!$sortorder) {
88 $sortorder = "DESC";
89}
90
91// Initialize array of search criteria
92$search_all = GETPOST('search_all', 'alphanohtml');
93$search = array();
94foreach ($object->fields as $key => $val) {
95 if (GETPOST('search_'.$key, 'alpha') !== '') {
96 $search[$key] = GETPOST('search_'.$key, 'alpha');
97 }
98 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
99 $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOSTINT('search_'.$key.'_dtstartmonth'), GETPOSTINT('search_'.$key.'_dtstartday'), GETPOSTINT('search_'.$key.'_dtstartyear'));
100 $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOSTINT('search_'.$key.'_dtendmonth'), GETPOSTINT('search_'.$key.'_dtendday'), GETPOSTINT('search_'.$key.'_dtendyear'));
101 }
102}
103
104// List of fields to search into when doing a "search in all"
105$fieldstosearchall = array();
106foreach ($object->fields as $key => $val) {
107 if (!empty($val['searchall'])) {
108 $fieldstosearchall['t.'.$key] = $val['label'];
109 }
110}
111
112// Definition of array of fields for columns
113$arrayfields = array();
114foreach ($object->fields as $key => $val) {
115 // If $val['visible']==0, then we never show the field
116 if (!empty($val['visible'])) {
117 $visible = (int) dol_eval((string) $val['visible'], 1, 1, '1');
118 $arrayfields['t.'.$key] = array(
119 'label' => $val['label'],
120 'checked' => (($visible < 0) ? '0' : '1'),
121 'enabled' => (string) (int) (abs($visible) != 3 && (bool) dol_eval((string) $val['enabled'], 1)),
122 'position' => $val['position'],
123 'help' => isset($val['help']) ? $val['help'] : ''
124 );
125 }
126}
127// Extra fields
128include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
129// Add hook to complete $arrayfield
130$parameters = array('arrayfields' => &$arrayfields);
131$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
132
133// Load object
134include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
135
136$object->fields = dol_sort_array($object->fields, 'position');
137$arrayfields['nbapplications'] = array('type' => 'integer', 'label' => 'Applications', 'checked' => 1, 'enabled' => 1, 'position' => 90, 'csslist' => 'right');
138$arrayfields = dol_sort_array($arrayfields, 'position');
139
140$permissiontoread = $user->hasRight('recruitment', 'recruitmentjobposition', 'read');
141$permissiontoadd = $user->hasRight('recruitment', 'recruitmentjobposition', 'write');
142$permissiontodelete = $user->hasRight('recruitment', 'recruitmentjobposition', 'delete');
143
144// Security check - Protection if external user
145//if ($user->socid > 0) accessforbidden();
146//if ($user->socid > 0) $socid = $user->socid;
147//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
148restrictedArea($user, 'recruitment', 0, 'recruitment_recruitmentjobposition', 'recruitmentjobposition');
149
150
151
152/*
153 * Actions
154 */
155
156if (GETPOST('cancel', 'alpha')) {
157 $action = 'list';
158 $massaction = '';
159}
160if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
161 $massaction = '';
162}
163
164$parameters = array();
165$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
166if ($reshook < 0) {
167 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
168}
169
170if (empty($reshook)) {
171 // Selection of new fields
172 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
173
174 // Purge search criteria
175 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
176 foreach ($object->fields as $key => $val) {
177 $search[$key] = '';
178 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
179 $search[$key.'_dtstart'] = '';
180 $search[$key.'_dtend'] = '';
181 }
182 }
183 $toselect = array();
184 $search_array_options = array();
185 }
186 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
187 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
188 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
189 }
190
191 // Mass actions
192 $objectclass = 'RecruitmentJobPosition';
193 $objectlabel = 'RecruitmentJobPosition';
194 $uploaddir = $conf->recruitment->dir_output;
195 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
196}
197
198
199
200/*
201 * View
202 */
203
204$form = new Form($db);
205
206$now = dol_now();
207
208//$help_url="EN:Module_RecruitmentJobPosition|FR:Module_RecruitmentJobPosition_FR|ES:Módulo_RecruitmentJobPosition";
209$help_url = '';
210$title = $langs->trans('PositionsToBeFilled');
211$morejs = array();
212$morecss = array();
213
214
215// Build and execute select
216// --------------------------------------------------------------------
217$sql = 'SELECT ';
218$sql .= $object->getFieldList('t');
219
220// Add fields from extrafields
221if (!empty($extrafields->attributes[$object->table_element]['label'])) {
222 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
223 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
224 }
225}
226// Add fields from hooks
227$parameters = array();
228$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
229$sql .= $hookmanager->resPrint;
230$sql = preg_replace('/,\s*$/', '', $sql);
231$sql .= ", COUNT(rc.rowid) as nbapplications";
232$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
233$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc ON rc.fk_recruitmentjobposition = t.rowid";
234if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
235 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
236}
237// Add table from hooks
238$parameters = array();
239$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
240$sql .= $hookmanager->resPrint;
241if ($object->ismultientitymanaged == 1) {
242 $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
243} else {
244 $sql .= " WHERE 1 = 1";
245}
246foreach ($search as $key => $val) {
247 if (array_key_exists($key, $object->fields)) {
248 if ($key == 'status' && $search[$key] == -1) {
249 continue;
250 }
251 $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
252 if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
253 if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
254 $search[$key] = '';
255 }
256 $mode_search = 2;
257 }
258 if ($search[$key] != '') {
259 $sql .= natural_search("t.".$db->sanitize($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
260 }
261 } else {
262 if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
263 $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
264 if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
265 if (preg_match('/_dtstart$/', $key)) {
266 $sql .= " AND t.".$db->sanitize($columnName)." >= '".$db->idate($search[$key])."'";
267 }
268 if (preg_match('/_dtend$/', $key)) {
269 $sql .= " AND t.".$db->sanitize($columnName)." <= '" . $db->idate($search[$key])."'";
270 }
271 }
272 }
273 }
274}
275if ($search_all) {
276 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
277}
278//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
279// Add where from extra fields
280include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
281// Add where from hooks
282$parameters = array();
283$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
284$sql .= $hookmanager->resPrint;
285
286/* If a group by is required */
287$sql .= " GROUP BY ";
288foreach ($object->fields as $key => $val) {
289 $sql .= "t.".$db->sanitize($key).", ";
290}
291// Add fields from extrafields
292if (!empty($extrafields->attributes[$object->table_element]['label'])) {
293 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
294 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
295 }
296}
297// Add where from hooks
298$parameters = array();
299$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
300$sql .= $hookmanager->resPrint;
301$sql = preg_replace('/,\s*$/', '', $sql);
302
303// Count total nb of records
304$nbtotalofrecords = '';
305if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
306 /* This old and fast method to get and count full list returns all record so use a high amount of memory. */
307 $resql = $db->query($sql);
308 $nbtotalofrecords = $db->num_rows($resql);
309 /* The slow method does not consume memory on mysql (not tested on pgsql) */
310 /*$resql = $db->query($sql, 0, 'auto', 1);
311 while ($db->fetch_object($resql)) {
312 $nbtotalofrecords++;
313 }*/
314 /* The fast and low memory method to get and count full list converts the sql into a sql count */
315 /*
316 $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\‍(\‍),=<>\:\-\']+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
317 print $sqlforcount;
318 $resql = $db->query($sqlforcount);
319 $objforcount = $db->fetch_object($resql);
320 $nbtotalofrecords = $objforcount->nbtotalofrecords;
321 */
322
323 if (($page * $limit) > (int) $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
324 $page = 0;
325 $offset = 0;
326 }
327 $db->free($resql);
328}
329
330// Complete request and execute it with limit
331$sql .= $db->order($sortfield, $sortorder);
332if ($limit) {
333 $sql .= $db->plimit($limit + 1, $offset);
334}
335
336$resql = $db->query($sql);
337if (!$resql) {
339 exit;
340}
341
342$num = $db->num_rows($resql);
343
344
345// Direct jump if only one record found
346if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
347 $obj = $db->fetch_object($resql);
348 $id = $obj->rowid;
349 header("Location: ".DOL_URL_ROOT.'/recruitment/recruitmentjobposition_card.php?id='.$id);
350 exit;
351}
352
353
354// Output page
355// --------------------------------------------------------------------
356
357llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist');
358
359$arrayofselected = is_array($toselect) ? $toselect : array();
360
361$param = '';
362if (!empty($mode)) {
363 $param .= '&mode='.urlencode($mode);
364}
365if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
366 $param .= '&contextpage='.urlencode($contextpage);
367}
368if ($limit > 0 && $limit != $conf->liste_limit) {
369 $param .= '&limit='.((int) $limit);
370}
371foreach ($search as $key => $val) {
372 if (is_array($search[$key]) && count($search[$key])) {
373 foreach ($search[$key] as $skey) {
374 if ($skey != '') {
375 $param .= '&search_'.$key.'[]='.urlencode($skey);
376 }
377 }
378 } elseif ($search[$key] != '') {
379 $param .= '&search_'.$key.'='.urlencode($search[$key]);
380 }
381}
382if ($optioncss != '') {
383 $param .= '&optioncss='.urlencode($optioncss);
384}
385// Add $param from extra fields
386include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
387// Add $param from hooks
388$parameters = array('param' => &$param);
389$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
390$param .= $hookmanager->resPrint;
391
392// List of mass actions available
393$arrayofmassactions = array(
394 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
395 //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
396 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
397 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
398);
399if ($permissiontodelete) {
400 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
401}
402if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
403 $arrayofmassactions = array();
404}
405$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
406
407print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
408if ($optioncss != '') {
409 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
410}
411print '<input type="hidden" name="token" value="'.newToken().'">';
412print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
413print '<input type="hidden" name="action" value="list">';
414print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
415print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
416//print '<input type="hidden" name="page" value="'.$page.'">';
417print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
418print '<input type="hidden" name="mode" value="'.$mode.'">';
419
420$newcardbutton = '';
421$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/^&mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition'));
422$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/^&mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition'));
423$newcardbutton .= dolGetButtonTitleSeparator();
424$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/recruitment/recruitmentjobposition_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
425
426print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
427
428// Add code for pre mass action (confirmation or email presend form)
429$topicmail = "SendRecruitmentJobPositionRef";
430$modelmail = "recruitmentjobposition";
431$objecttmp = new RecruitmentJobPosition($db);
432$trackid = 'recruitmentjobposition'.$object->id;
433include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
434
435if ($search_all) {
436 foreach ($fieldstosearchall as $key => $val) {
437 $fieldstosearchall[$key] = $langs->trans($val);
438 }
439 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
440}
441
442$moreforfilter = '';
443/*$moreforfilter.='<div class="divsearchfield">';
444$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
445$moreforfilter.= '</div>';*/
446
447$parameters = array();
448$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
449if (empty($reshook)) {
450 $moreforfilter .= $hookmanager->resPrint;
451} else {
452 $moreforfilter = $hookmanager->resPrint;
453}
454
455if (!empty($moreforfilter)) {
456 print '<div class="liste_titre liste_titre_bydiv centpercent">';
457 print $moreforfilter;
458 print '</div>';
459}
460
461$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
462$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields
463$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
464
465print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
466print '<table class="tagtable nobottomiftotal noborder liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
467
468
469// Fields title search
470// --------------------------------------------------------------------
471print '<tr class="liste_titre_filter">';
472// Action column
473if ($conf->main_checkbox_left_column) {
474 print '<td class="liste_titre maxwidthsearch">';
475 $searchpicto = $form->showFilterButtons('left');
476 print $searchpicto;
477 print '</td>';
478}
479foreach ($object->fields as $key => $val) {
480 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
481 if ($key == 'status') {
482 $cssforfield .= ($cssforfield ? ' ' : '').'center';
483 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
484 $cssforfield .= ($cssforfield ? ' ' : '').'center';
485 } elseif (in_array($val['type'], array('timestamp'))) {
486 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
487 } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
488 $cssforfield .= ($cssforfield ? ' ' : '').'right';
489 }
490 if (!empty($arrayfields['t.'.$key]['checked'])) {
491 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
492 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
493 print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
494 } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
495 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1);
496 } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
497 print '<div class="nowrap">';
498 print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
499 print '</div>';
500 print '<div class="nowrap">';
501 print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
502 print '</div>';
503 } elseif ($key == 'lang') {
504 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
505 $formadmin = new FormAdmin($db);
506 print $formadmin->select_language($search[$key], 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2);
507 } else {
508 print '<input type="text" class="flat maxwidth'.($val['type'] == 'integer' ? '50' : '75').'" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
509 }
510 print '</td>';
511 }
512}
513// Extra fields
514include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
515
516// Fields from hook
517$parameters = array('arrayfields' => $arrayfields);
518$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
519print $hookmanager->resPrint;
520if (!empty($arrayfields['nbapplications']['checked'])) {
521 print '<td class="liste_titre"></td>';
522}
523// Action column
524if (!$conf->main_checkbox_left_column) {
525 print '<td class="liste_titre maxwidthsearch">';
526 $searchpicto = $form->showFilterButtons();
527 print $searchpicto;
528 print '</td>';
529}
530print '</tr>'."\n";
531
532$totalarray = array();
533$totalarray['nbfield'] = 0;
534
535// Fields title label
536// --------------------------------------------------------------------
537print '<tr class="liste_titre">';
538// Action column
539if ($conf->main_checkbox_left_column) {
540 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
541 $totalarray['nbfield']++;
542}
543foreach ($object->fields as $key => $val) {
544 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
545 if ($key == 'status') {
546 $cssforfield .= ($cssforfield ? ' ' : '').'center';
547 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
548 $cssforfield .= ($cssforfield ? ' ' : '').'center';
549 } elseif (in_array($val['type'], array('timestamp'))) {
550 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
551 } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
552 $cssforfield .= ($cssforfield ? ' ' : '').'right';
553 }
554 if (!empty($arrayfields['t.'.$key]['checked'])) {
555 print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
556 $totalarray['nbfield']++;
557 }
558}
559// Extra fields
560include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
561// Hook fields
562$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
563$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
564print $hookmanager->resPrint;
565if (!empty($arrayfields['nbapplications']['checked'])) {
566 print '<th class="liste_titre right">'.$langs->trans("RecruitmentCandidatures").'</th>';
567 $totalarray['nbfield']++;
568}
569// Action column
570if (!$conf->main_checkbox_left_column) {
571 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
572 $totalarray['nbfield']++;
573}
574print '</tr>'."\n";
575
576
577// Detect if we need a fetch on each output line
578$needToFetchEachLine = 0;
579if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
580 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
581 if (!is_null($val) && preg_match('/\$object/', $val)) {
582 $needToFetchEachLine++; // There is at least one compute field that use $object
583 }
584 }
585}
586
587
588// Loop on record
589// --------------------------------------------------------------------
590$i = 0;
591$savnbfield = $totalarray['nbfield'];
592$totalarray['nbfield'] = 0;
593$imaxinloop = ($limit ? min($num, $limit) : $num);
594while ($i < $imaxinloop) {
595 $obj = $db->fetch_object($resql);
596 if (empty($obj)) {
597 break; // Should not happen
598 }
599
600 // Store properties in $object
601 $object->setVarsFromFetchObj($obj);
602 $object->date_planned = $obj->date_planned;
603
604 if ($mode == 'kanban') {
605 if ($i == 0) {
606 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
607 print '<div class="box-flex-container kanban">';
608 }
609 if ($massactionbutton || $massaction) {
610 $selected = 0;
611 }
612 // Output Kanban
613 $selected = -1;
614 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
615 $selected = 0;
616 if (in_array($object->id, $arrayofselected)) {
617 $selected = 1;
618 }
619 }
620 print $object->getKanbanView('', array('nbapplications' => $obj->nbapplications, 'selected' => $selected));
621 if ($i == ($imaxinloop - 1)) {
622 print '</div>';
623 print '</td></tr>';
624 }
625 } else {
626 // Show here line of result
627 $j = 0;
628 print '<tr class="oddeven">';
629 // Action column
630 if ($conf->main_checkbox_left_column) {
631 print '<td class="nowrap center">';
632 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
633 $selected = 0;
634 if (in_array($object->id, $arrayofselected)) {
635 $selected = 1;
636 }
637 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
638 }
639 print '</td>';
640 if (!$i) {
641 $totalarray['nbfield']++;
642 }
643 }
644 foreach ($object->fields as $key => $val) {
645 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
646 if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
647 $cssforfield .= ($cssforfield ? ' ' : '').'center';
648 } elseif ($key == 'status') {
649 $cssforfield .= ($cssforfield ? ' ' : '').'center';
650 }
651
652 if (in_array($val['type'], array('timestamp'))) {
653 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
654 } elseif ($key == 'ref') {
655 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
656 }
657
658 if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
659 $cssforfield .= ($cssforfield ? ' ' : '').'right';
660 }
661 //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
662
663 if (!empty($arrayfields['t.'.$key]['checked'])) {
664 print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
665 if ($key == 'status') {
666 print $object->getLibStatut(5);
667 } elseif ($key == 'rowid') {
668 print $object->showOutputField($val, $key, (string) $object->id, '');
669 } else {
670 print $object->showOutputField($val, $key, $object->$key, '');
671 }
672 print '</td>';
673 if (!$i) {
674 $totalarray['nbfield']++;
675 }
676 if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
677 if (!$i) {
678 $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
679 }
680 if (!isset($totalarray['val'])) {
681 $totalarray['val'] = array();
682 }
683 if (!isset($totalarray['val']['t.'.$key])) {
684 $totalarray['val']['t.'.$key] = 0;
685 }
686 $totalarray['val']['t.'.$key] += $object->$key;
687 }
688 }
689 }
690 // Extra fields
691 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
692 // Fields from hook
693 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
694 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
695 print $hookmanager->resPrint;
696 if (!empty($arrayfields['nbapplications']['checked'])) {
697 print '<td class="right">'.$obj->nbapplications.'</td>';
698 if (!$i) {
699 $totalarray['nbfield']++;
700 }
701 }
702 // Action column
703 if (!$conf->main_checkbox_left_column) {
704 print '<td class="nowrap center">';
705 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
706 $selected = 0;
707 if (in_array($object->id, $arrayofselected)) {
708 $selected = 1;
709 }
710 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
711 }
712 print '</td>';
713 if (!$i) {
714 $totalarray['nbfield']++;
715 }
716 }
717
718 print '</tr>'."\n";
719 }
720
721 $i++;
722}
723
724// Show total line
725include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
726
727// If no record found
728if ($num == 0) {
729 $colspan = 1;
730 foreach ($arrayfields as $key => $val) {
731 if (!empty($val['checked'])) {
732 $colspan++;
733 }
734 }
735 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
736}
737
738
739$db->free($resql);
740
741$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
742$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
743print $hookmanager->resPrint;
744
745print '</table>'."\n";
746print '</div>'."\n";
747
748print '</form>'."\n";
749
750if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
751 $hidegeneratedfilelistifempty = 1;
752 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
753 $hidegeneratedfilelistifempty = 0;
754 }
755
756 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
757 $formfile = new FormFile($db);
758
759 // Show list of available documents
760 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
761 $urlsource .= str_replace('&amp;', '&', $param);
762
763 $filedir = $diroutputmassaction;
764 $genallowed = $permissiontoread;
765 $delallowed = $permissiontoadd;
766
767 print $formfile->showdocuments('massfilesarea_recruitment', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
768}
769
770// End of page
771llxFooter();
772$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:501
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 generate html code for admin pages.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class for RecruitmentJobPosition.
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...
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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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)
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.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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...
Definition html.lib.php:172
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
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.