Migliorie creazione documento con serial

This commit is contained in:
MatteoPistorello 2022-03-02 17:18:05 +01:00
parent 897b6fa131
commit b8a7ec9d21
1 changed files with 28 additions and 2 deletions

View File

@ -258,6 +258,19 @@ if (in_array($final_module['name'], ['Fatture di vendita', 'Fatture di acquisto'
</div>';
}
$has_serial = 0;
if (!empty($options['serials'])) {
foreach ($righe as $riga) {
if (!empty($riga['abilita_serial'])) {
$serials = $riga->serials ?: 0;
if (!empty($serials)) {
$has_serial = 1;
}
}
}
}
// Righe del documento
echo '
<div class="box box-success">
@ -279,7 +292,7 @@ echo '
<th width="15%">'.tr('Q. da evadere').'</th>
<th width="20%" class="text-center">'.tr('Subtot.').'</th>';
if (!empty($options['serials'])) {
if (!empty($has_serial)) {
echo '
<th width="20%">'.tr('Seriali').'</th>';
}
@ -322,6 +335,19 @@ foreach ($righe as $i => $riga) {
echo '&nbsp;'.nl2br($descrizione);
if ($riga->isArticolo() && !empty($riga->abilita_serial)) {
$serials = $riga->serials;
$mancanti = abs($riga->qta) - count($serials);
if (!empty($mancanti)) {
echo '
<br><b><small class="text-danger">'.tr('_NUM_ serial mancanti', [
'_NUM_' => $mancanti,
]).'</small></b>';
}
}
echo '
</td>';
@ -343,7 +369,7 @@ foreach ($righe as $i => $riga) {
</td>';
// Seriali
if (!empty($options['serials'])) {
if (!empty($has_serial)) {
echo '
<td style="vertical-align:middle">';