From 3ad695d301d338bb82c4f9769c8ed0df1f8a730d Mon Sep 17 00:00:00 2001 From: loviuz Date: Fri, 24 Jan 2020 12:33:50 +0100 Subject: [PATCH] Fix eliminazione riga intervento da fattura --- modules/fatture/actions.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/modules/fatture/actions.php b/modules/fatture/actions.php index 115db3618..31de0f231 100644 --- a/modules/fatture/actions.php +++ b/modules/fatture/actions.php @@ -480,18 +480,24 @@ switch (post('op')) { case 'unlink_intervento': if (!empty($id_record) && post('idriga') !== null) { $id_riga = post('idriga'); + $type = post('type'); + $riga = $fattura->getRiga($type, $id_riga); - $righe = $fattura->getRighe(); - $riga = $righe->find($id_riga); + if (!empty($riga)) { + try { + $righe = $fattura->getRighe(); + $righe_intervento = $righe->where('idintervento', $riga->idintervento); + foreach ($righe_intervento as $r) { + $r->delete(); + } - $righe_intervento = $righe->where('idintervento', $riga->idintervento); - foreach ($righe_intervento as $r) { - $r->delete(); + flash()->info(tr('Intervento _NUM_ rimosso!', [ + '_NUM_' => $idintervento, + ])); + } catch (InvalidArgumentException $e) { + flash()->error(tr('Errore durante l\'eliminazione della riga!')); + } } - - flash()->info(tr('Intervento _NUM_ rimosso!', [ - '_NUM_' => $idintervento, - ])); } break;