1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-20 20:25:17 +01:00
openstamanager/modules/banche/actions.php
Thomas Zilio e72d86412d Fix #408
2018-12-28 08:07:56 +01:00

63 lines
1.7 KiB
PHP

<?php
include_once __DIR__.'/../../core.php';
switch (filter('op')) {
case 'update':
$nome = filter('nome');
if (isset($nome)) {
$array = [
'nome' => $nome,
'filiale' => post('filiale'),
'iban' => post('iban'),
'bic' => post('bic'),
'id_pianodeiconti3' => post('id_pianodeiconti3'),
'note' => post('note'),
];
if (!empty($id_record)) {
$dbo->update('co_banche', $array, ['id' => $id_record]);
}
flash()->info(tr('Salvataggio completato.'));
} else {
flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!'));
}
break;
case 'add':
$nome = filter('nome');
$bic = filter('bic');
$iban = filter('iban');
if (isset($nome)) {
$dbo->query('INSERT INTO `co_banche` (`nome`, `bic`, `iban`) VALUES ('.prepare($nome).', '.prepare($bic).', '.prepare($iban).')');
$id_record = $dbo->lastInsertedID();
if (isAjaxRequest()) {
echo json_encode(['id' => $id_record, 'text' => $nome]);
}
flash()->info(tr('Aggiunta nuova _TYPE_', [
'_TYPE_' => 'banca',
]));
} else {
flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!'));
}
break;
case 'delete':
$dbo->update('co_banche', [
'deleted_at' => date('Y-m-d H:i:s'),
], ['id' => $id_record]);
flash()->info(tr('_TYPE_ eliminata con successo!', [
'_TYPE_' => 'Banca',
]));
break;
}