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
|
2021-01-20 15:08:51 +01:00
|
|
|
* Copyright (C) DevCode s.r.l.
|
2020-09-07 15:04:06 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
2020-09-09 16:55:45 +02:00
|
|
|
use Modules\Anagrafiche\Anagrafica;
|
2021-04-26 08:45:52 +02:00
|
|
|
use Modules\Anagrafiche\Nazione;
|
2020-09-09 16:55:45 +02:00
|
|
|
use Modules\Banche\Banca;
|
2021-04-26 08:45:52 +02:00
|
|
|
use Modules\Banche\IBAN;
|
2020-09-09 16:55:45 +02:00
|
|
|
|
2018-03-28 17:04:10 +02:00
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
|
|
|
switch (filter('op')) {
|
2020-09-09 16:55:45 +02:00
|
|
|
case 'add':
|
|
|
|
$id_anagrafica = filter('id_anagrafica');
|
|
|
|
$anagrafica = Anagrafica::find($id_anagrafica);
|
|
|
|
|
2018-03-28 17:04:10 +02:00
|
|
|
$nome = filter('nome');
|
|
|
|
|
2021-04-26 09:27:05 +02:00
|
|
|
$banca = Banca::build($anagrafica, $nome, filter('iban'), filter('bic'));
|
2020-09-09 16:55:45 +02:00
|
|
|
$id_record = $banca->id;
|
|
|
|
|
|
|
|
if (isAjaxRequest()) {
|
|
|
|
echo json_encode([
|
|
|
|
'id' => $id_record,
|
|
|
|
'text' => $nome,
|
|
|
|
]);
|
2018-03-28 17:04:10 +02:00
|
|
|
}
|
|
|
|
|
2020-09-09 16:55:45 +02:00
|
|
|
flash()->info(tr('Aggiunta nuova _TYPE_', [
|
|
|
|
'_TYPE_' => 'banca',
|
|
|
|
]));
|
|
|
|
|
2018-03-28 17:04:10 +02:00
|
|
|
break;
|
|
|
|
|
2020-09-09 16:55:45 +02:00
|
|
|
case 'update':
|
2018-03-28 17:04:10 +02:00
|
|
|
$nome = filter('nome');
|
|
|
|
|
2020-09-09 16:55:45 +02:00
|
|
|
$banca->nome = post('nome');
|
|
|
|
$banca->iban = post('iban');
|
2021-04-26 09:27:05 +02:00
|
|
|
$banca->bic = post('bic');
|
2018-06-26 14:30:26 +02:00
|
|
|
|
2020-09-09 16:55:45 +02:00
|
|
|
$banca->note = post('note');
|
|
|
|
$banca->id_pianodeiconti3 = post('id_pianodeiconti3');
|
|
|
|
$banca->filiale = post('filiale');
|
2020-09-24 17:27:33 +02:00
|
|
|
$banca->creditor_id = post('creditor_id');
|
2020-10-02 17:25:26 +02:00
|
|
|
$banca->codice_sia = post('codice_sia');
|
2018-06-26 14:30:26 +02:00
|
|
|
|
2020-09-24 16:41:43 +02:00
|
|
|
$banca->predefined = post('predefined');
|
|
|
|
|
2020-09-09 16:55:45 +02:00
|
|
|
$banca->save();
|
|
|
|
|
|
|
|
flash()->info(tr('Salvataggio completato'));
|
2018-03-28 17:04:10 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'delete':
|
2020-09-09 16:55:45 +02:00
|
|
|
$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
|
|
|
|
2021-04-26 08:45:52 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'compose':
|
|
|
|
$nazione = Nazione::find(filter('id_nazione'));
|
|
|
|
|
|
|
|
$iban = IBAN::generate([
|
|
|
|
'nation' => $nazione->iso2,
|
|
|
|
'bank_code' => filter('bank_code'),
|
|
|
|
'branch_code' => filter('branch_code'),
|
|
|
|
'account_number' => filter('account_number'),
|
|
|
|
'check_digits' => filter('check_digits'),
|
|
|
|
'national_check_digits' => filter('national_check_digits'),
|
|
|
|
]);
|
|
|
|
|
|
|
|
echo json_encode([
|
|
|
|
'iban' => $iban->getIban(),
|
|
|
|
]);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'decompose':
|
|
|
|
$iban = new IBAN(filter('iban'));
|
|
|
|
$nazione = Nazione::where('iso2', '=', $iban->getNation())->first();
|
|
|
|
|
|
|
|
echo json_encode([
|
|
|
|
'id_nazione' => [
|
|
|
|
'id' => $nazione->id,
|
2023-03-23 18:19:13 +01:00
|
|
|
'iso2' => $nazione->iso2,
|
2021-04-26 08:45:52 +02:00
|
|
|
'text' => $nazione->nome,
|
|
|
|
],
|
|
|
|
'bank_code' => $iban->getBankCode(),
|
|
|
|
'branch_code' => $iban->getBranchCode(),
|
|
|
|
'account_number' => $iban->getAccountNumber(),
|
|
|
|
'check_digits' => $iban->getCheckDigits(),
|
|
|
|
'national_check_digits' => $iban->getNationalCheckDigits(),
|
|
|
|
]);
|
|
|
|
|
2018-03-28 17:04:10 +02:00
|
|
|
break;
|
|
|
|
}
|