dolibarr 22.0.5
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 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'); // 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
130// Load object
131include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
132
133$object->fields = dol_sort_array($object->fields, 'position');
134$arrayfields['nbapplications'] = array('type' => 'integer', 'label' => 'Applications', 'checked' => 1, 'enabled' => 1, 'position' => 90, 'csslist' => 'right');
135$arrayfields = dol_sort_array($arrayfields, 'position');
136
137$permissiontoread = $user->hasRight('recruitment', 'recruitmentjobposition', 'read');
138$permissiontoadd = $user->hasRight('recruitment', 'recruitmentjobposition', 'write');
139$permissiontodelete = $user->hasRight('recruitment', 'recruitmentjobposition', 'delete');
140
141// Security check - Protection if external user
142//if ($user->socid > 0) accessforbidden();
143//if ($user->socid > 0) $socid = $user->socid;
144//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
145restrictedArea($user, 'recruitment', 0, 'recruitment_recruitmentjobposition', 'recruitmentjobposition');
146
147
148
149/*
150 * Actions
151 */
152
153if (GETPOST('cancel', 'alpha')) {
154 $action = 'list';
155 $massaction = '';
156}
157if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
158 $massaction = '';
159}
160
161$parameters = array();
162$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
163if ($reshook < 0) {
164 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
165}
166
167if (empty($reshook)) {
168 // Selection of new fields
169 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
170
171 // Purge search criteria
172 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
173 foreach ($object->fields as $key => $val) {
174 $search[$key] = '';
175 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
176 $search[$key.'_dtstart'] = '';
177 $search[$key.'_dtend'] = '';
178 }
179 }
180 $toselect = array();
181 $search_array_options = array();
182 }
183 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
184 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
185 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
186 }
187
188 // Mass actions
189 $objectclass = 'RecruitmentJobPosition';
190 $objectlabel = 'RecruitmentJobPosition';
191 $uploaddir = $conf->recruitment->dir_output;
192 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
193}
194
195
196
197/*
198 * View
199 */
200
201$form = new Form($db);
202
203$now = dol_now();
204
205//$help_url="EN:Module_RecruitmentJobPosition|FR:Module_RecruitmentJobPosition_FR|ES:Módulo_RecruitmentJobPosition";
206$help_url = '';
207$title = $langs->trans('PositionsToBeFilled');
208$morejs = array();
209$morecss = array();
210
211
212// Build and execute select
213// --------------------------------------------------------------------
214$sql = 'SELECT ';
215$sql .= $object->getFieldList('t');
216
217// Add fields from extrafields
218if (!empty($extrafields->attributes[$object->table_element]['label'])) {
219 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
220 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
221 }
222}
223// Add fields from hooks
224$parameters = array();
225$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
226$sql .= $hookmanager->resPrint;
227$sql = preg_replace('/,\s*$/', '', $sql);
228$sql .= ", COUNT(rc.rowid) as nbapplications";
229$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
230$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc ON rc.fk_recruitmentjobposition = t.rowid";
231if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
232 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
233}
234// Add table from hooks
235$parameters = array();
236$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
237$sql .= $hookmanager->resPrint;
238if ($object->ismultientitymanaged == 1) {
239 $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
240} else {
241 $sql .= " WHERE 1 = 1";
242}
243foreach ($search as $key => $val) {
244 if (array_key_exists($key, $object->fields)) {
245 if ($key == 'status' && $search[$key] == -1) {
246 continue;
247 }
248 $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
249 if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
250 if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
251 $search[$key] = '';
252 }
253 $mode_search = 2;
254 }
255 if ($search[$key] != '') {
256 $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
257 }
258 } else {
259 if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
260 $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
261 if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
262 if (preg_match('/_dtstart$/', $key)) {
263 $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'";
264 }
265 if (preg_match('/_dtend$/', $key)) {
266 $sql .= " AND t.".$db->escape($columnName)." <= '" . $db->idate($search[$key])."'";
267 }
268 }
269 }
270 }
271}
272if ($search_all) {
273 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
274}
275//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
276// Add where from extra fields
277include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
278// Add where from hooks
279$parameters = array();
280$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
281$sql .= $hookmanager->resPrint;
282
283/* If a group by is required */
284$sql .= " GROUP BY ";
285foreach ($object->fields as $key => $val) {
286 $sql .= "t.".$db->escape($key).", ";
287}
288// Add fields from extrafields
289if (!empty($extrafields->attributes[$object->table_element]['label'])) {
290 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
291 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
292 }
293}
294// Add where from hooks
295$parameters = array();
296$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
297$sql .= $hookmanager->resPrint;
298$sql = preg_replace('/,\s*$/', '', $sql);
299
300// Count total nb of records
301$nbtotalofrecords = '';
302if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
303 /* This old and fast method to get and count full list returns all record so use a high amount of memory. */
304 $resql = $db->query($sql);
305 $nbtotalofrecords = $db->num_rows($resql);
306 /* The slow method does not consume memory on mysql (not tested on pgsql) */
307 /*$resql = $db->query($sql, 0, 'auto', 1);
308 while ($db->fetch_object($resql)) {
309 $nbtotalofrecords++;
310 }*/
311 /* The fast and low memory method to get and count full list converts the sql into a sql count */
312 /*
313 $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\‍(\‍),=<>\:\-\']+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
314 print $sqlforcount;
315 $resql = $db->query($sqlforcount);
316 $objforcount = $db->fetch_object($resql);
317 $nbtotalofrecords = $objforcount->nbtotalofrecords;
318 */
319
320 if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
321 $page = 0;
322 $offset = 0;
323 }
324 $db->free($resql);
325}
326
327// Complete request and execute it with limit
328$sql .= $db->order($sortfield, $sortorder);
329if ($limit) {
330 $sql .= $db->plimit($limit + 1, $offset);
331}
332
333$resql = $db->query($sql);
334if (!$resql) {
335 dol_print_error($db);
336 exit;
337}
338
339$num = $db->num_rows($resql);
340
341
342// Direct jump if only one record found
343if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
344 $obj = $db->fetch_object($resql);
345 $id = $obj->rowid;
346 header("Location: ".DOL_URL_ROOT.'/recruitment/recruitmentjobposition_card.php?id='.$id);
347 exit;
348}
349
350
351// Output page
352// --------------------------------------------------------------------
353
354llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist');
355
356$arrayofselected = is_array($toselect) ? $toselect : array();
357
358$param = '';
359if (!empty($mode)) {
360 $param .= '&mode='.urlencode($mode);
361}
362if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
363 $param .= '&contextpage='.urlencode($contextpage);
364}
365if ($limit > 0 && $limit != $conf->liste_limit) {
366 $param .= '&limit='.((int) $limit);
367}
368foreach ($search as $key => $val) {
369 if (is_array($search[$key]) && count($search[$key])) {
370 foreach ($search[$key] as $skey) {
371 if ($skey != '') {
372 $param .= '&search_'.$key.'[]='.urlencode($skey);
373 }
374 }
375 } elseif ($search[$key] != '') {
376 $param .= '&search_'.$key.'='.urlencode($search[$key]);
377 }
378}
379if ($optioncss != '') {
380 $param .= '&optioncss='.urlencode($optioncss);
381}
382// Add $param from extra fields
383include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
384// Add $param from hooks
385$parameters = array('param' => &$param);
386$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
387$param .= $hookmanager->resPrint;
388
389// List of mass actions available
390$arrayofmassactions = array(
391 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
392 //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
393 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
394 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
395);
396if ($permissiontodelete) {
397 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
398}
399if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predelete'))) {
400 $arrayofmassactions = array();
401}
402$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
403
404print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
405if ($optioncss != '') {
406 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
407}
408print '<input type="hidden" name="token" value="'.newToken().'">';
409print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
410print '<input type="hidden" name="action" value="list">';
411print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
412print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
413//print '<input type="hidden" name="page" value="'.$page.'">';
414print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
415print '<input type="hidden" name="mode" value="'.$mode.'">';
416
417$newcardbutton = '';
418$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'));
419$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'));
420$newcardbutton .= dolGetButtonTitleSeparator();
421$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/recruitment/recruitmentjobposition_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
422
423print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
424
425// Add code for pre mass action (confirmation or email presend form)
426$topicmail = "SendRecruitmentJobPositionRef";
427$modelmail = "recruitmentjobposition";
428$objecttmp = new RecruitmentJobPosition($db);
429$trackid = 'recruitmentjobposition'.$object->id;
430include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
431
432if ($search_all) {
433 foreach ($fieldstosearchall as $key => $val) {
434 $fieldstosearchall[$key] = $langs->trans($val);
435 }
436 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
437}
438
439$moreforfilter = '';
440/*$moreforfilter.='<div class="divsearchfield">';
441$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
442$moreforfilter.= '</div>';*/
443
444$parameters = array();
445$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
446if (empty($reshook)) {
447 $moreforfilter .= $hookmanager->resPrint;
448} else {
449 $moreforfilter = $hookmanager->resPrint;
450}
451
452if (!empty($moreforfilter)) {
453 print '<div class="liste_titre liste_titre_bydiv centpercent">';
454 print $moreforfilter;
455 print '</div>';
456}
457
458$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
459$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
460$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
461
462print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
463print '<table class="tagtable nobottomiftotal noborder liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
464
465
466// Fields title search
467// --------------------------------------------------------------------
468print '<tr class="liste_titre_filter">';
469// Action column
470if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
471 print '<td class="liste_titre maxwidthsearch">';
472 $searchpicto = $form->showFilterButtons('left');
473 print $searchpicto;
474 print '</td>';
475}
476foreach ($object->fields as $key => $val) {
477 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
478 if ($key == 'status') {
479 $cssforfield .= ($cssforfield ? ' ' : '').'center';
480 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
481 $cssforfield .= ($cssforfield ? ' ' : '').'center';
482 } elseif (in_array($val['type'], array('timestamp'))) {
483 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
484 } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
485 $cssforfield .= ($cssforfield ? ' ' : '').'right';
486 }
487 if (!empty($arrayfields['t.'.$key]['checked'])) {
488 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
489 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
490 print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
491 } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
492 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1);
493 } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
494 print '<div class="nowrap">';
495 print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
496 print '</div>';
497 print '<div class="nowrap">';
498 print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
499 print '</div>';
500 } elseif ($key == 'lang') {
501 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
502 $formadmin = new FormAdmin($db);
503 print $formadmin->select_language($search[$key], 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2);
504 } else {
505 print '<input type="text" class="flat maxwidth'.($val['type'] == 'integer' ? '50' : '75').'" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
506 }
507 print '</td>';
508 }
509}
510// Extra fields
511include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
512
513// Fields from hook
514$parameters = array('arrayfields' => $arrayfields);
515$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
516print $hookmanager->resPrint;
517if (!empty($arrayfields['nbapplications']['checked'])) {
518 print '<td class="liste_titre"></td>';
519}
520// Action column
521if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
522 print '<td class="liste_titre maxwidthsearch">';
523 $searchpicto = $form->showFilterButtons();
524 print $searchpicto;
525 print '</td>';
526}
527print '</tr>'."\n";
528
529$totalarray = array();
530$totalarray['nbfield'] = 0;
531
532// Fields title label
533// --------------------------------------------------------------------
534print '<tr class="liste_titre">';
535// Action column
536if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
537 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
538 $totalarray['nbfield']++;
539}
540foreach ($object->fields as $key => $val) {
541 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
542 if ($key == 'status') {
543 $cssforfield .= ($cssforfield ? ' ' : '').'center';
544 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
545 $cssforfield .= ($cssforfield ? ' ' : '').'center';
546 } elseif (in_array($val['type'], array('timestamp'))) {
547 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
548 } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
549 $cssforfield .= ($cssforfield ? ' ' : '').'right';
550 }
551 if (!empty($arrayfields['t.'.$key]['checked'])) {
552 print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
553 $totalarray['nbfield']++;
554 }
555}
556// Extra fields
557include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
558// Hook fields
559$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
560$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
561print $hookmanager->resPrint;
562if (!empty($arrayfields['nbapplications']['checked'])) {
563 print '<th class="liste_titre right">'.$langs->trans("RecruitmentCandidatures").'</th>';
564 $totalarray['nbfield']++;
565}
566// Action column
567if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
568 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
569 $totalarray['nbfield']++;
570}
571print '</tr>'."\n";
572
573
574// Detect if we need a fetch on each output line
575$needToFetchEachLine = 0;
576if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
577 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
578 if (!is_null($val) && preg_match('/\$object/', $val)) {
579 $needToFetchEachLine++; // There is at least one compute field that use $object
580 }
581 }
582}
583
584
585// Loop on record
586// --------------------------------------------------------------------
587$i = 0;
588$savnbfield = $totalarray['nbfield'];
589$totalarray['nbfield'] = 0;
590$imaxinloop = ($limit ? min($num, $limit) : $num);
591while ($i < $imaxinloop) {
592 $obj = $db->fetch_object($resql);
593 if (empty($obj)) {
594 break; // Should not happen
595 }
596
597 // Store properties in $object
598 $object->setVarsFromFetchObj($obj);
599 $object->date_planned = $obj->date_planned;
600
601 if ($mode == 'kanban') {
602 if ($i == 0) {
603 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
604 print '<div class="box-flex-container kanban">';
605 }
606 if ($massactionbutton || $massaction) {
607 $selected = 0;
608 }
609 // Output Kanban
610 $selected = -1;
611 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
612 $selected = 0;
613 if (in_array($object->id, $arrayofselected)) {
614 $selected = 1;
615 }
616 }
617 print $object->getKanbanView('', array('nbapplications' => $obj->nbapplications, 'selected' => $selected));
618 if ($i == ($imaxinloop - 1)) {
619 print '</div>';
620 print '</td></tr>';
621 }
622 } else {
623 // Show here line of result
624 $j = 0;
625 print '<tr class="oddeven">';
626 // Action column
627 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
628 print '<td class="nowrap center">';
629 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
630 $selected = 0;
631 if (in_array($object->id, $arrayofselected)) {
632 $selected = 1;
633 }
634 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
635 }
636 print '</td>';
637 if (!$i) {
638 $totalarray['nbfield']++;
639 }
640 }
641 foreach ($object->fields as $key => $val) {
642 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
643 if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
644 $cssforfield .= ($cssforfield ? ' ' : '').'center';
645 } elseif ($key == 'status') {
646 $cssforfield .= ($cssforfield ? ' ' : '').'center';
647 }
648
649 if (in_array($val['type'], array('timestamp'))) {
650 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
651 } elseif ($key == 'ref') {
652 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
653 }
654
655 if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
656 $cssforfield .= ($cssforfield ? ' ' : '').'right';
657 }
658 //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
659
660 if (!empty($arrayfields['t.'.$key]['checked'])) {
661 print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
662 if ($key == 'status') {
663 print $object->getLibStatut(5);
664 } elseif ($key == 'rowid') {
665 print $object->showOutputField($val, $key, (string) $object->id, '');
666 } else {
667 print $object->showOutputField($val, $key, $object->$key, '');
668 }
669 print '</td>';
670 if (!$i) {
671 $totalarray['nbfield']++;
672 }
673 if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
674 if (!$i) {
675 $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
676 }
677 if (!isset($totalarray['val'])) {
678 $totalarray['val'] = array();
679 }
680 if (!isset($totalarray['val']['t.'.$key])) {
681 $totalarray['val']['t.'.$key] = 0;
682 }
683 $totalarray['val']['t.'.$key] += $object->$key;
684 }
685 }
686 }
687 // Extra fields
688 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
689 // Fields from hook
690 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
691 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
692 print $hookmanager->resPrint;
693 if (!empty($arrayfields['nbapplications']['checked'])) {
694 print '<td class="right">'.$obj->nbapplications.'</td>';
695 if (!$i) {
696 $totalarray['nbfield']++;
697 }
698 }
699 // Action column
700 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
701 print '<td class="nowrap center">';
702 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
703 $selected = 0;
704 if (in_array($object->id, $arrayofselected)) {
705 $selected = 1;
706 }
707 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
708 }
709 print '</td>';
710 if (!$i) {
711 $totalarray['nbfield']++;
712 }
713 }
714
715 print '</tr>'."\n";
716 }
717
718 $i++;
719}
720
721// Show total line
722include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
723
724// If no record found
725if ($num == 0) {
726 $colspan = 1;
727 foreach ($arrayfields as $key => $val) {
728 if (!empty($val['checked'])) {
729 $colspan++;
730 }
731 }
732 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
733}
734
735
736$db->free($resql);
737
738$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
739$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
740print $hookmanager->resPrint;
741
742print '</table>'."\n";
743print '</div>'."\n";
744
745print '</form>'."\n";
746
747if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
748 $hidegeneratedfilelistifempty = 1;
749 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
750 $hidegeneratedfilelistifempty = 0;
751 }
752
753 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
754 $formfile = new FormFile($db);
755
756 // Show list of available documents
757 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
758 $urlsource .= str_replace('&amp;', '&', $param);
759
760 $filedir = $diroutputmassaction;
761 $genallowed = $permissiontoread;
762 $delallowed = $permissiontoadd;
763
764 print $formfile->showdocuments('massfilesarea_recruitment', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
765}
766
767// End of page
768llxFooter();
769$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
$totalarray
Definition export.php:1206
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.
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.
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_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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...
dol_now($mode='auto')
Return date for now.
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.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
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...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.