mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
some import stuff
This commit is contained in:
parent
fb001caee4
commit
3e3bb594ea
|
@ -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')]),
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
Loading…
Reference in a new issue