dolibarr 19.0.3
evaluation_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/evaluation.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// Get Parameters
46$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
47$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
48$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
49$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
50$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
51$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
52$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'evaluationlist'; // To manage different context of search
53$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
54$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
55$mode = GETPOST('mode', 'alpha'); // for mode view result
56
57$id = GETPOST('id', 'int');
58$ref = GETPOST('ref', 'alpha');
59
60// Load variable for pagination
61$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
62$sortfield = GETPOST('sortfield', 'aZ09comma');
63$sortorder = GETPOST('sortorder', 'aZ09comma');
64$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
65if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
66 // If $page is not defined, or '' or -1 or if we click on clear filters
67 $page = 0;
68}
69$offset = $limit * $page;
70$pageprev = $page - 1;
71$pagenext = $page + 1;
72
73// Initialize technical objects
74$object = new Evaluation($db);
75$extrafields = new ExtraFields($db);
76$diroutputmassaction = $conf->hrm->dir_output.'/temp/massgeneration/'.$user->id;
77$hookmanager->initHooks(array('evaluationlist')); // Note that conf->hooks_modules contains array
78
79// Fetch optionals attributes and labels
80$extrafields->fetch_name_optionals_label($object->table_element);
81//$extrafields->fetch_name_optionals_label($object->table_element_line);
82
83$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
84
85// Default sort order (if not yet defined by previous GETPOST)
86if (!$sortfield) {
87 reset($object->fields); // Reset is required to avoid key() to return null.
88 $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
89}
90if (!$sortorder) {
91 $sortorder = "ASC";
92}
93
94// Initialize array of search criterias
95$search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
96$search = array();
97foreach ($object->fields as $key => $val) {
98 if (GETPOST('search_'.$key, 'alpha') !== '') {
99 $search[$key] = GETPOST('search_'.$key, 'alpha');
100 }
101 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
102 $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
103 $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
104 }
105}
106
107// List of fields to search into when doing a "search in all"
108$fieldstosearchall = array();
109foreach ($object->fields as $key => $val) {
110 if (!empty($val['searchall'])) {
111 $fieldstosearchall['t.'.$key] = $val['label'];
112 }
113}
114
115// Definition of array of fields for columns
116$arrayfields = array();
117foreach ($object->fields as $key => $val) {
118 // If $val['visible']==0, then we never show the field
119 if (!empty($val['visible'])) {
120 $visible = (int) dol_eval($val['visible'], 1);
121 $arrayfields['t.'.$key] = array(
122 'label'=>$val['label'],
123 'checked'=>(($visible < 0) ? 0 : 1),
124 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)),
125 'position'=>$val['position'],
126 'help'=> isset($val['help']) ? $val['help'] : ''
127 );
128 }
129}
130// Extra fields
131include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
132
133$object->fields = dol_sort_array($object->fields, 'position');
134$arrayfields = dol_sort_array($arrayfields, 'position');
135
136// Permissions
137$permissiontoread = $user->hasRight('hrm', 'evaluation', 'read');
138$permissiontoreadall = $user->hasRight('hrm', 'evaluation', 'readall');
139$permissiontoadd = $user->hasRight('hrm', 'evaluation', 'write');
140$permissiontodelete = $user->hasRight('hrm', 'evaluation', 'delete');
141
142// Security check
143if (!isModEnabled('hrm')) {
144 accessforbidden('Module not enabled');
145}
146
147// Security check (enable the most restrictive one)
148if ($user->socid > 0) {
150}
151//if ($user->socid > 0) accessforbidden();
152//$socid = 0; if ($user->socid > 0) $socid = $user->socid;
153//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
154//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
155//if (empty($conf->hrm->enabled)) accessforbidden();
156if (!$permissiontoread) {
158}
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 = 'Evaluation';
203 $objectlabel = 'Evaluation';
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_Evaluation|FR:Module_Evaluation_FR|ES:Módulo_Evaluation";
219$help_url = '';
220$title = $langs->trans('Evaluations');
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
290if (empty($permissiontoreadall)) {
291 $sql.= " AND t.fk_user IN(".$db->sanitize(implode(", ", $user->getAllChildIds(1))).") ";
292}
293
294//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
295// Add where from extra fields
296include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
297// Add where from hooks
298$parameters = array();
299$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
300$sql .= $hookmanager->resPrint;
301
302/* If a group by is required
303$sql .= " GROUP BY ";
304foreach($object->fields as $key => $val) {
305 $sql .= "t.".$key.", ";
306}
307// Add fields from extrafields
308if (!empty($extrafields->attributes[$object->table_element]['label'])) {
309 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
310 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
311 }
312}
313// Add where from hooks
314$parameters = array();
315$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
316$sql .= $hookmanager->resPrint;
317$sql = preg_replace('/,\s*$/', '', $sql);
318*/
319
320// Count total nb of records
321$nbtotalofrecords = '';
322if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
323 /* The fast and low memory method to get and count full list converts the sql into a sql count */
324 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
325 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
326 $resql = $db->query($sqlforcount);
327 if ($resql) {
328 $objforcount = $db->fetch_object($resql);
329 $nbtotalofrecords = $objforcount->nbtotalofrecords;
330 } else {
331 dol_print_error($db);
332 }
333
334 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
335 $page = 0;
336 $offset = 0;
337 }
338 $db->free($resql);
339}
340
341// Complete request and execute it with limit
342$sql .= $db->order($sortfield, $sortorder);
343if ($limit) {
344 $sql .= $db->plimit($limit + 1, $offset);
345}
346
347$resql = $db->query($sql);
348if (!$resql) {
349 dol_print_error($db);
350 exit;
351}
352
353$num = $db->num_rows($resql);
354
355
356// Direct jump if only one record found
357if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
358 $obj = $db->fetch_object($resql);
359 $id = $obj->rowid;
360 header("Location: ".dol_buildpath('/hrm/evaluation_card.php', 1).'?id='.$id);
361 exit;
362}
363
364
365// Output page
366// --------------------------------------------------------------------
367
368llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', '');
369
370// Example : Adding jquery code
371// print '<script type="text/javascript" language="javascript">
372// jQuery(document).ready(function() {
373// function init_myfunc()
374// {
375// jQuery("#myid").removeAttr(\'disabled\');
376// jQuery("#myid").attr(\'disabled\',\'disabled\');
377// }
378// init_myfunc();
379// jQuery("#mybutton").click(function() {
380// init_myfunc();
381// });
382// });
383// </script>';
384
385$arrayofselected = is_array($toselect) ? $toselect : array();
386
387$param = '';
388if (!empty($mode)) {
389 $param .= '&mode='.urlencode($mode);
390}
391if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
392 $param .= '&contextpage='.urlencode($contextpage);
393}
394if ($limit > 0 && $limit != $conf->liste_limit) {
395 $param .= '&limit='.((int) $limit);
396}
397foreach ($search as $key => $val) {
398 if (is_array($search[$key])) {
399 foreach ($search[$key] as $skey) {
400 if ($skey != '') {
401 $param .= '&search_'.$key.'[]='.urlencode($skey);
402 }
403 }
404 } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
405 $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int'));
406 $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int'));
407 $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int'));
408 } elseif ($search[$key] != '') {
409 $param .= '&search_'.$key.'='.urlencode($search[$key]);
410 }
411}
412if ($optioncss != '') {
413 $param .= '&optioncss='.urlencode($optioncss);
414}
415// Add $param from extra fields
416include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
417// Add $param from hooks
418$parameters = array('param' => &$param);
419$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
420$param .= $hookmanager->resPrint;
421
422// List of mass actions available
423$arrayofmassactions = array(
424 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
425 //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
426 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
427 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
428);
429if (!empty($permissiontodelete)) {
430 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
431}
432if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
433 $arrayofmassactions = array();
434}
435$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
436
437print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
438if ($optioncss != '') {
439 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
440}
441print '<input type="hidden" name="token" value="'.newToken().'">';
442print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
443print '<input type="hidden" name="action" value="list">';
444print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
445print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
446print '<input type="hidden" name="page" value="'.$page.'">';
447print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
448print '<input type="hidden" name="mode" value="'.$mode.'">';
449
450$newcardbutton = '';
451$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'));
452$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'));
453$newcardbutton .= dolGetButtonTitleSeparator();
454$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/hrm/evaluation_card.php', 1).'?action=create', '', $permissiontoadd);
455
456print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
457
458// Add code for pre mass action (confirmation or email presend form)
459$topicmail = "SendEvaluationRef";
460$modelmail = "evaluation";
461$objecttmp = new Evaluation($db);
462$trackid = 'xxxx'.$object->id;
463include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
464
465if ($search_all) {
466 $setupstring = '';
467 foreach ($fieldstosearchall as $key => $val) {
468 $fieldstosearchall[$key] = $langs->trans($val);
469 $setupstring .= $key."=".$val.";";
470 }
471 print '<!-- Search done like if HRM_EVALUATION_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
472 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
473}
474
475$moreforfilter = '';
476/*$moreforfilter.='<div class="divsearchfield">';
477$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
478$moreforfilter.= '</div>';*/
479
480$parameters = array();
481$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
482if (empty($reshook)) {
483 $moreforfilter .= $hookmanager->resPrint;
484} else {
485 $moreforfilter = $hookmanager->resPrint;
486}
487
488if (!empty($moreforfilter)) {
489 print '<div class="liste_titre liste_titre_bydiv centpercent">';
490 print $moreforfilter;
491 $parameters = array('type'=>$type);
492 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
493 print $hookmanager->resPrint;
494 print '</div>';
495}
496
497$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
498$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
499$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
500
501print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
502print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
503
504// Fields title search
505// --------------------------------------------------------------------
506print '<tr class="liste_titre_filter">';
507// Action column
508if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
509 print '<td class="liste_titre maxwidthsearch center">';
510 $searchpicto = $form->showFilterButtons('left');
511 print $searchpicto;
512 print '</td>';
513}
514foreach ($object->fields as $key => $val) {
515 $searchkey = empty($search[$key]) ? '' : $search[$key];
516 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
517 if ($key == 'status') {
518 $cssforfield .= ($cssforfield ? ' ' : '').'center';
519 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
520 $cssforfield .= ($cssforfield ? ' ' : '').'center';
521 } elseif (in_array($val['type'], array('timestamp'))) {
522 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
523 } 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'])) {
524 $cssforfield .= ($cssforfield ? ' ' : '').'right';
525 }
526 if (!empty($arrayfields['t.'.$key]['checked'])) {
527 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').($key == 'status' ? ' parentonrightofpage' : '').'">';
528 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
529 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);
530 } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
531 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1);
532 } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
533 print '<div class="nowrap">';
534 print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
535 print '</div>';
536 print '<div class="nowrap">';
537 print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
538 print '</div>';
539 } elseif ($key == 'lang') {
540 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
541 $formadmin = new FormAdmin($db);
542 print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2);
543 } else {
544 print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
545 }
546 print '</td>';
547 }
548}
549// Extra fields
550include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
551
552// Fields from hook
553$parameters = array('arrayfields'=>$arrayfields);
554$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
555print $hookmanager->resPrint;
556// Action column
557if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
558 print '<td class="liste_titre maxwidthsearch">';
559 $searchpicto = $form->showFilterButtons();
560 print $searchpicto;
561 print '</td>';
562}
563print '</tr>'."\n";
564
565$totalarray = array();
566$totalarray['nbfield'] = 0;
567
568// Fields title label
569// --------------------------------------------------------------------
570print '<tr class="liste_titre">';
571// Action column
572if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
573 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
574 $totalarray['nbfield']++;
575}
576foreach ($object->fields as $key => $val) {
577 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
578 if ($key == 'status') {
579 $cssforfield .= ($cssforfield ? ' ' : '').'center';
580 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
581 $cssforfield .= ($cssforfield ? ' ' : '').'center';
582 } elseif (in_array($val['type'], array('timestamp'))) {
583 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
584 } 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'])) {
585 $cssforfield .= ($cssforfield ? ' ' : '').'right';
586 }
587 $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
588 if (!empty($arrayfields['t.'.$key]['checked'])) {
589 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";
590 $totalarray['nbfield']++;
591 }
592}
593// Extra fields
594include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
595// Hook fields
596$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
597$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
598print $hookmanager->resPrint;
599// Action column
600if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
601 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
602 $totalarray['nbfield']++;
603}
604print '</tr>'."\n";
605
606
607// Detect if we need a fetch on each output line
608$needToFetchEachLine = 0;
609if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
610 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
611 if (!is_null($val) && preg_match('/\$object/', $val)) {
612 $needToFetchEachLine++; // There is at least one compute field that use $object
613 }
614 }
615}
616
617
618// Loop on record
619// --------------------------------------------------------------------
620$i = 0;
621$savnbfield = $totalarray['nbfield'];
622$totalarray = array();
623$totalarray['nbfield'] = 0;
624$imaxinloop = ($limit ? min($num, $limit) : $num);
625while ($i < $imaxinloop) {
626 $obj = $db->fetch_object($resql);
627 if (empty($obj)) {
628 break; // Should not happen
629 }
630
631 // Store properties in $object
632 $object->setVarsFromFetchObj($obj);
633
634 if ($mode == 'kanban') {
635 if ($i == 0) {
636 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
637 print '<div class="box-flex-container kanban">';
638 }
639 // Output Kanban
640 $object->date_eval = $obj->date_eval;
641
642 // TODO Use a cache on job
643 $job = new Job($db);
644 $job->fetch($obj->fk_job);
645
646 // TODO Use a cache on user
647 $userstatic = new User($db);
648 $userstatic->fetch($obj->fk_user);
649
650 $selected = -1;
651 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
652 $selected = 0;
653 if (in_array($object->id, $arrayofselected)) {
654 $selected = 1;
655 }
656 }
657 print $object->getKanbanView('', array('user'=>$userstatic->getNomUrl(-1), 'job'=>$job->getNomUrl(1), 'selected' => $selected));
658 if ($i == ($imaxinloop - 1)) {
659 print '</div>';
660 print '</td></tr>';
661 }
662 } else {
663 // Show here line of result
664 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
665 // Action column
666 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
667 print '<td class="nowrap center">';
668 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
669 $selected = 0;
670 if (in_array($object->id, $arrayofselected)) {
671 $selected = 1;
672 }
673 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
674 }
675 print '</td>';
676 if (!$i) {
677 $totalarray['nbfield']++;
678 }
679 }
680 foreach ($object->fields as $key => $val) {
681 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
682 if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
683 $cssforfield .= ($cssforfield ? ' ' : '').'center';
684 } elseif ($key == 'status') {
685 $cssforfield .= ($cssforfield ? ' ' : '').'center';
686 }
687
688 if (in_array($val['type'], array('timestamp'))) {
689 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
690 } elseif ($key == 'ref') {
691 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
692 }
693
694 if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
695 $cssforfield .= ($cssforfield ? ' ' : '').'right';
696 }
697 //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
698
699 if (!empty($arrayfields['t.'.$key]['checked'])) {
700 print '<td'.($cssforfield ? ' class="'.$cssforfield.(preg_match('/tdoverflow/', $cssforfield) ? ' classfortooltip' : '').'"' : '');
701 if (preg_match('/tdoverflow/', $cssforfield) && !is_numeric($object->$key)) {
702 print ' title="'.dol_escape_htmltag($object->$key).'"';
703 }
704 print '>';
705 if ($key == 'status') {
706 print $object->getLibStatut(5);
707 } elseif ($key == 'rowid') {
708 print $object->showOutputField($val, $key, $object->id, '');
709 } elseif ($key == 'label') {
710 print $object->getNomUrl(1);
711 } else {
712 print $object->showOutputField($val, $key, $object->$key, '');
713 }
714 print '</td>';
715 if (!$i) {
716 $totalarray['nbfield']++;
717 }
718 if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
719 if (!$i) {
720 $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
721 }
722 if (!isset($totalarray['val'])) {
723 $totalarray['val'] = array();
724 }
725 if (!isset($totalarray['val']['t.'.$key])) {
726 $totalarray['val']['t.'.$key] = 0;
727 }
728 $totalarray['val']['t.'.$key] += $object->$key;
729 }
730 }
731 }
732 // Extra fields
733 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
734 // Fields from hook
735 $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
736 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
737 print $hookmanager->resPrint;
738 // Action column
739 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
740 print '<td class="nowrap center">';
741 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
742 $selected = 0;
743 if (in_array($object->id, $arrayofselected)) {
744 $selected = 1;
745 }
746 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
747 }
748 print '</td>';
749 if (!$i) {
750 $totalarray['nbfield']++;
751 }
752 }
753 print '</tr>'."\n";
754 }
755
756 $i++;
757}
758
759// Show total line
760include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
761
762// If no record found
763if ($num == 0) {
764 $colspan = 1;
765 foreach ($arrayfields as $key => $val) {
766 if (!empty($val['checked'])) {
767 $colspan++;
768 }
769 }
770 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
771}
772
773
774$db->free($resql);
775
776$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
777$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
778print $hookmanager->resPrint;
779
780print '</table>'."\n";
781print '</div>'."\n";
782
783print '</form>'."\n";
784
785if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
786 $hidegeneratedfilelistifempty = 1;
787 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
788 $hidegeneratedfilelistifempty = 0;
789 }
790
791 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
792 $formfile = new FormFile($db);
793
794 // Show list of available documents
795 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
796 $urlsource .= str_replace('&amp;', '&', $param);
797
798 $filedir = $diroutputmassaction;
799 $genallowed = $permissiontoread;
800 $delallowed = $permissiontoadd;
801
802 print $formfile->showdocuments('massfilesarea_hrm', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
803}
804
805// End of page
806llxFooter();
807$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:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class for Evaluation.
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 Job.
Definition job.class.php:37
Class to manage Dolibarr users.
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 a 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.