2017-09-07 16:51:14 +02:00
< ? php
2019-07-11 18:10:38 +02:00
// Calcoli
2019-07-12 17:35:14 +02:00
$imponibile = abs ( $documento -> imponibile );
2019-07-12 12:40:13 +02:00
$sconto = $documento -> sconto ;
2019-07-12 17:35:14 +02:00
$totale_imponibile = abs ( $documento -> totale_imponibile );
$totale_iva = abs ( $documento -> iva );
$totale = abs ( $documento -> totale );
$netto_a_pagare = abs ( $documento -> netto );
2019-07-11 18:10:38 +02:00
$show_sconto = $sconto > 0 ;
2019-07-12 17:35:14 +02:00
2019-07-16 10:34:51 +02:00
$volume = $righe -> sum ( function ( $item ) {
return $item -> isArticolo () ? $item -> articolo -> volume : 0 ;
});
$peso_lordo = $righe -> sum ( function ( $item ) {
return $item -> isArticolo () ? $item -> articolo -> peso_lordo : 0 ;
});
2019-07-11 18:10:38 +02:00
$width = round ( 100 / ( $show_sconto ? 5 : 3 ), 2 );
2017-09-07 16:51:14 +02:00
// SCADENZE | TOTALI
// TABELLA PRINCIPALE
echo "
2017-09-13 11:15:31 +02:00
< table class = 'table-bordered' >
2017-09-07 16:51:14 +02:00
< tr >
2019-07-11 18:10:38 +02:00
< td colspan = " .( $show_sconto ? 5 : 3). " class = 'cell-padded' style = 'height:".($record[' ritenutaacconto '] != 0 ? 20 : 30)."mm' > " ;
2017-09-07 16:51:14 +02:00
// Tabella (scadenze + iva)
echo "
2017-09-13 11:15:31 +02:00
< table class = 'table-normal' >
2017-09-07 16:51:14 +02:00
< tr >
2017-09-13 11:15:31 +02:00
< td style = 'width:10mm;' >& nbsp ; </ td >
2017-09-07 16:51:14 +02:00
< td style = 'width:45mm;' >
2017-09-13 11:15:31 +02:00
< table class = 'border-bottom' >
2017-09-07 16:51:14 +02:00
< tr >
2017-09-13 11:15:31 +02:00
< td colspan = '2' >
2017-09-10 14:35:41 +02:00
< p class = 'small-bold' > " .tr('Scadenze pagamenti', [], ['upper' => true]).'</p>
2017-09-07 16:51:14 +02:00
</ td >
</ tr > ' ;
// Elenco scadenze
2017-09-21 15:51:39 +02:00
$rs2 = $dbo -> fetchArray ( 'SELECT * FROM co_scadenziario WHERE iddocumento=' . prepare ( $id_record ) . ' ORDER BY `data_emissione` ASC' );
2017-09-07 16:51:14 +02:00
if ( ! empty ( $rs2 )) {
for ( $i = 0 ; $i < sizeof ( $rs2 ); ++ $i ) {
echo "
< tr >
2017-09-13 11:15:31 +02:00
< td style = 'width:50%;' >
2017-09-07 16:51:14 +02:00
< small > " .Translator::dateToLocale( $rs2[$i] ['scadenza']). " </ small >
</ td >
2017-09-13 11:15:31 +02:00
< td style = 'width:50%;' class = 'text-right' >
2019-05-02 10:03:57 +02:00
< small > " .moneyFormat( $rs2[$i] ['da_pagare'], 2).'</small>
2017-09-07 16:51:14 +02:00
</ td >
</ tr > ' ;
}
}
2017-09-13 11:15:31 +02:00
2017-09-07 16:51:14 +02:00
echo '
</ table >
</ td > ' ;
// Fine elenco scadenze
// Separatore
echo "
< td style = 'width:10mm;' >& nbsp ; </ td > " ;
// Tabella iva
echo "
< td style = 'width:75mm;' > " ;
if ( ! empty ( $v_iva )) {
echo "
2017-09-13 11:15:31 +02:00
< table class = 'border-bottom' >
2017-09-07 16:51:14 +02:00
< tr >
2017-09-13 11:15:31 +02:00
< td style = 'width:40mm;' >
2017-09-10 14:35:41 +02:00
< p class = 'small-bold' > " .tr('Aliquota IVA', [], ['upper' => true]). " </ p >
2017-09-07 16:51:14 +02:00
</ td >
2017-09-13 11:15:31 +02:00
< td style = 'width:20mm;' class = 'text-center' >
2017-09-10 14:35:41 +02:00
< p class = 'small-bold' > " .tr('Importo', [], ['upper' => true]). " </ p >
2017-09-07 16:51:14 +02:00
</ td >
2017-09-13 11:15:31 +02:00
< td style = 'width:20mm;' class = 'text-center' >
2017-09-10 14:35:41 +02:00
< p class = 'small-bold' > " .tr('Importo IVA', [], ['upper' => true]).'</p>
2017-09-07 16:51:14 +02:00
</ td >
</ tr > ' ;
foreach ( $v_iva as $desc_iva => $tot_iva ) {
if ( ! empty ( $desc_iva )) {
2017-09-13 11:15:31 +02:00
echo '
2017-09-07 16:51:14 +02:00
< tr >
2017-09-13 11:15:31 +02:00
< td >
< small > ' . $desc_iva . " </small>
2017-09-07 16:51:14 +02:00
</ td >
2017-09-13 11:15:31 +02:00
< td class = 'text-right' >
2019-05-02 10:03:57 +02:00
< small > " .moneyFormat( $v_totale[$desc_iva] , 2). " </ small >
2017-09-07 16:51:14 +02:00
</ td >
2017-09-13 11:15:31 +02:00
< td class = 'text-right' >
2019-05-02 10:03:57 +02:00
< small > " .moneyFormat( $v_iva[$desc_iva] , 2).'</small>
2017-09-07 16:51:14 +02:00
</ td >
</ tr > ' ;
}
}
echo '
</ table > ' ;
}
echo '
</ td >
2019-07-11 18:10:38 +02:00
< td style = " width:10mm; " >& nbsp ; </ td >
2017-09-07 16:51:14 +02:00
</ tr > ' ;
// Fine tabelle iva
echo '
</ table > ' ;
// Fine tabella (scadenze + iva)
echo '
</ td > ' ;
2017-09-13 11:15:31 +02:00
// TOTALI
2017-09-07 16:51:14 +02:00
echo "
2017-09-13 11:15:31 +02:00
< tr >
< th class = 'text-center small' style = 'width:".$width."' >
2017-09-21 16:42:27 +02:00
" .tr('Imponibile', [], ['upper' => true]).'
</ th > ' ;
2017-09-13 11:15:31 +02:00
2019-07-11 18:10:38 +02:00
if ( $show_sconto ) {
2017-09-21 16:42:27 +02:00
echo "
2017-09-13 11:15:31 +02:00
< th class = 'text-center small' style = 'width:".$width."' >
" .tr('Sconto', [], ['upper' => true]). "
</ th >
< th class = 'text-center small' style = 'width:".$width."' >
2019-07-11 17:44:42 +02:00
" .tr('Totale imponibile', [], ['upper' => true]).'
2017-09-21 16:42:27 +02:00
</ th > ' ;
2017-09-13 11:15:31 +02:00
}
2017-09-07 16:51:14 +02:00
echo "
2017-09-13 11:15:31 +02:00
< th class = 'text-center small' style = 'width:".$width."' >
" .tr('Totale IVA', [], ['upper' => true]). "
</ th >
< th class = 'text-center small' style = 'width:".$width."' >
" .tr('Totale documento', [], ['upper' => true]). "
</ th >
2017-09-07 16:51:14 +02:00
</ tr >
< tr >
2017-09-13 11:15:31 +02:00
< td class = 'cell-padded text-center' >
2019-07-11 18:10:38 +02:00
" .moneyFormat( $show_sconto ? $imponibile : $totale_imponibile , 2).'
2017-09-21 16:42:27 +02:00
</ td > ' ;
2017-09-13 11:15:31 +02:00
2019-07-11 18:10:38 +02:00
if ( $show_sconto ) {
2017-09-13 11:15:31 +02:00
echo "
< td class = 'cell-padded text-center' >
2019-07-11 18:10:38 +02:00
" .moneyFormat(abs( $sconto ), 2). "
2017-09-07 16:51:14 +02:00
</ td >
2017-09-13 11:15:31 +02:00
< td class = 'cell-padded text-center' >
2019-07-11 18:10:38 +02:00
" .moneyFormat( $totale_imponibile , 2).'
2017-09-21 16:42:27 +02:00
</ td > ' ;
2017-09-13 11:15:31 +02:00
}
2017-12-20 14:05:14 +01:00
echo "
2017-09-13 11:15:31 +02:00
< td class = 'cell-padded text-center' >
2019-05-02 10:03:57 +02:00
" .moneyFormat( $totale_iva , 2). "
2017-09-07 16:51:14 +02:00
</ td >
2017-09-13 11:15:31 +02:00
< td class = 'cell-padded text-center' >
2019-05-02 10:03:57 +02:00
" .moneyFormat( $totale , 2).'
2017-09-07 16:51:14 +02:00
</ td >
</ tr > ' ;
2019-04-19 17:31:52 +02:00
// Rivalsa INPS
2018-09-27 16:19:25 +02:00
if ( ! empty ( $record [ 'rivalsainps' ])) {
2019-01-22 15:52:22 +01:00
$rs2 = $dbo -> fetchArray ( 'SELECT percentuale FROM co_rivalse WHERE id=(SELECT idrivalsainps FROM co_righe_documenti WHERE iddocumento=' . prepare ( $id_record ) . ' AND idrivalsainps!=0 LIMIT 0,1)' );
2017-12-20 14:05:14 +01:00
$first_colspan = 3 ;
$second_colspan = 2 ;
2019-05-04 00:32:28 +02:00
2017-12-20 14:05:14 +01:00
if ( empty ( $sconto )) {
-- $first_colspan ;
-- $second_colspan ;
}
echo '
< tr >
< th class = " text-center small " colspan = " '. $first_colspan .' " >
2019-01-22 15:07:09 +01:00
'.tr(' Rivalsa _PRC_ % ' , [
2017-12-20 14:05:14 +01:00
'_PRC_' => Translator :: numberToLocale ( $rs2 [ 0 ][ 'percentuale' ], 0 ),
], [ 'upper' => true ]) . '
</ th > ' ;
echo '
< th class = " text-center small " colspan = " '. $second_colspan .' " >
'.tr(' Totale documento ', [], [' upper ' => true]).'
</ th >
</ tr >
< tr >
< td class = " cell-padded text-center " colspan = " '. $first_colspan .' " >
2019-05-02 10:03:57 +02:00
'.moneyFormat($record[' rivalsainps '], 2).'
2017-12-20 14:05:14 +01:00
</ td > ' ;
echo '
< td class = " cell-padded text-center " colspan = " '. $second_colspan .' " >
2019-05-02 10:03:57 +02:00
'.moneyFormat($totale, 2).'
2017-12-20 14:05:14 +01:00
</ td >
</ tr > ' ;
}
2019-04-19 17:31:52 +02:00
// Ritenuta d'acconto ( + se no rivalsa inps)
2019-07-12 12:40:13 +02:00
if ( ! empty ( $record [ 'ritenutaacconto' ]) || ! empty ( $documento -> totale_ritenuta_contributi ) || ! empty ( $record [ 'spit_payment' ])) {
2017-09-21 15:51:39 +02:00
$rs2 = $dbo -> fetchArray ( 'SELECT percentuale FROM co_ritenutaacconto WHERE id=(SELECT idritenutaacconto FROM co_righe_documenti WHERE iddocumento=' . prepare ( $id_record ) . ' AND idritenutaacconto!=0 LIMIT 0,1)' );
2017-09-07 16:51:14 +02:00
2017-12-20 14:05:14 +01:00
$first_colspan = 3 ;
$second_colspan = 2 ;
2019-04-19 17:31:52 +02:00
2017-12-20 14:05:14 +01:00
if ( empty ( $sconto )) {
-- $first_colspan ;
-- $second_colspan ;
}
2019-03-01 15:30:54 +01:00
$contributi = ( ! empty ( $record [ 'ritenutaacconto' ]) ? ' - ' : '' ) . tr ( 'contributi: _PRC_%' , [
2019-07-12 12:40:13 +02:00
'_PRC_' => Translator :: numberToLocale ( $documento -> ritenutaContributi -> percentuale , 2 ),
2019-03-01 15:30:54 +01:00
]);
$acconto = tr ( 'acconto: _PRC_%' , [
'_PRC_' => Translator :: numberToLocale ( $rs2 [ 0 ][ 'percentuale' ], 0 ),
]);
2017-12-20 14:05:14 +01:00
echo '
2017-09-07 16:51:14 +02:00
< tr >
2017-12-20 14:05:14 +01:00
< th class = " text-center small " colspan = " '. $first_colspan .' " >
2019-03-01 15:30:54 +01:00
'.tr(' Ritenuta ( _ACCONTO__CONTRIBUTI_ ) ' , [
'_ACCONTO_' => $acconto ,
2019-07-12 12:40:13 +02:00
'_CONTRIBUTI_' => empty ( $documento -> ritenutaContributi ) ? null : $contributi ,
2017-12-20 14:05:14 +01:00
], [ 'upper' => true ]) . '
</ th > ' ;
2017-09-13 11:15:31 +02:00
2018-12-29 12:03:22 +01:00
echo '
2018-12-28 18:03:38 +01:00
< th class = " text-center small " colspan = " '. $second_colspan .' " > ' ;
2018-12-29 12:03:22 +01:00
if ( empty ( $record [ 'split_payment' ])) {
echo tr ( 'Netto a pagare' , [], [ 'upper' => true ]);
} else {
echo tr ( 'Totale' , [], [ 'upper' => true ]);
}
2017-12-20 14:05:14 +01:00
echo '
2018-12-28 18:03:38 +01:00
</ th > ' ;
echo '
</ tr >
2017-09-07 16:51:14 +02:00
< tr >
2017-12-20 14:05:14 +01:00
< td class = " cell-padded text-center " colspan = " '. $first_colspan .' " >
2019-07-12 12:40:13 +02:00
'.moneyFormat(abs($documento->ritenuta_acconto) + $documento->totale_ritenuta_contributi, 2).'
2017-12-20 14:05:14 +01:00
</ td > ' ;
echo '
2017-09-07 16:51:14 +02:00
2018-01-05 17:24:39 +01:00
< td class = " cell-padded text-center " colspan = " '. $second_colspan .' " >
2019-07-12 12:40:13 +02:00
'.moneyFormat($totale - abs($documento->ritenuta_acconto) - $documento->totale_ritenuta_contributi, 2).'
2018-01-05 17:24:39 +01:00
</ td >
</ tr > ' ;
}
2018-12-28 18:03:38 +01:00
// Split payment
if ( ! empty ( $record [ 'split_payment' ])) {
2018-12-29 12:03:22 +01:00
$first_colspan = 1 ;
$second_colspan = 2 ;
echo '
2018-12-28 18:03:38 +01:00
< tr >
< th class = " text-center small " colspan = " '. $first_colspan .' " >
'.tr(' iva a carico del destinatario ', [], [' upper ' => true]).'
</ th >
< th class = " text-center small " colspan = " '. $second_colspan .' " >
'.tr(' Netto a pagare ', [], [' upper ' => true]).'
</ th >
</ tr > ' ;
2018-12-29 12:03:22 +01:00
echo '
2018-12-28 18:03:38 +01:00
< tr >
< td class = " cell-padded text-center " colspan = " '. $first_colspan .' " >
2019-05-02 10:03:57 +02:00
'.moneyFormat($totale_iva, 2).'
2018-12-28 18:03:38 +01:00
</ td >
< td class = " cell-padded text-center " colspan = " '. $second_colspan .' " >
2019-07-12 12:40:13 +02:00
'.moneyFormat($totale - $totale_iva - abs($documento->ritenuta_acconto) - $documento->totale_ritenuta_contributi, 2).'
2018-12-28 18:03:38 +01:00
</ td >
</ tr > ' ;
2017-09-07 16:51:14 +02:00
}
echo '
</ table > ' ;
2017-09-21 16:42:27 +02:00
if ( $fattura_accompagnatoria ) {
// Informazioni aggiuntive
echo '
< table class = " table-bordered " >
< tr >
2019-07-16 10:32:54 +02:00
< th class = " small " class style = " width:15% " >
'.tr(' Peso lordo ', [], [' upper ' => true]).'
</ th >
2019-07-16 10:34:51 +02:00
2019-07-16 10:32:54 +02:00
< th class = " small " class style = " width:15% " >
'.tr(' Volume ', [], [' upper ' => true]).'
</ th >
2019-07-16 10:34:51 +02:00
2019-07-16 10:32:54 +02:00
< th class = " small " class style = " width:15% " >
2017-09-21 16:42:27 +02:00
'.tr(' Aspetto beni ', [], [' upper ' => true]).'
</ th >
2019-07-16 10:32:54 +02:00
< th class = " small " class style = " width:10% " >
'.tr(' Colli ', [], [' upper ' => true]).'
2017-09-21 16:42:27 +02:00
</ th >
< th class = " small " style = " width:30% " >
'.tr(' Causale trasporto ', [], [' upper ' => true]).'
</ th >
2019-07-16 10:32:54 +02:00
< th class = " small " style = " width:15% " >
2017-09-21 16:42:27 +02:00
'.tr(' Porto ', [], [' upper ' => true]).'
</ th >
</ tr >
< tr >
2019-07-16 10:32:54 +02:00
< td class = " cell-padded " >
'.(!empty($peso_lordo) ? Translator::numberToLocale($peso_lordo).' & nbsp ; KG ' : ' ').'
</ td >
< td class = " cell-padded " >
'.(!empty($volume) ? Translator::numberToLocale($volume).' & nbsp ; M < sup > 3 </ sup > ' : ' ').'
</ td >
2019-07-16 10:34:51 +02:00
2017-09-21 16:42:27 +02:00
< td class = " cell-padded " >
$aspettobeni $ & nbsp ;
</ td >
< td class = " cell-padded " >
$n_colli $ & nbsp ;
</ td >
< td class = " cell-padded " >
$causalet $ & nbsp ;
</ td >
< td class = " cell-padded " >
$porto $ & nbsp ;
</ td >
</ tr >
</ table > ' ;
// Firme
echo '
< table class = " table-bordered " >
< tr >
< th class = " small " style = " width:33% " >
'.tr(' Tipo di spedizione ', [], [' upper ' => true]).'
</ th >
< th class = " small " style = " width:33% " >
'.tr(' Firma conducente ', [], [' upper ' => true]).'
</ th >
< th class = " small " style = " width:33% " >
'.tr(' Firma destinatario ', [], [' upper ' => true]).'
</ th >
</ tr >
< tr >
< td style = " height: 10mm " > $spedizione $ $vettore $ </ td >
< td style = " height: 10mm " ></ td >
< td style = " height: 10mm " ></ td >
</ tr >
</ table > ' ;
}
2017-09-07 16:51:14 +02:00
echo '
< table style = " font-size:7pt; color:#999; " >
2017-09-13 11:15:31 +02:00
< tr >
< td style = " text-align:center; " >
$dicitura_fissa_fattura $
</ td >
</ tr >
2018-08-29 16:28:50 +02:00
</ table > ' ;
if ( $options [ 'hide_footer' ]) {
2018-09-03 16:49:43 +02:00
echo '
2018-08-29 16:28:50 +02:00
< table style = " color:#aaa; font-size:10px; " >
< tr >
< td align = " left " style = " width:97mm; height:5mm; " >
& nbsp ;
</ td >
< td align = " right " style = " width:97mm; " >
& nbsp ;
</ td >
</ tr >
</ table > ' ;
2018-09-03 16:49:43 +02:00
} else {
echo '$default_footer$' ;
2018-08-29 16:28:50 +02:00
}