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