diff --git a/modules/fasce_orarie/actions.php b/modules/fasce_orarie/actions.php index 4ba9f1090..e4093c5bc 100644 --- a/modules/fasce_orarie/actions.php +++ b/modules/fasce_orarie/actions.php @@ -26,20 +26,25 @@ switch (post('op')) { $ora_inizio = post('ora_inizio'); $ora_fine = post('ora_fine'); $include_bank_holidays = post('include_bank_holidays'); - + $is_predefined = post('is_predefined'); + if ($dbo->fetchNum('SELECT * FROM `in_fasceorarie` WHERE `nome`='.prepare($nome).' AND `id`!='.prepare($id_record)) == 0) { + + if (!empty($is_predefined)) { + $dbo->query('UPDATE in_fasceorarie SET is_predefined = 0'); + } $dbo->update('in_fasceorarie', [ 'nome' => $nome, 'giorni' => $giorni ? implode(',' , $giorni) : null, - 'ora_inizio' =>$ora_inizio, + 'ora_inizio' => $ora_inizio, 'ora_fine' => $ora_fine, 'include_bank_holidays' => $include_bank_holidays, + 'is_predefined' => $is_predefined, ], [ 'id' => $id_record, ]); - flash()->info(tr('Salvataggio completato.')); } else { flash()->error(tr("E' già presente una _TYPE_ con lo stesso nome", [ diff --git a/modules/fasce_orarie/edit.php b/modules/fasce_orarie/edit.php index b256b5442..1540cc52f 100644 --- a/modules/fasce_orarie/edit.php +++ b/modules/fasce_orarie/edit.php @@ -46,20 +46,21 @@ include_once __DIR__.'/../../core.php';
-
+
{[ "type": "time", "label": "", "name": "ora_inizio", "required": 1, "value": "$ora_inizio$" ]}
-
+
{[ "type": "time", "label": "", "name": "ora_fine", "required": 1, "value": "$ora_fine$" ]}
-
+
{[ "type": "checkbox", "label": "", "name": "include_bank_holidays", "required": 0, "value": "$include_bank_holidays$" ]}
- - +
+ {[ "type": "checkbox", "label": "", "name": "is_predefined", "required": 0, "value": "$is_predefined$" ]} +
diff --git a/update/2_4_33.sql b/update/2_4_33.sql index aaeb2dd1d..3f61779f8 100644 --- a/update/2_4_33.sql +++ b/update/2_4_33.sql @@ -6,6 +6,7 @@ CREATE TABLE IF NOT EXISTS `in_fasceorarie` ( `ora_inizio` time DEFAULT NULL, `ora_fine` time DEFAULT NULL, `can_delete` BOOLEAN NOT NULL DEFAULT TRUE, + `is_predefined` BOOLEAN NOT NULL DEFAULT FALSE, `include_bank_holidays` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB; @@ -23,7 +24,7 @@ INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `visible`, -- Fascia oraria "Ordinaria" -INSERT INTO `in_fasceorarie` (`id`, `nome`, `giorni`, `ora_inizio`, `ora_fine`, `can_delete`) VALUES (NULL, 'Ordinario', '1,2,3,4,5,6,7', '00:00', '23:59', '0'); +INSERT INTO `in_fasceorarie` (`id`, `nome`, `giorni`, `ora_inizio`, `ora_fine`, `can_delete`, `is_predefined`) VALUES (NULL, 'Ordinario', '1,2,3,4,5,6,7', '00:00', '23:59', '0', '1'); -- Relazione fasca oraria / tipo intervento CREATE TABLE IF NOT EXISTS `in_fasceorarie_tipiintervento` ( @@ -114,7 +115,7 @@ CREATE TABLE `an_regioni` ( `iso2` varchar(2) DEFAULT NULL, `name` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), - FOREIGN KEY (`id_nazione`) REFERENCES `an_nazioni`(`id`) ON DELETE CASCADE + FOREIGN KEY (`id_nazione`) REFERENCES `an_nazioni`(`id`) ) ENGINE=InnoDB;