1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-20 04:06:34 +01:00
openstamanager/modules/banche/actions.php

75 lines
2.1 KiB
PHP
Raw Normal View History

2018-03-28 17:04:10 +02:00
<?php
include_once __DIR__.'/../../core.php';
switch (filter('op')) {
case 'update':
2018-06-26 14:30:26 +02:00
2018-03-28 17:04:10 +02:00
$nome = filter('nome');
if (isset($nome)) {
2018-06-26 14:30:26 +02:00
$array = [
'nome' => $nome,
2018-07-19 15:33:32 +02:00
'filiale' => post('filiale'),
'iban' => post('iban'),
'bic' => post('bic'),
'id_pianodeiconti3' => post('id_pianodeiconti3'),
'note' => post('note'),
2018-06-26 14:30:26 +02:00
];
if (!empty($id_record)) {
$dbo->update('co_banche', $array, ['id' => $id_record]);
}
2018-07-19 17:29:21 +02:00
flash()->info(tr('Salvataggio completato!'));
2018-03-28 17:04:10 +02:00
} else {
2018-07-19 17:29:21 +02:00
flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!'));
2018-03-28 17:04:10 +02:00
}
break;
case 'add':
$nome = filter('nome');
if (isset($nome)) {
$dbo->query('INSERT INTO `co_banche` (`nome`) VALUES ('.prepare($nome).')');
$id_record = $dbo->lastInsertedID();
2018-06-26 14:30:26 +02:00
if (isAjaxRequest()) {
echo json_encode(['id' => $id_record, 'text' => $nome]);
}
2018-07-19 17:29:21 +02:00
flash()->info(tr('Aggiunta nuova _TYPE_', [
2018-03-28 17:04:10 +02:00
'_TYPE_' => 'banca',
]));
2018-03-28 17:04:10 +02:00
} else {
2018-07-19 17:29:21 +02:00
flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!'));
2018-03-28 17:04:10 +02:00
}
break;
case 'delete':
2018-06-26 14:30:26 +02:00
$documenti = $dbo->fetchNum('SELECT idanagrafica FROM an_anagrafiche WHERE idbanca_vendite='.prepare($id_record).'
2018-03-28 17:22:55 +02:00
UNION SELECT idanagrafica FROM an_anagrafiche WHERE idbanca_acquisti='.prepare($id_record));
2018-06-26 14:30:26 +02:00
2018-03-28 17:22:55 +02:00
if (isset($id_record) && empty($documenti)) {
2018-03-28 17:04:10 +02:00
$dbo->query('DELETE FROM `co_banche` WHERE `id`='.prepare($id_record));
2018-07-19 17:29:21 +02:00
flash()->info(tr('_TYPE_ eliminata con successo!', [
2018-03-28 17:04:10 +02:00
'_TYPE_' => 'Banca',
]));
2018-06-26 14:30:26 +02:00
} else {
$array = [
'deleted' => 1,
];
$dbo->update('co_banche', $array, ['id' => $id_record]);
2018-07-19 17:29:21 +02:00
flash()->info(tr('_TYPE_ eliminata con successo!', [
2018-03-28 17:22:55 +02:00
'_TYPE_' => 'Banca',
]));
2018-06-26 14:30:26 +02:00
}
2018-03-28 17:04:10 +02:00
break;
}