Skip to content

Commit ce0d8e8

Browse files
committed
fix: numerazione stampa definitiva registro iva
1 parent fc05b8d commit ce0d8e8

3 files changed

Lines changed: 18 additions & 17 deletions

File tree

modules/stampe_contabili/actions.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323
switch (filter('op')) {
2424
case 'crea_definitiva':
2525
$year = date('Y', strtotime(post('date_start')));
26-
$print = Prints::render(post('id_print'), null, null, true);
27-
$pages = count($print['pages']);
2826

2927
$first_page = $dbo->fetchOne('SELECT MAX(last_page) AS last_page FROM co_stampecontabili WHERE `id_print`='.prepare(post('id_print')).' AND YEAR(`date_end`)='.prepare($year).' AND `dir`='.prepare(post('dir')))['last_page'] + 1;
28+
29+
$print = Prints::render(post('id_print'), null, null, true, true, ['reset' => $first_page-1, 'suppress' => 0]);
30+
$pages = count($print['pages']);
3031
$last_page = $first_page + $pages - 1;
3132

3233
$result = $dbo->table('co_stampecontabili')->insertGetId([
@@ -38,7 +39,7 @@
3839
'dir' => post('dir'),
3940
]);
4041

41-
$print = Prints::render(post('id_print'), null, null, true);
42+
$print = Prints::render(post('id_print'), null, null, true, true, ['reset' => $first_page - 1, 'suppress' => 0]);
4243
$name = 'Registro_iva_'.(post('dir') == 'entrata' ? 'vendite' : 'acquisti').'_del_'.post('date_start');
4344
$upload = Uploads::upload($print['pdf'], [
4445
'name' => $name,

src/Prints.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public static function getModulePredefinedPrint($module)
144144
* @param bool $return_string
145145
* @param bool $overwrite
146146
*/
147-
public static function render($print, $id_record, $directory = null, $return_string = false, $overwrite = true)
147+
public static function render($print, $id_record = null, $directory = null, $return_string = false, $overwrite = true, $mpdfPageNumSubstitutions = [])
148148
{
149149
// ob_end_clean(); // Compatibilità con versioni vecchie delle stampe
150150
$dbo = $database = database();
@@ -193,7 +193,7 @@ public static function render($print, $id_record, $directory = null, $return_str
193193
} elseif (self::isOldStandard($print)) {
194194
return self::oldLoader($infos['id'], $id_record, $directory, $return_string, $overwrite);
195195
} else {
196-
return self::loader($infos['id'], $id_record, $directory, $return_string, $overwrite);
196+
return self::loader($infos['id'], $id_record, $directory, $return_string, $overwrite, $mpdfPageNumSubstitutions);
197197
}
198198
}
199199

@@ -481,7 +481,7 @@ protected static function getFile($record, $id_record, $directory, $original_rep
481481
* @param string $directory
482482
* @param bool $return_string
483483
*/
484-
protected static function loader($id_print, $id_record, $directory = null, $return_string = false, $overwrite = true)
484+
protected static function loader($id_print, $id_record, $directory = null, $return_string = false, $overwrite = true, $mpdfPageNumSubstitutions = [])
485485
{
486486
$infos = self::get($id_print);
487487
$options = self::readOptions($infos['options']);
@@ -538,6 +538,10 @@ protected static function loader($id_print, $id_record, $directory = null, $retu
538538
// 'PDFAauto' => true,
539539
]);
540540

541+
if (!empty($mpdfPageNumSubstitutions)) {
542+
$mpdf->PageNumSubstitutions[] = $mpdfPageNumSubstitutions;
543+
}
544+
541545
if (setting('Filigrana stampe')) {
542546
$mpdf->SetWatermarkImage(
543547
base_dir().'/files/anagrafiche/'.setting('Filigrana stampe'),

templates/registro_iva/footer.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,10 @@
1818
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1919
*/
2020

21-
if (!empty($page)) {
22-
echo '
23-
<p class="text-right">
24-
'.tr('_YEAR_/_PAGE_', [
25-
'_PAGE_' => $page++,
26-
'_YEAR_' => date('Y'),
27-
]).'
28-
</p>';
29-
} else {
30-
echo '<p></p>';
31-
}
21+
echo '
22+
<p class="text-right">
23+
'.tr('_YEAR_/_PAGE_', [
24+
'_PAGE_' => '{PAGENO}',
25+
'_YEAR_' => date('Y'),
26+
]).'
27+
</p>';

0 commit comments

Comments
 (0)