From 3e3bb594eab81376d831328908cf0eeccfa054fc Mon Sep 17 00:00:00 2001 From: spencerrlongg Date: Tue, 22 Aug 2023 16:20:05 -0500 Subject: [PATCH] some import stuff --- app/Http/Livewire/Importer.php | 2 +- app/Importer/AssetImporter.php | 20 -------------------- app/Importer/ItemImporter.php | 15 ++++++++------- 3 files changed, 9 insertions(+), 28 deletions(-) diff --git a/app/Http/Livewire/Importer.php b/app/Http/Livewire/Importer.php index 257c3f1fe0..488187ec72 100644 --- a/app/Http/Livewire/Importer.php +++ b/app/Http/Livewire/Importer.php @@ -194,7 +194,7 @@ class Importer extends Component ]; $this->assets_fields = [ - 'asset_eol_date' => 'Asset EOL DAte', + 'asset_eol_date' => trans('general.eol'), 'company' => trans('general.company'), 'location' => trans('general.location'), 'item_name' => trans('general.item_name_var', ['item' => trans('general.asset')]), diff --git a/app/Importer/AssetImporter.php b/app/Importer/AssetImporter.php index 39f7b9f1b3..76eae0739a 100644 --- a/app/Importer/AssetImporter.php +++ b/app/Importer/AssetImporter.php @@ -120,26 +120,6 @@ class AssetImporter extends ItemImporter $item['next_audit_date'] = $this->item['next_audit_date']; } - $item['asset_eol_date'] = null; - if (isset($this->item['asset_eol_date'])) { - $model = AssetModel::find($this->item['model_id']); - if(is_null($model->eol)) { - $item['asset_eol_date'] = Carbon::parse($this->item['asset_eol_date'])->format('Y-m-d'); - $item['eol_explicit'] = true; - } elseif (!is_null($model->eol) && !is_null($this->item['purchase_date'])) { - $item['asset_eol_date'] = Carbon::parse($this->item['purchase_date'])->addMonths($model->eol)->format('Y-m-d'); - } - } - - // if(($item['asset_eol_date'] == null) && ($asset->model?->eol != null) && ($asset->asset_purchase_date != null)){ - // $asset->eol_explicit = false; - // $asset->asset_eol_date = Carbon::parse($asset->asset_purchase_date)->addMonths($asset->model->eol)->format('Y-m-d'); - // } else { - // $asset->eol_explicit = true; - // $parsedDate = Carbon::parse($this->item['asset_eol_date']); - // $asset->asset_eol_date = $parsedDate->format('Y-m-d'); - // } - if ($editingAsset) { $asset->update($item); } else { diff --git a/app/Importer/ItemImporter.php b/app/Importer/ItemImporter.php index 256d74d921..f8a21cfe53 100644 --- a/app/Importer/ItemImporter.php +++ b/app/Importer/ItemImporter.php @@ -10,6 +10,7 @@ use App\Models\Manufacturer; use App\Models\Statuslabel; use App\Models\Supplier; use App\Models\User; +use Carbon\CarbonImmutable; class ItemImporter extends Importer { @@ -87,13 +88,12 @@ class ItemImporter extends Importer $this->item['next_audit_date'] = date('Y-m-d', strtotime($this->findCsvMatch($row, 'next_audit_date'))); } - // $this->item['asset_eol_date'] = null; - // if ($this->findCsvMatch($row, 'asset_eol_date') != '') { - // ray()->clearAll(); - // ray('item importer line 93'); - // return; - // $this->item['asset_eol_date'] = Carbon::parse($this->findCsvMatch($row, 'asset_eol_date'))->format('Y-m-d'); - // } + $this->item['asset_eol_date'] = null; + if ($this->findCsvMatch($row, 'asset_eol_date') != '') { + if(!empty($this->findCsvMatch($row, 'asset_eol_date'))) { + $this->item['asset_eol_date'] = CarbonImmutable::parse($this->findCsvMatch($row, 'asset_eol_date')); + } + } $this->item['qty'] = $this->findCsvMatch($row, 'quantity'); $this->item['requestable'] = $this->findCsvMatch($row, 'requestable'); @@ -240,6 +240,7 @@ class ItemImporter extends Importer $this->log('Asset Model Updated'); return $asset_model->id; + // here } $this->log('No Matching Model, Creating a new one');