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