mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-02 08:21:09 -08:00
Fixed #16097 - allow location update by ID in importer
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
4fe83467ee
commit
801328ec42
|
@ -39,6 +39,7 @@ abstract class Importer
|
|||
* @var array
|
||||
*/
|
||||
private $defaultFieldMap = [
|
||||
'id' => 'id',
|
||||
'asset_tag' => 'asset tag',
|
||||
'activated' => 'activated',
|
||||
'category' => 'category',
|
||||
|
|
|
@ -456,14 +456,13 @@ class ItemImporter extends Importer
|
|||
{
|
||||
if (empty($asset_location)) {
|
||||
$this->log('No location given, so none created.');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$location = Location::where(['name' => $asset_location])->first();
|
||||
|
||||
if ($location) {
|
||||
$this->log('Location '.$asset_location.' already exists');
|
||||
|
||||
return $location->id;
|
||||
}
|
||||
// No matching locations in the collection, create a new one.
|
||||
|
|
|
@ -38,7 +38,14 @@ class LocationImporter extends ItemImporter
|
|||
{
|
||||
|
||||
$editingLocation = false;
|
||||
$location = Location::where('name', '=', $this->findCsvMatch($row, 'name'))->first();
|
||||
|
||||
if ($this->findCsvMatch($row, 'id')) {
|
||||
$location = Location::find($this->findCsvMatch($row, 'id'));
|
||||
} else {
|
||||
$location = Location::where('name', '=', $this->findCsvMatch($row, 'name'))->first();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($location) {
|
||||
if (! $this->updating) {
|
||||
|
|
|
@ -329,6 +329,7 @@ class Importer extends Component
|
|||
];
|
||||
|
||||
$this->locations_fields = [
|
||||
'id' => trans('general.id'),
|
||||
'name' => trans('general.item_name_var', ['item' => trans('general.location')]),
|
||||
'address' => trans('general.address'),
|
||||
'address2' => trans('general.importer.address2'),
|
||||
|
@ -400,7 +401,6 @@ class Importer extends Component
|
|||
'requestable',
|
||||
'Requestable',
|
||||
],
|
||||
|
||||
'gravatar' =>
|
||||
[
|
||||
'gravatar',
|
||||
|
|
Loading…
Reference in a new issue