From 8d7387c471cd6da3157e47087932f05da85b1b47 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Mon, 8 Jul 2024 13:26:58 +0200 Subject: [PATCH 1/3] #261 [RegistrationCertificate] add: linked control on list --- .../registrationcertificatefr_list.php | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/view/registrationcertificatefr/registrationcertificatefr_list.php b/view/registrationcertificatefr/registrationcertificatefr_list.php index d13f67d..3e86397 100644 --- a/view/registrationcertificatefr/registrationcertificatefr_list.php +++ b/view/registrationcertificatefr/registrationcertificatefr_list.php @@ -161,7 +161,15 @@ } // Definition of array of fields for columns -$arrayfields = array(); +$arrayfields = []; +if (isModEnabled('digiquali')) { + $arrayfields['t.controls'] = [ + 'label' => 'Controls', + 'checked' => 1, + 'enabled' => 1, + 'position' => 200 + ]; +} foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field if (!empty($val['visible'])) { @@ -482,6 +490,10 @@ $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +if (isModEnabled('digiquali')) { + $object->fields['controls'] = $arrayfields['t.controls']; +} + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''."\n"; @@ -517,6 +529,8 @@ 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')) { + continue; } else { print ''; } @@ -553,7 +567,11 @@ $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + $disableSortField = 0; + if ($key == 'controls' && 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"; } } // Extra fields @@ -617,7 +635,14 @@ print ''; if ($key == 'status') { print $object->getLibStatut(5); - } elseif ($key == 'rowid') { + } 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 == 'rowid') { print $object->showOutputField($val, $key, $object->id, ''); } else { print $object->showOutputField($val, $key, $object->$key, ''); From cef2f95acce673240ef90cac9ecd9bd312a37b9a Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Mon, 8 Jul 2024 16:42:38 +0200 Subject: [PATCH 2/3] #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 3e86397..ac44c60 100644 --- a/view/registrationcertificatefr/registrationcertificatefr_list.php +++ b/view/registrationcertificatefr/registrationcertificatefr_list.php @@ -169,6 +169,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 @@ -491,7 +505,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 @@ -529,7 +545,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 ''; @@ -568,7 +584,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"; @@ -631,17 +647,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 { From a0a88a555ae2425f0e893091e934367c85f0a714 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Tue, 9 Jul 2024 01:50:09 +0200 Subject: [PATCH 3/3] #261 [RegistrationCertificate] add: nextControl and improve design --- .../registrationcertificatefr_list.php | 72 +++++++++++++------ 1 file changed, 49 insertions(+), 23 deletions(-) diff --git a/view/registrationcertificatefr/registrationcertificatefr_list.php b/view/registrationcertificatefr/registrationcertificatefr_list.php index ac44c60..2dbef73 100644 --- a/view/registrationcertificatefr/registrationcertificatefr_list.php +++ b/view/registrationcertificatefr/registrationcertificatefr_list.php @@ -170,18 +170,25 @@ 'position' => 200 ]; - $arrayfields['t.last_control'] = [ - 'label' => 'LastControl', + $arrayfields['t.control_date'] = [ + 'label' => 'ControlDate', 'checked' => 1, 'enabled' => 1, 'position' => 210 ]; + $arrayfields['t.days_remaining_before_next_control'] = [ + 'label' => 'DaysBeforeNextControl', + 'checked' => 1, + 'enabled' => 1, + 'position' => 220 + ]; + $arrayfields['t.control_verdict'] = [ 'label' => 'Verdict', 'checked' => 1, 'enabled' => 1, - 'position' => 220 + 'position' => 230 ]; } foreach ($object->fields as $key => $val) { @@ -505,9 +512,10 @@ $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); if (isModEnabled('digiquali')) { - $object->fields['controls'] = $arrayfields['t.controls']; - $object->fields['last_control'] = $arrayfields['t.last_control']; - $object->fields['control_verdict'] = $arrayfields['t.control_verdict']; + $object->fields['controls'] = $arrayfields['t.controls']; + $object->fields['control_date'] = $arrayfields['t.control_date']; + $object->fields['days_remaining_before_next_control'] = $arrayfields['t.days_remaining_before_next_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 @@ -545,7 +553,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' || $key == 'last_control' || $key == 'control_verdict' && isModEnabled('digiquali')) { + } elseif ($key == 'controls' || $key == 'control_date' || $key == 'control_verdict' || $key == 'days_remaining_before_next_control' && isModEnabled('digiquali')) { continue; } else { print ''; @@ -584,7 +592,7 @@ } if (!empty($arrayfields['t.'.$key]['checked'])) { $disableSortField = 0; - if ($key == 'controls' || $key == 'last_control' || $key == 'control_verdict' && isModEnabled('digiquali')) { + if ($key == 'controls' || $key == 'control_date' || $key == 'control_verdict' || $key == 'days_remaining_before_next_control' && 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,7 +640,7 @@ $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif ($key == 'status') { + } elseif ($key == 'status' || ($key == 'control_verdict' || $key == 'days_remaining_before_next_control' && isModEnabled('digiquali'))) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } @@ -646,27 +654,45 @@ $cssforfield .= ($cssforfield ? ' ' : '').'right'; } //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; - - $object->fetchObjectLinked($object->fk_lot,'productbatch', '', 'digiquali_control'); + if (isModEnabled('digiquali')) { + $controls = []; + $object->fetchObjectLinked($object->fk_lot,'productbatch', '', 'digiquali_control'); + if (is_array($object->linkedObjects['digiquali_control']) && !empty($object->linkedObjects['digiquali_control'])) { + $countControls = 1; + arsort($object->linkedObjects['digiquali_control']); + foreach ($object->linkedObjects['digiquali_control'] as $controlID => $control) { + if ($control->status == Control::STATUS_LOCKED) { + if ($countControls <= getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT')) { + $controls[$controlID] = $control; + } + $countControls++; + } + } + } + } if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; if ($key == 'status') { print $object->getLibStatut(5); } elseif ($key == 'controls' && isModEnabled('digiquali')) { - 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'); + $firstOccurrence = true; + foreach ($controls as $control) { + print $control->getNomUrl(1, '', 0, $firstOccurrence ? 'bold' : '') . '
'; + $firstOccurrence = false; } + } elseif ($key == 'control_date' && isModEnabled('digiquali')) { + $control = reset($controls); + 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]; + $control = reset($controls); + $verdictColor = $control->verdict == 1 ? 'green' : ($control->verdict == 2 ? 'red' : 'grey'); + print dol_strlen($control->verdict) > 0 ? '
' . $control->fields['verdict']['arrayofkeyval'][(!empty($control->verdict)) ? $control->verdict : 3] . '
' : 'N/A'; + } elseif ($key == 'days_remaining_before_next_control' && isModEnabled('digiquali')) { + $control = reset($controls); + if (dol_strlen($control->next_control_date) > 0) { + $nextControl = floor(($control->next_control_date - dol_now('tzuser'))/(3600 * 24)); + $nextControlColor = $nextControl < 0 ? 'red' : ($nextControl <= 30 ? 'orange' : ($nextControl <= 60 ? 'yellow' : 'green')); + print '
' . $nextControl . '
'; } } elseif ($key == 'rowid') { print $object->showOutputField($val, $key, $object->id, '');