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