2017-08-04 16:28:16 +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/>.
|
|
|
|
*/
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
|
|
|
$operazione = filter('op');
|
|
|
|
|
|
|
|
switch ($operazione) {
|
|
|
|
case 'addsede':
|
2019-06-29 11:01:26 +02:00
|
|
|
if (!empty(post('nomesede'))) {
|
|
|
|
$dbo->insert('an_sedi', [
|
2019-06-25 17:13:17 +02:00
|
|
|
'idanagrafica' => $id_parent,
|
|
|
|
'nomesede' => post('nomesede'),
|
|
|
|
'indirizzo' => post('indirizzo'),
|
2019-11-20 10:16:15 +01:00
|
|
|
'codice_destinatario' => post('codice_destinatario'),
|
2019-06-25 17:13:17 +02:00
|
|
|
'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,
|
2019-06-25 17:13:17 +02:00
|
|
|
]);
|
2019-06-29 11:01:26 +02:00
|
|
|
$id_record = $dbo->lastInsertedID();
|
2019-06-25 17:13:17 +02:00
|
|
|
|
2019-06-29 11:01:26 +02:00
|
|
|
if (isAjaxRequest() && !empty($id_record)) {
|
|
|
|
echo json_encode(['id' => $id_record, 'text' => post('nomesede').' - '.post('citta')]);
|
|
|
|
}
|
2019-06-25 17:13:17 +02:00
|
|
|
|
2019-06-29 11:01:26 +02:00
|
|
|
flash()->info(tr('Aggiunta una nuova sede!'));
|
|
|
|
} else {
|
|
|
|
flash()->warning(tr('Errore durante aggiunta della sede'));
|
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'updatesede':
|
2020-03-06 16:27:02 +01:00
|
|
|
$dbo->update('an_sedi', [
|
2018-07-19 15:33:32 +02:00
|
|
|
'nomesede' => post('nomesede'),
|
|
|
|
'indirizzo' => post('indirizzo'),
|
2018-12-07 12:50:42 +01:00
|
|
|
'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'),
|
2019-11-20 00:21:58 +01:00
|
|
|
'note' => post('note'),
|
2018-07-19 15:33:32 +02:00
|
|
|
'gaddress' => post('gaddress'),
|
|
|
|
'lat' => post('lat'),
|
|
|
|
'lng' => post('lng'),
|
2020-03-06 16:27:02 +01:00
|
|
|
], ['id' => $id_record]);
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2018-07-19 17:29:21 +02:00
|
|
|
flash()->info(tr('Salvataggio completato!'));
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'deletesede':
|
2019-06-11 18:12:00 +02:00
|
|
|
$id = filter('id');
|
|
|
|
$dbo->query('DELETE FROM `an_sedi` WHERE `id` = '.prepare($id).'');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2018-07-19 17:29:21 +02:00
|
|
|
flash()->info(tr('Sede eliminata!'));
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|