dolibarr  13.0.2
recruitmentcandidature_list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) ---Put here your own copyright and developer email---
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
25 //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
26 //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
27 //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
28 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
29 //if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
30 //if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
31 //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).
32 //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
33 //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
34 //if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
35 //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
36 //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
37 //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
38 //if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
39 //if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
40 //if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
41 //if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', '1'); // The main.inc.php does not make a redirect if not logged, instead show simple error message
42 //if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL', '1'); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL'
43 
44 // Load Dolibarr environment
45 $res = 0;
46 // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
47 if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
48 // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
49 $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
50 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
51 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
52 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
53 // Try main.inc.php using relative path
54 if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
55 if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
56 if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
57 if (!$res) die("Include of main fails");
58 
59 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
60 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
61 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
62 
63 // load recruitment libraries
64 require_once __DIR__.'/class/recruitmentcandidature.class.php';
65 
66 // for other modules
67 //dol_include_once('/othermodule/class/otherobject.class.php');
68 
69 // Load translation files required by the page
70 $langs->loadLangs(array("recruitment@recruitment", "other"));
71 
72 $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
73 $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
74 $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
75 $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
76 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
77 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
78 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'recruitmentcandidaturelist'; // To manage different context of search
79 $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
80 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
81 
82 $id = GETPOST('id', 'int');
83 
84 // Load variable for pagination
85 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
86 $sortfield = GETPOST('sortfield', 'aZ09comma');
87 $sortorder = GETPOST('sortorder', 'aZ09comma');
88 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
89 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters
90 $offset = $limit * $page;
91 $pageprev = $page - 1;
92 $pagenext = $page + 1;
93 
94 // Initialize technical objects
95 $object = new RecruitmentCandidature($db);
96 $extrafields = new ExtraFields($db);
97 $diroutputmassaction = $conf->recruitment->dir_output.'/temp/massgeneration/'.$user->id;
98 $hookmanager->initHooks(array('recruitmentcandidaturelist')); // Note that conf->hooks_modules contains array
99 
100 // Fetch optionals attributes and labels
101 $extrafields->fetch_name_optionals_label($object->table_element);
102 //$extrafields->fetch_name_optionals_label($object->table_element_line);
103 
104 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
105 
106 // Default sort order (if not yet defined by previous GETPOST)
107 if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
108 if (!$sortorder) $sortorder = "ASC";
109 
110 // Initialize array of search criterias
111 $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
112 $search = array();
113 foreach ($object->fields as $key => $val)
114 {
115  if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
116 }
117 
118 // List of fields to search into when doing a "search in all"
119 $fieldstosearchall = array();
120 foreach ($object->fields as $key => $val)
121 {
122  if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
123 }
124 
125 // Definition of fields for list
126 $arrayfields = array();
127 foreach ($object->fields as $key => $val)
128 {
129  // If $val['visible']==0, then we never show the field
130  if (!empty($val['visible'])) {
131  $visible = dol_eval($val['visible'], 1);
132  $arrayfields['t.'.$key] = array(
133  'label'=>$val['label'],
134  'checked'=>(($visible < 0) ? 0 : 1),
135  'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
136  'position'=>$val['position']
137  );
138  }
139 }
140 // Extra fields
141 if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
142 {
143  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
144  {
145  if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
146  $arrayfields["ef.".$key] = array(
147  'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
148  'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1),
149  'position'=>$extrafields->attributes[$object->table_element]['pos'][$key],
150  'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])
151  );
152  }
153  }
154 }
155 $object->fields = dol_sort_array($object->fields, 'position');
156 $arrayfields = dol_sort_array($arrayfields, 'position');
157 
158 $permissiontoread = $user->rights->recruitment->recruitmentjobposition->read;
159 $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write;
160 $permissiontodelete = $user->rights->recruitment->recruitmentjobposition->delete;
161 
162 // Security check
163 if (empty($conf->recruitment->enabled)) accessforbidden('Module not enabled');
164 $socid = 0;
165 if ($user->socid > 0) // Protection if external user
166 {
167  //$socid = $user->socid;
168  accessforbidden();
169 }
170 //$result = restrictedArea($user, 'recruitment', $id, '');
171 //if (!$permissiontoread) accessforbidden();
172 
173 
174 
175 /*
176  * Actions
177  */
178 
179 if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
180 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
181 
182 $parameters = array();
183 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
184 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
185 
186 if (empty($reshook))
187 {
188  // Selection of new fields
189  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
190 
191  // Purge search criteria
192  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
193  {
194  foreach ($object->fields as $key => $val)
195  {
196  $search[$key] = '';
197  }
198  $toselect = '';
199  $search_array_options = array();
200  }
201  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
202  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
203  {
204  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
205  }
206 
207  // Mass actions
208  $objectclass = 'RecruitmentCandidature';
209  $objectlabel = 'RecruitmentCandidature';
210  $uploaddir = $conf->recruitment->dir_output;
211  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
212 }
213 
214 
215 
216 /*
217  * View
218  */
219 
220 $form = new Form($db);
221 
222 $now = dol_now();
223 
224 //$help_url="EN:Module_RecruitmentCandidature|FR:Module_RecruitmentCandidature_FR|ES:Módulo_RecruitmentCandidature";
225 $help_url = '';
226 $title = $langs->trans('ListOfCandidatures');
227 
228 
229 // Build and execute select
230 // --------------------------------------------------------------------
231 $sql = 'SELECT ';
232 foreach ($object->fields as $key => $val)
233 {
234  $sql .= 't.'.$key.', ';
235 }
236 // Add fields from extrafields
237 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
238  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
239 }
240 // Add fields from hooks
241 $parameters = array();
242 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
243 $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
244 $sql = preg_replace('/,\s*$/', '', $sql);
245 $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
246 if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
247 if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
248 else $sql .= " WHERE 1 = 1";
249 foreach ($search as $key => $val)
250 {
251  if ($key == 'status' && $search[$key] == -1) continue;
252  $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
253  if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
254  if ($search[$key] == '-1') $search[$key] = '';
255  $mode_search = 2;
256  }
257  if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
258 }
259 if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
260 //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
261 // Add where from extra fields
262 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
263 // Add where from hooks
264 $parameters = array();
265 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
266 $sql .= $hookmanager->resPrint;
267 
268 /* If a group by is required
269 $sql.= " GROUP BY ";
270 foreach ($object->fields as $key => $val)
271 {
272  $sql.='t.'.$key.', ';
273 }
274 // Add fields from extrafields
275 if (! empty($extrafields->attributes[$object->table_element]['label'])) {
276  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
277 }
278 // Add where from hooks
279 $parameters=array();
280 $reshook=$hookmanager->executeHooks('printFieldListGroupBy', $parameters); // Note that $action and $object may have been modified by hook
281 $sql.=$hookmanager->resPrint;
282 $sql=preg_replace('/,\s*$/', '', $sql);
283 */
284 
285 $sql .= $db->order($sortfield, $sortorder);
286 
287 // Count total nb of records
288 $nbtotalofrecords = '';
289 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
290 {
291  $resql = $db->query($sql);
292  $nbtotalofrecords = $db->num_rows($resql);
293  if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
294  {
295  $page = 0;
296  $offset = 0;
297  }
298 }
299 // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
300 if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
301 {
302  $num = $nbtotalofrecords;
303 } else {
304  if ($limit) $sql .= $db->plimit($limit + 1, $offset);
305 
306  $resql = $db->query($sql);
307  if (!$resql)
308  {
309  dol_print_error($db);
310  exit;
311  }
312 
313  $num = $db->num_rows($resql);
314 }
315 
316 // Direct jump if only one record found
317 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page)
318 {
319  $obj = $db->fetch_object($resql);
320  $id = $obj->rowid;
321  header("Location: ".dol_buildpath('/recruitment/recruitmentcandidature_card.php', 1).'?id='.$id);
322  exit;
323 }
324 
325 
326 // Output page
327 // --------------------------------------------------------------------
328 
329 llxHeader('', $title, $help_url);
330 
331 // Example : Adding jquery code
332 print '<script type="text/javascript" language="javascript">
333 jQuery(document).ready(function() {
334  function init_myfunc()
335  {
336  jQuery("#myid").removeAttr(\'disabled\');
337  jQuery("#myid").attr(\'disabled\',\'disabled\');
338  }
339  init_myfunc();
340  jQuery("#mybutton").click(function() {
341  init_myfunc();
342  });
343 });
344 </script>';
345 
346 $arrayofselected = is_array($toselect) ? $toselect : array();
347 
348 $param = '';
349 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
350 if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
351 foreach ($search as $key => $val)
352 {
353  if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey);
354  else $param .= '&search_'.$key.'='.urlencode($search[$key]);
355 }
356 if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
357 // Add $param from extra fields
358 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
359 
360 // List of mass actions available
361 $arrayofmassactions = array(
362  'validate'=>$langs->trans("Validate"),
363  //'generate_doc'=>$langs->trans("ReGeneratePDF"),
364  //'builddoc'=>$langs->trans("PDFMerge"),
365  //'presend'=>$langs->trans("SendByMail"),
366 );
367 if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
368 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
369 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
370 
371 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
372 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
373 print '<input type="hidden" name="token" value="'.newToken().'">';
374 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
375 print '<input type="hidden" name="action" value="list">';
376 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
377 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
378 //print '<input type="hidden" name="page" value="'.$page.'">';
379 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
380 
381 $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/recruitment/recruitmentcandidature_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
382 
383 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
384 
385 // Add code for pre mass action (confirmation or email presend form)
386 $topicmail = "SendRecruitmentCandidatureRef";
387 $modelmail = "recruitmentcandidature";
388 $objecttmp = new RecruitmentCandidature($db);
389 $trackid = 'xxxx'.$object->id;
390 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
391 
392 if ($search_all)
393 {
394  foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
395  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
396 }
397 
398 $moreforfilter = '';
399 /*$moreforfilter.='<div class="divsearchfield">';
400 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
401 $moreforfilter.= '</div>';*/
402 
403 $parameters = array();
404 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
405 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
406 else $moreforfilter = $hookmanager->resPrint;
407 
408 if (!empty($moreforfilter))
409 {
410  print '<div class="liste_titre liste_titre_bydiv centpercent">';
411  print $moreforfilter;
412  print '</div>';
413 }
414 
415 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
416 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
417 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
418 
419 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
420 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
421 
422 
423 // Fields title search
424 // --------------------------------------------------------------------
425 print '<tr class="liste_titre">';
426 foreach ($object->fields as $key => $val)
427 {
428  $cssforfield = (empty($val['css']) ? '' : $val['css']);
429  if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
430  elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
431  elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
432  elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
433  if (!empty($arrayfields['t.'.$key]['checked']))
434  {
435  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
436  if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
437  elseif (strpos($val['type'], 'integer:') === 0) {
438  print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
439  } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
440  print '</td>';
441  }
442 }
443 // Extra fields
444 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
445 
446 // Fields from hook
447 $parameters = array('arrayfields'=>$arrayfields);
448 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
449 print $hookmanager->resPrint;
450 // Action column
451 print '<td class="liste_titre maxwidthsearch">';
452 $searchpicto = $form->showFilterButtons();
453 print $searchpicto;
454 print '</td>';
455 print '</tr>'."\n";
456 
457 
458 // Fields title label
459 // --------------------------------------------------------------------
460 print '<tr class="liste_titre">';
461 foreach ($object->fields as $key => $val)
462 {
463  $cssforfield = (empty($val['css']) ? '' : $val['css']);
464  if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
465  elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
466  elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
467  elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
468  if (!empty($arrayfields['t.'.$key]['checked']))
469  {
470  print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
471  }
472 }
473 // Extra fields
474 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
475 // Hook fields
476 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
477 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
478 print $hookmanager->resPrint;
479 // Action column
480 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
481 print '</tr>'."\n";
482 
483 
484 // Detect if we need a fetch on each output line
485 $needToFetchEachLine = 0;
486 if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0)
487 {
488  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
489  {
490  if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
491  }
492 }
493 
494 
495 // Loop on record
496 // --------------------------------------------------------------------
497 $i = 0;
498 $totalarray = array();
499 while ($i < ($limit ? min($num, $limit) : $num))
500 {
501  $obj = $db->fetch_object($resql);
502  if (empty($obj)) break; // Should not happen
503 
504  // Store properties in $object
505  $object->setVarsFromFetchObj($obj);
506 
507  // Show here line of result
508  print '<tr class="oddeven">';
509  foreach ($object->fields as $key => $val)
510  {
511  $cssforfield = (empty($val['css']) ? '' : $val['css']);
512  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
513  elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
514 
515  if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
516  elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
517 
518  if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right';
519  //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
520 
521  if (!empty($arrayfields['t.'.$key]['checked']))
522  {
523  print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
524  if ($key == 'status') print $object->getLibStatut(5);
525  else print $object->showOutputField($val, $key, $object->$key, '');
526  print '</td>';
527  if (!$i) $totalarray['nbfield']++;
528  if (!empty($val['isameasure']))
529  {
530  if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
531  $totalarray['val']['t.'.$key] += $object->$key;
532  }
533  }
534  }
535  // Extra fields
536  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
537  // Fields from hook
538  $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
539  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
540  print $hookmanager->resPrint;
541  // Action column
542  print '<td class="nowrap center">';
543  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
544  {
545  $selected = 0;
546  if (in_array($object->id, $arrayofselected)) $selected = 1;
547  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
548  }
549  print '</td>';
550  if (!$i) $totalarray['nbfield']++;
551 
552  print '</tr>'."\n";
553 
554  $i++;
555 }
556 
557 // Show total line
558 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
559 
560 // If no record found
561 if ($num == 0)
562 {
563  $colspan = 1;
564  foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
565  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
566 }
567 
568 
569 $db->free($resql);
570 
571 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
572 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
573 print $hookmanager->resPrint;
574 
575 print '</table>'."\n";
576 print '</div>'."\n";
577 
578 print '</form>'."\n";
579 
580 if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
581 {
582  $hidegeneratedfilelistifempty = 1;
583  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
584 
585  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
586  $formfile = new FormFile($db);
587 
588  // Show list of available documents
589  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
590  $urlsource .= str_replace('&amp;', '&', $param);
591 
592  $filedir = $diroutputmassaction;
593  $genallowed = $permissiontoread;
594  $delallowed = $permissiontoadd;
595 
596  print $formfile->showdocuments('massfilesarea_recruitment', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
597 }
598 
599 // End of page
600 llxFooter();
601 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_eval($s, $returnvalue=0, $hideerrors=1)
Replace eval function to add more security.
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.
foreach($object->fields as $key=> $val) if(is_array($extrafields->attributes[$object->table_element]['label'])&&count($extrafields->attributes[$object->table_element]['label']) > 0) $object fields
dol_now($mode= 'auto')
Return date for now.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:108
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
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.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
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...
Class to offer components to list and upload files.
print $_SERVER["PHP_SELF"]
Edit parameters.
Class for RecruitmentCandidature.
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...
print
Draft customers invoices.
Definition: index.php:89
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
print $_SERVER["PHP_SELF"] n
Edit parameters.
Definition: categories.php:101
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.
llxFooter()
Empty footer.
Definition: wrapper.php:59
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:105
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...