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