dolibarr 20.0.0
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 = GETPOSTINT('show_files'); // 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 = GETPOSTINT('id');
58$ref = GETPOST('ref', 'alpha');
59
60// Load variable for pagination
61$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
62$sortfield = GETPOST('sortfield', 'aZ09comma');
63$sortorder = GETPOST('sortorder', 'aZ09comma');
64$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
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 criteria
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, GETPOSTINT('search_'.$key.'_dtstartmonth'), GETPOSTINT('search_'.$key.'_dtstartday'), GETPOSTINT('search_'.$key.'_dtstartyear'));
103 $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOSTINT('search_'.$key.'_dtendmonth'), GETPOSTINT('search_'.$key.'_dtendday'), GETPOSTINT('search_'.$key.'_dtendyear'));
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 && (bool) 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='.(GETPOSTINT('search_'.$key.'month'));
406 $param .= '&search_'.$key.'day='.(GETPOSTINT('search_'.$key.'day'));
407 $param .= '&search_'.$key.'year='.(GETPOSTINT('search_'.$key.'year'));
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 (GETPOSTINT('nomassaction') || 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).implode(', ', $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$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields with user setup
499$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
500$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
501
502print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
503print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
504
505// Fields title search
506// --------------------------------------------------------------------
507print '<tr class="liste_titre_filter">';
508// Action column
509if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
510 print '<td class="liste_titre maxwidthsearch center">';
511 $searchpicto = $form->showFilterButtons('left');
512 print $searchpicto;
513 print '</td>';
514}
515foreach ($object->fields as $key => $val) {
516 $searchkey = empty($search[$key]) ? '' : $search[$key];
517 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
518 if ($key == 'status') {
519 $cssforfield .= ($cssforfield ? ' ' : '').'center';
520 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
521 $cssforfield .= ($cssforfield ? ' ' : '').'center';
522 } elseif (in_array($val['type'], array('timestamp'))) {
523 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
524 } 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'])) {
525 $cssforfield .= ($cssforfield ? ' ' : '').'right';
526 }
527 if (!empty($arrayfields['t.'.$key]['checked'])) {
528 print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').($key == 'status' ? ' parentonrightofpage' : '').'">';
529 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
530 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);
531 } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
532 print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1);
533 } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
534 print '<div class="nowrap">';
535 print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
536 print '</div>';
537 print '<div class="nowrap">';
538 print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
539 print '</div>';
540 } elseif ($key == 'lang') {
541 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
542 $formadmin = new FormAdmin($db);
543 print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth100imp maxwidth125', 2);
544 } else {
545 print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
546 }
547 print '</td>';
548 }
549}
550// Extra fields
551include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
552
553// Fields from hook
554$parameters = array('arrayfields'=>$arrayfields);
555$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
556print $hookmanager->resPrint;
557// Action column
558if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
559 print '<td class="liste_titre maxwidthsearch">';
560 $searchpicto = $form->showFilterButtons();
561 print $searchpicto;
562 print '</td>';
563}
564print '</tr>'."\n";
565
566$totalarray = array();
567$totalarray['nbfield'] = 0;
568
569// Fields title label
570// --------------------------------------------------------------------
571print '<tr class="liste_titre">';
572// Action column
573if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
574 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
575 $totalarray['nbfield']++;
576}
577foreach ($object->fields as $key => $val) {
578 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
579 if ($key == 'status') {
580 $cssforfield .= ($cssforfield ? ' ' : '').'center';
581 } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
582 $cssforfield .= ($cssforfield ? ' ' : '').'center';
583 } elseif (in_array($val['type'], array('timestamp'))) {
584 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
585 } 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'])) {
586 $cssforfield .= ($cssforfield ? ' ' : '').'right';
587 }
588 $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
589 if (!empty($arrayfields['t.'.$key]['checked'])) {
590 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";
591 $totalarray['nbfield']++;
592 }
593}
594// Extra fields
595include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
596// Hook fields
597$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
598$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
599print $hookmanager->resPrint;
600// Action column
601if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
602 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
603 $totalarray['nbfield']++;
604}
605print '</tr>'."\n";
606
607
608// Detect if we need a fetch on each output line
609$needToFetchEachLine = 0;
610if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
611 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
612 if (!is_null($val) && preg_match('/\$object/', $val)) {
613 $needToFetchEachLine++; // There is at least one compute field that use $object
614 }
615 }
616}
617
618
619// Loop on record
620// --------------------------------------------------------------------
621$i = 0;
622$savnbfield = $totalarray['nbfield'];
623$totalarray = array();
624$totalarray['nbfield'] = 0;
625$imaxinloop = ($limit ? min($num, $limit) : $num);
626while ($i < $imaxinloop) {
627 $obj = $db->fetch_object($resql);
628 if (empty($obj)) {
629 break; // Should not happen
630 }
631
632 // Store properties in $object
633 $object->setVarsFromFetchObj($obj);
634
635 if ($mode == 'kanban') {
636 if ($i == 0) {
637 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
638 print '<div class="box-flex-container kanban">';
639 }
640 // Output Kanban
641 $object->date_eval = $obj->date_eval;
642
643 // TODO Use a cache on job
644 $job = new Job($db);
645 $job->fetch($obj->fk_job);
646
647 // TODO Use a cache on user
648 $userstatic = new User($db);
649 $userstatic->fetch($obj->fk_user);
650
651 $selected = -1;
652 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
653 $selected = 0;
654 if (in_array($object->id, $arrayofselected)) {
655 $selected = 1;
656 }
657 }
658 print $object->getKanbanView('', array('user'=>$userstatic->getNomUrl(-1), 'job'=>$job->getNomUrl(1), 'selected' => $selected));
659 if ($i == ($imaxinloop - 1)) {
660 print '</div>';
661 print '</td></tr>';
662 }
663 } else {
664 // Show here line of result
665 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
666 // Action column
667 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
668 print '<td class="nowrap center">';
669 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
670 $selected = 0;
671 if (in_array($object->id, $arrayofselected)) {
672 $selected = 1;
673 }
674 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
675 }
676 print '</td>';
677 if (!$i) {
678 $totalarray['nbfield']++;
679 }
680 }
681 foreach ($object->fields as $key => $val) {
682 $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
683 if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
684 $cssforfield .= ($cssforfield ? ' ' : '').'center';
685 } elseif ($key == 'status') {
686 $cssforfield .= ($cssforfield ? ' ' : '').'center';
687 }
688
689 if (in_array($val['type'], array('timestamp'))) {
690 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
691 } elseif ($key == 'ref') {
692 $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
693 }
694
695 if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
696 $cssforfield .= ($cssforfield ? ' ' : '').'right';
697 }
698 //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
699
700 if (!empty($arrayfields['t.'.$key]['checked'])) {
701 print '<td'.($cssforfield ? ' class="'.$cssforfield.(preg_match('/tdoverflow/', $cssforfield) ? ' classfortooltip' : '').'"' : '');
702 if (preg_match('/tdoverflow/', $cssforfield) && !is_numeric($object->$key)) {
703 print ' title="'.dol_escape_htmltag($object->$key).'"';
704 }
705 print '>';
706 if ($key == 'status') {
707 print $object->getLibStatut(5);
708 } elseif ($key == 'rowid') {
709 print $object->showOutputField($val, $key, $object->id, '');
710 } elseif ($key == 'label') {
711 print $object->getNomUrl(1);
712 } else {
713 print $object->showOutputField($val, $key, $object->$key, '');
714 }
715 print '</td>';
716 if (!$i) {
717 $totalarray['nbfield']++;
718 }
719 if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
720 if (!$i) {
721 $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
722 }
723 if (!isset($totalarray['val'])) {
724 $totalarray['val'] = array();
725 }
726 if (!isset($totalarray['val']['t.'.$key])) {
727 $totalarray['val']['t.'.$key] = 0;
728 }
729 $totalarray['val']['t.'.$key] += $object->$key;
730 }
731 }
732 }
733 // Extra fields
734 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
735 // Fields from hook
736 $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
737 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
738 print $hookmanager->resPrint;
739 // Action column
740 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
741 print '<td class="nowrap center">';
742 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
743 $selected = 0;
744 if (in_array($object->id, $arrayofselected)) {
745 $selected = 1;
746 }
747 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
748 }
749 print '</td>';
750 if (!$i) {
751 $totalarray['nbfield']++;
752 }
753 }
754 print '</tr>'."\n";
755 }
756
757 $i++;
758}
759
760// Show total line
761include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
762
763// If no record found
764if ($num == 0) {
765 $colspan = 1;
766 foreach ($arrayfields as $key => $val) {
767 if (!empty($val['checked'])) {
768 $colspan++;
769 }
770 }
771 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
772}
773
774
775$db->free($resql);
776
777$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
778$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
779print $hookmanager->resPrint;
780
781print '</table>'."\n";
782print '</div>'."\n";
783
784print '</form>'."\n";
785
786if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
787 $hidegeneratedfilelistifempty = 1;
788 if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
789 $hidegeneratedfilelistifempty = 0;
790 }
791
792 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
793 $formfile = new FormFile($db);
794
795 // Show list of available documents
796 $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
797 $urlsource .= str_replace('&amp;', '&', $param);
798
799 $filedir = $diroutputmassaction;
800 $genallowed = $permissiontoread;
801 $delallowed = $permissiontoadd;
802
803 print $formfile->showdocuments('massfilesarea_hrm', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
804}
805
806// End of page
807llxFooter();
808$db->close();
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()
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:38
Class to manage Dolibarr users.
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...
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 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.