From 054188c53c9df622ec472d0ae678c113965e71d8 Mon Sep 17 00:00:00 2001 From: Sajo <75281007+sajotrei@users.noreply.github.com> Date: Wed, 5 Aug 2026 16:38:19 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Aggiunge=20azione=20di=20gruppo=20per=20cam?= =?UTF-8?q?biare=20le=20date=20delle=20attivit=C3=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/interventi/bulk.php | 76 ++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/modules/interventi/bulk.php b/modules/interventi/bulk.php index e2cd4aca1..e3f8583c9 100755 --- a/modules/interventi/bulk.php +++ b/modules/interventi/bulk.php @@ -238,6 +238,67 @@ break; + case 'change_date': + $campo_data = post('date_field'); + $nuova_data = post('new_date'); + + $campi_disponibili = [ + 'request' => 'data_richiesta', + 'deadline' => 'data_scadenza', + ]; + + $data = DateTime::createFromFormat('Y-m-d', (string) $nuova_data); + if (!isset($campi_disponibili[$campo_data]) || empty($nuova_data) || $data === false || $data->format('Y-m-d') !== $nuova_data) { + flash()->error(tr('Seleziona un campo e una data validi.')); + break; + } + + $campo = $campi_disponibili[$campo_data]; + $aggiornate = 0; + $ignorate_stato = 0; + $ignorate_scadenza = 0; + + foreach ($id_records as $id) { + $intervento = Intervento::find($id); + + if (empty($intervento) || empty($intervento->stato) || $intervento->stato->codice !== 'TODO') { + ++$ignorate_stato; + continue; + } + + if ($campo === 'data_scadenza' && !empty($intervento->data_richiesta) && $nuova_data < $intervento->data_richiesta->format('Y-m-d')) { + ++$ignorate_scadenza; + continue; + } + + $intervento->{$campo} = $nuova_data; + $intervento->save(); + + ++$aggiornate; + } + + if ($aggiornate > 0) { + flash()->info(tr('_NUM_ attività aggiornate correttamente.', [ + '_NUM_' => $aggiornate, + ])); + } else { + flash()->warning(tr('Nessuna attività aggiornata.')); + } + + if ($ignorate_stato > 0) { + flash()->warning(tr('_NUM_ attività ignorate perché non erano nello stato Da programmare.', [ + '_NUM_' => $ignorate_stato, + ])); + } + + if ($ignorate_scadenza > 0) { + flash()->warning(tr('_NUM_ attività ignorate perché la nuova data di scadenza precede la data richiesta.', [ + '_NUM_' => $ignorate_scadenza, + ])); + } + + break; + case 'copy_bulk': $id_stato = post('id_stato'); $data_richiesta = post('data_richiesta'); @@ -457,6 +518,19 @@ ], ]; +$operations['change_date'] = [ + 'text' => ' '.tr('Cambia data').'', + 'data' => [ + 'title' => tr('Cambiare la data delle attività selezionate?'), + 'msg' => tr('La modifica sarà applicata solamente alle attività nello stato Da programmare.').'

+ {[ "type": "select", "label": "'.tr('Campo da modificare').'", "name": "date_field", "required": 1, "values": "list=\"request\":\"'.tr('Data richiesta').'\",\"deadline\":\"'.tr('Data scadenza').'\"", "value": "request" ]}
+ {[ "type": "date", "label": "'.tr('Nuova data').'", "name": "new_date", "required": 1 ]}', + 'button' => tr('Procedi'), + 'class' => 'btn btn-lg btn-warning', + 'blank' => false, + ], +]; + $operations['copy_bulk'] = [ 'text' => ' '.tr('Duplica'), 'data' => [ @@ -536,4 +610,4 @@ ], ]; -return $operations; +return $operations; \ No newline at end of file From d2f342067f70374a2b0390bb5f4124bd71bd94db Mon Sep 17 00:00:00 2001 From: Sajo <75281007+sajotrei@users.noreply.github.com> Date: Thu, 20 Aug 2026 15:33:53 +0200 Subject: [PATCH 2/2] Corregge visualizzazione calendario nell'azione cambio date --- modules/interventi/bulk.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/interventi/bulk.php b/modules/interventi/bulk.php index e3f8583c9..f61259fac 100755 --- a/modules/interventi/bulk.php +++ b/modules/interventi/bulk.php @@ -523,8 +523,11 @@ 'data' => [ 'title' => tr('Cambiare la data delle attività selezionate?'), 'msg' => tr('La modifica sarà applicata solamente alle attività nello stato Da programmare.').'

- {[ "type": "select", "label": "'.tr('Campo da modificare').'", "name": "date_field", "required": 1, "values": "list=\"request\":\"'.tr('Data richiesta').'\",\"deadline\":\"'.tr('Data scadenza').'\"", "value": "request" ]}
- {[ "type": "date", "label": "'.tr('Nuova data').'", "name": "new_date", "required": 1 ]}', + {[ "type": "select", "label": "'.tr('Campo da modificare').'", "name": "date_field", "required": 1, "values": "list=\"request\":\"'.tr('Data richiesta').'\",\"deadline\":\"'.tr('Data scadenza').'\"", "value": "request" ]} +
+ + +
', 'button' => tr('Procedi'), 'class' => 'btn btn-lg btn-warning', 'blank' => false, @@ -610,4 +613,4 @@ ], ]; -return $operations; \ No newline at end of file +return $operations;