'' AND co_documenti.data>='".$date_start."' AND co_documenti.data<='".$date_end."' and co_documenti.idstatodocumento='1' and co_tipidocumento.mod_riepilogo_iva='1' and co_righe_documenti.qta > 0 GROUP BY co_documenti.id, co_righe_documenti.idiva"; // } elseif ('uscita' == $dir) { // $Testo="REGISTRO IVA USCITE"; // $query = "SELECT *, SUM(subtotale-co_righe_documenti.sconto) AS subtotale, SUM(iva) AS iva, (SELECT ragione_sociale FROM an_anagrafiche WHERE an_anagrafiche.idanagrafica=co_documenti.idanagrafica) AS ragione_sociale FROM co_documenti INNER JOIN co_righe_documenti ON co_documenti.id=co_righe_documenti.iddocumento INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE dir='uscita' AND co_documenti.data>='".$date_start."' AND co_documenti.data<='".$date_end."' and co_documenti.idstatodocumento='1' and co_tipidocumento.mod_riepilogo_iva='1' and co_righe_documenti.qta > 0 GROUP BY co_documenti.id, co_righe_documenti.idiva"; // } $rs = $dbo->fetchArray($query); $totrows = sizeof($rs); $body .= "

$Testo AL ".date("d/m/Y")."

\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; for( $r=0; $r\n"; $body .= " \n"; if ('entrata' == $dir) { $body .= "'; } elseif ('uscita' == $dir) { $body .= "'; } $body .= " \n"; $body .= " \n"; $body .= " \n"; $body .= "\n"; $v_iva[$rs[$r]['desc_iva']] += $rs[$r]['iva']; $v_totale[$rs[$r]['desc_iva']] += $rs[$r]['subtotale']; $totale_iva += $rs[$r]['iva']; $totale_subtotale += $rs[$r]['subtotale']; } $body .= "
N° DocumentoDataCausale
Ragione sociale
AliquotaImponibileImposta
".date('d/m/Y', strtotime($rs[$r]['data']))." Fattura di vendita
".$rs[$r]['ragione_sociale'].'
Fattura di acquisto
".$rs[$r]['ragione_sociale'].'
". $rs[$r]['desc_iva']." €".number_format( $rs[$r]['subtotale'], 2, ",", "." )."".number_format( $rs[$r]['iva'], 2, ",", "." )." €
\n"; $body .= "

RIEPILOGO IVA

\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; foreach ($v_iva as $desc_iva => $tot_iva) { if ('' != $desc_iva) { $body .= "\n"; $body .= " \n"; $body .= " \n"; $body .= " \n"; $body .= "\n"; } } $body .= "
Cod. IVAImponibileImposta
".$desc_iva."".number_format( $v_totale[$desc_iva], 2, ",", "." )."".number_format( $v_iva[$desc_iva], 2, ",", "." )."
\n"; $orientation = 'L'; $report_name = 'registro_iva.pdf'; ?>