mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Add the field model_number to Accessory importer
This commit is contained in:
parent
5e76d50f2d
commit
0f1c48cb6f
|
@ -14,7 +14,7 @@ class AccessoryImporter extends ItemImporter
|
|||
protected function handle($row)
|
||||
{
|
||||
parent::handle($row); // TODO: Change the autogenerated stub
|
||||
$this->createAccessoryIfNotExists();
|
||||
$this->createAccessoryIfNotExists($row);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,7 @@ class AccessoryImporter extends ItemImporter
|
|||
* @author Daniel Melzter
|
||||
* @since 3.0
|
||||
*/
|
||||
public function createAccessoryIfNotExists()
|
||||
public function createAccessoryIfNotExists($row)
|
||||
{
|
||||
$accessory = Accessory::where('name', $this->item['name'])->first();
|
||||
if ($accessory) {
|
||||
|
@ -33,12 +33,14 @@ class AccessoryImporter extends ItemImporter
|
|||
}
|
||||
|
||||
$this->log('Updating Accessory');
|
||||
$this->item['model_number'] = $this->findCsvMatch($row, "model_number");
|
||||
$accessory->update($this->sanitizeItemForUpdating($accessory));
|
||||
$accessory->save();
|
||||
return;
|
||||
}
|
||||
$this->log("No Matching Accessory, Creating a new one");
|
||||
$accessory = new Accessory();
|
||||
$this->item['model_number'] = $this->findCsvMatch($row, "model_number");
|
||||
$accessory->fill($this->sanitizeItemForStoring($accessory));
|
||||
|
||||
//FIXME: this disables model validation. Need to find a way to avoid double-logs without breaking everything.
|
||||
|
|
|
@ -141,6 +141,9 @@
|
|||
{id: 'username', text: 'Username' },
|
||||
{id: 'department', text: 'Department' },
|
||||
],
|
||||
accessories:[
|
||||
{id: 'model_number', text: 'Model Number'},
|
||||
],
|
||||
assets: [
|
||||
{id: 'asset_tag', text: 'Asset Tag' },
|
||||
{id: 'asset_model', text: 'Model Name' },
|
||||
|
@ -208,7 +211,10 @@
|
|||
.concat(this.columnOptions.assets)
|
||||
.concat(this.columnOptions.customFields)
|
||||
.sort(sorter);
|
||||
|
||||
case 'accessory':
|
||||
return this.columnOptions.general
|
||||
.concat(this.columnOptions.accessories)
|
||||
.sort(sorter);
|
||||
case 'consumable':
|
||||
return this.columnOptions.general
|
||||
.concat(this.columnOptions.consumables)
|
||||
|
|
Loading…
Reference in a new issue