mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-27 14:39:49 -08:00
Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
88db2d9e18
|
@ -20,7 +20,7 @@ class ReportsController extends Controller
|
||||||
{
|
{
|
||||||
$this->authorize('reports.view');
|
$this->authorize('reports.view');
|
||||||
|
|
||||||
$actionlogs = Actionlog::with('item', 'user', 'target', 'location');
|
$actionlogs = Actionlog::with('item', 'user', 'admin', 'target', 'location');
|
||||||
|
|
||||||
if ($request->filled('search')) {
|
if ($request->filled('search')) {
|
||||||
$actionlogs = $actionlogs->TextSearch(e($request->input('search')));
|
$actionlogs = $actionlogs->TextSearch(e($request->input('search')));
|
||||||
|
|
|
@ -95,11 +95,11 @@ class ActionlogsTransformer
|
||||||
'next_audit_date' => ($actionlog->itemType()=='asset') ? Helper::getFormattedDateObject($actionlog->calcNextAuditDate(null, $actionlog->item), 'date'): null,
|
'next_audit_date' => ($actionlog->itemType()=='asset') ? Helper::getFormattedDateObject($actionlog->calcNextAuditDate(null, $actionlog->item), 'date'): null,
|
||||||
'days_to_next_audit' => $actionlog->daysUntilNextAudit($settings->audit_interval, $actionlog->item),
|
'days_to_next_audit' => $actionlog->daysUntilNextAudit($settings->audit_interval, $actionlog->item),
|
||||||
'action_type' => $actionlog->present()->actionType(),
|
'action_type' => $actionlog->present()->actionType(),
|
||||||
'admin' => ($actionlog->user) ? [
|
'admin' => ($actionlog->admin) ? [
|
||||||
'id' => (int) $actionlog->user->id,
|
'id' => (int) $actionlog->admin->id,
|
||||||
'name' => e($actionlog->user->getFullNameAttribute()),
|
'name' => e($actionlog->admin->getFullNameAttribute()),
|
||||||
'first_name'=> e($actionlog->user->first_name),
|
'first_name'=> e($actionlog->admin->first_name),
|
||||||
'last_name'=> e($actionlog->user->last_name)
|
'last_name'=> e($actionlog->admin->last_name)
|
||||||
] : null,
|
] : null,
|
||||||
'target' => ($actionlog->target) ? [
|
'target' => ($actionlog->target) ? [
|
||||||
'id' => (int) $actionlog->target->id,
|
'id' => (int) $actionlog->target->id,
|
||||||
|
|
|
@ -55,6 +55,11 @@ class AssetImporter extends ItemImporter
|
||||||
{
|
{
|
||||||
$editingAsset = false;
|
$editingAsset = false;
|
||||||
$asset_tag = $this->findCsvMatch($row, 'asset_tag');
|
$asset_tag = $this->findCsvMatch($row, 'asset_tag');
|
||||||
|
|
||||||
|
if(empty($asset_tag)){
|
||||||
|
$asset_tag = Asset::autoincrement_asset();
|
||||||
|
}
|
||||||
|
|
||||||
$asset = Asset::where(['asset_tag'=> $asset_tag])->first();
|
$asset = Asset::where(['asset_tag'=> $asset_tag])->first();
|
||||||
if ($asset) {
|
if ($asset) {
|
||||||
if (! $this->updating) {
|
if (! $this->updating) {
|
||||||
|
|
|
@ -43,7 +43,9 @@ class Actionlog extends SnipeModel
|
||||||
*/
|
*/
|
||||||
protected $searchableRelations = [
|
protected $searchableRelations = [
|
||||||
'company' => ['name'],
|
'company' => ['name'],
|
||||||
'user' => ['first_name','last_name','username'],
|
'admin' => ['first_name','last_name','username', 'email'],
|
||||||
|
'user' => ['first_name','last_name','username', 'email'],
|
||||||
|
'assets' => ['asset_tag','name'],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,6 +97,19 @@ class Actionlog extends SnipeModel
|
||||||
return $this->hasMany(\App\Models\Company::class, 'id', 'company_id');
|
return $this->hasMany(\App\Models\Company::class, 'id', 'company_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Establishes the actionlog -> asset relationship
|
||||||
|
*
|
||||||
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
|
* @since [v3.0]
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\Relation
|
||||||
|
*/
|
||||||
|
public function assets()
|
||||||
|
{
|
||||||
|
return $this->hasMany(\App\Models\Asset::class, 'id', 'item_id');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Establishes the actionlog -> item type relationship
|
* Establishes the actionlog -> item type relationship
|
||||||
*
|
*
|
||||||
|
@ -154,6 +169,19 @@ class Actionlog extends SnipeModel
|
||||||
return $this->target();
|
return $this->target();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Establishes the actionlog -> admin user relationship
|
||||||
|
*
|
||||||
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
|
* @since [v3.0]
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\Relation
|
||||||
|
*/
|
||||||
|
public function admin()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'user_id')
|
||||||
|
->withTrashed();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Establishes the actionlog -> user relationship
|
* Establishes the actionlog -> user relationship
|
||||||
*
|
*
|
||||||
|
@ -163,8 +191,8 @@ class Actionlog extends SnipeModel
|
||||||
*/
|
*/
|
||||||
public function user()
|
public function user()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'user_id')
|
return $this->belongsTo(User::class, 'target_id')
|
||||||
->withTrashed();
|
->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue