diff --git a/src/Util/Autofill.php b/src/Util/Autofill.php index 5e1419db4..89ae92121 100755 --- a/src/Util/Autofill.php +++ b/src/Util/Autofill.php @@ -30,8 +30,8 @@ class Autofill protected $space = 0; protected $current = 0; - protected $max_rows = 26; - protected $max_rows_first_page = 38; + protected $max_rows = 27; + protected $max_rows_first_page = 39; protected $max_additional = 0; public function __construct(protected $column_number, protected $char_number = 70) diff --git a/templates/contratti/body.php b/templates/contratti/body.php index 0fed85e96..1c974ef66 100755 --- a/templates/contratti/body.php +++ b/templates/contratti/body.php @@ -39,100 +39,20 @@ if ($has_image) { // Creazione righe fantasma $autofill = new Util\Autofill($columns); -$autofill->setRows(20, 10); +$autofill->setRows(23, 0, 38); + +// Conteggio righe destinazione diversa +$autofill->count($destinazione); // Elenco impianti $impianti = $dbo->fetchArray('SELECT nome, matricola FROM my_impianti WHERE id IN (SELECT my_impianti_contratti.idimpianto FROM my_impianti_contratti WHERE idcontratto = '.prepare($documento['id']).')'); -echo ' -<div class="col-xs-5"> - <div class="text-center" style="height:5mm;"> - <b>CONTRATTO</b> - </div> - <br> - - <table class="table text-center"> - <tr> - <td valign="top" class="border-bottom border-top"> - <p class="small-bold text-muted">'.tr('Nr. documento', [], ['upper' => true]).'</p> - <p>'.$documento['numero'].'</p> - </td> - - <td class="border-bottom border-top"> - <p class="small-bold text-muted">'.tr('Data documento', [], ['upper' => true]).'</p> - <p>'.Translator::dateToLocale($documento['data_bozza']).'</p> - </td> - - <td class="border-bottom border-top"> - <p class="small-bold text-muted">'.tr('Foglio', [], ['upper' => true]).'</p> - <p> {PAGENO}/{nb} </p> - </td> - </tr>'; -if (!empty($impianti)) { - $list = []; - foreach ($impianti as $impianto) { - $list[] = $impianto['nome']." <span style='color:#777;'>(".$impianto['matricola'].')</span>'; - } - - echo ' - <br> - <p class="small-bold text-muted">'.tr('Impianti', [], ['upper' => true]).'</p> - <p><small>'.implode(', ', $list).'</small></p>'; -} -echo ' - </table> -</div> - -<div class="col-xs-6 pull-right"> - <table class="table border-bottom"> - <tr> - <td colspan=2 style="height:16mm;"> - <p class="small-bold text-muted ">'.tr('Spett.le', [], ['upper' => true]).'</p> - <p>$c_ragionesociale$</p> - <p>$c_indirizzo$</p> - <p>$c_citta_full$</p> - </td> - </tr> - - <tr> - <td class="border-bottom"> - <p class="small-bold text-muted">'.tr('Partita IVA', [], ['upper' => true]).'</p> - </td> - <td class="border-bottom text-right"> - <small>$c_piva$</small> - </td> - </tr> - - <tr> - <td class="border-bottom"> - <p class="small-bold text-muted">'.tr('Codice fiscale', [], ['upper' => true]).'</p> - </td> - <td class="border-bottom text-right"> - <small>$c_codicefiscale$</small> - </td> - </tr>'; - -if (!empty($destinazione)) { - echo ' - <tr> - <td class="border-bottom"> - <p class="small-bold text-muted">'.tr('Destinazione diversa', [], ['upper' => true]).'</p> - </td> - <td class="border-bottom text-right"> - <small>'.$destinazione.'</small> - </td> - </tr>'; -} -echo ' - </table> - </div> -</div>'; - // Descrizione if (!empty($documento['descrizione'])) { echo ' <p>'.nl2br((string) $documento['descrizione']).'</p> <br>'; +$autofill->count($documento['descrizione']); } // Intestazione tabella per righe @@ -191,8 +111,6 @@ foreach ($righe as $riga) { ++$num; $r = $riga->toArray(); - $autofill->count($r['descrizione']); - echo ' <tr> <td class="text-center" nowrap="nowrap" style="vertical-align: middle" width="25"> @@ -234,12 +152,14 @@ foreach ($righe as $riga) { $text = $text.'</td><td></td></tr><tr><td>'; echo nl2br($text); + $autofill->count($text); } } $r['descrizione'] = str_replace('Rif. '.strtolower((string) $key), '', $r['descrizione']); } $source_type = $riga::class; + $autofill->count($r['descrizione']); if (!setting('Visualizza riferimento su ogni riga in stampa')) { echo $r['descrizione']; @@ -249,8 +169,7 @@ foreach ($righe as $riga) { if ($riga->isArticolo()) { echo nl2br('<br><small>'.$riga->codice.'</small>'); - } else { - echo '-'; + $autofill->count($riga->codice, true); } if ($riga->isArticolo()) { diff --git a/templates/contratti/header.php b/templates/contratti/header.php new file mode 100644 index 000000000..cb028b7db --- /dev/null +++ b/templates/contratti/header.php @@ -0,0 +1,117 @@ +<?php + +/* + * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione + * Copyright (C) DevCode s.r.l. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +if ($options['hide-header']) { + echo ' + <!-- Intestazione vuota fornitore --> + <div class="row" style="height:111px;"> + <div class="col-xs-6"> + </div> + <div class="col-xs-6 text-right"> + </div> + </div>'; +} else { + echo ' + <!-- Intestazione fornitore --> + $default_header$'; +} + +echo ' +<div class="col-xs-5"> + <div class="text-center" style="height:5mm;"> + <b>CONTRATTO</b> + </div> + <br> + + <table class="table text-center"> + <tr> + <td valign="top" class="border-bottom border-top"> + <p class="small-bold text-muted">'.tr('Nr. documento', [], ['upper' => true]).'</p> + <p>'.$documento['numero'].'</p> + </td> + + <td class="border-bottom border-top"> + <p class="small-bold text-muted">'.tr('Data documento', [], ['upper' => true]).'</p> + <p>'.Translator::dateToLocale($documento['data_bozza']).'</p> + </td> + <td class="border-bottom border-top center text-center"> + <p class="small-bold text-muted">'.tr('Foglio', [], ['upper' => true]).'</p> + <p>{PAGENO}/{nb}</p> + </td> + </tr>'; +if (!empty($impianti)) { + $list = []; + foreach ($impianti as $impianto) { + $list[] = $impianto['nome']." <span style='color:#777;'>(".$impianto['matricola'].')</span>'; + } + + echo ' + <br> + <p class="small-bold text-muted">'.tr('Impianti', [], ['upper' => true]).'</p> + <p><small>'.implode(', ', $list).'</small></p>'; +} +echo ' + </table> +</div> + +<div class="col-xs-6 pull-right"> + <table class="table border-bottom"> + <tr> + <td colspan=2 style="height:16mm;"> + <p class="small-bold text-muted ">'.tr('Spett.le', [], ['upper' => true]).'</p> + <p>$c_ragionesociale$</p> + <p>$c_indirizzo$</p> + <p>$c_citta_full$</p> + </td> + </tr> + + <tr> + <td class="border-bottom"> + <p class="small-bold text-muted">'.tr('Partita IVA', [], ['upper' => true]).'</p> + </td> + <td class="border-bottom text-right"> + <small>$c_piva$</small> + </td> + </tr> + + <tr> + <td class="border-bottom"> + <p class="small-bold text-muted">'.tr('Codice fiscale', [], ['upper' => true]).'</p> + </td> + <td class="border-bottom text-right"> + <small>$c_codicefiscale$</small> + </td> + </tr>'; + +if (!empty($destinazione)) { + echo ' + <tr> + <td class="border-bottom"> + <p class="small-bold text-muted">'.tr('Destinazione diversa', [], ['upper' => true]).'</p> + </td> + <td class="border-bottom text-right"> + <small>'.$destinazione.'</small> + </td> + </tr>'; +} +echo ' + </table> + </div> +</div>'; diff --git a/templates/ddt/body.php b/templates/ddt/body.php index 9c9a043e3..c15e830ab 100755 --- a/templates/ddt/body.php +++ b/templates/ddt/body.php @@ -24,8 +24,12 @@ $prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA'); // Creazione righe fantasma $autofill = new Util\Autofill($options['pricing'] ? 6 : 3, 70); -$rows_per_page = ($documento['note'] || $options['pricing'] ? 19 : 27); -$autofill->setRows($rows_per_page, 0, 32); +$rows_per_page = ($documento['note'] || $options['pricing'] ? ($tipo_doc == 'Ddt in uscita' ? 20 : 22) : 27); +$autofill->setRows($rows_per_page, 0, $options['last-page-footer'] ? 34 : $rows_per_page); + +// Conteggio righe destinazione diversa +$autofill->count($destinazione); +$autofill->count($partenza); // Intestazione tabella per righe echo " diff --git a/templates/ddt/header.php b/templates/ddt/header.php index 4fe51454f..ccc146d7a 100755 --- a/templates/ddt/header.php +++ b/templates/ddt/header.php @@ -103,8 +103,9 @@ echo ' <td class="text-right"> <small>$c_codicefiscale$</small> </td> - </tr> - + </tr>'; +if (!empty($partenza)) { + echo' <tr> <td class="border-bottom"> <p class="small-bold text-muted">'.tr('Partenza merce', [], ['upper' => true]).'</p> @@ -113,6 +114,7 @@ echo ' <p><small>'.$partenza.'</small></p> </td> </tr>'; +} if (!empty($destinazione)) { echo ' diff --git a/templates/ddt/init.php b/templates/ddt/init.php index 687a5f430..d5c020000 100755 --- a/templates/ddt/init.php +++ b/templates/ddt/init.php @@ -52,7 +52,11 @@ if (empty($documento['numero_esterno'])) { // Leggo i dati della destinazione (se 0=sede legale, se!=altra sede da leggere da tabella an_sedi) $destinazione = ''; if (!empty($documento['idsede_destinazione'])) { - $rsd = $dbo->fetchArray('SELECT (SELECT codice FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS codice, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS ragione_sociale, nomesede, indirizzo, indirizzo2, cap, citta, provincia, piva, codice_fiscale, id_nazione, telefono, cellulare FROM an_sedi WHERE idanagrafica='.prepare($id_cliente).' AND id='.prepare($documento['idsede_destinazione'])); + if ($tipo_doc == 'Ddt in uscita') { + $rsd = $dbo->fetchArray('SELECT (SELECT codice FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS codice, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS ragione_sociale, nomesede, indirizzo, indirizzo2, cap, citta, provincia, piva, codice_fiscale, id_nazione, telefono, cellulare FROM an_sedi WHERE idanagrafica='.prepare($documento['idanagrafica']).' AND id='.prepare($documento['idsede_destinazione'])); + }else{ + $rsd = $dbo->fetchArray('SELECT (SELECT codice FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS codice, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS ragione_sociale, nomesede, indirizzo, indirizzo2, cap, citta, provincia, piva, codice_fiscale, id_nazione, telefono, cellulare FROM an_sedi WHERE idanagrafica='.prepare($id_azienda).' AND id='.prepare($documento['idsede_destinazione'])); + } if (!empty($rsd[0]['nomesede'])) { $destinazione .= $rsd[0]['nomesede'].'<br/>'; @@ -89,7 +93,11 @@ if (!empty($documento['idsede_destinazione'])) { // Leggo i dati della destinazione (se 0=sede legale, se!=altra sede da leggere da tabella an_sedi) $partenza = ''; if (!empty($documento['idsede_partenza'])) { - $rsd = $dbo->fetchArray('SELECT (SELECT codice FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS codice, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS ragione_sociale, nomesede, indirizzo, indirizzo2, cap, citta, provincia, piva, codice_fiscale, id_nazione, telefono, cellulare FROM an_sedi WHERE idanagrafica='.prepare($documento['idanagrafica']).' AND id='.prepare($documento['idsede_partenza'])); + if ($tipo_doc != 'Ddt in uscita') { + $rsd = $dbo->fetchArray('SELECT (SELECT codice FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS codice, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS ragione_sociale, nomesede, indirizzo, indirizzo2, cap, citta, provincia, piva, codice_fiscale, id_nazione, telefono, cellulare FROM an_sedi WHERE idanagrafica='.prepare($documento['idanagrafica']).' AND id='.prepare($documento['idsede_partenza'])); + }else{ + $rsd = $dbo->fetchArray('SELECT (SELECT codice FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS codice, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS ragione_sociale, nomesede, indirizzo, indirizzo2, cap, citta, provincia, piva, codice_fiscale, id_nazione, telefono, cellulare FROM an_sedi WHERE idanagrafica='.prepare($id_azienda).' AND id='.prepare($documento['idsede_partenza'])); + } if (!empty($rsd[0]['nomesede'])) { $partenza .= $rsd[0]['nomesede'].'<br/>'; diff --git a/templates/fatture/body.php b/templates/fatture/body.php index 5a19e9130..0058b28fa 100755 --- a/templates/fatture/body.php +++ b/templates/fatture/body.php @@ -27,7 +27,7 @@ $prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA'); // Creazione righe fantasma $autofill = new Util\Autofill(6, 70); -$rows_per_page = $rows_per_page ?: ($fattura_accompagnatoria ? 24 : 26); +$rows_per_page = ($fattura_accompagnatoria ? 24 : 26); $autofill->setRows($rows_per_page, 0); // Intestazione tabella per righe @@ -214,8 +214,10 @@ foreach ($righe as $riga) { } foreach ($v_iva as $desc_iva => $tot_iva) { - $autofill->count($desc_iva, true); + $autofill->count($desc_iva); } +$autofill->count($record['note']); +$autofill->next(); echo ' |autofill| @@ -253,7 +255,6 @@ if (!empty($record['note'])) { echo ' <p class="small-bold text-muted">'.tr('Note', [], ['upper' => true]).':</p> <p><small>'.nl2br((string) $record['note']).'</small></p>'; - $autofill->count($record['note'], true); } echo ' diff --git a/templates/ordini/body.php b/templates/ordini/body.php index 005fc867c..58bd390e4 100755 --- a/templates/ordini/body.php +++ b/templates/ordini/body.php @@ -60,7 +60,12 @@ $columns = $options['pricing'] ? $columns : $columns - 3; // Creazione righe fantasma $autofill = new Util\Autofill($columns); -$autofill->setRows(27, 0, 32); +$autofill->setRows(31, 0, 34); + +// Conteggio righe destinazione diversa +$autofill->count($destinazione); +$autofill->count($codice_destinatario); + // Intestazione tabella per righe echo " diff --git a/templates/preventivi/body.php b/templates/preventivi/body.php index 41f4e0bb3..cc2026649 100755 --- a/templates/preventivi/body.php +++ b/templates/preventivi/body.php @@ -68,88 +68,8 @@ if ($has_image) { $autofill = new Util\Autofill($columns); $autofill->setRows(22, 0, 36); -echo ' -<div class="col-xs-5"> - <div class="text-center" style="height:5mm;"> - <b>PREVENTIVO</b> - </div> - <br> - - <table class="table text-center"> - <tr> - <td valign="top" class="border-bottom border-top"> - <p class="small-bold text-muted">'.tr('Nr. documento', [], ['upper' => true]).'</p> - <p>'.$documento['numero'].'</p> - </td> - - <td class="border-bottom border-top"> - <p class="small-bold text-muted">'.tr('Data documento', [], ['upper' => true]).'</p> - <p>'.Translator::dateToLocale($documento['data_bozza']).'</p> - </td> - - <td class="border-bottom border-top"> - <p class="small-bold text-muted">'.tr('Foglio', [], ['upper' => true]).'</p> - <p> {PAGENO}/{nb} </p> - </td> - </tr>'; -if (!empty($impianti)) { - $list = []; - foreach ($impianti as $impianto) { - $list[] = $impianto['nome']." <span style='color:#777;'>(".$impianto['matricola'].')</span>'; - } - - echo ' - <br> - <p class="small-bold text-muted">'.tr('Impianti', [], ['upper' => true]).'</p> - <p><small>'.implode(', ', $list).'</small></p>'; -} -echo ' - </table> -</div> - <div class="col-xs-6 pull-right"> - <table class="table border-bottom"> - <tr> - <td colspan=2 style="height:16mm;"> - <p class="small-bold text-muted ">'.tr('Spett.le', [], ['upper' => true]).'</p> - <p>$c_ragionesociale$</p> - <p>$c_indirizzo$</p> - <p>$c_citta_full$</p> - </td> - </tr> - - <tr> - <td class="border-bottom"> - <p class="small-bold text-muted">'.tr('Partita IVA', [], ['upper' => true]).'</p> - </td> - <td class="border-bottom text-right"> - <small>$c_piva$</small> - </td> - </tr> - - <tr> - <td class="border-bottom"> - <p class="small-bold text-muted">'.tr('Codice fiscale', [], ['upper' => true]).'</p> - </td> - <td class="border-bottom text-right"> - <small>$c_codicefiscale$</small> - </td> - </tr>'; - -if (!empty($destinazione)) { - echo ' - <tr> - <td class="border-bottom"> - <p class="small-bold text-muted">'.tr('Destinazione diversa', [], ['upper' => true]).'</p> - </td> - <td class="border-bottom text-right"> - <small>'.$destinazione.'</small> - </td> - </tr>'; -} -echo ' - </table> - </div> -</div>'; +// Conteggio righe destinazione diversa +$autofill->count($destinazione); // Descrizione if (!empty($documento['descrizione'])) { @@ -215,7 +135,7 @@ foreach ($righe as $key => $riga) { $subtotale_gruppo += $riga->totale_imponibile; $iva_gruppo += $riga->iva; - $autofill->count($r['descrizione']); + $autofill->count($descrizione); echo ' <tr> @@ -278,7 +198,6 @@ foreach ($righe as $key => $riga) { echo ' <br><small class="text-muted">'.$text.'</small>'; - $autofill->count($text, true); } @@ -316,9 +235,6 @@ foreach ($righe as $key => $riga) { echo ' </tr>'; - $autofill->next(); - - $next = $righe->flatten()[$num]; if ($has_gruppo && ($next->is_titolo || $next == null) && ($options['pricing'] || $options['show-only-total'])) { echo ' <tr> @@ -348,10 +264,9 @@ foreach ($righe as $key => $riga) { </td> </tr>'; } - $autofill->next(); - $autofill->next(); - $autofill->next(); } + + $autofill->next(); } echo ' diff --git a/templates/preventivi/header.php b/templates/preventivi/header.php new file mode 100644 index 000000000..d1cb54898 --- /dev/null +++ b/templates/preventivi/header.php @@ -0,0 +1,117 @@ +<?php + +/* + * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione + * Copyright (C) DevCode s.r.l. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +if ($options['hide-header']) { + echo ' + <!-- Intestazione vuota fornitore --> + <div class="row" style="height:111px;"> + <div class="col-xs-6"> + </div> + <div class="col-xs-6 text-right"> + </div> + </div>'; +} else { + echo ' + <!-- Intestazione fornitore --> + $default_header$'; +} + +echo ' +<div class="col-xs-5"> + <div class="text-center" style="height:5mm;"> + <b>PREVENTIVO</b> + </div> + <br> + + <table class="table text-center"> + <tr> + <td valign="top" class="border-bottom border-top"> + <p class="small-bold text-muted">'.tr('Nr. documento', [], ['upper' => true]).'</p> + <p>'.$documento['numero'].'</p> + </td> + + <td class="border-bottom border-top"> + <p class="small-bold text-muted">'.tr('Data documento', [], ['upper' => true]).'</p> + <p>'.Translator::dateToLocale($documento['data_bozza']).'</p> + </td> + + <td class="border-bottom border-top"> + <p class="small-bold text-muted">'.tr('Foglio', [], ['upper' => true]).'</p> + <p> {PAGENO}/{nb} </p> + </td> + </tr>'; +if (!empty($impianti)) { + $list = []; + foreach ($impianti as $impianto) { + $list[] = $impianto['nome']." <span style='color:#777;'>(".$impianto['matricola'].')</span>'; + } + + echo ' + <br> + <p class="small-bold text-muted">'.tr('Impianti', [], ['upper' => true]).'</p> + <p><small>'.implode(', ', $list).'</small></p>'; +} +echo ' + </table> +</div> + <div class="col-xs-6 pull-right"> + <table class="table border-bottom"> + <tr> + <td colspan=2 style="height:16mm;"> + <p class="small-bold text-muted ">'.tr('Spett.le', [], ['upper' => true]).'</p> + <p>$c_ragionesociale$</p> + <p>$c_indirizzo$</p> + <p>$c_citta_full$</p> + </td> + </tr> + + <tr> + <td class="border-bottom"> + <p class="small-bold text-muted">'.tr('Partita IVA', [], ['upper' => true]).'</p> + </td> + <td class="border-bottom text-right"> + <small>$c_piva$</small> + </td> + </tr> + + <tr> + <td class="border-bottom"> + <p class="small-bold text-muted">'.tr('Codice fiscale', [], ['upper' => true]).'</p> + </td> + <td class="border-bottom text-right"> + <small>$c_codicefiscale$</small> + </td> + </tr>'; + +if (!empty($destinazione)) { + echo ' + <tr> + <td class="border-bottom"> + <p class="small-bold text-muted">'.tr('Destinazione diversa', [], ['upper' => true]).'</p> + </td> + <td class="border-bottom text-right"> + <small>'.$destinazione.'</small> + </td> + </tr>'; +} +echo ' + </table> + </div> +</div>'; \ No newline at end of file