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