2017-08-04 16:28:16 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
include_once $docroot . '/modules/interventi/modutil.php' ;
2017-09-07 16:51:14 +02:00
$report_name = 'intervento_' . $idintervento . '.pdf' ;
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 >
2017-09-11 13:08:50 +02:00
< th colspan = " 4 " style = " font-size:14pt; " class = " text-center " > '.tr(' Rapporto operazioni e interventi ', [], [' upper ' => true]).' </ th >
2017-09-08 18:19:39 +02:00
</ tr >
2017-08-04 16:28:16 +02:00
< tr >
2017-09-11 13:08:50 +02:00
< td class = " text-center " style = " width:40% " > '.tr(' Intervento numero ').' : < b > '.$records[0][' codice '].' </ b ></ td >
< td class = " text-center " style = " width:20% " > '.tr(' Data ').' : < b > '.Translator::dateToLocale($records[0][' data_richiesta ']).' </ b ></ td >
< td class = " text-center " style = " width:20% " > '.tr(' Preventivo N < sup > o </ sup > ').' : < b > '.$records[0][' numero_preventivo '].' </ b ></ td >
< td class = " text-center " style = " width:20% " > '.tr(' Contratto N < sup > o </ sup > ').' : < b > '.$records[0][' numero_contratto '].' </ b ></ td >
2017-09-08 18:19:39 +02:00
</ tr > ' ;
2017-09-11 13:08:50 +02:00
// Dati cliente
2017-09-08 18:19:39 +02:00
echo '
< tr >
< td colspan = 3 >
2017-09-11 13:08:50 +02:00
'.tr(' Cliente ').' : < b > '.$c_ragionesociale.' </ b >
2017-09-08 18:19:39 +02:00
</ td > ' ;
2017-09-11 13:08:50 +02:00
// Codice fiscale
2017-09-08 18:19:39 +02:00
echo '
< td >
2017-09-11 13:08:50 +02:00
'.tr(' P . Iva ').' : < b > '.strtoupper($c_piva).' </ b >
2017-08-04 16:28:16 +02:00
</ td >
2017-09-08 18:19:39 +02:00
</ tr > ' ;
2017-09-11 13:08:50 +02:00
// riga 2
2017-09-08 18:19:39 +02:00
echo '
< tr >
< td colspan = " 4 " >
2017-09-11 13:08:50 +02:00
'.tr(' Via ').' : < b > '.$c_indirizzo.' </ b > -
'.tr(' CAP ').' : < b > '.$c_cap.' </ b > -
'.tr(' Comune ').' : < b > '.$c_citta.' ( '.strtoupper($c_provincia).' ) </ b >
2017-08-04 16:28:16 +02:00
</ td >
</ tr > ' ;
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 > ' ;
2017-09-08 18:19:39 +02:00
if ( ! empty ( $c_cellulare )) {
2017-09-11 13:08:50 +02:00
echo ' - ' . tr ( 'Cellulare' ) . ': <b>' . $c_cellulare . '</b>' ;
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-08 18:19: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 ( $idintervento ));
$impianti = [];
for ( $j = 0 ; $j < sizeof ( $rs2 ); ++ $j ) {
$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 > ' ;
2017-09-11 13:08:50 +02:00
// Richiesta
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 >
2017-09-08 18:19:39 +02:00
< p > '.nl2br($records[0][' richiesta ']).' </ p >
</ td >
</ tr > ' ;
2017-09-11 13:08:50 +02:00
// Descrizione
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 >
< p > '.nl2br($records[0][' descrizione_intervento ']).' </ p >
</ 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 > ' ;
$totale = [];
// MATERIALE UTILIZZATO
2017-09-11 13:08:50 +02:00
$rs2 = $dbo -> fetchArray ( 'SELECT *, (SELECT codice FROM mg_articoli WHERE id=idarticolo) AS codice_art FROM `mg_articoli_interventi` WHERE idintervento=' . prepare ( $idintervento ) . " AND NOT idarticolo='0' ORDER BY idarticolo ASC " );
2017-08-04 16:28:16 +02:00
if ( ! empty ( $rs2 )) {
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 " >
< b > '.tr(' Materiale utilizzato ', [], [' upper ' => true]).' </ b >
</ th >
</ tr >
< tr >
< th style = " font-size:8pt;width:20% " class = " text-center " >
< b > '.tr(' Codice ').' </ b >
</ th >
< 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 ').' </ b >
</ th >
</ tr >
</ thead >
< tbody > ' ;
2017-08-04 16:28:16 +02:00
foreach ( $rs2 as $r ) {
2017-09-07 16:51:14 +02:00
echo '
2017-09-11 13:08:50 +02:00
< tr > ' ;
2017-08-04 16:28:16 +02:00
// Codice
2017-09-07 16:51:14 +02:00
echo '
2017-09-11 13:08:50 +02:00
< td >
'.$r[' codice_art '].'
</ td > ' ;
2017-08-04 16:28:16 +02:00
// Descrizione
2017-09-07 16:51:14 +02:00
echo '
2017-09-11 13:08:50 +02:00
< td >
'.$r[' descrizione '].'
</ 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 " >
'.Translator::numberToLocale($r[' qta '], 2).' '.$r[' um '].'
</ td > ' ;
2017-08-04 16:28:16 +02:00
// Netto
2017-09-11 13:08:50 +02:00
$netto = $r [ 'prezzo_vendita' ] * $r [ 'qta' ] - $r [ 'sconto' ];
2017-09-07 16:51:14 +02:00
echo '
2017-09-11 13:08:50 +02:00
< td class = " text-center " >
'.($visualizza_costi ? Translator::numberToLocale($netto, 2) : ' - ').'
</ td >
</ tr > ' ;
2017-08-04 16:28:16 +02:00
}
2017-09-11 13:08:50 +02:00
echo '
</ tbody > ' ;
2017-08-04 16:28:16 +02:00
// Totale spesa articoli
if ( $visualizza_costi ) {
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 = " 2 " class = " text-right " >
2017-09-10 14:35:41 +02:00
< b > '.tr(' Totale materiale utilizzato ', [], [' upper ' => true]).' :</ b >
2017-08-04 16:28:16 +02:00
</ td >
2017-09-11 13:08:50 +02:00
< th colspan = " 2 " class = " text-center " >
< b > '.Translator::numberToLocale($costi_intervento[' ricambi_scontato '], 2).' & euro ; </ b >
</ 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 > ' ;
}
// FINE MATERIALE UTILIZZATO
// Conteggio SPESE AGGIUNTIVE
$rs2 = $dbo -> fetchArray ( 'SELECT * FROM in_righe_interventi WHERE idintervento=' . prepare ( $idintervento ) . ' ORDER BY id ASC' );
if ( ! empty ( $rs2 )) {
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 " >
< b > '.tr(' Spese aggiuntive ', [], [' upper ' => true]).' </ b >
</ 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 " >
< b > '.tr(' Subtot . ').' </ b >
</ th >
</ tr >
</ thead >
< tbody > ' ;
2017-08-04 16:28:16 +02:00
foreach ( $rs2 as $r ) {
// Articolo
2017-09-07 16:51:14 +02:00
echo '
2017-08-04 16:28:16 +02:00
< tr >
< td >
'.nl2br($r[' descrizione ']).'
</ td > ' ;
// Quantità
2017-09-07 16:51:14 +02:00
echo '
2017-09-11 13:08:50 +02:00
< td class = " text-center " >
2017-08-04 16:28:16 +02:00
'.Translator::numberToLocale($r[' qta '], 2).'
</ td > ' ;
// Prezzo unitario
2017-09-07 16:51:14 +02:00
echo '
2017-09-11 13:08:50 +02:00
< td class = " text-center " >
2017-08-04 16:28:16 +02:00
'.($visualizza_costi ? Translator::numberToLocale($r[' prezzo_vendita '], 2).' & euro ; ' : ' - ').'
</ td > ' ;
// Prezzo totale
2017-09-11 13:08:50 +02:00
$netto = $r [ 'prezzo_vendita' ] * $r [ 'qta' ] - $r [ 'sconto' ];
2017-09-07 16:51:14 +02:00
echo '
2017-09-11 13:08:50 +02:00
< td class = " text-center " >
2017-08-04 16:28:16 +02:00
'.($visualizza_costi ? Translator::numberToLocale($netto, 2) : ' - ').'
</ td >
</ tr > ' ;
}
2017-09-11 13:08:50 +02:00
echo '
</ tbody > ' ;
2017-08-04 16:28:16 +02:00
if ( $visualizza_costi ) {
// 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 " >
2017-09-10 14:35:41 +02:00
< b > '.tr(' Totale spese aggiuntive ', [], [' upper ' => true]).' :</ b >
2017-08-04 16:28:16 +02:00
</ td >
2017-09-11 13:08:50 +02:00
< th class = " text-center " >
< b > '.Translator::numberToLocale($costi_intervento[' altro_scontato '], 2).' & euro ; </ b >
</ 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 > ' ;
}
// FINE SPESE AGGIUNTIVE
// INTESTAZIONE ELENCO TECNICI
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 class = " text-center " colspan = " 5 " style = " font-size:11pt; " >
< b > '.tr(' Ore tecnici ', [], [' upper ' => true]).' </ b >
</ th >
</ tr >
< tr >
< th class = " text-center " style = " font-size:8pt;width:30% " >
< b > '.tr(' Tecnico ').' </ b >
</ th >
< th class = " text-center " style = " font-size:8pt;width:15% " >
< b > '.tr(' Data ').' </ b >
</ th >
< th class = " text-center " style = " font-size:8pt;width:10% " >
< b > '.tr(' Dalle ').' </ b >
</ th >
< th class = " text-center " style = " font-size:8pt;width:10% " >
< b > '.tr(' Alle ').' </ b >
</ th >
< td class = " text-center " style = " font-size:6pt;width:35% " >
'.tr(' I dati del ricevente verrano trattati in base al D . lgs n . 196 / 2003 ').'
</ td >
</ tr >
</ thead >
< tbody > ' ;
2017-08-04 16:28:16 +02:00
// Sessioni di lavoro dei tecnici
$rst = $dbo -> fetchArray ( 'SELECT an_anagrafiche.*, in_interventi_tecnici.* FROM in_interventi_tecnici JOIN an_anagrafiche ON in_interventi_tecnici.idtecnico=an_anagrafiche.idanagrafica WHERE in_interventi_tecnici.idintervento=' . prepare ( $idintervento ) . ' ORDER BY in_interventi_tecnici.orario_inizio' );
2017-09-11 13:08:50 +02:00
foreach ( $rst as $i => $r ) {
2017-09-07 16:51:14 +02:00
echo '
2017-08-04 16:28:16 +02:00
< tr > ' ;
// nome tecnico
2017-09-07 16:51:14 +02:00
echo '
2017-09-11 13:08:50 +02:00
< td style = " vertical-align:middle " >
2017-08-04 16:28:16 +02:00
'.$r[' ragione_sociale '].'
</ td > ' ;
// data
2017-09-07 16:51:14 +02:00
echo '
2017-09-11 13:08:50 +02:00
< td class = " text-center " style = " vertical-align:middle " >
2017-08-04 16:28:16 +02:00
'.Translator::dateToLocale($r[' orario_inizio '], ' - ').'
</ td > ' ;
// ora inizio
2017-09-07 16:51:14 +02:00
echo '
2017-09-11 13:08:50 +02:00
< td class = " text-center " style = " vertical-align:middle " >
2017-08-04 16:28:16 +02:00
'.Translator::timeToLocale($r[' orario_inizio '], ' - ').'
</ td > ' ;
// ora fine
2017-09-07 16:51:14 +02:00
echo '
2017-09-11 13:08:50 +02:00
< td class = " text-center " style = " vertical-align:middle " >
2017-08-04 16:28:16 +02:00
'.Translator::timeToLocale($r[' orario_fine '], ' - ').'
2017-09-11 13:08:50 +02:00
</ td > ' ;
// Spazio aggiuntivo
if ( $i == 0 ) {
echo '
< td class = " text-center " style = " font-size:8pt; " >
'.tr(' Si dichiara che i lavori sono stati eseguiti ed i materiali installati ').'
</ 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-07 16:51:14 +02:00
echo '
2017-09-11 13:08:50 +02:00
< tr > ' ;
2017-08-04 16:28:16 +02:00
2017-09-11 13:08:50 +02:00
// Ore lavorate
if ( $visualizza_costi ) {
$ore = get_ore_intervento ( $idintervento );
2017-08-04 16:28:16 +02:00
2017-09-11 13:08:50 +02:00
$costo_orario = $records [ 0 ][ 'tot_ore_consuntivo' ] - $records [ 0 ][ 'tot_dirittochiamata' ];
2017-08-04 16:28:16 +02:00
2017-09-11 13:08:50 +02:00
if ( $ore > 0 ) {
$costo_orario /= $ore ;
}
2017-08-04 16:28:16 +02:00
2017-09-07 16:51:14 +02:00
echo '
2017-09-11 13:08:50 +02:00
< td class = " text-center " style = " vertical-align:middle " >
'.tr(' Ore lavorate ').' :< br />< b > '.Translator::numberToLocale($ore, 2).' </ b >
2017-08-04 16:28:16 +02:00
</ td > ' ;
2017-09-11 13:08:50 +02:00
// Costo orario
2017-09-07 16:51:14 +02:00
echo '
2017-09-11 13:08:50 +02:00
< td class = " text-center " style = " vertical-align:middle " >
'.tr(' Costo orario ').' :< br />< b > '.Translator::numberToLocale($costo_orario, 2).' </ b > ' ;
2017-08-04 16:28:16 +02:00
2017-09-11 13:08:50 +02:00
if ( $records [ 0 ][ 'tot_dirittochiamata' ] != 0 ) {
echo '
< small > + '.Translator::numberToLocale($records[0][' tot_dirittochiamata '], 2).' d . c .</ small > ' ;
}
2017-08-04 16:28:16 +02:00
2017-09-11 13:08:50 +02:00
echo '
2017-08-04 16:28:16 +02:00
</ td > ' ;
2017-09-11 13:08:50 +02:00
// Costo totale manodopera
echo '
< td colspan = " 2 " class = " text-center " style = " vertical-align:middle " >
'.tr(' Manodopera ').' :< br />< b > '.Translator::numberToLocale($costi_intervento[' manodopera_scontato '], 2).' </ 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 '
2017-09-11 13:08:50 +02:00
< td colspan = " 4 " ></ td > ' ;
2017-08-04 16:28:16 +02:00
}
2017-09-11 13:08:50 +02:00
// Timbro e firma
$firma = ! empty ( $records [ 0 ][ 'firma_file' ]) ? '<img src="' . $docroot . '/files/interventi/' . $records [ 0 ][ 'firma_file' ] . '" style="width:70mm;">' : '' ;
echo '
< td class = " text-center " style = " font-size:8pt;height:30mm;vertical-align:bottom " >
'.$firma.' < br >
< i > ( '.tr(' Timbro e firma leggibile ').' . ) </ i >
2017-08-04 16:28:16 +02:00
</ td >
</ tr > ' ;
// TOTALE COSTI FINALI
if ( $visualizza_costi ) {
// Totale imponibile
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 = " 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 " >
< b > '.Translator::numberToLocale($costi_intervento[' totale_scontato '], 2).' & euro ; </ b >
</ th >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
// Eventuale sconto incondizionato
2017-09-11 13:08:50 +02:00
if ( ! empty ( $costi_intervento [ 'sconto_globale' ])) {
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 = " 4 " class = " text-right " >
2017-09-10 14:35:41 +02:00
< b > '.tr(' Sconto incondizionato ', [], [' upper ' => true]).' :</ b >
2017-08-04 16:28:16 +02:00
</ td >
2017-09-11 13:08:50 +02:00
< th class = " text-center " >
< b >- '.Translator::numberToLocale($costi_intervento[' sconto_globale '], 2).' & euro ; </ b >
</ th >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
// Imponibile scontato
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 = " 4 " class = " text-right " >
2017-09-10 14:35:41 +02:00
< b > '.tr(' Imponibile scontato ', [], [' upper ' => true]).' :</ b >
2017-08-04 16:28:16 +02:00
</ td >
2017-09-11 13:08:50 +02:00
< th class = " text-center " >
< b > '.Translator::numberToLocale($costi_intervento[' totale '], 2).' & euro ; </ b >
</ th >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
}
// Leggo iva da applicare
2017-09-11 13:08:50 +02:00
$rs1 = $dbo -> fetchArray ( 'SELECT percentuale FROM co_iva WHERE id=' . prepare ( get_var ( 'Iva predefinita' )));
2017-08-04 16:28:16 +02:00
$percentuale_iva = $rs1 [ 0 ][ 'percentuale' ];
2017-09-11 13:08:50 +02:00
$iva = ( $costi_intervento [ 'totale' ] / 100 * $percentuale_iva );
2017-08-04 16:28:16 +02:00
// IVA
// Totale intervento
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 = " 4 " class = " text-right " >
2017-09-10 14:35:41 +02:00
< b > '.tr(' Iva ( _PRC_ % ) ' , [
'_PRC_' => Translator :: numberToLocale ( $percentuale_iva , 0 ),
], [ 'upper' => true ]) . ' :</ b >
2017-08-04 16:28:16 +02:00
</ td >
2017-09-11 13:08:50 +02:00
< th class = " text-center " >
2017-08-04 16:28:16 +02:00
< b > '.Translator::numberToLocale($iva, 2).' & euro ; </ b >
2017-09-11 13:08:50 +02:00
</ th >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
2017-09-11 13:08:50 +02:00
$totale = sum ( $costi_intervento [ 'totale' ], $iva );
2017-08-04 16:28:16 +02:00
// TOTALE INTERVENTO
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 = " 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 " >
2017-08-04 16:28:16 +02:00
< b > '.Translator::numberToLocale($totale, 2).' & euro ; </ 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 > ' ;