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

Aggiunta stampa dello spesometro

This commit is contained in:
Thomas Zilio 2017-09-15 12:50:59 +02:00
parent b33cad6d58
commit fa1dcef03c
9 changed files with 270 additions and 26 deletions

View File

@ -3,24 +3,52 @@
include_once __DIR__.'/../../core.php';
echo '
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">'.tr('Registri iva').'</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<a class="btn btn-primary btn-block" href="'.$rootdir.'/pdfgen.php?ptype=registro_iva&dir=entrata" target="_blank">
<i class="fa fa-print"></i> '.tr('Stampa registro iva vendite').'
</a>
<div class="row">
<div class="col-xs-12 col-md-6">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">'.tr('Registri iva dal _START_ al _END_', [
'_START_' => Translator::dateToLocale($_SESSION['period_start']),
'_END_' => Translator::dateToLocale($_SESSION['period_end']),
]).'</h3>
</div>
<div class="col-md-6">
<a class="btn btn-primary btn-block" href="'.$rootdir.'/pdfgen.php?ptype=registro_iva&dir=uscita" target="_blank">
<i class="fa fa-print"></i> '.tr('Stampa registro iva acquisti').'
<div class="panel-body">
<a class="btn btn-primary" href="'.$rootdir.'/pdfgen.php?ptype=registro_iva&dir=entrata" target="_blank">
<i class="fa fa-print fa-2x"></i><br>
'.tr('Stampa registro').'<br>
'.tr('IVA vendite').'
</a>
<a class="btn btn-primary" href="'.$rootdir.'/pdfgen.php?ptype=registro_iva&dir=uscita" target="_blank">
<i class="fa fa-print fa-2x"></i><br>
'.tr('Stampa registro').'<br>
'.tr('IVA acquisti').'
</a>
</div>
</div>
</div>
<div class="col-xs-12 col-md-6">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">'.tr('Spesometro dal _START_ al _END_', [
'_START_' => Translator::dateToLocale($_SESSION['period_start']),
'_END_' => Translator::dateToLocale($_SESSION['period_end']),
]).'</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<a class="btn btn-primary" href="'.$rootdir.'/pdfgen.php?ptype=spesometro" target="_blank">
<i class="fa fa-print fa-2x"></i><br>
'.tr('Stampa').'<br>
'.tr('Spesometro').'
</a>
</div>
</div>
</div>
</div>
</div>
</div>';

View File

@ -9,11 +9,11 @@ foreach ($get as $key => $value) {
${$key} = !empty(${$key}) ? ${$key} : $value;
}
// Mostro o nascondo i costi dell'intervento...
$visualizza_costi = get_var('Visualizza i costi sulle stampe degli interventi');
// Individuazione del formato della stampa
$old_format = file_exists($docroot.'/templates/'.$ptype.'/pdfgen.'.$ptype.'.php') || file_exists($docroot.'/templates/'.$ptype.'/custom/pdfgen.'.$ptype.'.php');
// Nuovo sistema di generazione stampe
if (file_exists($docroot.'/templates/'.$ptype.'/init.php')) {
if (!$old_format) {
// Impostazioni di default
if (file_exists($docroot.'/templates/base/custom/settings.php')) {
$default = include $docroot.'/templates/base/custom/settings.php';
@ -34,7 +34,7 @@ if (file_exists($docroot.'/templates/'.$ptype.'/init.php')) {
// Individuazione delle variabili fondamentali per la sostituzione dei contenuti
if (file_exists($docroot.'/templates/'.$ptype.'/custom/init.php')) {
include $docroot.'/templates/'.$ptype.'/custom/init.php';
} else {
} elseif (file_exists($docroot.'/templates/'.$ptype.'/init.php')) {
include $docroot.'/templates/'.$ptype.'/init.php';
}
@ -141,16 +141,19 @@ $mode = !empty($filename) ? 'F' : 'I';
$filename = !empty($filename) ? $filename : sanitizeFilename($report_name);
$title = basename($filename);
if (file_exists($docroot.'/templates/'.$ptype.'/init.php')) {
if (!$old_format) {
$styles = [
'templates/base/bootstrap.css',
'templates/base/style.css',
];
$settings['orientation'] = strtoupper($settings['orientation']) == 'L' ? 'L' : 'P';
$settings['format'] = is_string($settings['format']) ? $settings['format'].($settings['orientation'] == 'L' ? '-L' : '') : $settings['format'];
// Instanziamento dell'oggetto mPDF
$mpdf = new mPDF(
'c',
$settings['dimension'],
$settings['format'],
$settings['font-size'],
'helvetica',
$settings['margins']['left'],
@ -159,7 +162,7 @@ if (file_exists($docroot.'/templates/'.$ptype.'/init.php')) {
$settings['margins']['bottom'] + $settings['footer-height'],
$settings['margins']['top'],
$settings['margins']['bottom'],
strtolower($settings['orientation']) == 'l' ? 'l' : 'p'
$settings['orientation']
);
// Impostazione di header e footer
@ -177,6 +180,7 @@ if (file_exists($docroot.'/templates/'.$ptype.'/init.php')) {
// Impostazione del font-size
$mpdf->WriteHTML('body {font-size: '.$settings['font-size'].'pt;}', 1);
$mpdf->shrink_tables_to_fit = 1;
// Aggiunta dei contenuti
$mpdf->WriteHTML($report);

View File

@ -1,8 +1,8 @@
<?php
return [
'orientation' => 'p',
'dimension' => 'A4',
'orientation' => 'L',
'format' => 'A4',
'font-size' => 10,
'margins' => [
'top' => 10,

View File

@ -15,7 +15,9 @@ p {
table {
width: 100%;
overflow: wrap
overflow: wrap;
word-break: break-all;
word-wrap: break-word;
}
table td,
@ -24,6 +26,7 @@ table th {
padding: 4px;
}
.row-bg,
table.table-striped tbody tr:nth-child(2n) td {
background-color: #eee;
}

View File

@ -53,9 +53,15 @@ if ($dir == 'entrata') {
$rs = $dbo->fetchArray($query);
if ($dir == 'entrata') {
$body .= "<span style='font-size:15pt; margin-left:6px;'><b>REGISTRO IVA VENDITA</b></span><br><br>";
$body .= "<span style='font-size:15pt; margin-left:6px;'><b>".tr('Registro iva vendita dal _START_ al _END_', [
'_START_' => Translator::dateToLocale($_SESSION['period_start']),
'_END_' => Translator::dateToLocale($_SESSION['period_end']),
], ['upper' => true]).'</b></span><br><br>';
} elseif ($dir == 'uscita') {
$body .= "<span style='font-size:15pt; margin-left:6px;'><b>REGISTRO IVA ACQUISTO</b></span><br><br>";
$body .= "<span style='font-size:15pt; margin-left:6px;'><b>".tr('Registro iva acquisto dal _START_ al _END_', [
'_START_' => Translator::dateToLocale($_SESSION['period_start']),
'_END_' => Translator::dateToLocale($_SESSION['period_end']),
], ['upper' => true]).'</b></span><br><br>';
}
$body .= "

View File

@ -0,0 +1,181 @@
<?php
include_once __DIR__.'/../../core.php';
$report_name = 'spesometro.pdf';
// Intestazione tabella per righe
echo "
<h3 class='text-bold'>".tr('Spesometro dal _START_ al _END_', [
'_START_' => Translator::dateToLocale($_SESSION['period_start']),
'_END_' => Translator::dateToLocale($_SESSION['period_end']),
], ['upper' => true])."</h3>
<table class='table table-bordered'>
<thead>
<tr>
<th class='text-center' style='width:10%'>".tr('P.Iva', [], ['upper' => true])."</th>
<th class='text-center' style='width:15%'>".tr('Ragione sociale', [], ['upper' => true])."</th>
<th class='text-center' style='width:25%'>".tr('Documento', [], ['upper' => true])."</th>
<th class='text-center' style='width:20%'>".tr('Aliquota', [], ['upper' => true])."</th>
<th class='text-center' style='width:10%'>".tr('Imponibile', [], ['upper' => true])."</th>
<th class='text-center' style='width:10%'>".tr('IVA', [], ['upper' => true])."</th>
<th class='text-center' style='width:10%'>".tr('Totale', [], ['upper' => true]).'</th>
</tr>
</thead>
<tbody>';
$imponibile = [];
$iva = [];
$totale = [];
$date_start = $_SESSION['period_start'];
$date_end = $_SESSION['period_end'];
$anagrafiche = $dbo->fetchArray('SELECT idanagrafica, piva, ragione_sociale FROM `an_anagrafiche` WHERE `idanagrafica` IN (SELECT DISTINCT `idanagrafica` FROM `co_documenti` WHERE co_documenti.data>='.prepare($date_start).' AND co_documenti.data<='.prepare($date_end).' AND `co_documenti`.`id` IN (SELECT `iddocumento` FROM co_movimenti WHERE primanota = 1)) ORDER BY `ragione_sociale`');
foreach ($anagrafiche as $i => $anagrafica) {
$fatture = $dbo->fetchArray('SELECT `co_documenti`.*, `co_tipidocumento`.`descrizione` AS tipo_documento, `co_tipidocumento`.`dir` FROM `co_documenti` JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento` WHERE `co_documenti`.`idanagrafica` = '.prepare($anagrafica['idanagrafica']).' AND `co_documenti`.`id` IN (SELECT `iddocumento` FROM co_movimenti WHERE primanota = 1) AND co_documenti.data>='.prepare($date_start).' AND co_documenti.data<='.prepare($date_end).' ORDER BY `data`');
$num = 0;
foreach ($fatture as $key => $fattura) {
$righe = $dbo->fetchArray('SELECT `idiva`, `desc_iva`, SUM(subtotale) - SUM(sconto) AS imponibile, SUM(iva) AS iva, SUM(subtotale) - SUM(sconto) + SUM(iva) AS totale FROM `co_righe_documenti` WHERE iddocumento='.prepare($fattura['id']).' GROUP BY `idiva`, `desc_iva` ORDER BY `idiva`');
$fatture[$key]['righe'] = $righe;
$num += count($righe);
}
$extra = ($i % 2) != 0 ? ' class="row-bg"' : '';
if ($num > 0) {
echo '
<tr'.$extra.'>
<td rowspan="'.$num.'">
'.$anagrafica['ragione_sociale'].'
</td>';
// Partita IVA
echo '
<td rowspan="'.$num.'">
'.$anagrafica['piva'].'
</td>';
$count = 0;
foreach ($fatture as $fattura) {
$descrizione = tr('_DOC_ num. _NUM_ del _DATE_', [
'_DOC_' => $fattura['tipo_documento'],
'_NUM_' => !empty($fattura['numero_esterno']) ? $fattura['numero_esterno'] : $fattura['numero'],
'_DATE_' => Translator::dateToLocale($fattura['data']),
]);
// Documenti replicati per IVA
foreach ($fattura['righe'] as $riga) {
if ($count != 0) {
echo '
<tr'.$extra.'>';
}
++$count;
// Documento
echo '
<td>
'.$descrizione.'
</td>';
// Descrizione IVA
echo '
<td>
'.$riga['desc_iva'].'
</td>';
// Imponible
echo '
<td class="text-center">
'.Translator::numberToLocale($riga['imponibile'], 2).' &euro;
</td>';
// IVA
echo '
<td class="text-center">
'.Translator::numberToLocale($riga['iva'], 2).' &euro;
</td>';
// Totale
echo '
<td class="text-center">
'.Translator::numberToLocale($riga['totale'], 2).' &euro;
</td>
</tr>';
if (empty($iva[$riga['desc_iva']])) {
$iva[$riga['desc_iva']] = [];
}
$imponibile[] = $riga['imponibile'];
$iva[$riga['desc_iva']][] = $riga['iva'];
$totale[] = $riga['totale'];
}
}
}
}
echo '
</tbody>';
// Totale imponibile
echo '
<tr>
<td colspan="4" class="text-right">
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
</td>
<th colspan="3" class="text-center">
<b>'.Translator::numberToLocale(sum($imponibile), 2).' &euro;</b>
</th>
</tr>';
foreach ($iva as $desc => $values) {
$sum = sum($values);
// Totale IVA
echo '
<tr>
<td colspan="4" class="text-right">
<b>'.tr('IVA "_TYPE_"', [
'_TYPE_' => $desc,
], ['upper' => true]).':</b>
</td>
<th colspan="3" class="text-center">
<b>'.Translator::numberToLocale($sum, 2).' &euro;</b>
</th>
</tr>';
$totale_iva += $sum;
}
// Totale IVA
echo '
<tr>
<td colspan="4" class="text-right">
<b>'.tr('Totale IVA', [], ['upper' => true]).':</b>
</td>
<th colspan="3" class="text-center">
<b>'.Translator::numberToLocale($totale_iva, 2).' &euro;</b>
</th>
</tr>';
// TOTALE
echo '
<tr>
<td colspan="4" class="text-right">
<b>'.tr('Totale', [], ['upper' => true]).':</b>
</td>
<th colspan="3" class="text-center">
<b>'.Translator::numberToLocale(sum($totale), 2).' &euro;</b>
</th>
</tr>';
echo '
</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="'.__DIR__.'/logo_azienda.jpg" alt="Logo" border="0"/>
</div>
</div>';

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -0,0 +1,5 @@
<?php
return [
'orientation' => 'L',
];