openstamanager/plugins/sedi/actions.php

77 lines
2.5 KiB
PHP
Raw Normal View History

<?php
include_once __DIR__.'/../../core.php';
$operazione = filter('op');
switch ($operazione) {
case 'addsede':
if (!empty(post('nomesede'))) {
$dbo->insert('an_sedi', [
'idanagrafica' => $id_parent,
'nomesede' => post('nomesede'),
'indirizzo' => post('indirizzo'),
2019-11-20 10:16:15 +01:00
'codice_destinatario' => post('codice_destinatario'),
'citta' => post('citta'),
'cap' => post('cap'),
'provincia' => strtoupper(post('provincia')),
'km' => post('km'),
'cellulare' => post('cellulare'),
'telefono' => post('telefono'),
'email' => post('email'),
'id_nazione' => !empty(post('id_nazione')) ? post('id_nazione') : null,
2019-11-20 10:36:05 +01:00
'idzona' => !empty(post('id_zona')) ? post('id_zona') : 0,
]);
$id_record = $dbo->lastInsertedID();
if (isAjaxRequest() && !empty($id_record)) {
echo json_encode(['id' => $id_record, 'text' => post('nomesede').' - '.post('citta')]);
}
flash()->info(tr('Aggiunta una nuova sede!'));
} else {
flash()->warning(tr('Errore durante aggiunta della sede'));
}
break;
case 'updatesede':
2019-06-11 18:12:00 +02:00
$id = filter('id');
$array = [
2018-07-19 15:33:32 +02:00
'nomesede' => post('nomesede'),
'indirizzo' => post('indirizzo'),
'codice_destinatario' => post('codice_destinatario'),
2018-07-19 15:33:32 +02:00
'piva' => post('piva'),
'codice_fiscale' => post('codice_fiscale'),
'citta' => post('citta'),
'cap' => post('cap'),
2019-01-03 15:24:21 +01:00
'provincia' => strtoupper(post('provincia')),
2018-07-19 15:33:32 +02:00
'km' => post('km'),
'cellulare' => post('cellulare'),
'telefono' => post('telefono'),
'email' => post('email'),
'fax' => post('fax'),
'id_nazione' => !empty(post('id_nazione')) ? post('id_nazione') : null,
'idzona' => post('idzona'),
'note' => post('note'),
2018-07-19 15:33:32 +02:00
'gaddress' => post('gaddress'),
'lat' => post('lat'),
'lng' => post('lng'),
];
2019-06-11 18:12:00 +02:00
$dbo->update('an_sedi', $array, ['id' => $id]);
2018-07-19 17:29:21 +02:00
flash()->info(tr('Salvataggio completato!'));
break;
case 'deletesede':
2019-06-11 18:12:00 +02:00
$id = filter('id');
$dbo->query('DELETE FROM `an_sedi` WHERE `id` = '.prepare($id).'');
2018-07-19 17:29:21 +02:00
flash()->info(tr('Sede eliminata!'));
break;
}