2017-09-12 16:17:11 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
2018-03-02 20:34:32 +01:00
$report_name = 'preventivo_' . $records [ 0 ][ 'numero' ] . '.pdf' ;
2017-09-12 16:17:11 +02:00
$autofill = [
'count' => 0 , // Conteggio delle righe
'words' => 70 , // Numero di parolo dopo cui contare una riga nuova
'rows' => 20 , // Numero di righe massimo presente nella pagina
'additional' => 10 , // Numero di righe massimo da aggiungere
'columns' => 5 , // Numero di colonne della tabella
];
echo '
< div class = " row " >
< div class = " col-xs-6 " >
< div class = " text-center " style = " height:5mm; " >
2017-09-21 11:02:31 +02:00
< b > '.tr(' Preventivo num . _NUM_ del _DATE_ ' , [
2017-09-12 16:17:11 +02:00
'_NUM_' => $records [ 0 ][ 'numero' ],
'_DATE_' => Translator :: dateToLocale ( $records [ 0 ][ 'data' ]),
], [ 'upper' => true ]) . ' </ b >
</ div >
</ div >
< div class = " col-xs-5 col-xs-offset-1 " >
< table class = " table " style = " width:100%;margin-top:5mm; " >
< tr >
< td colspan = 2 class = " border-full " style = " height:16mm; " >
< p class = " small-bold " > '.tr(' Spett . le ', [], [' upper ' => true]).' </ p >
< p > $c_ragionesociale $ </ p >
2018-08-08 19:00:19 +02:00
< p > $c_indirizzo $ </ p >
< p > $c_citta_full $ </ p >
2017-09-12 16:17:11 +02:00
</ td >
</ tr >
< tr >
< td class = " border-bottom border-left " >
< p class = " small-bold " > '.tr(' Partita IVA ', [], [' upper ' => true]).' </ p >
</ td >
< td class = " border-right border-bottom text-right " >
< small > $c_piva $ </ small >
</ td >
</ tr >
< tr >
< td class = " border-bottom border-left " >
< p class = " small-bold " > '.tr(' Codice fiscale ', [], [' upper ' => true]).' </ p >
</ td >
< td class = " border-right border-bottom text-right " >
< small > $c_codicefiscale $ </ small >
</ td >
</ tr >
</ table >
</ div >
</ div > ' ;
// Descrizione
if ( ! empty ( $records [ 0 ][ 'descrizione' ])) {
echo '
< p > '.nl2br($records[0][' descrizione ']).' </ p >
< br > ' ;
}
$sconto = [];
$imponibile = [];
$iva = [];
// Intestazione tabella per righe
echo "
2017-09-12 16:45:18 +02:00
< table class = 'table table-striped table-bordered' id = 'contents' >
2017-09-12 16:17:11 +02:00
< thead >
< tr >
< th class = 'text-center' style = 'width:50%' > " .tr('Descrizione', [], ['upper' => true]). " </ th >
< th class = 'text-center' style = 'width:10%' > " .tr('Q.tà', [], ['upper' => true]). " </ th >
2017-09-12 16:45:18 +02:00
< th class = 'text-center' style = 'width:15%' > " .tr('Prezzo unitario', [], ['upper' => true]). " </ th >
2017-09-12 16:17:11 +02:00
< th class = 'text-center' style = 'width:15%' > " .tr('Imponibile', [], ['upper' => true]). " </ th >
< th class = 'text-center' style = 'width:10%' > " .tr('IVA', [], ['upper' => true]).' (%)</th>
</ tr >
</ thead >
< tbody > ' ;
// RIGHE PREVENTIVO CON ORDINAMENTO UNICO
2019-01-10 15:19:17 +01:00
$righe = $dbo -> fetchArray ( " SELECT *, IFNULL((SELECT codice FROM mg_articoli WHERE id=idarticolo),'') AS codice_articolo, (SELECT percentuale FROM co_iva WHERE id=idiva) AS perc_iva FROM `co_righe_preventivi` WHERE idpreventivo= " . prepare ( $id_record ) . ' ORDER BY `order`' );
2017-09-12 16:17:11 +02:00
foreach ( $righe as $r ) {
$count = 0 ;
$count += ceil ( strlen ( $r [ 'descrizione' ]) / $autofill [ 'words' ]);
$count += substr_count ( $r [ 'descrizione' ], PHP_EOL );
echo '
< tr >
< td >
'.nl2br($r[' descrizione ' ]);
if ( ! empty ( $r [ 'codice_articolo' ])) {
echo '
< br >< small > '.tr(' COD . _COD_ ' , [
'_COD_' => $r [ 'codice_articolo' ],
]) . '</small>' ;
if ( $count <= 1 ) {
$count += 0.4 ;
}
}
echo '
</ td > ' ;
echo "
2018-01-18 19:03:06 +01:00
< td class = 'text-center' > " ;
2018-02-17 09:02:19 +01:00
if ( empty ( $r [ 'is_descrizione' ])) {
echo '
2018-06-29 13:35:39 +02:00
'.(empty($r[' qta ']) ? ' ' : Translator::numberToLocale($r[' qta '], ' qta ')).' '.$r[' um ' ];
2018-01-18 19:03:06 +01:00
}
echo '
2017-09-12 16:17:11 +02:00
</ td > ' ;
2017-09-21 15:51:39 +02:00
if ( $options [ 'pricing' ]) {
2017-09-12 17:46:19 +02:00
// Prezzo unitario
echo "
2018-01-18 19:03:06 +01:00
< td class = 'text-right' > " ;
2018-02-17 09:02:19 +01:00
if ( empty ( $r [ 'is_descrizione' ])) {
echo '
'.(empty($r[' qta ']) || empty($r[' subtotale ']) ? ' ' : Translator::numberToLocale($r[' subtotale '] / $r[' qta '])).' & euro ; ' ;
2018-01-18 19:03:06 +01:00
if ( $r [ 'sconto' ] > 0 ) {
echo "
2018-02-17 09:02:19 +01:00
< br >< small class = 'text-muted' >- " .tr('sconto _TOT_ _TYPE_', [
'_TOT_' => Translator :: numberToLocale ( $r [ 'sconto_unitario' ]),
'_TYPE_' => ( $r [ 'tipo_sconto' ] == 'PRC' ? '%' : '€' ),
]) . '</small>' ;
2018-01-18 19:03:06 +01:00
if ( $count <= 1 ) {
$count += 0.4 ;
}
2017-09-21 10:01:07 +02:00
}
}
echo '
2017-09-12 16:17:11 +02:00
</ td > ' ;
2017-09-12 17:46:19 +02:00
// Imponibile
echo "
2018-01-18 19:03:06 +01:00
< td class = 'text-right' > " ;
2018-02-17 09:02:19 +01:00
if ( empty ( $r [ 'is_descrizione' ])) {
echo '
'.(empty($r[' subtotale ']) ? ' ' : Translator::numberToLocale($r[' subtotale '])).' & euro ; ' ;
2018-02-16 00:50:29 +01:00
2018-01-18 19:03:06 +01:00
if ( $r [ 'sconto' ] > 0 ) {
echo "
2018-02-17 09:02:19 +01:00
< br >< small class = 'text-muted' >- " .tr('sconto _TOT_ _TYPE_', [
'_TOT_' => Translator :: numberToLocale ( $r [ 'sconto' ]),
'_TYPE_' => '€' ,
]) . '</small>' ;
2017-09-12 16:17:11 +02:00
2018-01-18 19:03:06 +01:00
if ( $count <= 1 ) {
$count += 0.4 ;
}
2017-09-12 17:46:19 +02:00
}
2017-09-12 16:17:11 +02:00
}
2017-09-12 17:46:19 +02:00
echo '
2017-09-12 16:17:11 +02:00
</ td > ' ;
2017-09-12 17:46:19 +02:00
} else {
echo '
< td class = " text-center " >-</ td >
< td class = " text-center " >-</ td > ' ;
}
2017-09-12 16:17:11 +02:00
// Iva
echo '
2018-01-18 19:03:06 +01:00
< td class = " text-center " > ' ;
2018-02-17 09:02:19 +01:00
if ( empty ( $r [ 'is_descrizione' ])) {
echo '
'.Translator::numberToLocale($r[' perc_iva ' ]);
2018-01-18 19:03:06 +01:00
}
echo '
2017-09-12 16:17:11 +02:00
</ td >
</ tr > ' ;
$autofill [ 'count' ] += $count ;
$sconto [] = $r [ 'sconto' ];
$imponibile [] = $r [ 'subtotale' ];
$iva [] = $r [ 'iva' ];
}
$sconto = sum ( $sconto );
$imponibile = sum ( $imponibile );
2018-08-08 19:00:19 +02:00
$iva = sum ( $iva );
2017-09-12 16:17:11 +02:00
$totale = $imponibile - $sconto ;
echo '
| autofill |
</ tbody > ' ;
// TOTALE COSTI FINALI
2019-03-14 19:45:11 +01:00
if ( $options [ 'pricing' ] and ! isset ( $options [ 'hide_total' ]) ) {
2017-09-12 16:17:11 +02:00
// Totale imponibile
echo '
< tr >
< td colspan = " 3 " class = " text-right border-top " >
< b > '.tr(' Imponibile ', [], [' upper ' => true]).' :</ b >
</ td >
< th colspan = " 2 " class = " text-center " >
2017-09-21 10:01:07 +02:00
< b > '.Translator::numberToLocale($imponibile).' & euro ; </ b >
2017-09-12 16:17:11 +02:00
</ th >
</ tr > ' ;
// Eventuale sconto incondizionato
if ( ! empty ( $sconto )) {
echo '
< tr >
< td colspan = " 3 " class = " text-right border-top " >
< b > '.tr(' Sconto ', [], [' upper ' => true]).' :</ b >
</ td >
< th colspan = " 2 " class = " text-center " >
2017-09-21 10:01:07 +02:00
< b >- '.Translator::numberToLocale($sconto).' & euro ; </ b >
2017-09-12 16:17:11 +02:00
</ th >
</ tr > ' ;
// Imponibile scontato
echo '
< tr >
< td colspan = " 3 " class = " text-right border-top " >
< b > '.tr(' Imponibile scontato ', [], [' upper ' => true]).' :</ b >
</ td >
< th colspan = " 2 " class = " text-center " >
2017-09-21 10:01:07 +02:00
< b > '.Translator::numberToLocale($totale).' & euro ; </ b >
2017-09-12 16:17:11 +02:00
</ th >
</ tr > ' ;
}
// IVA
echo '
< tr >
< td colspan = " 3 " class = " text-right border-top " >
< b > '.tr(' Totale IVA ', [], [' upper ' => true]).' :</ b >
</ td >
< th colspan = " 2 " class = " text-center " >
2017-09-21 10:01:07 +02:00
< b > '.Translator::numberToLocale($iva).' & euro ; </ b >
2017-09-12 16:17:11 +02:00
</ th >
</ tr > ' ;
$totale = sum ( $totale , $iva );
2017-09-12 17:46:19 +02:00
// TOTALE
2017-09-12 16:17:11 +02:00
echo '
< tr >
< td colspan = " 3 " class = " text-right border-top " >
< b > '.tr(' Quotazione totale ', [], [' upper ' => true]).' :</ b >
</ td >
< th colspan = " 2 " class = " text-center " >
2017-09-21 10:01:07 +02:00
< b > '.Translator::numberToLocale($totale).' & euro ; </ b >
2017-09-12 16:17:11 +02:00
</ th >
</ tr > ' ;
}
echo '
</ table > ' ;
// CONDIZIONI GENERALI DI FORNITURA
// Lettura pagamenti
2017-09-12 17:46:19 +02:00
$rs = $dbo -> fetchArray ( 'SELECT * FROM co_pagamenti WHERE id = ' . $records [ 0 ][ 'idpagamento' ]);
2017-09-12 16:17:11 +02:00
$pagamento = $rs [ 0 ][ 'descrizione' ];
// Lettura resa
2018-08-08 19:00:19 +02:00
//$rs = $dbo->fetchArray('SELECT * FROM dt_porto WHERE id = '.$records[0]['idporto']);
//$resa_materiale = $rs[0]['descrizione'];
2017-09-12 16:17:11 +02:00
echo '
< table class = " table table-bordered " >
< tr >
2017-09-13 11:15:31 +02:00
< th colspan = " 2 " class = " text-center " style = " font-size:13pt; " >
2017-09-12 16:17:11 +02:00
'.tr(' Condizioni generali di fornitura ', [], [' upper ' => true]).'
</ th >
</ tr >
< tr >
< th style = " width:25% " >
'.tr(' Pagamento ', [], [' upper ' => true]).'
</ th >
< td >
'.$pagamento.'
</ td >
</ tr >
2018-08-08 19:00:19 +02:00
<!-- tr >
2017-09-12 16:17:11 +02:00
< th >
'.tr(' Resa materiale ', [], [' upper ' => true]).'
</ th >
< td >
'.$resa_materiale.'
</ td >
2018-08-08 19:00:19 +02:00
</ tr -->
2017-09-12 16:17:11 +02:00
< tr >
< th >
'.tr(' Validità offerta ', [], [' upper ' => true]).'
</ th >
2017-09-13 13:05:35 +02:00
< td > ' ;
if ( ! empty ( $records [ 0 ][ 'validita' ])) {
echo '
2017-09-12 16:17:11 +02:00
'.tr(' _TOT_ giorni ' , [
'_TOT_' => $records [ 0 ][ 'validita' ],
2017-09-13 13:05:35 +02:00
]);
} else {
echo '-' ;
}
echo '
2017-09-12 16:17:11 +02:00
</ td >
</ tr >
< tr >
< th >
'.tr(' Tempi consegna ', [], [' upper ' => true]).'
</ th >
< td >
'.$records[0][' tempi_consegna '].'
</ td >
</ tr >
< tr >
< th >
'.tr(' Esclusioni ', [], [' upper ' => true]).'
</ th >
< td >
'.nl2br($records[0][' esclusioni ']).'
</ td >
</ tr >
</ table > ' ;
// Conclusione
echo '
< p class = " text-center " > '.tr("In attesa di un Vostro Cortese riscontro, colgo l' occasione per porgere Cordiali Saluti " ).'</p>';
2018-02-20 12:05:10 +01:00
//Firma
echo '<div style=\'position:absolute; bottom:' . ( $settings [ 'margins' ][ 'bottom' ] + $settings [ 'footer-height' ]) . ' px\ ' > < table >
< tr >
< td style = " vertical-align:bottom; " width = " 50% " >
lì , ___________________________
</ td >
< td align = " center " style = " vertical-align:bottom; " width = " 50% " >
FIRMA PER ACCETTAZIONE < br >< br >
2018-02-20 16:42:59 +01:00
_____________________________________________
2018-02-20 12:05:10 +01:00
</ td >
</ tr >
</ table >
2018-03-02 20:34:32 +01:00
< br ></ div > ' ;