From 7291b9178983eefbc5bb86601e2ba9c583bd592a Mon Sep 17 00:00:00 2001 From: Luca Date: Sat, 5 Feb 2022 22:05:46 +0100 Subject: [PATCH] Fix stampa consuntivo preventivo Fix stampa consuntivo ordine --- modules/ordini/add.php | 2 +- modules/ordini/modutil.php | 12 ++++++++++++ modules/preventivi/modutil.php | 14 ++++++++++++++ templates/contratti_cons/bottom.php | 2 -- templates/ordini_cons/bottom.php | 2 +- templates/preventivi_cons/bottom.php | 2 +- 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/modules/ordini/add.php b/modules/ordini/add.php index 34ee0f39f..703ec3b7b 100755 --- a/modules/ordini/add.php +++ b/modules/ordini/add.php @@ -49,7 +49,7 @@ $id_anagrafica = !empty(get('idanagrafica')) ? get('idanagrafica') : $user['idan
- {[ "type": "select", "label": "", "name": "idanagrafica", "required": 1, "value": "", "ajax-source": "", "icon-after": "add||tipoanagrafica=" ]} + {[ "type": "select", "label": "", "name": "idanagrafica", "required": 1, "value": "", "ajax-source": "", "icon-after": "add||tipoanagrafica=&readonly_tipo=1" ]}
diff --git a/modules/ordini/modutil.php b/modules/ordini/modutil.php index 436011322..75da1ee98 100755 --- a/modules/ordini/modutil.php +++ b/modules/ordini/modutil.php @@ -20,6 +20,7 @@ include_once __DIR__.'/../../core.php'; use Modules\Ordini\Ordine; +use Modules\Interventi\Intervento; /** * Funzione per generare un nuovo numero per l'ordine. @@ -240,3 +241,14 @@ function get_stato_ordine($idordine) return $stato; } + +function get_totale_interventi_ordine($idordine) +{ + + $interventi = Intervento::where('id_ordine', $idordine)->get(); + $array_interventi = $interventi->toArray(); + + $totale = sum(array_column($array_interventi, 'totale_imponibile')); + + return $totale; +} diff --git a/modules/preventivi/modutil.php b/modules/preventivi/modutil.php index 528a0a2c4..3cbab84b1 100755 --- a/modules/preventivi/modutil.php +++ b/modules/preventivi/modutil.php @@ -20,6 +20,7 @@ include_once __DIR__.'/../../core.php'; use Modules\Preventivi\Preventivo; +use Modules\Interventi\Intervento; function get_imponibile_preventivo($idpreventivo) { @@ -47,3 +48,16 @@ function get_stato_preventivo($idpreventivo) return 'Non evaso'; } } + + +function get_totale_interventi_preventivo($idpreventivo) +{ + + $interventi = Intervento::where('id_preventivo', $idpreventivo)->get(); + $array_interventi = $interventi->toArray(); + + $totale = sum(array_column($array_interventi, 'totale_imponibile')); + + return $totale; +} + diff --git a/templates/contratti_cons/bottom.php b/templates/contratti_cons/bottom.php index f3beb90af..d3b250a44 100755 --- a/templates/contratti_cons/bottom.php +++ b/templates/contratti_cons/bottom.php @@ -20,9 +20,7 @@ include_once __DIR__.'/../riepilogo_interventi/bottom.php'; $budget = get_imponibile_contratto($id_record); - $somma_totale_imponibile = get_totale_interventi_contratto($id_record); - $rapporto = floatval($budget) - floatval($somma_totale_imponibile); $rs = $dbo->fetchArray("SELECT SUM(qta) AS totale_ore FROM `co_righe_contratti` WHERE um='ore' AND idcontratto = ".prepare($id_record)); diff --git a/templates/ordini_cons/bottom.php b/templates/ordini_cons/bottom.php index 0b8906f39..e165e98b4 100644 --- a/templates/ordini_cons/bottom.php +++ b/templates/ordini_cons/bottom.php @@ -20,7 +20,7 @@ include_once __DIR__.'/../riepilogo_interventi/bottom.php'; $budget = get_imponibile_ordine($id_record); - +$somma_totale_imponibile = get_totale_interventi_ordine($id_record); $rapporto = floatval($budget) - floatval($somma_totale_imponibile); if ($pricing && empty($options['dir'])) { diff --git a/templates/preventivi_cons/bottom.php b/templates/preventivi_cons/bottom.php index 2eaa78f91..a40c7fa22 100755 --- a/templates/preventivi_cons/bottom.php +++ b/templates/preventivi_cons/bottom.php @@ -20,7 +20,7 @@ include_once __DIR__.'/../riepilogo_interventi/bottom.php'; $budget = get_imponibile_preventivo($id_record); - +$somma_totale_imponibile = get_totale_interventi_preventivo($id_record); $rapporto = floatval($budget) - floatval($somma_totale_imponibile); if ($pricing && empty($options['dir'])) {