A free open source IT asset/license management system
Added more common fields for mapping
snipe36767c0a5c96
diff --git a/app/Importer/ItemImporter.php b/app/Importer/ItemImporter.phpindex 435f081aba..b8f2494096 100644--- a/app/Importer/ItemImporter.php+++ b/app/Importer/ItemImporter.php@@ -24,6 +24,12 @@ class ItemImporter extends Importerprotected function handle($row){++ /**+ * This section adds the most common fields into the $item array so we don't have to manually add them to+ * things like accessories, consumables, etc.+ */+// Need to reset this between iterations or we'll have stale data.$this->item = [];@@ -73,29 +79,20 @@ class ItemImporter extends Importer$this->item['notes'] = $this->findCsvMatch($row, 'notes');$this->item['order_number'] = $this->findCsvMatch($row, 'order_number');$this->item['purchase_cost'] = $this->findCsvMatch($row, 'purchase_cost');+ $this->item['model_number'] = trim($this->findCsvMatch($row, 'model_number'));+ $this->item['min_amt'] = $this->findCsvMatch($row, 'min_amt');+ $this->item['qty'] = $this->findCsvMatch($row, 'quantity');+ $this->item['requestable'] = $this->findCsvMatch($row, 'requestable');+ $this->item['created_by'] = auth()->id();+ $this->item['serial'] = $this->findCsvMatch($row, 'serial');+ $this->item['item_no'] = trim($this->findCsvMatch($row, 'item_number'));+$this->item['purchase_date'] = null;if ($this->findCsvMatch($row, 'purchase_date') != '') {$this->item['purchase_date'] = date('Y-m-d', strtotime($this->findCsvMatch($row, 'purchase_date')));}-// $this->item['asset_eol_date'] = null;-// if ($this->findCsvMatch($row, 'asset_eol_date') != '') {-// $csvMatch = $this->findCsvMatch($row, 'asset_eol_date');-// \Log::warning('EOL Date for $csvMatch is '.$csvMatch);-// try {-// $this->item['asset_eol_date'] = CarbonImmutable::parse($csvMatch)->format('Y-m-d');-// } catch (\Exception $e) {-// Log::info($e->getMessage());-// $this->log('Unable to parse date: '.$csvMatch);-// }-// }--- $this->item['qty'] = $this->findCsvMatch($row, 'quantity');- $this->item['requestable'] = $this->findCsvMatch($row, 'requestable');- $this->item['created_by'] = auth()->id();- $this->item['serial'] = $this->findCsvMatch($row, 'serial');// NO need to call this method if we're running the user import.// TODO: Merge these methods.$this->item['checkout_class'] = $this->findCsvMatch($row, 'checkout_class');@@ -512,7 +509,6 @@ class ItemImporter extends Importerif ($supplier->save()) {$this->log('Supplier '.$item_supplier.' was created');-return $supplier->id;}$this->logError($supplier, 'Supplier');