diff --git a/modules/stampe_contabili/edit.php b/modules/stampe_contabili/edit.php index 1b5a3cf3c..32141a102 100644 --- a/modules/stampe_contabili/edit.php +++ b/modules/stampe_contabili/edit.php @@ -3,24 +3,52 @@ include_once __DIR__.'/../../core.php'; echo ' -
-
-

'.tr('Registri iva').'

-
- -
-
-
- - '.tr('Stampa registro iva vendite').' - +
+
+
+
+

'.tr('Registri iva dal _START_ al _END_', [ + '_START_' => Translator::dateToLocale($_SESSION['period_start']), + '_END_' => Translator::dateToLocale($_SESSION['period_end']), + ]).'

-
+ +
+
+
+

'.tr('Spesometro dal _START_ al _END_', [ + '_START_' => Translator::dateToLocale($_SESSION['period_start']), + '_END_' => Translator::dateToLocale($_SESSION['period_end']), + ]).'

+
+ + +
+
'; diff --git a/pdfgen.php b/pdfgen.php index 2148b43ea..1d3bf3dd0 100644 --- a/pdfgen.php +++ b/pdfgen.php @@ -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); diff --git a/templates/base/settings.php b/templates/base/settings.php index 721e335c0..620835ef2 100644 --- a/templates/base/settings.php +++ b/templates/base/settings.php @@ -1,8 +1,8 @@ 'p', - 'dimension' => 'A4', + 'orientation' => 'L', + 'format' => 'A4', 'font-size' => 10, 'margins' => [ 'top' => 10, diff --git a/templates/base/style.css b/templates/base/style.css index 0043f9833..d62022afa 100644 --- a/templates/base/style.css +++ b/templates/base/style.css @@ -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; } diff --git a/templates/registro_iva/pdfgen.registro_iva.php b/templates/registro_iva/pdfgen.registro_iva.php index 78c87ff04..6b7f382de 100644 --- a/templates/registro_iva/pdfgen.registro_iva.php +++ b/templates/registro_iva/pdfgen.registro_iva.php @@ -53,9 +53,15 @@ if ($dir == 'entrata') { $rs = $dbo->fetchArray($query); if ($dir == 'entrata') { - $body .= "REGISTRO IVA VENDITA

"; + $body .= "".tr('Registro iva vendita dal _START_ al _END_', [ + '_START_' => Translator::dateToLocale($_SESSION['period_start']), + '_END_' => Translator::dateToLocale($_SESSION['period_end']), + ], ['upper' => true]).'

'; } elseif ($dir == 'uscita') { - $body .= "REGISTRO IVA ACQUISTO

"; + $body .= "".tr('Registro iva acquisto dal _START_ al _END_', [ + '_START_' => Translator::dateToLocale($_SESSION['period_start']), + '_END_' => Translator::dateToLocale($_SESSION['period_end']), + ], ['upper' => true]).'

'; } $body .= " diff --git a/templates/spesometro/body.php b/templates/spesometro/body.php new file mode 100644 index 000000000..ee9bfefb1 --- /dev/null +++ b/templates/spesometro/body.php @@ -0,0 +1,181 @@ +".tr('Spesometro dal _START_ al _END_', [ + '_START_' => Translator::dateToLocale($_SESSION['period_start']), + '_END_' => Translator::dateToLocale($_SESSION['period_end']), +], ['upper' => true])." + + + + + + + + + + + + + + + '; + +$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 ' + + '; + + // Partita IVA + echo ' + '; + + $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 ' + '; + } + ++$count; + + // Documento + echo ' + '; + + // Descrizione IVA + echo ' + '; + + // Imponible + echo ' + '; + + // IVA + echo ' + '; + + // Totale + echo ' + + '; + + if (empty($iva[$riga['desc_iva']])) { + $iva[$riga['desc_iva']] = []; + } + + $imponibile[] = $riga['imponibile']; + $iva[$riga['desc_iva']][] = $riga['iva']; + $totale[] = $riga['totale']; + } + } + } +} + +echo ' + '; + +// Totale imponibile +echo ' + + + + + '; + +foreach ($iva as $desc => $values) { + $sum = sum($values); + // Totale IVA + echo ' + + + + +'; + + $totale_iva += $sum; +} + +// Totale IVA +echo ' + + + + + '; + +// TOTALE +echo ' + + + + '; + +echo ' +
".tr('P.Iva', [], ['upper' => true])."".tr('Ragione sociale', [], ['upper' => true])."".tr('Documento', [], ['upper' => true])."".tr('Aliquota', [], ['upper' => true])."".tr('Imponibile', [], ['upper' => true])."".tr('IVA', [], ['upper' => true])."".tr('Totale', [], ['upper' => true]).'
+ '.$anagrafica['ragione_sociale'].' + + '.$anagrafica['piva'].' + + '.$descrizione.' + + '.$riga['desc_iva'].' + + '.Translator::numberToLocale($riga['imponibile'], 2).' € + + '.Translator::numberToLocale($riga['iva'], 2).' € + + '.Translator::numberToLocale($riga['totale'], 2).' € +
+ '.tr('Imponibile', [], ['upper' => true]).': + + '.Translator::numberToLocale(sum($imponibile), 2).' € +
+ '.tr('IVA "_TYPE_"', [ + '_TYPE_' => $desc, + ], ['upper' => true]).': + + '.Translator::numberToLocale($sum, 2).' € +
+ '.tr('Totale IVA', [], ['upper' => true]).': + + '.Translator::numberToLocale($totale_iva, 2).' € +
+ '.tr('Totale', [], ['upper' => true]).': + + '.Translator::numberToLocale(sum($totale), 2).' € +
'; diff --git a/templates/spesometro/header.php b/templates/spesometro/header.php new file mode 100644 index 000000000..10edc41ab --- /dev/null +++ b/templates/spesometro/header.php @@ -0,0 +1,17 @@ + +
+
+

$f_ragionesociale$

+

$f_indirizzo$ $f_citta_full$

+

'.(!empty($f_piva) ? tr('P.Iva').': ' : '').'$f_piva$

+

'.(!empty($f_codicefiscale) ? tr('C.F.').': ' : '').'$f_codicefiscale$

+

'.(!empty($f_capsoc) ? tr('Cap.Soc.').': ' : '').'$f_capsoc$

+

'.(!empty($f_telefono) ? tr('Tel').': ' : '').'$f_telefono$

+
+
+ Logo +
+
'; diff --git a/templates/spesometro/logo_azienda.jpg b/templates/spesometro/logo_azienda.jpg new file mode 100644 index 000000000..3fd391452 Binary files /dev/null and b/templates/spesometro/logo_azienda.jpg differ diff --git a/templates/spesometro/settings.php b/templates/spesometro/settings.php new file mode 100644 index 000000000..d03065d6e --- /dev/null +++ b/templates/spesometro/settings.php @@ -0,0 +1,5 @@ + 'L', +];