';
-
-$object->fields['Custom']['MasterWorker'] = $arrayfields['MasterWorker'] ;
-$object->fields['Custom']['ExtSociety'] = $arrayfields['ExtSociety'];
-$object->fields['Custom']['ExtSocietyResponsible'] = $arrayfields['ExtSocietyResponsible'];
-$object->fields['Custom']['ExtSocietyAttendant'] = $arrayfields['ExtSocietyAttendant'] ;
+// Initialize array of search criterias
+$searchAll = trim(GETPOST('search_all'));
+$search = [];
foreach ($object->fields as $key => $val) {
- $cssforfield = (empty($val['css']) ? '' : $val['css']);
- if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
- if ( ! empty($arrayfields['t.' . $key]['checked'])) {
- print '| ';
-
- if (isset($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_' . $key, $val['arrayofkeyval'], $search[$key] ?? '', $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75');
- elseif (strpos($val['type'], 'integer:') === 0) {
- print $object->showInputField($val, $key, $search[$key] ?? '', '', '', 'search_', 'maxwidth150', 1);
- } elseif ( ! preg_match('/^(date|timestamp)/', $val['type'])) print '';
- print ' | ';
- }
- if ($key == 'Custom') {
- foreach ($val as $resource) {
- if ($resource['checked']) {
- print '';
- if (isset($resource['arrayofkeyval']) && is_array($resource['arrayofkeyval'])) {
- print $form->selectarray('search_' . dol_strtolower($resource['label']), $resource['arrayofkeyval'], GETPOSTINT('search_' . dol_strtolower($resource['label'])), 1, 0, 0, '', 1, 0, 0, '', 'maxwidth150');
- }
- print ' | ';
- }
- }
- }
+ if (!empty($val['searchmulti'])) {
+ $search[$key] = GETPOST('search_' . $key, 'array');
+ } elseif (GETPOST('search_' . $key, 'alpha') !== '') {
+ $search[$key] = GETPOST('search_' . $key, 'alpha');
+ }
+ if (isset($val['type']) && in_array($val['type'], ['date', 'datetime', 'timestamp'])) {
+ $search[$key . '_dtstart'] = dol_mktime(0, 0, 0, GETPOSTINT('search_' . $key . '_dtstartmonth'), GETPOSTINT('search_' . $key . '_dtstartday'), GETPOSTINT('search_' . $key . '_dtstartyear'));
+ $search[$key . '_dtend'] = dol_mktime(23, 59, 59, GETPOSTINT('search_' . $key . '_dtendmonth'), GETPOSTINT('search_' . $key . '_dtendday'), GETPOSTINT('search_' . $key . '_dtendyear'));
+ }
}
-// Extra fields
-include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php';
-
-// Fields from hook
-$parameters = array('arrayfields' => $arrayfields);
-$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $objectdocument may have been modified by hook
-print $hookmanager->resPrint;
-
-// Action column
-print '';
-$searchpicto = $form->showFilterButtons();
-print $searchpicto;
-print ' | ';
-print '
' . "\n";
-
-// Fields title label
-// --------------------------------------------------------------------
-print '';
- foreach ($object->fields as $key => $val) {
- $cssforfield = (empty($val['css']) ? '' : $val['css']);
- if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
- elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
- elseif ($key == 'category') $cssforfield .= ($cssforfield ? ' ' : '') . 'preventionplandocument-category';
- elseif ($key == 'description') $cssforfield .= ($cssforfield ? ' ' : '') . 'preventionplandocument-description';
- if ( ! empty($arrayfields['t.' . $key]['checked'])) {
- print '| ';
- if ($key == 'status') print $object->getLibStatut(5);
- elseif ($key == 'ref') {
- print ' ' . $object->getNomUrl();
- } elseif ($key == 'date_start') {
- print dol_print_date($object->date_start, 'dayhour', 'tzserver'); // We suppose dates without time are always gmt (storage of course + output)
- } elseif ($key == 'date_end') {
- print dol_print_date($object->date_end, 'dayhour', 'tzserver'); // We suppose dates without time are always gmt (storage of course + output)
- } else print $object->showOutputField($val, $key, $object->$key, '');
- print ' | ';
- if ( ! $i) $totalarray['nbfield']++;
- if ( ! empty($val['isameasure'])) {
- if ( ! $i) $totalarray['pos'][$totalarray['nbfield']] = 't.' . $key;
- $totalarray['val']['t.' . $key] += $object->$key;
- }
- }
- if ($key == 'Custom') {
- foreach ($val as $name => $resource) {
- if ($resource['checked']) {
- print '';
- if ($resource['label'] == 'MasterWorker') {
- $element = $signatory->fetchSignatory('MasterWorker', $object->id, 'preventionplan');
- if (is_array($element) && !empty($element)) {
- $element = array_shift($element);
- $usertmp->fetch($element->element_id);
- print $usertmp->getNomUrl(1);
- }
- } elseif ($resource['label'] == 'ExtSociety') {
- $extSociety = $digiriskresources->fetchResourcesFromObject('ExtSociety', $object);
- if ($extSociety > 0) {
- print $extSociety->getNomUrl(1);
- }
- }
- if ($resource['label'] == 'ExtSocietyResponsible') {
- $element = $signatory->fetchSignatory('ExtSocietyResponsible', $object->id, 'preventionplan');
- if (is_array($element) && !empty($element)) {
- $element = array_shift($element);
- $contact->fetch($element->element_id);
- print $contact->getNomUrl(1);
- }
- }
- if ($resource['label'] == 'ExtSocietyAttendant') {
- $extSociety_intervenants = $signatory->fetchSignatory('ExtSocietyAttendant', $object->id, 'preventionplan');
- if (is_array($extSociety_intervenants) && ! empty($extSociety_intervenants) && $extSociety_intervenants > 0) {
- foreach ($extSociety_intervenants as $element) {
- if ($element > 0) {
- $contact->fetch($element->element_id);
- print $contact->getNomUrl(1);
- print ' ';
- }
- }
- }
- }
- print ' | ';
- }
- }
- }
- }
- // Action column
- print '';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($object->id, $arrayofselected)) $selected = 1;
- print '';
- }
-
- print ' | ';
- if ( ! $i) $totalarray['nbfield']++;
- print '
' . "\n";
- $i++;
-}
-// If no record found
-if ($num == 0) {
- $colspan = 1;
- foreach ($arrayfields as $key => $val) { if ( ! empty($val['checked'])) $colspan++; }
- print '