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