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