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
2020-08-31 09:48:29 +02:00
use Carbon\Carbon ;
2024-03-05 16:01:45 +01:00
use Models\Module ;
2024-04-03 17:21:32 +02:00
use Modules\Checklists\Check ;
2020-08-31 09:48:29 +02:00
2017-08-04 16:28:16 +02:00
include_once __DIR__ . '/../../core.php' ;
2023-12-06 15:06:49 +01:00
$d_qta = ( int ) setting ( 'Cifre decimali per quantità in stampa' );
$d_importi = ( int ) setting ( 'Cifre decimali per importi in stampa' );
$d_totali = ( int ) setting ( 'Cifre decimali per totali in stampa' );
2023-12-05 17:43:35 +01:00
2017-08-04 16:28:16 +02:00
/*
Dati intervento
*/
2017-09-07 16:51:14 +02:00
echo '
2017-09-08 18:19:39 +02:00
< table class = " table table-bordered " >
< tr >
2020-05-18 17:38:14 +02:00
< th colspan = " 4 " style = " font-size:13pt; " class = " text-center " > '.tr(' Rapporto attività e interventi ', [], [' upper ' => true]).' </ th >
2017-09-08 18:19:39 +02:00
</ tr >
2017-08-04 16:28:16 +02:00
< tr >
2020-05-18 17:38:14 +02:00
< td class = " text-left " style = " width:30% " > '.tr(' Intervento n . ').' : < b > '.$documento[' codice '].' </ b ></ td >
2020-11-12 17:11:09 +01:00
< td class = " text-left " colspan = " '.(empty( $preventivo ) && empty( $contratto ) ? '3' : '1').' " style = " width:30% " > '.tr(' Data richiesta ').' : < b > '.Translator::dateToLocale($documento[' data_richiesta ']).' </ b ></ td > ' ;
if ( ! empty ( $preventivo )) {
echo '
2020-11-09 19:19:55 +01:00
< td class = " text-left " colspan = " 2 " style = " width:20% " > '.tr(' Preventivo n . ').' : < b > '.(!empty($preventivo) ? $preventivo[' numero '].' del '.Translator::dateToLocale($preventivo[' data_bozza ']) : ' ').' </ b ></ td > ' ;
2020-11-12 17:11:09 +01:00
} elseif ( ! empty ( $contratto )) {
echo '
2020-11-09 19:19:55 +01:00
< td class = " text-left " colspan = " 2 " style = " width:20% " > '.tr(' Contratto n . ').' : < b > '.(!empty($contratto) ? $contratto[' numero '].' del '.Translator::dateToLocale($contratto[' data_bozza ']) : ' ').' </ b ></ td > ' ;
}
echo '
2017-09-08 18:19:39 +02:00
</ tr > ' ;
2020-08-31 09:48:29 +02:00
// Dati cliente
echo '
2018-03-24 21:31:49 +01:00
< tr >
< td colspan = 2 >
'.tr(' Cliente ').' : < b > '.$c_ragionesociale.' </ b >
</ td > ' ;
2017-09-08 18:19:39 +02:00
2020-08-31 09:48:29 +02:00
// Codice fiscale o P.Iva
2018-03-24 21:31:49 +01:00
2020-08-31 09:48:29 +02:00
if ( ! empty ( $c_piva )) {
echo '
2018-11-02 17:49:11 +01:00
< td colspan = 2 >
'.tr(' P . Iva ').' : < b > '.strtoupper($c_piva).' </ b >
</ td > ' ;
2020-08-31 09:48:29 +02:00
} else {
echo '
2018-03-24 21:31:49 +01:00
< td colspan = 2 >
'.tr(' C . F . ').' : < b > '.strtoupper($c_codicefiscale).' </ b >
2018-11-02 17:49:11 +01:00
</ td > ' ;
2020-08-31 09:48:29 +02:00
}
2018-11-30 16:10:15 +01:00
2020-08-31 09:48:29 +02:00
echo '</tr>' ;
2018-11-30 16:10:15 +01:00
2020-08-31 09:48:29 +02:00
// Indirizzo
if ( ! empty ( $s_indirizzo ) or ! empty ( $s_cap ) or ! empty ( $s_citta ) or ! empty ( $s_provincia )) {
echo '
2020-01-15 19:37:36 +01:00
< tr >
< td colspan = " 4 " >
'.((!empty($s_indirizzo)) ? tr(' Via ').' : < b > '.$s_indirizzo.' </ b > ' : ' ').'
'.((!empty($s_cap)) ? tr(' CAP ').' : < b > '.$s_cap.' </ b > ' : ' ').'
'.((!empty($s_citta)) ? tr(' Città ').' : < b > '.$s_citta.' </ b > ' : ' ').'
'.((!empty($s_provincia)) ? tr(' Provincia ').' : < b > '.strtoupper($s_provincia).' </ b > ' : ' ').'
</ td >
</ tr > ' ;
2020-08-31 09:48:29 +02:00
} elseif ( ! empty ( $c_indirizzo ) or ! empty ( $c_cap ) or ! empty ( $c_citta ) or ! empty ( $c_provincia )) {
echo '
2018-11-02 17:49:11 +01:00
< tr >
< td colspan = " 4 " >
'.((!empty($c_indirizzo)) ? tr(' Via ').' : < b > '.$c_indirizzo.' </ b > ' : ' ').'
'.((!empty($c_cap)) ? tr(' CAP ').' : < b > '.$c_cap.' </ b > ' : ' ').'
'.((!empty($c_citta)) ? tr(' Città ').' : < b > '.$c_citta.' </ b > ' : ' ').'
'.((!empty($c_provincia)) ? tr(' Provincia ').' : < b > '.strtoupper($c_provincia).' </ b > ' : ' ').'
</ td >
</ tr > ' ;
2020-08-31 09:48:29 +02:00
}
2017-08-04 16:28:16 +02:00
2017-09-07 16:51:14 +02:00
echo '
2017-08-04 16:28:16 +02:00
< tr >
2017-09-08 18:19:39 +02:00
< td colspan = " 4 " >
2017-09-11 13:08:50 +02:00
'.tr(' Telefono ').' : < b > '.$c_telefono.' </ b > ' ;
2020-08-31 09:48:29 +02:00
if ( ! empty ( $c_cellulare )) {
2021-02-18 18:48:44 +01:00
echo ' - ' . tr ( 'Cellulare' ) . ': <b>' . $c_cellulare . '</b>' ;
2020-08-31 09:48:29 +02:00
}
2017-09-08 18:19:39 +02:00
echo '
</ td >
</ tr > ' ;
2017-09-11 13:08:50 +02:00
// riga 3
// Elenco impianti su cui è stato fatto l'intervento
2017-09-21 15:51:39 +02:00
$rs2 = $dbo -> fetchArray ( 'SELECT *, (SELECT nome FROM my_impianti WHERE id=my_impianti_interventi.idimpianto) AS nome, (SELECT matricola FROM my_impianti WHERE id=my_impianti_interventi.idimpianto) AS matricola FROM my_impianti_interventi WHERE idintervento=' . prepare ( $id_record ));
2017-09-08 18:19:39 +02:00
$impianti = [];
2018-03-24 21:31:49 +01:00
for ( $j = 0 ; $j < count ( $rs2 ); ++ $j ) {
2017-09-08 18:19:39 +02:00
$impianti [] = '<b>' . $rs2 [ $j ][ 'nome' ] . " </b> <small style='color:#777;'>( " . $rs2 [ $j ][ 'matricola' ] . ')</small>' ;
}
echo '
2017-08-04 16:28:16 +02:00
< tr >
2017-09-08 18:19:39 +02:00
< td colspan = " 4 " >
2017-09-11 13:08:50 +02:00
'.tr(' Impianti ').' : '.implode(' , ', $impianti).'
2017-09-08 18:19:39 +02:00
</ td >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
2018-01-19 22:10:37 +01:00
// Tipo intervento
echo '
< tr >
< td colspan = " 4 " >
2024-04-18 17:44:05 +02:00
< b > '.tr(' Tipo intervento ').' :</ b > '.$documento->tipo->getTranslation(' title ').'
2018-01-19 22:10:37 +01:00
</ td >
</ tr > ' ;
2017-09-11 13:08:50 +02:00
// Richiesta
2021-02-19 13:20:07 +01:00
// Rimosso nl2br, non necessario con ckeditor
2017-09-11 13:08:50 +02:00
echo '
2017-09-08 18:19:39 +02:00
< tr >
< td colspan = " 4 " style = " height:20mm; " >
2017-09-11 13:08:50 +02:00
< b > '.tr(' Richiesta ').' :</ b >
2024-01-15 15:30:45 +01:00
< p > '.$documento[' richiesta '].' </ p >
2017-09-08 18:19:39 +02:00
</ td >
</ tr > ' ;
2017-09-11 13:08:50 +02:00
// Descrizione
2020-02-01 12:48:42 +01:00
// Rimosso nl2br, non necessario con ckeditor
2017-09-11 13:08:50 +02:00
echo '
2017-08-04 16:28:16 +02:00
< tr >
2017-09-11 13:08:50 +02:00
< td colspan = " 4 " style = " height:20mm; " >
< b > '.tr(' Descrizione ').' :</ b >
2024-01-15 15:30:45 +01:00
< p > '.$documento[' descrizione '].' </ p >
2017-09-11 13:08:50 +02:00
</ td >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
2017-09-11 13:08:50 +02:00
2017-09-07 16:51:14 +02:00
echo '
2017-08-04 16:28:16 +02:00
</ table > ' ;
2019-07-12 17:35:14 +02:00
$righe = $documento -> getRighe ();
2017-08-04 16:28:16 +02:00
2023-12-13 17:33:24 +01:00
if ( ! setting ( 'Visualizza riferimento su ogni riga in stampa' )) {
$riferimenti = [];
$id_rif = [];
foreach ( $righe as $riga ) {
$riferimento = ( $riga -> getOriginalComponent () ? $riga -> getOriginalComponent () -> getDocument () -> getReference () : null );
if ( ! empty ( $riferimento )) {
if ( ! array_key_exists ( $riferimento , $riferimenti )) {
$riferimenti [ $riferimento ] = [];
}
if ( ! in_array ( $riga -> id , $riferimenti [ $riferimento ])) {
$id_rif [] = $riga -> id ;
$riferimenti [ $riferimento ][] = $riga -> id ;
}
}
}
}
2019-07-12 17:35:14 +02:00
if ( ! $righe -> isEmpty ()) {
2017-09-07 16:51:14 +02:00
echo '
2017-09-11 13:08:50 +02:00
< table class = " table table-bordered " >
< thead >
< tr >
< th colspan = " 4 " class = " text-center " >
2019-07-12 17:35:14 +02:00
< b > '.tr(' Materiale utilizzato e spese aggiuntive ', [], [' upper ' => true]).' </ b >
2017-09-11 13:08:50 +02:00
</ th >
</ tr >
< tr >
< th style = " font-size:8pt;width:50% " class = " text-center " >
< b > '.tr(' Descrizione ').' </ b >
</ th >
< th style = " font-size:8pt;width:15% " class = " text-center " >
< b > '.tr(' Q . tà ').' </ b >
</ th >
< th style = " font-size:8pt;width:15% " class = " text-center " >
< b > '.tr(' Prezzo unitario ').' </ b >
</ th >
< th style = " font-size:8pt;width:20% " class = " text-center " >
2020-07-08 11:03:27 +02:00
< b > '.tr(' Importo ').' </ b >
2017-09-11 13:08:50 +02:00
</ th >
</ tr >
</ thead >
< tbody > ' ;
2017-08-04 16:28:16 +02:00
2019-07-12 17:35:14 +02:00
foreach ( $righe as $riga ) {
2021-07-07 07:57:10 +02:00
if ( setting ( 'Formato ore in stampa' ) == 'Sessantesimi' ) {
if ( $riga -> um == 'ore' ) {
2021-06-15 11:45:49 +02:00
$qta = Translator :: numberToHours ( $riga -> qta );
2021-07-07 07:57:10 +02:00
} else {
2023-12-05 17:43:35 +01:00
$qta = Translator :: numberToLocale ( $riga -> qta , $d_qta );
2021-06-15 11:45:49 +02:00
}
2021-07-07 07:57:10 +02:00
} else {
2023-12-05 17:43:35 +01:00
$qta = Translator :: numberToLocale ( $riga -> qta , $d_qta );
2021-06-15 11:45:49 +02:00
}
2017-08-04 16:28:16 +02:00
// Articolo
2017-09-07 16:51:14 +02:00
echo '
2023-12-13 17:33:24 +01:00
< tr >
< td > ' ;
$text = '' ;
foreach ( $riferimenti as $key => $riferimento ) {
if ( in_array ( $riga -> id , $riferimento )) {
if ( $riga -> id === $riferimento [ 0 ]) {
$riga_ordine = $riga -> getOriginalComponent () -> getDocument ();
$text = '<b>' . $key . '</b><br>' ;
if ( $options [ 'pricing' ]) {
$text = $text . '</td><td></td><td>' ;
}
$text = $text . '</td><td></td></tr><tr><td>' ;
echo nl2br ( $text );
}
}
$riga [ 'descrizione' ] = str_replace ( 'Rif. ' . strtolower ( $key ), '' , $riga [ 'descrizione' ]);
}
$source_type = get_class ( $riga );
if ( ! setting ( 'Visualizza riferimento su ogni riga in stampa' )) {
echo $riga [ 'descrizione' ];
} else {
echo nl2br ( $riga [ 'descrizione' ]);
}
2019-07-12 17:35:14 +02:00
if ( $riga -> isArticolo ()) {
2023-12-13 17:33:24 +01:00
echo nl2br ( '<br><small>' . $riga -> codice . '</small>' );
}
2019-07-12 17:35:14 +02:00
2023-12-13 17:33:24 +01:00
if ( $riga -> isArticolo ()) {
2019-07-12 17:35:14 +02:00
// Seriali
$seriali = $riga -> serials ;
if ( ! empty ( $seriali )) {
$text = tr ( 'SN' ) . ': ' . implode ( ', ' , $seriali );
echo '
2023-12-13 17:33:24 +01:00
< small > '.$text.' </ small > ' ;
2019-07-12 17:35:14 +02:00
}
}
echo '
2023-12-13 17:33:24 +01:00
</ td > ' ;
2017-08-04 16:28:16 +02:00
// Quantità
2017-09-07 16:51:14 +02:00
echo '
2017-09-11 13:08:50 +02:00
< td class = " text-center " >
2021-06-15 11:45:49 +02:00
'.$qta.' '.$riga->um.'
2017-08-04 16:28:16 +02:00
</ td > ' ;
// Prezzo unitario
2017-09-07 16:51:14 +02:00
echo '
2017-09-11 13:08:50 +02:00
< td class = " text-center " >
2023-12-05 17:43:35 +01:00
'.($options[' pricing '] ? moneyFormat($riga->prezzo_unitario_corrente, $d_importi) : ' - ' );
2018-12-29 11:42:53 +01:00
2020-06-30 17:28:59 +02:00
if ( $options [ 'pricing' ] && $riga -> sconto > 0 ) {
$text = discountInfo ( $riga , false );
echo '
< br >< small class = " text-muted " > '.$text.' </ small > ' ;
2018-12-29 11:42:53 +01:00
}
echo '
2017-08-04 16:28:16 +02:00
</ td > ' ;
// Prezzo totale
2017-09-07 16:51:14 +02:00
echo '
2017-09-11 13:08:50 +02:00
< td class = " text-center " >
2024-01-19 10:32:20 +01:00
'.($options[' pricing '] ? moneyFormat($riga->importo, $d_importi) : ' - ').'
2017-08-04 16:28:16 +02:00
</ td >
</ tr > ' ;
}
2019-07-12 17:35:14 +02:00
2017-09-11 13:08:50 +02:00
echo '
</ tbody > ' ;
2017-08-04 16:28:16 +02:00
2017-09-21 15:51:39 +02:00
if ( $options [ 'pricing' ]) {
2017-08-04 16:28:16 +02:00
// Totale spese aggiuntive
2017-09-07 16:51:14 +02:00
echo '
2017-08-04 16:28:16 +02:00
< tr >
2017-09-11 13:08:50 +02:00
< td colspan = " 3 " class = " text-right " >
2019-07-12 17:35:14 +02:00
< b > '.tr(' Totale ', [], [' upper ' => true]).' :</ b >
2017-08-04 16:28:16 +02:00
</ td >
2017-09-11 13:08:50 +02:00
< th class = " text-center " >
2023-12-06 10:06:36 +01:00
< b > '.moneyFormat($righe->sum(' importo '), $d_totali).' </ b >
2017-09-11 13:08:50 +02:00
</ th >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
}
2017-09-07 16:51:14 +02:00
echo '
2017-08-04 16:28:16 +02:00
</ table > ' ;
}
// INTESTAZIONE ELENCO TECNICI
2017-09-07 16:51:14 +02:00
echo '
2017-09-12 16:45:18 +02:00
< table class = " table table-bordered vertical-middle " >
2017-09-11 13:08:50 +02:00
< thead >
< tr >
< th class = " text-center " colspan = " 5 " style = " font-size:11pt; " >
< b > '.tr(' Ore tecnici ', [], [' upper ' => true]).' </ b >
</ th >
</ tr >
< tr >
2020-08-31 09:48:29 +02:00
< th class = " text-center " style = " font-size:8pt;width:30% " >
2017-09-11 13:08:50 +02:00
< b > '.tr(' Tecnico ').' </ b >
</ th >
2020-08-31 09:48:29 +02:00
< th class = " text-center " colspan = " 3 " style = " font-size:8pt;width:35% " >
< b > '.tr(' Orario ').' </ b >
2017-09-11 13:08:50 +02:00
</ th >
< td class = " text-center " style = " font-size:6pt;width:35% " >
2019-01-10 12:30:41 +01:00
'.tr(' I dati del ricevente verrano trattati in base alla normativa europea UE 2016 / 679 del 27 aprile 2016 ( GDPR ) ').'
2017-09-11 13:08:50 +02:00
</ td >
</ tr >
</ thead >
< tbody > ' ;
2017-08-04 16:28:16 +02:00
// Sessioni di lavoro dei tecnici
2020-11-09 19:19:55 +01:00
$sessioni = $documento -> sessioni -> sortBy ( 'orario_inizio' );
2019-07-12 17:35:14 +02:00
foreach ( $sessioni as $i => $sessione ) {
2017-09-07 16:51:14 +02:00
echo '
2017-08-04 16:28:16 +02:00
< tr > ' ;
2019-07-12 17:35:14 +02:00
// Nome tecnico
2017-09-07 16:51:14 +02:00
echo '
2017-09-12 16:45:18 +02:00
< td >
2020-11-09 19:19:55 +01:00
'.$sessione->anagrafica->ragione_sociale.'
2024-04-18 17:44:05 +02:00
( '.$sessione->tipo->getTranslation(' title ').' )
2017-08-04 16:28:16 +02:00
</ td > ' ;
2020-08-31 09:48:29 +02:00
$inizio = new Carbon ( $sessione [ 'orario_inizio' ]);
$fine = new Carbon ( $sessione [ 'orario_fine' ]);
if ( $inizio -> isSameDay ( $fine )) {
$orario = timestampFormat ( $inizio ) . ' - ' . timeFormat ( $fine );
} else {
$orario = timestampFormat ( $inizio ) . ' - ' . timestampFormat ( $fine );
}
2017-08-04 16:28:16 +02:00
2020-08-31 09:48:29 +02:00
// Orario
2017-09-07 16:51:14 +02:00
echo '
2020-08-31 09:48:29 +02:00
< td class = " text-center " colspan = " 3 " >
'.$orario.'
2017-08-04 16:28:16 +02:00
</ td > ' ;
2017-09-11 13:08:50 +02:00
// Spazio aggiuntivo
if ( $i == 0 ) {
echo '
2020-05-19 10:31:00 +02:00
< td class = " text-center " style = " font-size:6pt; " >
2020-05-18 17:38:14 +02:00
'.tr(' Si dichiara che i lavori sono stati eseguiti ed i materiali installati nel rispetto delle vigenti normative tecniche ').'
2017-09-11 13:08:50 +02:00
</ td > ' ;
} else {
echo '
< td class = " text-center " style = " border-bottom:0px;border-top:0px; " ></ td > ' ;
}
2017-08-04 16:28:16 +02:00
2017-09-07 16:51:14 +02:00
echo '
2017-08-04 16:28:16 +02:00
</ tr > ' ;
}
2017-09-11 13:08:50 +02:00
// Ore lavorate
2021-07-07 07:57:10 +02:00
if ( setting ( 'Formato ore in stampa' ) == 'Sessantesimi' ) {
2021-06-15 11:45:49 +02:00
$ore_totali = Translator :: numberToHours ( $documento -> ore_totali );
2021-07-07 07:57:10 +02:00
} else {
2023-12-06 10:06:36 +01:00
$ore_totali = Translator :: numberToLocale ( $documento -> ore_totali , $d_totali );
2021-06-15 11:45:49 +02:00
}
2018-01-23 16:11:02 +01:00
echo '
< tr >
2017-09-12 16:45:18 +02:00
< td class = " text-center " >
2021-06-15 11:45:49 +02:00
< small > '.tr(' Ore lavorate ').' :</ small >< br />< b > '.$ore_totali.' </ b >
2017-08-04 16:28:16 +02:00
</ td > ' ;
2018-01-23 16:11:02 +01:00
// Costo totale manodopera
2018-02-03 13:55:09 +01:00
if ( $options [ 'pricing' ]) {
2017-09-11 13:08:50 +02:00
echo '
2018-01-23 16:11:02 +01:00
< td colspan = " 3 " class = " text-center " >
2023-12-06 10:06:36 +01:00
< small > '.tr(' Totale manodopera ').' :</ small >< br />< b > '.moneyFormat($sessioni->sum(' prezzo_manodopera '), $d_totali).' </ b >
2017-08-04 16:28:16 +02:00
</ td > ' ;
2017-09-11 13:08:50 +02:00
} else {
2017-09-07 16:51:14 +02:00
echo '
2018-01-23 16:11:02 +01:00
< td colspan = " 3 " class = " text-center " >-</ td > ' ;
2017-08-04 16:28:16 +02:00
}
2017-09-11 13:08:50 +02:00
// Timbro e firma
2020-09-23 13:36:37 +02:00
$firma = ! empty ( $documento [ 'firma_file' ]) ? '<img src="' . base_dir () . '/files/interventi/' . $documento [ 'firma_file' ] . '" style="width:70mm;">' : '' ;
2020-08-11 11:50:03 +02:00
2017-09-11 13:08:50 +02:00
echo '
2018-01-19 22:10:37 +01:00
< td rowspan = " 2 " class = " text-center " style = " font-size:8pt;height:30mm;vertical-align:bottom " >
2020-08-11 11:50:03 +02:00
'.$firma.' < br > ' ;
2020-08-12 13:21:03 +02:00
if ( empty ( $documento [ 'firma_file' ])) {
2023-06-02 11:22:44 +02:00
echo ' <i>(' . tr ( 'Timbro e firma leggibile' ) . ')</i>' ;
2020-08-12 13:21:03 +02:00
} else {
echo ' <i>' . $documento [ 'firma_nome' ] . '</i>' ;
2020-08-11 11:50:03 +02:00
}
2021-02-18 18:48:44 +01:00
echo '
2017-08-04 16:28:16 +02:00
</ td >
</ tr > ' ;
2018-01-19 22:10:37 +01:00
// Totale km
echo '
2018-01-23 16:11:02 +01:00
< tr >
2018-01-19 22:10:37 +01:00
< td class = " text-center " >
2023-12-05 17:43:35 +01:00
< small > '.tr(' Km percorsi ').' :</ small >< br />< b > '.Translator::numberToLocale($documento->km_totali, $d_qta).' </ b >
2018-01-19 22:10:37 +01:00
</ td > ' ;
2018-01-23 16:11:02 +01:00
// Costo trasferta
2018-02-03 13:55:09 +01:00
if ( $options [ 'pricing' ]) {
2018-01-19 22:10:37 +01:00
echo '
< td class = " text-center " >
2023-12-06 10:06:36 +01:00
< small > '.tr(' Costi di trasferta ').' :</ small >< br />< b > '.moneyFormat($sessioni->sum(' prezzo_viaggio '), $d_totali).' </ b >
2018-01-19 22:10:37 +01:00
</ td > ' ;
2018-01-23 16:11:02 +01:00
} else {
2018-01-19 22:10:37 +01:00
echo '
2018-01-23 16:11:02 +01:00
< td class = " text-center " >-</ td > ' ;
}
2018-01-19 22:10:37 +01:00
2018-01-23 16:11:02 +01:00
// Diritto di chiamata
2018-02-03 13:55:09 +01:00
if ( $options [ 'pricing' ]) {
2018-01-23 16:11:02 +01:00
echo '
2020-11-09 19:19:55 +01:00
< td class = " text-center " colspan = " 2 " width = " 120px " >
2023-12-06 10:06:36 +01:00
< small > '.tr(' Diritto di chiamata ').' :</ small >< br />< b > '.moneyFormat($sessioni->sum(' prezzo_diritto_chiamata '), $d_totali).' </ b >
2018-01-23 16:11:02 +01:00
</ td > ' ;
2018-01-19 22:10:37 +01:00
} else {
echo '
2019-07-12 17:35:14 +02:00
< td class = " text-center " colspan = " 2 " >-</ td > ' ;
2018-01-19 22:10:37 +01:00
}
2019-07-12 17:35:14 +02:00
// Calcoli
$imponibile = abs ( $documento -> imponibile );
$sconto = $documento -> sconto ;
$totale_imponibile = abs ( $documento -> totale_imponibile );
$totale_iva = abs ( $documento -> iva );
$totale = abs ( $documento -> totale );
$netto_a_pagare = abs ( $documento -> netto );
$show_sconto = $sconto > 0 ;
2017-08-04 16:28:16 +02:00
// TOTALE COSTI FINALI
2017-09-21 15:51:39 +02:00
if ( $options [ 'pricing' ]) {
2022-09-15 10:56:12 +02:00
// Totale imponibile
echo '
2017-08-04 16:28:16 +02:00
< tr >
2017-09-11 13:08:50 +02:00
< td colspan = " 4 " class = " text-right " >
2017-09-10 14:35:41 +02:00
< b > '.tr(' Imponibile ', [], [' upper ' => true]).' :</ b >
2017-08-04 16:28:16 +02:00
</ td >
2017-09-11 13:08:50 +02:00
< th class = " text-center " >
2023-12-06 10:06:36 +01:00
'.moneyFormat($show_sconto ? $imponibile : $totale_imponibile, $d_totali).'
2017-09-11 13:08:50 +02:00
</ th >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
2018-06-29 13:35:39 +02:00
2022-09-15 10:56:12 +02:00
// Eventuale sconto totale
if ( $show_sconto ) {
echo '
< tr >
< td colspan = " 4 " class = " text-right " >
< b > '.tr(' Sconto ', [], [' upper ' => true]).' :</ b >
</ td >
2017-08-04 16:28:16 +02:00
2022-09-15 10:56:12 +02:00
< th class = " text-center " >
2023-12-06 10:06:36 +01:00
< b > '.moneyFormat($sconto, $d_totali).' </ b >
2022-09-15 10:56:12 +02:00
</ th >
</ tr > ' ;
2017-08-04 16:28:16 +02:00
2022-09-15 10:56:12 +02:00
// Totale imponibile
echo '
< tr >
< td colspan = " 4 " class = " text-right " >
< b > '.tr(' Totale imponibile ', [], [' upper ' => true]).' :</ b >
</ td >
2017-08-04 16:28:16 +02:00
2022-09-15 10:56:12 +02:00
< th class = " text-center " >
2023-12-06 10:06:36 +01:00
< b > '.moneyFormat($totale_imponibile, $d_totali).' </ b >
2022-09-15 10:56:12 +02:00
</ th >
</ tr > ' ;
}
2017-08-04 16:28:16 +02:00
2022-09-15 10:56:12 +02:00
// IVA
// Totale intervento
echo '
2017-08-04 16:28:16 +02:00
< tr >
2017-09-11 13:08:50 +02:00
< td colspan = " 4 " class = " text-right " >
2018-09-05 15:00:19 +02:00
< b > '.tr(' Iva ', [], [' upper ' => true]).' :</ b >
2017-08-04 16:28:16 +02:00
</ td >
2017-09-11 13:08:50 +02:00
< th class = " text-center " >
2023-12-06 10:06:36 +01:00
< b > '.moneyFormat($totale_iva, $d_totali).' </ b >
2017-09-11 13:08:50 +02:00
</ th >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
2022-09-15 10:56:12 +02:00
// TOTALE INTERVENTO
echo '
2017-08-04 16:28:16 +02:00
< tr >
2017-09-11 13:08:50 +02:00
< td colspan = " 4 " class = " text-right " >
2017-09-10 14:35:41 +02:00
< b > '.tr(' Totale intervento ', [], [' upper ' => true]).' :</ b >
2017-08-04 16:28:16 +02:00
</ td >
2017-09-11 13:08:50 +02:00
< th class = " text-center " >
2023-12-06 10:06:36 +01:00
< b > '.moneyFormat($totale, $d_totali).' </ b >
2017-09-11 13:08:50 +02:00
</ th >
</ tr > ' ;
2017-08-04 16:28:16 +02:00
}
2017-09-07 16:51:14 +02:00
echo '
2017-08-04 16:28:16 +02:00
</ table > ' ;
2022-04-04 17:58:46 +02:00
2023-08-04 14:54:28 +02:00
if ( $options [ 'checklist' ]) {
2024-04-22 12:32:48 +02:00
$structure = Module :: find (( new Module ()) -> getByField ( 'title' , 'Attività' , Models\Locale :: getPredefined () -> id ));
2022-04-04 17:58:46 +02:00
$checks = $structure -> mainChecks ( $id_record );
2023-08-04 14:54:28 +02:00
if ( ! empty ( $checks )) {
2022-04-04 17:58:46 +02:00
echo '
< pagebreak class = " page-break-after " />
< table class = " table table-bordered vertical-middle " >
< tr >
< th class = " text-center " colspan = " 2 " style = " font-size:11pt; " >
< b > CHECKLIST </ b >
</ th >
</ tr > ' ;
2024-04-22 12:32:48 +02:00
$structure = Module :: find (( new Module ()) -> getByField ( 'title' , 'Attività' , Models\Locale :: getPredefined () -> id ));
2022-04-04 17:58:46 +02:00
$checks = $structure -> mainChecks ( $id_record );
foreach ( $checks as $check ) {
echo renderChecklistHtml ( $check );
}
2024-04-09 12:18:08 +02:00
$impianti_collegati = $dbo -> fetchArray ( 'SELECT * FROM my_impianti_interventi INNER JOIN my_impianti ON my_impianti_interventi.idimpianto = my_impianti.id WHERE idintervento = ' . prepare ( $id_record ));
foreach ( $impianti_collegati as $impianto ) {
2024-04-22 12:32:48 +02:00
$checks = Check :: where ( 'id_module_from' , ( new Module ()) -> getByField ( 'title' , 'Impianti' , Models\Locale :: getPredefined () -> id )) -> where ( 'id_record_from' , $impianto [ 'id' ]) -> where ( 'id_module' , ( new Module ()) -> getByField ( 'title' , 'Attività' , Models\Locale :: getPredefined () -> id )) -> where ( 'id_record' , $id_record ) -> where ( 'id_parent' , null ) -> get ();
2024-04-09 12:18:08 +02:00
if ( sizeof ( $checks )) {
echo '
2024-04-03 17:21:32 +02:00
< tr >
< th class = " text-center " colspan = " 2 " style = " font-size:11pt; " >
< b > '.tr(' Impianto ', [], [' upper ' => true]).' '.$impianto[' matricola '].' - '.$impianto[' nome '].' </ b >
</ th >
</ tr > ' ;
2024-04-09 12:18:08 +02:00
foreach ( $checks as $check ) {
echo renderChecklistHtml ( $check );
}
2024-04-03 17:21:32 +02:00
}
}
2024-04-09 12:18:08 +02:00
echo '
2022-04-04 17:58:46 +02:00
</ table > ' ;
}
}