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