= '.prepare($date_start).' AND co_documenti.data <= '.prepare($date_end).' GROUP BY co_documenti.id, co_righe_documenti.idiva ORDER BY co_documenti.data';
$rs = $dbo->fetchArray($query);
if ('entrata' == $dir) {
$body .= "".tr('Registro iva vendita dal _START_ al _END_', [
'_START_' => Translator::dateToLocale($date_start),
'_END_' => Translator::dateToLocale($date_end),
], ['upper' => true]).'
';
} elseif ('uscita' == $dir) {
$body .= "".tr('Registro iva acquisto dal _START_ al _END_', [
'_START_' => Translator::dateToLocale($date_start),
'_END_' => Translator::dateToLocale($date_end),
], ['upper' => true]).'
';
}
$body .= "
No prot. |
No doc. |
Data |
".(($dir == 'entrata') ? 'Cliente' : 'Fornitore')." |
Causale |
Aliquota |
Imponibile |
Imposta |
";
for ($i = 0; $i < sizeof($rs); ++$i) {
$body .= '';
if ($rs[$i]['numero'] == $rs[$i - 1]['numero']) {
$body .= " | ";
$body .= " | ";
$body .= " | ";
} else {
$body .= " ".$rs[$i]['numero'].' | ';
$body .= " ".$rs[$i]['numero_esterno'].' | ';
$body .= " ".date('d/m/Y', strtotime($rs[$i]['data'])).' | ';
}
$body .= "".$rs[$i]['ragione_sociale'].' | ';
$body .= " ".(($dir == 'entrata') ? 'Fattura di vendita' : 'Fattura di acquisto').' | ';
$body .= " ".$rs[$i]['desc_iva'].' | ';
$body .= " ".Translator::numberToLocale($rs[$i]['subtotale']).' € | ';
$body .= " ".Translator::numberToLocale($rs[$i]['iva']).' € | ';
$body .= '
';
$v_iva[$rs[$i]['desc_iva']] += $rs[$i]['iva'];
$v_totale[$rs[$i]['desc_iva']] += $rs[$i]['subtotale'];
$totale_iva += $rs[$i]['iva'];
$totale_subtotale += $rs[$i]['subtotale'];
}
$body .= '
';
$body .= "
RIEPILOGO IVA
";
$body .= "
Cod. IVA |
Imponibile |
Imposta |
";
foreach ($v_iva as $desc_iva => $tot_iva) {
if ('' != $desc_iva) {
$body .= "\n";
$body .= $desc_iva."\n";
$body .= " | \n";
$body .= "\n";
$body .= Translator::numberToLocale($v_totale[$desc_iva])." €\n";
$body .= " | \n";
$body .= "\n";
$body .= Translator::numberToLocale($v_iva[$desc_iva])." €\n";
$body .= " |
\n";
}
}
$body .= "
TOTALE |
".Translator::numberToLocale($totale_subtotale)." € |
".Translator::numberToLocale($totale_iva).' € |
';
$body .= '
';
$orientation = 'L';
$report_name = 'registro_iva.pdf';