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