mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 05:04:07 -08:00
Updated importer
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
9adb2c24f3
commit
4363e8b34c
|
@ -177,7 +177,7 @@ class AssetImporter extends ItemImporter
|
|||
$this->log('Asset '.$this->item['name'].' with serial number '.$this->item['serial'].' was created');
|
||||
|
||||
// If we have a target to checkout to, lets do so.
|
||||
//-- user_id is a property of the abstract class Importer, which this class inherits from and it's set by
|
||||
//-- created_by is a property of the abstract class Importer, which this class inherits from and it's set by
|
||||
//-- the class that needs to use it (command importer or GUI importer inside the project).
|
||||
if (isset($target) && ($target !== false)) {
|
||||
if (!is_null($asset->assigned_to)){
|
||||
|
|
|
@ -58,7 +58,7 @@ class ComponentImporter extends ItemImporter
|
|||
if (isset($this->item['asset_tag']) && ($asset = Asset::where('asset_tag', $this->item['asset_tag'])->first())) {
|
||||
$component->assets()->attach($component->id, [
|
||||
'component_id' => $component->id,
|
||||
'user_id' => $this->created_by,
|
||||
'created_by' => $this->created_by,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'assigned_qty' => 1, // Only assign the first one to the asset
|
||||
'asset_id' => $asset->id,
|
||||
|
|
|
@ -22,7 +22,7 @@ abstract class Importer
|
|||
* @var
|
||||
*/
|
||||
|
||||
protected $user_id;
|
||||
protected $created_by;
|
||||
/**
|
||||
* Are we updating items in the import
|
||||
* @var bool
|
||||
|
@ -395,7 +395,7 @@ abstract class Importer
|
|||
}
|
||||
|
||||
/**
|
||||
* Matches a user by user_id if user_name provided is a number
|
||||
* Matches a user by created_by if user_name provided is a number
|
||||
* @param string $user_name users full name from csv
|
||||
* @return User User Matching ID
|
||||
*/
|
||||
|
@ -412,13 +412,13 @@ abstract class Importer
|
|||
/**
|
||||
* Sets the Id of User performing import.
|
||||
*
|
||||
* @param mixed $user_id the user id
|
||||
* @param mixed $created_by the user id
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setUserId($user_id)
|
||||
public function setUserId($created_by)
|
||||
{
|
||||
$this->created_by = $user_id;
|
||||
$this->created_by = $created_by;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ class ItemImporter extends Importer
|
|||
|
||||
$this->item['qty'] = $this->findCsvMatch($row, 'quantity');
|
||||
$this->item['requestable'] = $this->findCsvMatch($row, 'requestable');
|
||||
$this->item['user_id'] = $this->created_by;
|
||||
$this->item['created_by'] = $this->created_by;
|
||||
$this->item['serial'] = $this->findCsvMatch($row, 'serial');
|
||||
// NO need to call this method if we're running the user import.
|
||||
// TODO: Merge these methods.
|
||||
|
|
|
@ -65,7 +65,7 @@ class LocationImporter extends ItemImporter
|
|||
$this->item['ldap_ou'] = trim($this->findCsvMatch($row, 'ldap_ou'));
|
||||
$this->item['manager'] = trim($this->findCsvMatch($row, 'manager'));
|
||||
$this->item['manager_username'] = trim($this->findCsvMatch($row, 'manager_username'));
|
||||
$this->item['user_id'] = auth()->id();
|
||||
$this->item['created_by'] = auth()->id();
|
||||
|
||||
if ($this->findCsvMatch($row, 'parent_location')) {
|
||||
$this->item['parent_id'] = $this->createOrFetchLocation(trim($this->findCsvMatch($row, 'parent_location')));
|
||||
|
|
Loading…
Reference in a new issue