From e537c752df126e6929a05114bb80a96164c4d62f Mon Sep 17 00:00:00 2001 From: Luca Date: Tue, 25 Jun 2019 17:13:17 +0200 Subject: [PATCH] =?UTF-8?q?Aggiunta=20possibilit=C3=A0=20di=20aggiungere?= =?UTF-8?q?=20sedi=20al=20volo=20per=20le=20fatture?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/anagrafiche/ajax/select.php | 4 +-- modules/fatture/edit.php | 4 +-- plugins/referenti/actions.php | 32 ++++++++++++++------- plugins/sedi/actions.php | 44 ++++++++++++++++++----------- 4 files changed, 54 insertions(+), 30 deletions(-) diff --git a/modules/anagrafiche/ajax/select.php b/modules/anagrafiche/ajax/select.php index 641494fc8..010732a91 100644 --- a/modules/anagrafiche/ajax/select.php +++ b/modules/anagrafiche/ajax/select.php @@ -200,7 +200,7 @@ switch ($resource) { case 'sedi': if (isset($superselect['idanagrafica'])) { - $query = "SELECT * FROM (SELECT '0' AS id, 'Sede legale' AS descrizione UNION SELECT id, CONCAT_WS(' - ', nomesede, citta) FROM an_sedi |where|) AS tab |filter| ORDER BY descrizione"; + $query = "SELECT * FROM (SELECT '0' AS id, CONCAT('Sede legale', ' (' , (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica = ".$superselect['idanagrafica']." ), ')') AS descrizione UNION SELECT id, CONCAT_WS(' - ', nomesede, citta) FROM an_sedi |where|) AS tab |filter| ORDER BY descrizione"; foreach ($elements as $element) { $filter[] = 'id='.prepare($element); @@ -219,7 +219,7 @@ switch ($resource) { if (isset($superselect['idanagrafica'])) { $user = Auth::user(); - $query = "SELECT * FROM (SELECT '0' AS id, 'Sede legale' AS descrizione UNION SELECT id, CONCAT_WS(' - ', nomesede, citta) FROM an_sedi |where|) AS tab |filter| ORDER BY descrizione"; + $query = "SELECT * FROM (SELECT '0' AS id, CONCAT('Sede legale', ' (' , (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica = ".$user->idanagrafica." ), ')') AS descrizione UNION SELECT id, CONCAT_WS(' - ', nomesede, citta) FROM an_sedi |where|) AS tab |filter| ORDER BY descrizione"; foreach ($elements as $element) { $filter[] = 'id='.prepare($element); diff --git a/modules/fatture/edit.php b/modules/fatture/edit.php index 46ba6ce73..9540b6d17 100644 --- a/modules/fatture/edit.php +++ b/modules/fatture/edit.php @@ -157,7 +157,7 @@ if (empty($record['is_fiscale'])) { if ($dir == 'uscita') { ?>
- {[ "type": "select", "label": "", "name": "idsede_partenza", "ajax-source": "sedi", "placeholder": "Sede legale", "value": "$idsede_partenza$"]} + {[ "type": "select", "label": "", "name": "idsede_partenza", "ajax-source": "sedi", "placeholder": "Sede legale", "value": "$idsede_partenza$", "icon-after": "add||id_plugin=&id_parent=||" ]}
@@ -171,7 +171,7 @@ if (empty($record['is_fiscale'])) {
- {[ "type": "select", "label": "", "name": "idsede_destinazione", "ajax-source": "sedi", "value": "$idsede_destinazione$", "readonly": "" ]} + {[ "type": "select", "label": "", "name": "idsede_destinazione", "ajax-source": "sedi", "value": "$idsede_destinazione$", "readonly": "", "icon-after": "add||id_plugin=&id_parent=||" ]}
insert('an_referenti', [ - 'idanagrafica' => $id_parent, - 'nome' => post('nome'), - 'mansione' => post('mansione'), - 'telefono' => post('telefono'), - 'email' => post('email'), - 'idsede' => post('idsede'), - ]); - $id_record = $dbo->lastInsertedID(); + if (!empty(post('nome'))){ - flash()->info(tr('Aggiunto nuovo referente!')); + $dbo->insert('an_referenti', [ + 'idanagrafica' => $id_parent, + 'nome' => post('nome'), + 'mansione' => post('mansione'), + 'telefono' => post('telefono'), + 'email' => post('email'), + 'idsede' => post('idsede'), + ]); + $id_record = $dbo->lastInsertedID(); + + if (isAjaxRequest() && !empty($id_record)) { + echo json_encode(['id' => $id_record, 'text' => post('nome')]); + } + + flash()->info(tr('Aggiunto nuovo referente!')); + + }else{ + + flash()->warning(tr('Errore durante aggiunta del referente')); + + } break; diff --git a/plugins/sedi/actions.php b/plugins/sedi/actions.php index af2acad3a..f278ce1a4 100644 --- a/plugins/sedi/actions.php +++ b/plugins/sedi/actions.php @@ -6,23 +6,35 @@ $operazione = filter('op'); switch ($operazione) { case 'addsede': - $dbo->insert('an_sedi', [ - 'idanagrafica' => $id_parent, - 'nomesede' => post('nomesede'), - 'indirizzo' => post('indirizzo'), - '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, - 'idzona' => post('idzona'), - ]); - $id_record = $dbo->lastInsertedID(); - flash()->info(tr('Aggiunta una nuova sede!')); + if (!empty(post('nomesede'))){ + $dbo->insert('an_sedi', [ + 'idanagrafica' => $id_parent, + 'nomesede' => post('nomesede'), + 'indirizzo' => post('indirizzo'), + '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, + 'idzona' => post('idzona'), + ]); + $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;