= '.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 .= " "; for ($i = 0; $i < sizeof($rs); ++$i) { $body .= ''; if ($rs[$i]['numero'] == $rs[$i - 1]['numero']) { $body .= " "; $body .= " "; $body .= " "; } else { $body .= " '; $body .= " '; $body .= " '; } $body .= ""; $body .= " '; $body .= " '; $body .= " '; $body .= " '; $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 .= '
No prot. No doc. Data ".(($dir=='entrata') ? 'Cliente': 'Fornitore')." Causale Aliquota Imponibile Imposta
".$rs[$i]['numero'].'".$rs[$i]['numero_esterno'].'".date('d/m/Y', strtotime($rs[$i]['data'])).'".$rs[$i]['ragione_sociale']."".(($dir=='entrata') ? 'Fattura di vendita': 'Fattura di acquisto').'".$rs[$i]['desc_iva'].'".Translator::numberToLocale($rs[$i]['subtotale']).' €".Translator::numberToLocale($rs[$i]['iva']).' €
'; $body .= "

RIEPILOGO IVA

"; $body .= " "; foreach ($v_iva as $desc_iva => $tot_iva) { if ('' != $desc_iva) { $body .= "\n"; $body .= "\n"; $body .= "\n"; } } $body .= " '; $body .= '
Cod. IVA Imponibile Imposta
\n"; $body .= $desc_iva."\n"; $body .= "\n"; $body .= Translator::numberToLocale($v_totale[$desc_iva])." €\n"; $body .= "\n"; $body .= Translator::numberToLocale($v_iva[$desc_iva])." €\n"; $body .= "
TOTALE ".Translator::numberToLocale($totale_subtotale)." € ".Translator::numberToLocale($totale_iva).' €
'; $orientation = 'L'; $report_name = 'registro_iva.pdf';