mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-03 09:17:37 +01:00
Fix import impianti
This commit is contained in:
parent
f899c57ed2
commit
a2ef25ef13
@ -77,17 +77,17 @@ switch (post('op')) {
|
||||
$anagrafica = Anagrafica::find($id);
|
||||
if (empty($anagrafica->lat) && empty($anagrafica->lng) && !empty($anagrafica->sedeLegale->indirizzo) && !empty($anagrafica->sedeLegale->citta) && !empty($anagrafica->sedeLegale->cap)) {
|
||||
$indirizzo = urlencode($anagrafica->sedeLegale->indirizzo.' '.$anagrafica->sedeLegale->citta.' '.$anagrafica->sedeLegale->cap);
|
||||
|
||||
try{
|
||||
|
||||
try {
|
||||
// Ricerca indirizzo
|
||||
$address = $geocoder->geocode($indirizzo)->first();
|
||||
$coordinates = $address->getCoordinates();
|
||||
|
||||
|
||||
// Salvataggio informazioni
|
||||
$anagrafica->lat = $coordinates->getLatitude();
|
||||
$anagrafica->lng = $coordinates->getLongitude();
|
||||
$anagrafica->save();
|
||||
}catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
flash()->error("Impossibile recuperare le coordinate dell'anagrafica ".$anagrafica->ragione_sociale." per l'indirizzo ".$anagrafica->sedeLegale->indirizzo.' '.$anagrafica->sedeLegale->citta.' '.$anagrafica->sedeLegale->cap);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ use Models\Upload;
|
||||
use Modules;
|
||||
use Modules\Anagrafiche\Anagrafica;
|
||||
use Modules\Anagrafiche\Sede;
|
||||
use Modules\Anagrafiche\Tipo;
|
||||
use Modules\Impianti\Categoria;
|
||||
use Modules\Impianti\Impianto;
|
||||
use Uploads;
|
||||
@ -148,16 +147,6 @@ class CSV extends CSVImporter
|
||||
}
|
||||
|
||||
$impianto->id_sottocategoria = $sottocategoria['id'];
|
||||
$impianto->save();
|
||||
|
||||
$tipo = Tipo::where('descrizione', 'Cliente')->first();
|
||||
$tipi = $anagrafica->tipi->pluck('idtipoanagrafica')->toArray();
|
||||
|
||||
$tipi[] = $tipo->id;
|
||||
|
||||
$anagrafica->tipologie = $tipi;
|
||||
$anagrafica->save();
|
||||
|
||||
$impianto->idanagrafica = $anagrafica->idanagrafica;
|
||||
$impianto->save();
|
||||
|
||||
|
@ -21,11 +21,12 @@ namespace Modules\Interventi\Import;
|
||||
|
||||
use Importer\CSVImporter;
|
||||
use Modules\Anagrafiche\Anagrafica;
|
||||
use Modules\Anagrafiche\Tipo as TipoAnagrafica;
|
||||
use Modules\Impianti\Impianto;
|
||||
use Modules\Interventi\Components\Sessione;
|
||||
use Modules\Interventi\Intervento;
|
||||
use Modules\Interventi\Stato;
|
||||
use Modules\TipiIntervento\Tipo;
|
||||
use Modules\TipiIntervento\Tipo as TipoIntervento;
|
||||
|
||||
/**
|
||||
* Struttura per la gestione delle operazioni di importazione (da CSV) degli Interventi.
|
||||
@ -116,9 +117,9 @@ class CSV extends CSVImporter
|
||||
|
||||
// Verifico tipo e stato per creare l'intervento
|
||||
if (empty($record['tipo'])) {
|
||||
$tipo = Tipo::where('codice', 'GEN')->first();
|
||||
$tipo = TipoIntervento::where('codice', 'GEN')->first();
|
||||
} else {
|
||||
$tipo = Tipo::where('codice', $record['tipo'])->first();
|
||||
$tipo = TipoIntervento::where('codice', $record['tipo'])->first();
|
||||
}
|
||||
unset($record['tipo']);
|
||||
|
||||
@ -138,8 +139,12 @@ class CSV extends CSVImporter
|
||||
unset($record['ora_inizio']);
|
||||
unset($record['telefono']);
|
||||
|
||||
// Collega l'impianto all'intervento
|
||||
$database->query('INSERT INTO my_impianti_interventi(idimpianto, idintervento) VALUES('.prepare($impianto['id']).', '.prepare($intervento['id']).')');
|
||||
$collegamento = $database->table('my_impianti_interventi')->where('idimpianto', $impianto['id'])->where('idintervento', $intervento['id'])->first();
|
||||
|
||||
if (empty($collegamento)) {
|
||||
// Collega l'impianto all'intervento
|
||||
$database->query('INSERT INTO my_impianti_interventi(idimpianto, idintervento) VALUES('.prepare($impianto['id']).', '.prepare($intervento['id']).')');
|
||||
}
|
||||
unset($record['impianto']);
|
||||
|
||||
// Inserisce la data richiesta e la richiesta
|
||||
|
@ -837,7 +837,7 @@ switch (post('op')) {
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
// Duplica ordine
|
||||
case 'copy':
|
||||
$new = $ordine->replicate();
|
||||
|
@ -130,7 +130,7 @@ switch ($operazione) {
|
||||
$riga->setPrezzoUnitario($prezzo_unitario, $r->idiva);
|
||||
$riga->setSconto(($r->tipo_sconto == 'PRC' ? $r->sconto_percentuale : $r->sconto_unitario), $r->tipo_sconto);
|
||||
$riga->qta = $qta_riga;
|
||||
$riga->setProvvigione(($r->provvigione_percentuale?$r->provvigione_percentuale:$r->provvigione_unitaria), $r->tipo_provvigione);
|
||||
$riga->setProvvigione(($r->provvigione_percentuale ? $r->provvigione_percentuale : $r->provvigione_unitaria), $r->tipo_provvigione);
|
||||
$riga->idpianificazione = $pianificazioni[$rata];
|
||||
|
||||
$riga->save();
|
||||
|
Loading…
x
Reference in New Issue
Block a user