From b7716e0873db00a76808ec4f401ddb13aea96996 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Mon, 8 Jul 2024 16:42:38 +0200 Subject: [PATCH] #261 [RegistrationCertificate] add: last control on list and verdict --- .../registrationcertificatefr_list.php | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/view/registrationcertificatefr/registrationcertificatefr_list.php b/view/registrationcertificatefr/registrationcertificatefr_list.php index 0de6e7a..a520127 100644 --- a/view/registrationcertificatefr/registrationcertificatefr_list.php +++ b/view/registrationcertificatefr/registrationcertificatefr_list.php @@ -170,6 +170,20 @@ 'enabled' => 1, 'position' => 200 ]; + + $arrayfields['t.last_control'] = [ + 'label' => 'LastControl', + 'checked' => 1, + 'enabled' => 1, + 'position' => 210 + ]; + + $arrayfields['t.control_verdict'] = [ + 'label' => 'Verdict', + 'checked' => 1, + 'enabled' => 1, + 'position' => 220 + ]; } foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field @@ -492,7 +506,9 @@ $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); if (isModEnabled('digiquali')) { - $object->fields['controls'] = $arrayfields['t.controls']; + $object->fields['controls'] = $arrayfields['t.controls']; + $object->fields['last_control'] = $arrayfields['t.last_control']; + $object->fields['control_verdict'] = $arrayfields['t.control_verdict']; } print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table @@ -530,7 +546,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($db); print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2); - } elseif ($key == 'controls' && isModEnabled('digiquali')) { + } elseif ($key == 'controls' || $key == 'last_control' || $key == 'control_verdict' && isModEnabled('digiquali')) { continue; } else { print ''; @@ -569,7 +585,7 @@ } if (!empty($arrayfields['t.'.$key]['checked'])) { $disableSortField = 0; - if ($key == 'controls' && isModEnabled('digiquali')) { + if ($key == 'controls' || $key == 'last_control' || $key == 'control_verdict' && isModEnabled('digiquali')) { $disableSortField = 1; } print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''), $disableSortField)."\n"; @@ -632,17 +648,27 @@ } //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; + $object->fetchObjectLinked($object->fk_lot,'productbatch', '', 'digiquali_control'); if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; if ($key == 'status') { print $object->getLibStatut(5); } elseif ($key == 'controls' && isModEnabled('digiquali')) { - $object->fetchObjectLinked($object->fk_lot,'productbatch', '', 'digiquali_control'); if (is_array($object->linkedObjects['digiquali_control']) && !empty($object->linkedObjects['digiquali_control'])) { foreach ($object->linkedObjects['digiquali_control'] as $control) { print $control->getNomUrl(1) . '
'; } } + } elseif ($key == 'last_control' && isModEnabled('digiquali')) { + if (is_array($object->linkedObjects['digiquali_control']) && !empty($object->linkedObjects['digiquali_control'])) { + $control = end($object->linkedObjects['digiquali_control']); + print dol_print_date($control->control_date, 'day'); + } + } elseif ($key == 'control_verdict' && isModEnabled('digiquali')) { + if (is_array($object->linkedObjects['digiquali_control']) && !empty($object->linkedObjects['digiquali_control'])) { + $control = end($object->linkedObjects['digiquali_control']); + print $control->fields['verdict']['arrayofkeyval'][(!empty($control->verdict)) ?: 3]; + } } elseif ($key == 'rowid') { print $object->showOutputField($val, $key, $object->id, ''); } else {