openstamanager/modules/banche/actions.php

81 lines
2.3 KiB
PHP
Raw Normal View History

2018-03-28 17:04:10 +02:00
<?php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.n.c.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2018-03-28 17:04:10 +02:00
use Modules\Anagrafiche\Anagrafica;
use Modules\Banche\Banca;
2018-03-28 17:04:10 +02:00
include_once __DIR__.'/../../core.php';
switch (filter('op')) {
case 'add':
$id_anagrafica = filter('id_anagrafica');
$anagrafica = Anagrafica::find($id_anagrafica);
2018-03-28 17:04:10 +02:00
$nome = filter('nome');
$iban = filter('iban');
$bic = filter('bic');
2018-03-28 17:04:10 +02:00
$banca = Banca::build($anagrafica, $nome, $iban, $bic);
$id_record = $banca->id;
if (isAjaxRequest()) {
echo json_encode([
'id' => $id_record,
'text' => $nome,
]);
2018-03-28 17:04:10 +02:00
}
// Imposizione della banca come predefinita per l'Anagrafica se non impostato altrimenti
$anagrafica->idbanca_vendite = $anagrafica->idbanca_vendite ?: $id_record;
$anagrafica->idbanca_acquisti = $anagrafica->idbanca_acquisti ?: $id_record;
$anagrafica->save();
flash()->info(tr('Aggiunta nuova _TYPE_', [
'_TYPE_' => 'banca',
]));
2018-03-28 17:04:10 +02:00
break;
case 'update':
2018-03-28 17:04:10 +02:00
$nome = filter('nome');
$banca->nome = post('nome');
$banca->iban = post('iban');
$banca->bic = post('bic');
2018-06-26 14:30:26 +02:00
$banca->note = post('note');
$banca->id_pianodeiconti3 = post('id_pianodeiconti3');
$banca->filiale = post('filiale');
2018-06-26 14:30:26 +02:00
$banca->save();
flash()->info(tr('Salvataggio completato'));
2018-03-28 17:04:10 +02:00
break;
case 'delete':
$banca->delete();
2018-06-26 14:30:26 +02:00
2018-09-20 16:12:34 +02:00
flash()->info(tr('_TYPE_ eliminata con successo!', [
'_TYPE_' => 'Banca',
]));
2018-03-28 17:04:10 +02:00
break;
}