mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-24 23:37:51 +01:00
Aggiunta campi marca e modello in import Impianti
This commit is contained in:
parent
9df84eb7fb
commit
4152b51b83
@ -289,7 +289,7 @@ class CSV extends CSVImporter
|
||||
$id_settore = '';
|
||||
if (!empty($record['id_settore'])) {
|
||||
$settore = $record['id_settore'];
|
||||
$id_settore = $database->fetchOne('SELECT `an_settori`.`id` FROM `an_settori` LEFT JOIN (`an_settori_lang` ON`an_settori`.`id` = `an_settori_lang`.`id_record` AND `an_settori_lang`.`id_lang` = '.prepare(\Models\Locale::getDefault()->id).') WHERE LOWER(`name`) = LOWER('.prepare($settore).')')['id'];
|
||||
$id_settore = $database->fetchArray('SELECT `an_settori`.`id` FROM `an_settori` LEFT JOIN `an_settori_lang` ON (`an_settori`.`id` = `an_settori_lang`.`id_record` AND `an_settori_lang`.`id_lang` = '.prepare(\Models\Locale::getDefault()->id).') WHERE LOWER(`name`) = LOWER('.prepare($settore).')');
|
||||
|
||||
if (empty($id_settore)) {
|
||||
$id_settore = database()->query('INSERT INTO `an_settori` (`id`, `created_at`, `updated_at`) VALUES (NULL, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)');
|
||||
|
@ -86,6 +86,14 @@ class CSV extends CSVImporter
|
||||
'field' => 'data',
|
||||
'label' => 'Data installazione',
|
||||
],
|
||||
[
|
||||
'field' => 'marca',
|
||||
'label' => 'Marca',
|
||||
],
|
||||
[
|
||||
'field' => 'modello',
|
||||
'label' => 'Modello',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -128,6 +136,21 @@ class CSV extends CSVImporter
|
||||
}
|
||||
}
|
||||
|
||||
// Gestione marca
|
||||
$id_marca = null;
|
||||
if (!empty($record['marca'])) {
|
||||
// Marca
|
||||
$n = $database->fetchOne('SELECT `id` FROM `my_impianti_marche` WHERE `name`='.prepare($record['marca']))['id'];
|
||||
|
||||
if (empty($n)) {
|
||||
$query = 'INSERT INTO `my_impianti_marche` (`name`) VALUES ('.prepare($record['marca']).')';
|
||||
$database->query($query);
|
||||
$id_marca = $database->lastInsertedID();
|
||||
} else {
|
||||
$id_marca = $n;
|
||||
}
|
||||
}
|
||||
|
||||
// Individuazione impianto e generazione
|
||||
$impianto = null;
|
||||
|
||||
@ -145,6 +168,8 @@ class CSV extends CSVImporter
|
||||
}
|
||||
|
||||
$impianto->idanagrafica = $anagrafica->idanagrafica;
|
||||
$impianto->id_marca = $id_marca;
|
||||
$impianto->modello = $record['modello'];
|
||||
$impianto->save();
|
||||
|
||||
if (!empty($record['sede'])) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user