mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-18 04:20:50 +01:00
Aggiunta generazione stato in import attività
This commit is contained in:
parent
c96d66cbf9
commit
3613eb18dc
@ -107,7 +107,7 @@ class CSV extends CSVImporter
|
|||||||
$impianto = Impianto::where('matricola', $record['impianto'])->first();
|
$impianto = Impianto::where('matricola', $record['impianto'])->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($anagrafica) && !empty($impianto)) {
|
if (!empty($anagrafica)) {
|
||||||
$intervento = null;
|
$intervento = null;
|
||||||
|
|
||||||
// Ricerca sulla base della chiave primaria se presente
|
// Ricerca sulla base della chiave primaria se presente
|
||||||
@ -128,6 +128,10 @@ class CSV extends CSVImporter
|
|||||||
} else {
|
} else {
|
||||||
$stato = Stato::where('descrizione', $record['stato'])->first();
|
$stato = Stato::where('descrizione', $record['stato'])->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($stato)) {
|
||||||
|
$stato = Stato::build($record['stato']);
|
||||||
|
}
|
||||||
unset($record['stato']);
|
unset($record['stato']);
|
||||||
|
|
||||||
// Crea l'intervento
|
// Crea l'intervento
|
||||||
@ -139,13 +143,15 @@ class CSV extends CSVImporter
|
|||||||
unset($record['ora_inizio']);
|
unset($record['ora_inizio']);
|
||||||
unset($record['telefono']);
|
unset($record['telefono']);
|
||||||
|
|
||||||
$collegamento = $database->table('my_impianti_interventi')->where('idimpianto', $impianto['id'])->where('idintervento', $intervento['id'])->first();
|
if (!empty($impianto)) {
|
||||||
|
$collegamento = $database->table('my_impianti_interventi')->where('idimpianto', $impianto['id'])->where('idintervento', $intervento['id'])->first();
|
||||||
|
|
||||||
if (empty($collegamento)) {
|
if (empty($collegamento)) {
|
||||||
// Collega l'impianto all'intervento
|
// Collega l'impianto all'intervento
|
||||||
$database->query('INSERT INTO my_impianti_interventi(idimpianto, idintervento) VALUES('.prepare($impianto['id']).', '.prepare($intervento['id']).')');
|
$database->query('INSERT INTO my_impianti_interventi(idimpianto, idintervento) VALUES('.prepare($impianto['id']).', '.prepare($intervento['id']).')');
|
||||||
|
}
|
||||||
|
unset($record['impianto']);
|
||||||
}
|
}
|
||||||
unset($record['impianto']);
|
|
||||||
|
|
||||||
// Inserisce la data richiesta e la richiesta
|
// Inserisce la data richiesta e la richiesta
|
||||||
$intervento->data_richiesta = $record['data_richiesta'];
|
$intervento->data_richiesta = $record['data_richiesta'];
|
||||||
@ -185,7 +191,7 @@ class CSV extends CSVImporter
|
|||||||
public static function getExample()
|
public static function getExample()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['Codice', 'Telefono', 'Data', 'Data richiesta', 'Ora', 'Tecnico', 'Tipo', 'Note', 'Impianto', 'Richiesta', 'Descrizione', 'Stato'],
|
['Codice', 'Telefono', 'Data', 'Data richiesta', 'Ora inizio', 'Tecnico', 'Tipo', 'Note', 'Impianto', 'Richiesta', 'Descrizione', 'Stato'],
|
||||||
['001', '044444444', '07/11/2023', '03/11/2023', '18:30', 'Stefano Bianchi', '', '', '00000000001', 'Manutenzione ordinaria', 'eseguito intervento di manutenzione', 'Bozza'],
|
['001', '044444444', '07/11/2023', '03/11/2023', '18:30', 'Stefano Bianchi', '', '', '00000000001', 'Manutenzione ordinaria', 'eseguito intervento di manutenzione', 'Bozza'],
|
||||||
['002', '044444444', '08/11/2023', '04/11/2023', '11:20', 'Stefano Bianchi', '', '', '00000000002', 'Manutenzione ordinaria', 'eseguito intervento di manutenzione', ''],
|
['002', '044444444', '08/11/2023', '04/11/2023', '11:20', 'Stefano Bianchi', '', '', '00000000002', 'Manutenzione ordinaria', 'eseguito intervento di manutenzione', ''],
|
||||||
];
|
];
|
||||||
|
@ -37,8 +37,14 @@ trait SimpleModelTrait
|
|||||||
*
|
*
|
||||||
* @return static
|
* @return static
|
||||||
*/
|
*/
|
||||||
public static function build()
|
public static function build($nome)
|
||||||
{
|
{
|
||||||
return new static();
|
$model = new static();
|
||||||
|
|
||||||
|
$model->codice = 'NEW';
|
||||||
|
$model->descrizione = $nome;
|
||||||
|
$model->save();
|
||||||
|
|
||||||
|
return $model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user