Skip to content

Commit 1258012

Browse files
committed
fix: generazione progressivo per maschere senza riferimento all'anno
1 parent c83c337 commit 1258012

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

lib/common.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -734,20 +734,18 @@ function getNextNumeroProgressivo($table, $field, $data, $id_segment, $options =
734734

735735
// Calcola le condizioni in base alla maschera
736736
$has_month = str_contains($maschera, 'm');
737-
$has_year = str_contains($maschera, 'YYYY') || str_contains($maschera, 'yy');
737+
$data_timestamp = $data !== null ? strtotime((string) $data) : null;
738738

739739
// Costruisci le condizioni
740740
$conditions = [];
741741

742-
// Condizione per anno (solo se data è specificata)
743-
if ($has_year && $data !== null) {
744-
$data_timestamp = strtotime((string) $data);
742+
// Condizione per anno (sempre se la data è specificata)
743+
if ($data_timestamp !== null) {
745744
$conditions[] = 'YEAR('.$options['data_field'].') = '.prepare(date('Y', $data_timestamp));
746745
}
747746

748747
// Condizione per mese (solo se data è specificata)
749-
if ($has_month && $data !== null) {
750-
$data_timestamp = strtotime((string) $data);
748+
if ($has_month && $data_timestamp !== null) {
751749
$conditions[] = 'MONTH('.$options['data_field'].') = '.prepare(date('m', $data_timestamp));
752750
}
753751

0 commit comments

Comments
 (0)