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