dolibarr  18.0.6
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
25 require_once '../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentjobposition.lib.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
30 require_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');
53 if (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)
74 if (!$sortfield) {
75  $sortfield = "t.ref";
76 }
77 if (!$sortorder) {
78  $sortorder = "DESC";
79 }
80 
81 // Initialize array of search criterias
82 $search_all = GETPOST('search_all', 'alphanohtml');
83 $search = array();
84 foreach ($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();
96 foreach ($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();
104 foreach ($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
118 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
119 
120 // Load object
121 include 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);
135 restrictedArea($user, 'recruitment', 0, 'recruitment_recruitmentjobposition', 'recruitmentjobposition');
136 
137 
138 
139 /*
140  * Actions
141  */
142 
143 if (GETPOST('cancel', 'alpha')) {
144  $action = 'list';
145  $massaction = '';
146 }
147 if (!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
153 if ($reshook < 0) {
154  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
155 }
156 
157 if (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
208 if (!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";
221 if (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;
228 if ($object->ismultientitymanaged == 1) {
229  $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
230 } else {
231  $sql .= " WHERE 1 = 1";
232 }
233 foreach ($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 }
262 if ($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
267 include 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 ";
275 foreach ($object->fields as $key => $val) {
276  $sql .= "t.".$db->escape($key).", ";
277 }
278 // Add fields from extrafields
279 if (!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 = '';
292 if (!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);
319 if ($limit) {
320  $sql .= $db->plimit($limit + 1, $offset);
321 }
322 
323 $resql = $db->query($sql);
324 if (!$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
333 if ($num == 1 && !empty($conf->global->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 
344 llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', '');
345 
346 $arrayofselected = is_array($toselect) ? $toselect : array();
347 
348 $param = '';
349 if (!empty($mode)) {
350  $param .= '&mode='.urlencode($mode);
351 }
352 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
353  $param .= '&contextpage='.urlencode($contextpage);
354 }
355 if ($limit > 0 && $limit != $conf->liste_limit) {
356  $param .= '&limit='.((int) $limit);
357 }
358 foreach ($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 }
369 if ($optioncss != '') {
370  $param .= '&optioncss='.urlencode($optioncss);
371 }
372 // Add $param from extra fields
373 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
374 // Add $param from hooks
375 $parameters = array();
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 );
386 if ($permissiontodelete) {
387  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
388 }
389 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
390  $arrayofmassactions = array();
391 }
392 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
393 
394 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
395 if ($optioncss != '') {
396  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
397 }
398 print '<input type="hidden" name="token" value="'.newToken().'">';
399 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
400 print '<input type="hidden" name="action" value="list">';
401 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
402 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
403 //print '<input type="hidden" name="page" value="'.$page.'">';
404 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
405 print '<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 
413 print_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;
420 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
421 
422 if ($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
436 if (empty($reshook)) {
437  $moreforfilter .= $hookmanager->resPrint;
438 } else {
439  $moreforfilter = $hookmanager->resPrint;
440 }
441 
442 if (!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 
452 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
453 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
454 
455 
456 // Fields title search
457 // --------------------------------------------------------------------
458 print '<tr class="liste_titre">';
459 // Action column
460 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
461  print '<td class="liste_titre maxwidthsearch">';
462  $searchpicto = $form->showFilterButtons('left');
463  print $searchpicto;
464  print '</td>';
465 }
466 foreach ($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
501 include 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
506 print $hookmanager->resPrint;
507 if (!empty($arrayfields['nbapplications']['checked'])) {
508  print '<td class="liste_titre"></td>';
509 }
510 // Action column
511 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
512  print '<td class="liste_titre maxwidthsearch">';
513  $searchpicto = $form->showFilterButtons();
514  print $searchpicto;
515  print '</td>';
516 }
517 print '</tr>'."\n";
518 
519 $totalarray = array();
520 $totalarray['nbfield'] = 0;
521 
522 // Fields title label
523 // --------------------------------------------------------------------
524 print '<tr class="liste_titre">';
525 // Action column
526 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
527  print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
528  $totalarray['nbfield']++;
529 }
530 foreach ($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
547 include 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
551 print $hookmanager->resPrint;
552 if (!empty($arrayfields['nbapplications']['checked'])) {
553  print '<th class="liste_titre right">'.$langs->trans("RecruitmentCandidatures").'</th>';
554  $totalarray['nbfield']++;
555 }
556 // Action column
557 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
558  print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
559  $totalarray['nbfield']++;
560 }
561 print '</tr>'."\n";
562 
563 
564 // Detect if we need a fetch on each output line
565 $needToFetchEachLine = 0;
566 if (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);
581 while ($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  print $object->getKanbanView('', array('nbapplications'=>$obj->nbapplications, 'selected' => in_array($object->id, $arrayofselected)));
601  if ($i == ($imaxinloop - 1)) {
602  print '</div>';
603  print '</td></tr>';
604  }
605  } else {
606  // Show here line of result
607  $j = 0;
608  print '<tr class="oddeven">';
609  // Action column
610  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
611  print '<td class="nowrap center">';
612  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
613  $selected = 0;
614  if (in_array($object->id, $arrayofselected)) {
615  $selected = 1;
616  }
617  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
618  }
619  print '</td>';
620  if (!$i) {
621  $totalarray['nbfield']++;
622  }
623  }
624  foreach ($object->fields as $key => $val) {
625  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
626  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
627  $cssforfield .= ($cssforfield ? ' ' : '').'center';
628  } elseif ($key == 'status') {
629  $cssforfield .= ($cssforfield ? ' ' : '').'center';
630  }
631 
632  if (in_array($val['type'], array('timestamp'))) {
633  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
634  } elseif ($key == 'ref') {
635  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
636  }
637 
638  if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
639  $cssforfield .= ($cssforfield ? ' ' : '').'right';
640  }
641  //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
642 
643  if (!empty($arrayfields['t.'.$key]['checked'])) {
644  print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
645  if ($key == 'status') {
646  print $object->getLibStatut(5);
647  } elseif ($key == 'rowid') {
648  print $object->showOutputField($val, $key, $object->id, '');
649  } else {
650  print $object->showOutputField($val, $key, $object->$key, '');
651  }
652  print '</td>';
653  if (!$i) {
654  $totalarray['nbfield']++;
655  }
656  if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
657  if (!$i) {
658  $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
659  }
660  if (!isset($totalarray['val'])) {
661  $totalarray['val'] = array();
662  }
663  if (!isset($totalarray['val']['t.'.$key])) {
664  $totalarray['val']['t.'.$key] = 0;
665  }
666  $totalarray['val']['t.'.$key] += $object->$key;
667  }
668  }
669  }
670  // Extra fields
671  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
672  // Fields from hook
673  $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
674  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
675  print $hookmanager->resPrint;
676  if (!empty($arrayfields['nbapplications']['checked'])) {
677  print '<td class="right">'.$obj->nbapplications.'</td>';
678  if (!$i) {
679  $totalarray['nbfield']++;
680  }
681  }
682  // Action column
683  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
684  print '<td class="nowrap center">';
685  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
686  $selected = 0;
687  if (in_array($object->id, $arrayofselected)) {
688  $selected = 1;
689  }
690  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
691  }
692  print '</td>';
693  if (!$i) {
694  $totalarray['nbfield']++;
695  }
696  }
697 
698  print '</tr>'."\n";
699  }
700 
701  $i++;
702 }
703 
704 // Show total line
705 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
706 
707 // If no record found
708 if ($num == 0) {
709  $colspan = 1;
710  foreach ($arrayfields as $key => $val) {
711  if (!empty($val['checked'])) {
712  $colspan++;
713  }
714  }
715  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
716 }
717 
718 
719 $db->free($resql);
720 
721 $parameters = array('arrayfields' => $arrayfields, 'sql'=>$sql);
722 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
723 print $hookmanager->resPrint;
724 
725 print '</table>'."\n";
726 print '</div>'."\n";
727 
728 print '</form>'."\n";
729 
730 if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
731  $hidegeneratedfilelistifempty = 1;
732  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
733  $hidegeneratedfilelistifempty = 0;
734  }
735 
736  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
737  $formfile = new FormFile($db);
738 
739  // Show list of available documents
740  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
741  $urlsource .= str_replace('&amp;', '&', $param);
742 
743  $filedir = $diroutputmassaction;
744  $genallowed = $permissiontoread;
745  $delallowed = $permissiontoadd;
746 
747  print $formfile->showdocuments('massfilesarea_recruitment', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
748 }
749 
750 // End of page
751 llxFooter();
752 $db->close();
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:118
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
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.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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 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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.