From 56f4e10e849fa0d66015a1438196316de4305098 Mon Sep 17 00:00:00 2001 From: Thomas Zilio Date: Mon, 29 Jul 2019 16:54:20 +0200 Subject: [PATCH] Stampe con footer in ultima pagina Aggiunto supporto a footer specifici per l'ultima pagina della stampa: vengono **aggiunti** al footer presente di default con una distanza fissa dal bordo in basso. --- modules/ddt/edit.php | 8 ++++---- modules/ddt/init.php | 11 +++++++---- src/Prints.php | 31 +++++++++++++++++++++++-------- templates/base/settings.php | 2 -- templates/base/style.css | 15 +++++++++++++++ templates/dashboard/settings.php | 1 - templates/ddt/body.php | 6 +++++- templates/ddt/footer.php | 9 +++++++-- templates/ddt/init.php | 2 -- templates/ddt/settings.php | 6 ------ templates/fatture/body.php | 8 ++++++-- templates/fatture/footer.php | 18 +++++------------- templates/fatture/init.php | 2 -- templates/fatture/settings.php | 6 ------ templates/info.php | 2 ++ templates/ordini/settings.php | 5 ----- update/2_4_11.sql | 10 ++++++++++ 17 files changed, 84 insertions(+), 58 deletions(-) delete mode 100644 templates/ddt/settings.php delete mode 100644 templates/fatture/settings.php delete mode 100644 templates/ordini/settings.php diff --git a/modules/ddt/edit.php b/modules/ddt/edit.php index fa5673afb..e14e1ad0e 100644 --- a/modules/ddt/edit.php +++ b/modules/ddt/edit.php @@ -100,7 +100,7 @@ $_SESSION['superselect']['idsede_destinazione'] = $record['idsede_destinazione'] ?> - + fetchArray('SELECT mg_articoli.id FROM ((mg_articoli INNER JOIN dt_righe_ddt ON mg_articoli.id=dt_righe_ddt.idarticolo) INNER JOIN dt_ddt ON dt_ddt.id=dt_righe_ddt.idddt) WHERE dt_ddt.id='.prepare($id_record)); @@ -109,7 +109,7 @@ $_SESSION['superselect']['idsede_destinazione'] = $record['idsede_destinazione']
{[ "type": "select", "label": "", "name": "idanagrafica", "required": 1, "value": "$idanagrafica$", "ajax-source": "clienti_fornitori" ]}
- + @@ -127,7 +127,7 @@ $_SESSION['superselect']['idsede_destinazione'] = $record['idsede_destinazione']
{[ "type": "select", "label": "", "name": "idsede_destinazione", "ajax-source": "sedi_azienda", "value": "$idsede_destinazione$" ]} -
+ find($id_record); - $record = $dbo->fetchOne('SELECT dt_ddt.*, dt_ddt.note, dt_ddt.idpagamento, dt_ddt.id AS idddt, dt_statiddt.descrizione AS `stato`, dt_tipiddt.descrizione AS `descrizione_tipodoc`, - (SELECT tipo FROM an_anagrafiche WHERE idanagrafica = dt_ddt.idanagrafica) AS tipo_anagrafica, - (SELECT completato FROM dt_statiddt WHERE dt_statiddt.id=dt_ddt.idstatoddt) AS flag_completato + $record = $dbo->fetchOne('SELECT dt_ddt.*, + dt_ddt.id AS idddt, + dt_statiddt.descrizione AS `stato`, + dt_statiddt.completato AS `flag_completato`, + dt_tipiddt.descrizione AS `descrizione_tipodoc`, + an_anagrafiche.tipo AS tipo_anagrafica FROM dt_ddt LEFT OUTER JOIN dt_statiddt ON dt_ddt.idstatoddt=dt_statiddt.id INNER JOIN an_anagrafiche ON dt_ddt.idanagrafica=an_anagrafiche.idanagrafica @@ -30,7 +33,7 @@ if (isset($id_record)) { // Se la sede del ddt non รจ di mia competenza, blocco il ddt in modifica $field_name = ($dir == 'entrata') ? 'idsede_partenza' : 'idsede_destinazione'; - if (!in_array($record[$field_name], $user->sedi)) { + if (!Auth::admin() && !in_array($record[$field_name], $user->sedi)) { $record['flag_completato'] = 1; } } diff --git a/src/Prints.php b/src/Prints.php index e945e90f8..7217cb8b9 100644 --- a/src/Prints.php +++ b/src/Prints.php @@ -437,10 +437,8 @@ class Prints 'font-size' => $settings['font-size'], 'margin_left' => $settings['margins']['left'], 'margin_right' => $settings['margins']['right'], - 'margin_top' => $settings['margins']['top'] + $settings['header-height'], - 'margin_bottom' => $settings['margins']['bottom'] + $settings['footer-height'], - 'margin_header' => $settings['margins']['top'], - 'margin_footer' => $settings['margins']['bottom'], + 'setAutoBottomMargin' => 'stretch', + 'setAutoTopMargin' => 'stretch', // Abilitazione per lo standard PDF/A //'PDFA' => true, @@ -478,14 +476,14 @@ class Prints include self::filepath($id_print, 'header.php'); $head = ob_get_clean(); + // Header di default + $head = !empty($head) ? $head : '$default_header$'; + // Generazione dei contenuti del footer ob_start(); include self::filepath($id_print, 'footer.php'); $foot = ob_get_clean(); - // Header di default - $head = !empty($head) ? $head : '$default_header$'; - // Footer di default $foot = !empty($foot) ? $foot : '$default_footer$'; @@ -493,8 +491,8 @@ class Prints include DOCROOT.'/templates/replace.php'; // Impostazione di header e footer - $mpdf->SetHTMLFooter($foot); $mpdf->SetHTMLHeader($head); + $mpdf->SetHTMLFooter($foot); // Generazione dei contenuti della stampa @@ -526,6 +524,16 @@ class Prints $report = ''; } + // Footer per l'ultima pagina + if (!empty($options['last-page-footer'])) { + $is_last_page = true; + + // Generazione dei contenuti del footer + ob_start(); + include self::filepath($id_print, 'footer.php'); + $foot = ob_get_clean(); + } + // Operazioni di sostituzione include DOCROOT.'/templates/replace.php'; @@ -541,6 +549,13 @@ class Prints // Aggiunta dei contenuti $mpdf->WriteHTML($report); + // Impostazione footer per l'ultima pagina + if (!empty($options['last-page-footer'])) { + $mpdf->WriteHTML(''); + + $mpdf->WriteHTML('
'.$foot.'
'); + } + // Creazione effettiva del PDF $mpdf->Output($path, $mode); diff --git a/templates/base/settings.php b/templates/base/settings.php index 83117a135..8cce1dc92 100644 --- a/templates/base/settings.php +++ b/templates/base/settings.php @@ -10,8 +10,6 @@ $settings = [ 'left' => 12, 'right' => 12, ], - 'header-height' => 35, - 'footer-height' => 5, 'header-font-size' => 10, ]; diff --git a/templates/base/style.css b/templates/base/style.css index d62022afa..9fa2af605 100644 --- a/templates/base/style.css +++ b/templates/base/style.css @@ -122,3 +122,18 @@ table#contents tbody td { .cell-padded { padding: 4px; } + +.fake-footer p, +.fake-footer table, +.fake-footer table.table-bordered th, +.fake-footer table.table-striped tbody tr td, +.fake-footer th, +.fake-footer tbody, +.fake-footer thead, +.fake-footer tfoot, +.fake-footer td, +.fake-footer tr { + color: white !important; + background: none !important; + border-color: white !important; +} diff --git a/templates/dashboard/settings.php b/templates/dashboard/settings.php index 9fb324916..754a1e442 100644 --- a/templates/dashboard/settings.php +++ b/templates/dashboard/settings.php @@ -6,5 +6,4 @@ $orientation = (isset($_SESSION['settings']['orientation'])) ? $_SESSION['settin return [ 'format' => $format, 'orientation' => $orientation, - // 'header-height' => 0, ]; diff --git a/templates/ddt/body.php b/templates/ddt/body.php index e40637814..afd0fdba2 100644 --- a/templates/ddt/body.php +++ b/templates/ddt/body.php @@ -4,7 +4,11 @@ include_once __DIR__.'/../../core.php'; // Creazione righe fantasma $autofill = new \Util\Autofill($options['pricing'] ? 5 : 2); -$autofill->setRows(16); +$rows_per_page = 16; +if (!empty($options['last-page-footer'])) { + $rows_per_page += 10; +} +$autofill->setRows($rows_per_page); // Intestazione tabella per righe echo " diff --git a/templates/ddt/footer.php b/templates/ddt/footer.php index cdf5d32a9..82bb25faf 100644 --- a/templates/ddt/footer.php +++ b/templates/ddt/footer.php @@ -1,5 +1,9 @@ imponibile; $sconto = $documento->sconto; @@ -180,5 +184,6 @@ echo ' '; -echo ' -$default_footer$'; +if (empty($options['last-page-footer'])) { + echo '$default_footer$'; +} diff --git a/templates/ddt/init.php b/templates/ddt/init.php index 243b22376..3eedacd6e 100644 --- a/templates/ddt/init.php +++ b/templates/ddt/init.php @@ -48,8 +48,6 @@ if (!empty($documento['idsede_destinazione'])) { if (!empty($rsd[0]['provincia'])) { $destinazione .= ' ('.$rsd[0]['provincia'].')'; } - - $settings['header-height'] += 8; } // Sostituzioni specifiche diff --git a/templates/ddt/settings.php b/templates/ddt/settings.php deleted file mode 100644 index 823eee4e4..000000000 --- a/templates/ddt/settings.php +++ /dev/null @@ -1,6 +0,0 @@ - 67, - 'footer-height' => 80, -]; diff --git a/templates/fatture/body.php b/templates/fatture/body.php index 0e679fc55..c28a5d32c 100644 --- a/templates/fatture/body.php +++ b/templates/fatture/body.php @@ -6,8 +6,12 @@ $v_iva = []; $v_totale = []; // Creazione righe fantasma -$autofill = new \Util\Autofill(5, 70); -$autofill->setRows($fattura_accompagnatoria ? 15 : 20, $fattura_accompagnatoria ? 10 : 15); +$autofill = new \Util\Autofill(5, 40); +$rows_per_page = $fattura_accompagnatoria ? 15 : 20; +if (!empty($options['last-page-footer'])) { + $rows_per_page += 10; +} +$autofill->setRows($rows_per_page); // Intestazione tabella per righe echo " diff --git a/templates/fatture/footer.php b/templates/fatture/footer.php index 15dbd0607..1dac01326 100644 --- a/templates/fatture/footer.php +++ b/templates/fatture/footer.php @@ -1,5 +1,9 @@ imponibile); $sconto = $documento->sconto; @@ -391,18 +395,6 @@ echo ' '; -if ($options['hide_footer']) { - echo ' - - - - - -
-   - -   -
'; -} else { +if (empty($options['last-page-footer'])) { echo '$default_footer$'; } diff --git a/templates/fatture/init.php b/templates/fatture/init.php index d00756961..8379430e9 100644 --- a/templates/fatture/init.php +++ b/templates/fatture/init.php @@ -70,8 +70,6 @@ if (!empty($record['idsede_destinazione'])) { if (!empty($rsd[0]['provincia'])) { $destinazione .= ' ('.$rsd[0]['provincia'].')'; } - - $settings['header-height'] += 15; } // Sostituzioni specifiche diff --git a/templates/fatture/settings.php b/templates/fatture/settings.php deleted file mode 100644 index 93ca6f664..000000000 --- a/templates/fatture/settings.php +++ /dev/null @@ -1,6 +0,0 @@ - 70, - 'footer-height' => 55, -]; diff --git a/templates/info.php b/templates/info.php index 53dcddb08..32e29a543 100644 --- a/templates/info.php +++ b/templates/info.php @@ -87,10 +87,12 @@ foreach ($replace as $prefix => $values) { // Header di default $header_file = App::filepath('templates/base|custom|/header.php'); $default_header = include $header_file; +$default_header = !empty($options['hide-header']) ? '' : $default_header; // Footer di default $footer_file = App::filepath('templates/base|custom|/footer.php'); $default_footer = include $footer_file; +$default_footer = !empty($options['hide-footer']) ? '' : $default_footer; // Logo di default $default_logo = App::filepath('templates/base|custom|/logo_azienda.jpg'); diff --git a/templates/ordini/settings.php b/templates/ordini/settings.php deleted file mode 100644 index 24bb25a27..000000000 --- a/templates/ordini/settings.php +++ /dev/null @@ -1,5 +0,0 @@ - 60, -]; diff --git a/update/2_4_11.sql b/update/2_4_11.sql index 956a3a399..df304626f 100644 --- a/update/2_4_11.sql +++ b/update/2_4_11.sql @@ -1,4 +1,6 @@ UPDATE `zz_prints` SET `filename` = 'Preventivo num. {numero} del {data}' WHERE `name` = 'Preventivo (senza totali)'; +UPDATE `zz_prints` SET `filename` = 'Fattura num. {numero} del {data}' WHERE `name` = 'Fattura di vendita (senza intestazione)'; +UPDATE `zz_prints` SET `filename` = 'Calendario' WHERE `name` = 'Stampa calendario'; DELETE FROM `zz_plugins` WHERE `name` = 'Pianificazione ordini di servizio'; @@ -250,3 +252,11 @@ INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, ((SELECT `id` FROM `zz_modules` WHERE `name` = 'Checklists'), 'Nome', 'name', 2, 1, 0, 0, 1), ((SELECT `id` FROM `zz_modules` WHERE `name` = 'Checklists'), 'Modulo', '(SELECT name FROM zz_modules WHERE id = zz_checklists.id_module)', 5, 1, 0, 1, 1), ((SELECT `id` FROM `zz_modules` WHERE `name` = 'Checklists'), 'Plugin', '(SELECT name FROM zz_plugins WHERE id = zz_checklists.id_plugin)', 5, 1, 0, 1, 1); + +-- Miglioramento gestione header e footer per le stampe +UPDATE `zz_prints` SET `options` = REPLACE(`options`, "hide_header", "hide-header"); +UPDATE `zz_prints` SET `options` = REPLACE(`options`, "hide_footer", "hide-footer"); +UPDATE `zz_prints` SET `options` = '{"last-page-footer": true}' WHERE `zz_prints`.`name` = 'Fattura di vendita'; +UPDATE `zz_prints` SET `options` = '{"hide-header": true, "hide-footer": true, "last-page-footer": true}' WHERE `zz_prints`.`name` = 'Fattura di vendita (senza intestazione)'; +UPDATE `zz_prints` SET `options` = '{"pricing":true, "last-page-footer": true}' WHERE `zz_prints`.`name` = 'Ordine cliente'; +UPDATE `zz_prints` SET `options` = '{"pricing":false, "last-page-footer": true}' WHERE `zz_prints`.`name` = 'Ordine cliente (senza costi)';