mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 13:57:41 -08:00
Merge pull request #2189 from dmeltzer/importer-improvements
Two more importer fixes.
This commit is contained in:
commit
8942e085c3
|
@ -139,10 +139,13 @@ class ObjectImportCommand extends Command {
|
||||||
$item["notes"] = $this->array_smart_fetch($row, "notes");
|
$item["notes"] = $this->array_smart_fetch($row, "notes");
|
||||||
$item["quantity"] = $this->array_smart_fetch($row, "quantity");
|
$item["quantity"] = $this->array_smart_fetch($row, "quantity");
|
||||||
$item["requestable"] = $this->array_smart_fetch($row, "requestable");
|
$item["requestable"] = $this->array_smart_fetch($row, "requestable");
|
||||||
|
$item["asset_tag"] = $this->array_smart_fetch($row, "asset tag");
|
||||||
|
|
||||||
|
|
||||||
$this->current_assetId = $item["item_name"];
|
$this->current_assetId = $item["item_name"];
|
||||||
|
if($item["asset_tag"] != '') {
|
||||||
|
$this->current_assetId = $item["asset_tag"];
|
||||||
|
}
|
||||||
$this->log('Category: ' . $item_category);
|
$this->log('Category: ' . $item_category);
|
||||||
$this->log('Location: ' . $item_location);
|
$this->log('Location: ' . $item_location);
|
||||||
$this->log('Purchase Date: ' . $item["purchase_date"]);
|
$this->log('Purchase Date: ' . $item["purchase_date"]);
|
||||||
|
@ -226,9 +229,9 @@ class ObjectImportCommand extends Command {
|
||||||
|
|
||||||
public function jsonError($field, $errorString)
|
public function jsonError($field, $errorString)
|
||||||
{
|
{
|
||||||
$this->errors[$this->current_assetId] = array($field => $errorString);
|
$this->errors[$this->current_assetId][$field] = $errorString;
|
||||||
if($this->option('verbose'))
|
if($this->option('verbose'))
|
||||||
parent::error($errorString);
|
parent::error($field . $errorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -712,7 +715,6 @@ class ObjectImportCommand extends Command {
|
||||||
public function createAssetIfNotExists(array $row, array $item )
|
public function createAssetIfNotExists(array $row, array $item )
|
||||||
{
|
{
|
||||||
$asset_serial = $this->array_smart_fetch($row, "serial number");
|
$asset_serial = $this->array_smart_fetch($row, "serial number");
|
||||||
$asset_tag = $this->array_smart_fetch($row, "asset tag");
|
|
||||||
$asset_image = $this->array_smart_fetch($row, "image");
|
$asset_image = $this->array_smart_fetch($row, "image");
|
||||||
$asset_warranty_months = intval($this->array_smart_fetch($row, "warranty months"));
|
$asset_warranty_months = intval($this->array_smart_fetch($row, "warranty months"));
|
||||||
if(empty($asset_warranty_months)) {
|
if(empty($asset_warranty_months)) {
|
||||||
|
@ -722,17 +724,14 @@ class ObjectImportCommand extends Command {
|
||||||
$asset_model = $this->createOrFetchAssetModel($row, $item["category"], $item["manufacturer"]);
|
$asset_model = $this->createOrFetchAssetModel($row, $item["category"], $item["manufacturer"]);
|
||||||
$supplier = $this->createOrFetchSupplier($row);
|
$supplier = $this->createOrFetchSupplier($row);
|
||||||
|
|
||||||
$this->current_assetId = $asset_tag;
|
|
||||||
|
|
||||||
$this->log('Serial No: '.$asset_serial);
|
$this->log('Serial No: '.$asset_serial);
|
||||||
$this->log('Asset Tag: '.$asset_tag);
|
$this->log('Asset Tag: '.$item['asset_tag']);
|
||||||
$this->log('Notes: '.$item["notes"]);
|
$this->log('Notes: '.$item["notes"]);
|
||||||
$this->log('Warranty Months: ' . $asset_warranty_months);
|
$this->log('Warranty Months: ' . $asset_warranty_months);
|
||||||
|
|
||||||
foreach ($this->assets as $tempasset) {
|
foreach ($this->assets as $tempasset) {
|
||||||
if (strcasecmp($tempasset->asset_tag, $asset_tag ) == 0 ) {
|
if (strcasecmp($tempasset->asset_tag, $item['asset_tag'] ) == 0 ) {
|
||||||
$this->log('A matching Asset ' . $asset_tag . ' already exists');
|
$this->log('A matching Asset ' . $item['asset_tag'] . ' already exists');
|
||||||
// $this->comment('A matching Asset ' . $asset_tag . ' already exists');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -769,7 +768,7 @@ class ObjectImportCommand extends Command {
|
||||||
$asset->purchase_cost = 0.00;
|
$asset->purchase_cost = 0.00;
|
||||||
}
|
}
|
||||||
$asset->serial = $asset_serial;
|
$asset->serial = $asset_serial;
|
||||||
$asset->asset_tag = $asset_tag;
|
$asset->asset_tag = $item['asset_tag'];
|
||||||
$asset->warranty_months = $asset_warranty_months;
|
$asset->warranty_months = $asset_warranty_months;
|
||||||
|
|
||||||
if($asset_model)
|
if($asset_model)
|
||||||
|
|
|
@ -79,16 +79,18 @@
|
||||||
<th>Errors</th>
|
<th>Errors</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (session('import_errors') as $asset => $error)
|
@foreach (session('import_errors') as $asset => $itemErrors)
|
||||||
<tr>
|
<tr>
|
||||||
<td> {{ $asset }}</td>
|
<td> {{ $asset }}</td>
|
||||||
@foreach ($error as $field => $values )
|
<td>
|
||||||
<td> <span><b>{{ $field }}:</b>
|
@foreach ($itemErrors as $field => $values )
|
||||||
@foreach( $values as $errorString)
|
<b>{{ $field }}:</b>
|
||||||
<span>{{$errorString[0]}} </span>
|
@foreach( $values as $errorString)
|
||||||
@endforeach
|
<span>{{$errorString[0]}} </span>
|
||||||
</td>
|
@endforeach
|
||||||
|
<br />
|
||||||
@endforeach
|
@endforeach
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Reference in a new issue