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