='".$date_start."' AND co_documenti.data<='".$date_end."' GROUP BY co_documenti.id, co_righe_documenti.idiva";
} elseif ($dir == 'uscita') {
$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."' GROUP BY co_documenti.id, co_righe_documenti.idiva";
}
$rs = $dbo->fetchArray($query);
if ($dir == 'entrata') {
$body .= "REGISTRO IVA VENDITA
";
} elseif ($dir == 'uscita') {
$body .= "REGISTRO IVA ACQUISTO
";
}
$body .= "
Prot. | Data | N° Documento | Causale Ragione sociale |
Aliquota | Imponibile | Imposta | |||
---|---|---|---|---|---|---|---|---|---|
"; $body .= " | "; } else { $body .= " | ".$rs[$i]['numero'].' | '; $body .= "".date('d/m/Y', strtotime($rs[$i]['data'])).' | '; } $body .= "".$rs[$i]['numero_esterno'].' | '; if ($dir == 'entrata') { $body .= "
Fattura di vendita ".$rs[$i]['ragione_sociale'].' | ';
} elseif ($dir == 'uscita') {
$body .= "
Fattura di acquisto ".$rs[$i]['ragione_sociale'].' | ';
}
$body .= " ".$rs[$i]['desc_iva'].' | '; $body .= "".Translator::numberToLocale($rs[$i]['subtotale'], 2).' € | '; $body .= "".Translator::numberToLocale($rs[$i]['iva'], 2).' € | '; $body .= '
Cod. IVA | Imponibile | Imposta |
---|---|---|
\n"; $body .= $desc_iva."\n"; $body .= " | \n"; $body .= "\n"; $body .= Translator::numberToLocale($v_totale[$desc_iva], 2)." €\n"; $body .= " | \n"; $body .= "\n"; $body .= Translator::numberToLocale($v_iva[$desc_iva], 2)." €\n"; $body .= " |
TOTALE | ".Translator::numberToLocale($totale_subtotale, 2)." € | ".Translator::numberToLocale($totale_iva, 2).' € |