dolibarr  19.0.0-dev
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
30 require '../main.inc.php';
31 
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
35 
36 // load hrm libraries
37 require_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');
65 if (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)
86 if (!$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 }
90 if (!$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();
97 foreach ($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();
109 foreach ($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();
117 foreach ($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
131 include 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
143 if (!isModEnabled('hrm')) {
144  accessforbidden('Module not enabled');
145 }
146 
147 // Security check (enable the most restrictive one)
148 if ($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();
154 if (!$permissiontoread) accessforbidden();
155 
156 
157 
158 /*
159  * Actions
160  */
161 
162 if (GETPOST('cancel', 'alpha')) {
163  $action = 'list';
164  $massaction = '';
165 }
166 if (!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
172 if ($reshook < 0) {
173  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
174 }
175 
176 if (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
226 if (!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";
237 if (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;
244 if ($object->ismultientitymanaged == 1) {
245  $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
246 } else {
247  $sql .= " WHERE 1 = 1";
248 }
249 foreach ($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 }
278 if ($search_all) {
279  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
280 }
281 
282 if (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
288 include 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 ";
296 foreach($object->fields as $key => $val) {
297  $sql .= "t.".$key.", ";
298 }
299 // Add fields from extrafields
300 if (!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 = '';
316 if (!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.
325 if (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
342 if ($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 
353 llxHeader('', $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 = '';
373 if (!empty($mode)) {
374  $param .= '&mode='.urlencode($mode);
375 }
376 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
377  $param .= '&contextpage='.urlencode($contextpage);
378 }
379 if ($limit > 0 && $limit != $conf->liste_limit) {
380  $param .= '&limit='.((int) $limit);
381 }
382 foreach ($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 }
391 if ($optioncss != '') {
392  $param .= '&optioncss='.urlencode($optioncss);
393 }
394 // Add $param from extra fields
395 include 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 );
408 if ($permissiontodelete) {
409  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
410 }
411 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
412  $arrayofmassactions = array();
413 }
414 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
415 
416 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
417 if ($optioncss != '') {
418  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
419 }
420 print '<input type="hidden" name="token" value="'.newToken().'">';
421 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
422 print '<input type="hidden" name="action" value="list">';
423 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
424 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
425 print '<input type="hidden" name="page" value="'.$page.'">';
426 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
427 print '<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 
434 print_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;
441 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
442 
443 if ($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
457 if (empty($reshook)) {
458  $moreforfilter .= $hookmanager->resPrint;
459 } else {
460  $moreforfilter = $hookmanager->resPrint;
461 }
462 
463 if (!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 = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
471 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
472 
473 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
474 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
475 
476 
477 // Fields title search
478 // --------------------------------------------------------------------
479 print '<tr class="liste_titre">';
480 foreach ($object->fields as $key => $val) {
481  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
482  if ($key == 'status') {
483  $cssforfield .= ($cssforfield ? ' ' : '').'center';
484  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
485  $cssforfield .= ($cssforfield ? ' ' : '').'center';
486  } elseif (in_array($val['type'], array('timestamp'))) {
487  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
488  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
489  $cssforfield .= ($cssforfield ? ' ' : '').'right';
490  }
491  if (!empty($arrayfields['t.'.$key]['checked'])) {
492  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
493  if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
494  print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
495  } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
496  print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1);
497  } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
498  print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
499  } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
500  print '<div class="nowrap">';
501  print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
502  print '</div>';
503  print '<div class="nowrap">';
504  print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
505  print '</div>';
506  }
507  print '</td>';
508  }
509 }
510 // Extra fields
511 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
512 
513 // Fields from hook
514 $parameters = array('arrayfields'=>$arrayfields);
515 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
516 print $hookmanager->resPrint;
517 // Action column
518 print '<td class="liste_titre maxwidthsearch">';
519 $searchpicto = $form->showFilterButtons();
520 print $searchpicto;
521 print '</td>';
522 print '</tr>'."\n";
523 
524 $totalarray = array();
525 $totalarray['nbfield'] = 0;
526 
527 // Fields title label
528 // --------------------------------------------------------------------
529 print '<tr class="liste_titre">';
530 foreach ($object->fields as $key => $val) {
531  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
532  if ($key == 'status') {
533  $cssforfield .= ($cssforfield ? ' ' : '').'center';
534  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
535  $cssforfield .= ($cssforfield ? ' ' : '').'center';
536  } elseif (in_array($val['type'], array('timestamp'))) {
537  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
538  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
539  $cssforfield .= ($cssforfield ? ' ' : '').'right';
540  }
541  if (!empty($arrayfields['t.'.$key]['checked'])) {
542  print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
543  $totalarray['nbfield']++;
544  }
545 }
546 // Extra fields
547 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
548 // Hook fields
549 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
550 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
551 print $hookmanager->resPrint;
552 // Action column
553 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
554 $totalarray['nbfield']++;
555 print '</tr>'."\n";
556 
557 
558 // Detect if we need a fetch on each output line
559 $needToFetchEachLine = 0;
560 if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
561  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
562  if (!is_null($val) && preg_match('/\$object/', $val)) {
563  $needToFetchEachLine++; // There is at least one compute field that use $object
564  }
565  }
566 }
567 
568 
569 // Loop on record
570 // --------------------------------------------------------------------
571 $i = 0;
572 $savnbfield = $totalarray['nbfield'];
573 $totalarray = array();
574 $totalarray['nbfield'] = 0;
575 $imaxinloop = ($limit ? min($num, $limit) : $num);
576 while ($i < $imaxinloop) {
577  $obj = $db->fetch_object($resql);
578  if (empty($obj)) {
579  break; // Should not happen
580  }
581 
582  // Store properties in $object
583  $object->setVarsFromFetchObj($obj);
584 
585  if ($mode == 'kanban') {
586  if ($i == 0) {
587  print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
588  print '<div class="box-flex-container kanban">';
589  }
590  // Output Kanban
591  $object->date_eval = $obj->date_eval;
592 
593  // TODO Use a cache on job
594  $job = new Job($db);
595  $job->fetch($obj->fk_job);
596 
597  // TODO Use a cache on user
598  $userstatic = new User($db);
599  $userstatic->fetch($obj->fk_user);
600 
601  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
602  $selected = 0;
603  if (in_array($object->id, $arrayofselected)) {
604  $selected = 1;
605  }
606  print $object->getKanbanView('', array('user'=>$userstatic->getNomUrl(1), 'job'=>$job->getNomUrl(1), 'selected' => in_array($object->id, $arrayofselected)));
607  }
608  if ($i == ($imaxinloop - 1)) {
609  print '</div>';
610  print '</td></tr>';
611  }
612  } else {
613  // Show here line of result
614  print '<tr class="oddeven">';
615  foreach ($object->fields as $key => $val) {
616  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
617  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
618  $cssforfield .= ($cssforfield ? ' ' : '').'center';
619  } elseif ($key == 'status') {
620  $cssforfield .= ($cssforfield ? ' ' : '').'center';
621  }
622 
623  if (in_array($val['type'], array('timestamp'))) {
624  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
625  } elseif ($key == 'ref') {
626  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
627  }
628 
629  if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
630  $cssforfield .= ($cssforfield ? ' ' : '').'right';
631  }
632  //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
633 
634  if (!empty($arrayfields['t.'.$key]['checked'])) {
635  print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
636  if ($key == 'status') {
637  print $object->getLibStatut(5);
638  } elseif ($key == 'rowid') {
639  print $object->showOutputField($val, $key, $object->id, '');
640  } else {
641  print $object->showOutputField($val, $key, $object->$key, '');
642  }
643  print '</td>';
644  if (!$i) {
645  $totalarray['nbfield']++;
646  }
647  if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
648  if (!$i) {
649  $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
650  }
651  if (!isset($totalarray['val'])) {
652  $totalarray['val'] = array();
653  }
654  if (!isset($totalarray['val']['t.'.$key])) {
655  $totalarray['val']['t.'.$key] = 0;
656  }
657  $totalarray['val']['t.'.$key] += $object->$key;
658  }
659  }
660  }
661  // Extra fields
662  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
663  // Fields from hook
664  $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
665  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
666  print $hookmanager->resPrint;
667  // Action 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  print '</tr>'."\n";
682  }
683 
684  $i++;
685 }
686 
687 // Show total line
688 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
689 
690 // If no record found
691 if ($num == 0) {
692  $colspan = 1;
693  foreach ($arrayfields as $key => $val) {
694  if (!empty($val['checked'])) {
695  $colspan++;
696  }
697  }
698  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
699 }
700 
701 
702 $db->free($resql);
703 
704 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
705 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
706 print $hookmanager->resPrint;
707 
708 print '</table>'."\n";
709 print '</div>'."\n";
710 
711 print '</form>'."\n";
712 
713 if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
714  $hidegeneratedfilelistifempty = 1;
715  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
716  $hidegeneratedfilelistifempty = 0;
717  }
718 
719  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
720  $formfile = new FormFile($db);
721 
722  // Show list of available documents
723  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
724  $urlsource .= str_replace('&amp;', '&', $param);
725 
726  $filedir = $diroutputmassaction;
727  $genallowed = $permissiontoread;
728  $delallowed = $permissiontoadd;
729 
730  print $formfile->showdocuments('massfilesarea_hrm', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
731 }
732 
733 // End of page
734 llxFooter();
735 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
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.
Definition: user.class.php:48
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
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.