1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-02-16 19:40:44 +01:00

Aggiornamento stampa registro iva

This commit is contained in:
Matteo 2019-03-08 11:28:57 +01:00
parent dbc27e3217
commit ab45812a1f
8 changed files with 173 additions and 232 deletions

View File

@ -0,0 +1,133 @@
<?php
include_once __DIR__.'/../../core.php';
$dir = $_GET['dir'];
if($dir=='entrata'){
$tipo = 'vendite';
}else{
$tipo = 'acquisti';
}
$report_name = 'registro_iva_'.$tipo.'.pdf';
$periodo = $_GET['periodo'];
$v_iva = [];
$v_totale = [];
$totale_iva = 0;
$totale_subtotale = 0;
$date_start = $_SESSION['period_start'];
$date_end = $_SESSION['period_end'];
$query = 'SELECT *, IF(numero = "", numero_esterno, numero) AS numero, 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, (SELECT codice FROM an_anagrafiche WHERE an_anagrafiche.idanagrafica=co_documenti.idanagrafica) AS codice_anagrafica 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 INNER JOIN co_iva ON co_righe_documenti.idiva=co_iva.id WHERE dir = '.prepare($dir).' AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") AND is_descrizione = 0 AND co_documenti.data >= '.prepare($date_start).' AND co_documenti.data <= '.prepare($date_end).' GROUP BY co_documenti.id, co_righe_documenti.idiva ORDER BY co_documenti.'.(($dir == 'entrata') ? 'data' : 'numero');
$rs = $dbo->fetchArray($query);
if ('entrata' == $dir) {
echo "<span style='font-size:12pt;'><b>".tr('Registro iva vendita dal _START_ al _END_ _ESERCIZIO_', [
'_START_' => Translator::dateToLocale($date_start),
'_END_' => Translator::dateToLocale($date_end),
'_ESERCIZIO_' => (date('Y', strtotime($date_start))==date('Y', strtotime($date_end))? '- Esercizio '.date('Y', strtotime($date_end)): ''),
], ['upper' => true]).'</b></span><br><br>';
} elseif ('uscita' == $dir) {
echo "<span style='font-size:12pt;'><b>".tr('Registro iva acquisto dal _START_ al _END_ _ESERCIZIO_', [
'_START_' => Translator::dateToLocale($date_start),
'_END_' => Translator::dateToLocale($date_end),
'_ESERCIZIO_' => (date('Y', strtotime($date_start))==date('Y', strtotime($date_end))? '- Esercizio '.date('Y', strtotime($date_end)): ''),
], ['upper' => true]).'</b></span><br><br>';
}
echo "
<table cellspacing='0' style='table-layout:fixed;'>
<thead>
<tr>
<th bgcolor='#dddddd'>N<sup>o</sup> prot.</th>
<th bgcolor='#dddddd'>N<sup>o</sup> doc.</th>
<th bgcolor='#dddddd'>Data</th>
<th bgcolor='#dddddd'>Tipo</th>
<th bgcolor='#dddddd'>".(($dir == 'entrata') ? 'Cliente' : 'Fornitore')."</th>
<th bgcolor='#dddddd'>Tot doc.</th>
<th bgcolor='#dddddd'>Imponibile</th>
<th bgcolor='#dddddd'>%</th>
<th bgcolor='#dddddd'>Iva</th>
<th bgcolor='#dddddd'>Imposta</th>
</tr>
</thead>
";
for ($i = 0; $i < sizeof($rs); ++$i) {
echo ' <tr>';
if ($rs[$i]['numero'] == $rs[$i - 1]['numero']) {
echo " <td></td>";
echo " <td></td>";
echo " <td></td>";
echo " <td></td>";
echo " <td></td>";
echo " <td></td>";
} else {
echo " <td>".$rs[$i]['numero'].'</td>';
echo " <td>".$rs[$i]['numero_esterno'].'</td>';
echo " <td>".date('d/m/Y', strtotime($rs[$i]['data'])).'</td>';
echo " <td>".$rs[$i]['codice_tipo_documento_fe'].'</td>';
echo " <td>".$rs[$i]['codice_anagrafica']." / ".tr($rs[$i]['ragione_sociale'], [], ['upper' => true]).'</td>';
echo " <td class='text-right'>".Translator::numberToLocale(get_totale_fattura($rs[$i]['iddocumento'])).' &euro;</td>';
}
echo " <td class='text-right'>".Translator::numberToLocale($rs[$i]['subtotale']).' &euro;</td>';
echo " <td class='text-center'>".Translator::numberToLocale($rs[$i]['percentuale'], 0).'</td>';
echo " <td class='text-center'>".$rs[$i]['desc_iva'].'</td>';
echo " <td class='text-right'>".Translator::numberToLocale($rs[$i]['iva']).' &euro;</td>';
echo ' </tr>';
$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'];
}
echo '
</table>';
echo " <br><br><span style='font-size:12pt;'><b>RIEPILOGO IVA</b></span><br><br>";
echo "
<table cellspacing='0' style='table-layout:fixed;' style='width:50%'>
<tr>
<th bgcolor='#dddddd'>Iva</th>
<th bgcolor='#dddddd'>Imponibile</th>
<th bgcolor='#dddddd'>Imposta</th>
</tr>
";
foreach ($v_iva as $desc_iva => $tot_iva) {
if ('' != $desc_iva) {
echo "
<tr>
<td valign='top'>\n";
echo $desc_iva."\n";
echo " </td>\n";
echo " <td valign='top' align='right'>\n";
echo Translator::numberToLocale($v_totale[$desc_iva])." &euro;\n";
echo " </td>\n";
echo " <td valign='top' align='right'>\n";
echo Translator::numberToLocale($v_iva[$desc_iva])." &euro;\n";
echo " </td>
</tr>\n";
}
}
echo " <tr bgcolor='#dddddd'>
<td><b>TOTALE</b></td>
<td class='text-right'>".Translator::numberToLocale($totale_subtotale)." &euro;</td>
<td class='text-right'>".Translator::numberToLocale($totale_iva).' &euro;</td>
</tr>';
echo '
</table>';

View File

@ -0,0 +1,17 @@
<?php
echo '
<table style="color:#aaa; font-size:10px;">
<tr>
<td align="left" style="width:97mm;">
'.tr('Stampato con OpenSTAManager il _DATA_', ['_DATA_' => date('d/m/Y')]).'
</td>
<td align="right" style="width:97mm;">
'.tr('Pagina _PAGE_ di _TOTAL_', [
'_PAGE_' => '{PAGENO}',
'_TOTAL_' => '{nb}',
]).'
</td>
</tr>
</table>';

View File

@ -0,0 +1,17 @@
<?php
echo '
<!-- Intestazione fornitore -->
<div class="row">
<div class="col-xs-6">
<p><b>$f_ragionesociale$</b></p>
<p>$f_indirizzo$ $f_citta_full$</p>
<p>'.(!empty($f_piva) ? tr('P.Iva').': ' : '').'$f_piva$</p>
<p>'.(!empty($f_codicefiscale) ? tr('C.F.').': ' : '').'$f_codicefiscale$</p>
<p>'.(!empty($f_capsoc) ? tr('Cap.Soc.').': ' : '').'$f_capsoc$</p>
<p>'.(!empty($f_telefono) ? tr('Tel').': ' : '').'$f_telefono$</p>
</div>
<div class="col-xs-6 text-right">
<img src="$logo$" alt="Logo" border="0"/>
</div>
</div>';

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -1,151 +0,0 @@
<?php
//carica report html
$report = file_get_contents($docroot.'/templates/registro_iva/registroiva.html');
$body = file_get_contents($docroot.'/templates/registro_iva/registroiva_body.html');
include_once __DIR__.'/../pdfgen_variables.php';
$dir = $_GET['dir'];
$periodo = $_GET['periodo'];
$v_iva = [];
$v_totale = [];
$totale_iva = 0;
$totale_subtotale = 0;
$date_start = $_SESSION['period_start'];
$date_end = $_SESSION['period_end'];
/*
$periodo = explode('-', $periodo);
switch ($periodo[0]) {
//anno
case 'Y':
$date_start = $periodo[2].'-01-01';
$date_end = $periodo[2].'-12-31';
break;
//mese
case 'M':
$date_start = $periodo[2].'-'.$periodo[1].'-01';
$date_end = date('Y-m-t', strtotime($date_start));
break;
//trimestre
case 'T':
$date_start = $periodo[2].'-'.$periodo[1].'-01';
$date_end = date('Y-m-t', strtotime('+2 months', strtotime($date_start)));
break;
//semestre
case 'S':
$date_start = $periodo[2].'-'.$periodo[1].'-01';
$date_end = date('Y-m-t', strtotime('+5 months', strtotime($date_start)));
break;
}*/
$query = 'SELECT *, IF(numero = "", numero_esterno, numero) AS numero, 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 = '.prepare($dir).' AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") AND is_descrizione = 0 AND co_documenti.data >= '.prepare($date_start).' AND co_documenti.data <= '.prepare($date_end).' GROUP BY co_documenti.id, co_righe_documenti.idiva ORDER BY co_documenti.'.(($dir == 'entrata') ? 'data' : 'numero');
$rs = $dbo->fetchArray($query);
if ('entrata' == $dir) {
$body .= "<span style='font-size:15pt;'><b>".tr('Registro iva vendita dal _START_ al _END_', [
'_START_' => Translator::dateToLocale($date_start),
'_END_' => Translator::dateToLocale($date_end),
], ['upper' => true]).'</b></span><br><br>';
} elseif ('uscita' == $dir) {
$body .= "<span style='font-size:15pt;'><b>".tr('Registro iva acquisto dal _START_ al _END_', [
'_START_' => Translator::dateToLocale($date_start),
'_END_' => Translator::dateToLocale($date_end),
], ['upper' => true]).'</b></span><br><br>';
}
$body .= "
<table cellspacing='0' style='table-layout:fixed;'>
<col width='90'><col width='90'><col width='90'><col width='275'><col width='120'><col width='90'><col width='90'><col width='90'>
<thead>
<tr>
<th bgcolor='#dddddd' class='full_cell1 cell-padded'>N<sup>o</sup> prot.</th>
<th bgcolor='#dddddd' class='full_cell1 cell-padded'>N<sup>o</sup> doc.</th>
<th bgcolor='#dddddd' class='full_cell cell-padded'>Data</th>
<th bgcolor='#dddddd' class='full_cell cell-padded'>".(($dir == 'entrata') ? 'Cliente' : 'Fornitore')."</th>
<th bgcolor='#dddddd' class='full_cell cell-padded'>Causale</th>
<th bgcolor='#dddddd' class='full_cell cell-padded'>Aliquota</th>
<th bgcolor='#dddddd' class='full_cell cell-padded'>Imponibile</th>
<th bgcolor='#dddddd' class='full_cell cell-padded'>Imposta</th>
</tr>
</thead>
";
for ($i = 0; $i < sizeof($rs); ++$i) {
$body .= '<tr>';
if ($rs[$i]['numero'] == $rs[$i - 1]['numero']) {
$body .= " <td class='first_cell cell-padded text-center'> - </td>";
$body .= " <td class='table_cell cell-padded text-center'> - </td>";
$body .= " <td class='table_cell cell-padded text-center'> - </td>";
} else {
$body .= " <td class='first_cell cell-padded text-center'>".$rs[$i]['numero'].'</td>';
$body .= " <td class='table_cell cell-padded text-center'>".$rs[$i]['numero_esterno'].'</td>';
$body .= " <td class='table_cell cell-padded text-center'>".date('d/m/Y', strtotime($rs[$i]['data'])).'</td>';
}
$body .= "<td class='table_cell cell-padded'>".$rs[$i]['ragione_sociale'].'</td>';
$body .= " <td class='table_cell cell-padded'>".(($dir == 'entrata') ? 'Fattura di vendita' : 'Fattura di acquisto').'</td>';
$body .= " <td class='table_cell cell-padded'>".$rs[$i]['desc_iva'].'</td>';
$body .= " <td class='table_cell cell-padded text-right'>".Translator::numberToLocale($rs[$i]['subtotale']).' &euro;</td>';
$body .= " <td class='table_cell cell-padded text-right'>".Translator::numberToLocale($rs[$i]['iva']).' &euro;</td>';
$body .= '</tr>';
$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 .= '
</table>
';
$body .= "<br><br><span style='font-size:12pt;'><b>RIEPILOGO IVA</b></span><br><br>";
$body .= "
<table cellspacing='0' style='table-layout:fixed;'>
<col width='140'><col width='90'><col width='90'>
<tr>
<th bgcolor='#dddddd' class='full_cell1 cell-padded'>Cod. IVA</th>
<th bgcolor='#dddddd' class='full_cell1 cell-padded'>Imponibile</th>
<th bgcolor='#dddddd' class='full_cell1 cell-padded'>Imposta</th>
</tr>
";
foreach ($v_iva as $desc_iva => $tot_iva) {
if ('' != $desc_iva) {
$body .= "<tr><td valign='top' class='first_cell cell-padded'>\n";
$body .= $desc_iva."\n";
$body .= "</td>\n";
$body .= "<td valign='top' align='right' class='table_cell cell-padded'>\n";
$body .= Translator::numberToLocale($v_totale[$desc_iva])." &euro;\n";
$body .= "</td>\n";
$body .= "<td valign='top' align='right' class='table_cell cell-padded'>\n";
$body .= Translator::numberToLocale($v_iva[$desc_iva])." &euro;\n";
$body .= "</td></tr>\n";
}
}
$body .= " <tr bgcolor='#dddddd'>
<td class='full_cell1 cell-padded text-right'><b>TOTALE</b></td>
<td class='full_cell1 cell-padded text-right'>".Translator::numberToLocale($totale_subtotale)." &euro;</td>
<td class='full_cell1 cell-padded text-right'>".Translator::numberToLocale($totale_iva).' &euro;</td>
</tr>';
$body .= '
</table>
';
$orientation = 'L';
$report_name = 'registro_iva.pdf';

View File

@ -1,59 +0,0 @@
<style>
<!--
.table_values td{
border: 1px solid #888;
padding: 4px;
white-space: normal;
}
.table_values th{
background: #abbfcb;
padding: 4px;
}
.first_cell{
border-left: 1px solid #aaa;
border-right: 1px solid #aaa;
border-bottom: 1px solid #aaa;
}
.table_cell{
border-bottom: 1px solid #aaa;
border-right: 1px solid #aaa;
}
.full_cell1{
border: 1px solid #aaa;
}
.full_cell{
border-top: 1px solid #aaa;
border-right: 1px solid #aaa;
border-bottom: 1px solid #aaa;
}
.text-center{
text-align: center;
}
.text-right{
text-align: right;
}
.b-right{
border-right: 1px solid #aaa;
}
.b-bottom{
border-bottom: 1px solid #aaa;
}
.cell-padded{
padding: 4px;
}
-->
</style>
<page backcolor="#ffffff" backtop="40mm" backbottom="5mm" backleft="0mm" backright="0mm" footer="" style="font-size: $font_size$">
$body$
</page>

View File

@ -1,22 +0,0 @@
<page_header>
<br>
<table>
<tr>
<td style="width:215mm;" align="left">
<big><big><big><b>$f_ragionesociale$</b></big></big><p style="margin-left:4px; font-size:11px; line-height:12px;">$f_indirizzo$
$f_citta$
$f_piva$
$f_codicefiscale$
$f_capsoc$
$f_telefono$
</p>
</big>
</td>
<td valign="top" align="right">
<img src="$logo$" alt="Logo" style="width:60mm;" border="0">
</td>
</tr>
</table>
<br>
</page_header>

View File

@ -0,0 +1,6 @@
<?php
return [
'orientation' => 'L',
'font-size' => '11pt',
];