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