Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/banche/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
$banca->codice_sia = post('codice_sia');
$banca->commissioni_riba_insolute = post('commissioni_riba_insolute');

$banca->predefined = post('predefined');
$banca->enabled = post('enabled');
$banca->predefined = $banca->enabled ? post('predefined') : 0;

$banca->save();

Expand Down
1 change: 1 addition & 0 deletions modules/banche/ajax/select.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

if (empty($filter)) {
$where[] = 'deleted_at IS NULL';
$where[] = 'enabled = 1';
}

$where[] = 'id_anagrafica='.prepare($superselect['id_anagrafica']);
Expand Down
8 changes: 6 additions & 2 deletions modules/banche/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@
{[ "type": "checkbox", "label": "<?php echo tr('Predefinito'); ?>", "name": "predefined", "value": "$predefined$", "disabled": "<?php echo intval($record['predefined']); ?>" ]}
</div>

<div class="col-md-6">
<div class="col-md-2">
{[ "type": "checkbox", "label": "<?php echo tr('Attivo'); ?>", "name": "enabled", "value": "$enabled$" ]}
</div>

<div class="col-md-4">
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "nome", "required": "1", "value": "$nome$" ]}
</div>
</div>
Expand Down Expand Up @@ -412,4 +416,4 @@ function createSepaBadge(value, label) {
e.preventDefault();
checkIban();
});
</script>
</script>
12 changes: 11 additions & 1 deletion modules/banche/src/Banca.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static function build(?Anagrafica $anagrafica = null, $nome = null, $iban
$model->nome = $nome;
$model->iban = $iban;
$model->bic = $bic;
$model->enabled = 1;

// Salvataggio delle informazioni
$model->save();
Expand Down Expand Up @@ -84,11 +85,20 @@ public function save(array $options = [])

protected function fixPredefined()
{
$enabled = $this->enabled ?? true;
$predefined = $this->predefined ?? false;

// Selezione automatica per primo record
// Una banca disabilitata non può essere predefinita.
if (empty($enabled)) {
$this->attributes['predefined'] = 0;

return;
}

// Selezione automatica per primo record attivo.
$count = self::where('id_anagrafica', $this->id_anagrafica)
->where('id', '!=', $this->id)
->where('enabled', 1)
->count();
if (empty($predefined) && empty($count)) {
$predefined = true;
Expand Down
3 changes: 3 additions & 0 deletions update/2_12.sql
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`, `ord
INSERT INTO `zz_settings_lang` (`id_lang`, `id_record`, `title`, `help`) VALUES
(1, (SELECT `id` FROM `zz_settings` WHERE `nome` = 'Tipologia anagrafica predefinita'), 'Tipologia anagrafica predefinita', 'Tipologia (Azienda, Ente pubblico o Privato) preselezionata automaticamente nella finestra di aggiunta di una nuova anagrafica. Se non impostata, nessuna tipologia viene preselezionata.'),
(2, (SELECT `id` FROM `zz_settings` WHERE `nome` = 'Tipologia anagrafica predefinita'), 'Default entity classification', 'Classification (Company, Public entity or Private) automatically preselected in the new entity creation window. If not set, no classification is preselected.');

-- Gestione stato attivo delle banche
ALTER TABLE `co_banche` ADD `enabled` TINYINT(1) NOT NULL DEFAULT 1 AFTER `predefined`;