2017-08-04 16:28:16 +02:00
< ? php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager : il software gestionale open source per l ' assistenza tecnica e la fatturazione
2021-01-20 15:08:51 +01:00
* Copyright ( C ) DevCode s . r . l .
2020-09-07 15:04:06 +02:00
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < https :// www . gnu . org / licenses />.
*/
2017-08-04 16:28:16 +02:00
2019-11-08 15:09:05 +01:00
include_once __DIR__ . '/../../core.php' ;
2018-06-18 15:56:00 +02:00
2019-07-12 17:35:14 +02:00
use Modules\Interventi\Intervento ;
2018-09-28 16:43:40 +02:00
2019-07-12 17:35:14 +02:00
$intervento = Intervento :: find ( $id_record );
$sessioni = $intervento -> sessioni ;
$righe = $intervento -> getRighe ();
2017-11-16 18:55:03 +01:00
2019-07-12 17:35:14 +02:00
$show_prezzi = Auth :: user ()[ 'gruppo' ] != 'Tecnici' || ( Auth :: user ()[ 'gruppo' ] == 'Tecnici' && setting ( 'Mostra i prezzi al tecnico' ));
2018-02-18 19:53:23 +01:00
2019-07-12 17:35:14 +02:00
if ( $show_prezzi ) {
2020-03-12 22:15:02 +01:00
$rss = $dbo -> fetchArray ( 'SELECT in_statiintervento.is_completato AS flag_completato FROM in_statiintervento INNER JOIN in_interventi ON in_statiintervento.idstatointervento=in_interventi.idstatointervento WHERE in_interventi.id=' . prepare ( $id_record ));
2018-02-18 19:53:23 +01:00
2018-05-05 09:29:09 +02:00
if ( $rss [ 0 ][ 'flag_completato' ]) {
2018-02-16 15:45:15 +01:00
$readonly = 'readonly' ;
} else {
$readonly = '' ;
}
2017-08-04 16:28:16 +02:00
echo '
<!-- Riepilogo dei costi -->
< table class = " table table condensed table-striped table-hover table-bordered " >
2019-07-12 17:35:14 +02:00
< thead >
< tr >
< th width = " 40% " ></ th >
< th width = " 20% " class = " text-center " > '.tr(' Costo ', [], [' upper ' => true]).' < span class = " tip " title = " '.tr('Costo interno').' " >< i class = " fa fa-question-circle-o " ></ i ></ span ></ th >
< th width = " 20% " class = " text-center " > '.tr(' Addebito ', [], [' upper ' => true]).' < span class = " tip " title = " '.tr('Addebito al cliente').' " >< i class = " fa fa-question-circle-o " ></ i ></ span ></ th >
< th width = " 20% " class = " text-center " > '.tr(' Tot . Scontato ', [], [' upper ' => true]).' < span class = " tip " title = " '.tr('Addebito scontato al cliente').' " >< i class = " fa fa-question-circle-o " ></ i ></ span ></ th >
</ tr >
</ thead >
2020-02-27 17:14:00 +01:00
2019-07-12 17:35:14 +02:00
< tbody >
< tr >
< th > '.tr(' Totale manodopera ', [], [' upper ' => true]).' </ th >
< td class = " text-right " > '.moneyFormat($sessioni->sum(' costo_manodopera '), 2).' </ td >
< td class = " text-right " > '.moneyFormat($sessioni->sum(' prezzo_manodopera '), 2).' </ td >
< td class = " text-right " > '.moneyFormat($sessioni->sum(' prezzo_manodopera_scontato '), 2).' </ td >
</ tr >
2020-02-27 17:14:00 +01:00
2019-07-12 17:35:14 +02:00
< tr >
< th > '.tr(' Totale diritto di chiamata ', [], [' upper ' => true]).' </ th >
< td class = " text-right " > '.moneyFormat($sessioni->sum(' costo_diritto_chiamata '), 2).' </ td >
< td class = " text-right " > '.moneyFormat($sessioni->sum(' prezzo_diritto_chiamata '), 2).' </ td >
< td class = " text-right " > '.moneyFormat($sessioni->sum(' prezzo_diritto_chiamata '), 2).' </ td >
</ tr >
2020-02-27 17:14:00 +01:00
2019-07-12 17:35:14 +02:00
< tr >
< th > '.tr(' Totale viaggio ', [], [' upper ' => true]).' </ th >
< td class = " text-right " > '.moneyFormat($sessioni->sum(' costo_viaggio '), 2).' </ td >
< td class = " text-right " > '.moneyFormat($sessioni->sum(' prezzo_viaggio '), 2).' </ td >
< td class = " text-right " > '.moneyFormat($sessioni->sum(' prezzo_viaggio_scontato '), 2).' </ td >
</ tr >
2020-02-27 17:14:00 +01:00
2019-07-12 17:35:14 +02:00
< tr >
< th > '.tr(' Totale righe ', [], [' upper ' => true]).' </ th >
< td class = " text-right " > '.moneyFormat($righe->sum(' spesa '), 2).' </ td >
< td class = " text-right " > '.moneyFormat($righe->sum(' imponibile '), 2).' </ td >
< td class = " text-right " > '.moneyFormat($righe->sum(' totale_imponibile '), 2).' </ td >
</ tr >
</ tbody > ' ;
// Calcoli
$imponibile = abs ( $intervento -> imponibile );
$sconto = $intervento -> sconto ;
$totale_imponibile = abs ( $intervento -> totale_imponibile );
$iva = abs ( $intervento -> iva );
$totale = abs ( $intervento -> totale );
2017-08-04 16:28:16 +02:00
2019-07-12 17:35:14 +02:00
echo '
2017-08-04 16:28:16 +02:00
< tr >
2019-07-12 17:35:14 +02:00
< td colspan = " 3 " class = " text-right " >
< b > '.tr(' Imponibile ', [], [' upper ' => true]).' :</ b >
</ td >
2020-07-06 13:19:20 +02:00
< td class = " text-right " >
2019-07-12 17:35:14 +02:00
'.moneyFormat($imponibile, 2).'
</ td >
</ tr > ' ;
2022-01-29 23:49:19 +01:00
// Totale sconto
2019-07-12 17:35:14 +02:00
if ( ! empty ( $sconto )) {
echo '
2018-01-04 11:03:23 +01:00
< tr >
2019-07-12 17:35:14 +02:00
< td colspan = " 3 " class = " text-right " >
< b >< span class = " tip " title = " '.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').' " > < i class = " fa fa-question-circle-o " ></ i > '.tr(' Sconto / maggiorazione ', [], [' upper ' => true]).' :</ span ></ b >
</ td >
2020-07-06 13:19:20 +02:00
< td class = " text-right " >
2019-07-12 17:35:14 +02:00
'.moneyFormat($sconto, 2).'
</ td >
</ tr > ' ;
// Totale imponibile
echo '
2017-08-04 16:28:16 +02:00
< tr >
2019-07-12 17:35:14 +02:00
< td colspan = " 3 " class = " text-right " >
< b > '.tr(' Totale imponibile ', [], [' upper ' => true]).' :</ b >
</ td >
2020-07-06 13:19:20 +02:00
< td class = " text-right " >
2019-07-12 17:35:14 +02:00
'.moneyFormat($totale_imponibile, 2).'
</ td >
</ tr > ' ;
}
2017-08-04 16:28:16 +02:00
2019-07-12 17:35:14 +02:00
// Totale iva
echo '
2017-08-04 16:28:16 +02:00
< tr >
2019-07-12 17:35:14 +02:00
< td colspan = " 3 " class = " text-right " >
2022-04-08 13:10:58 +02:00
< b >< i class = " fa fa-question-circle-o tip " title = " '.tr( " Il valore dell 'IVA totale è esclusivamente indicativo e basato sulle impostazioni di default del gestionale se non è impostata l' iva predefinita nell 'anagrafica").' . " ></i> '.tr('IVA', [], ['upper' => true]).':</b>
2019-07-12 17:35:14 +02:00
</ td >
2020-07-06 13:19:20 +02:00
< td class = " text-right " >
2019-07-12 17:35:14 +02:00
'.moneyFormat($iva, 2).'
</ td >
</ tr > ' ;
2022-01-29 23:49:19 +01:00
// Totale attività
2019-07-12 17:35:14 +02:00
echo '
2017-08-04 16:28:16 +02:00
< tr >
2019-07-12 17:35:14 +02:00
< td colspan = " 3 " class = " text-right " >
< b > '.tr(' Totale ', [], [' upper ' => true]).' :</ b >
</ td >
2020-07-06 13:19:20 +02:00
< td class = " text-right " >
2019-07-12 17:35:14 +02:00
'.moneyFormat($totale, 2).'
</ td >
</ tr > ' ;
2018-01-04 11:03:23 +01:00
2019-07-12 17:35:14 +02:00
echo '
2017-08-04 16:28:16 +02:00
</ table > ' ;
}
2017-09-11 11:28:39 +02:00
echo '
2019-07-26 18:05:19 +02:00
< script > $ ( document ) . ready ( init ) </ script > ' ;