mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
Handle asset maintenances that do not have a valid asset associated
This commit is contained in:
parent
74c099f0b3
commit
1eace04ad9
|
@ -162,6 +162,10 @@ class AssetMaintenancesController extends Controller
|
|||
// Redirect to the improvement management page
|
||||
return redirect()->route('maintenances.index')
|
||||
->with('error', trans('admin/asset_maintenances/message.not_found'));
|
||||
} elseif (!$assetMaintenance->asset) {
|
||||
return redirect()->route('maintenances.index')
|
||||
->with('error', 'The asset associated with this maintenance does not exist.');
|
||||
|
||||
} elseif (!Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
|
||||
return static::getInsufficientPermissionsRedirect();
|
||||
}
|
||||
|
|
|
@ -28,10 +28,15 @@ class AssetMaintenancesTransformer
|
|||
'asset_tag'=> e($assetmaintenance->asset->asset_tag)
|
||||
|
||||
] : null,
|
||||
'model' => ($assetmaintenance->asset->model) ? [
|
||||
'model' => (($assetmaintenance->asset) && ($assetmaintenance->asset->model)) ? [
|
||||
'id' => (int) $assetmaintenance->asset->model->id,
|
||||
'name'=> ($assetmaintenance->asset->model->name) ? e($assetmaintenance->asset->model->name).' '.e($assetmaintenance->asset->model->model_number) : null
|
||||
] : null,
|
||||
'company' => (($assetmaintenance->asset) && ($assetmaintenance->asset->company)) ? [
|
||||
'id' => (int) $assetmaintenance->asset->company->id,
|
||||
'name'=> ($assetmaintenance->asset->company->name) ? e($assetmaintenance->asset->company->name) : null,
|
||||
|
||||
] : null,
|
||||
'title' => ($assetmaintenance->title) ? e($assetmaintenance->title) : null,
|
||||
'location' => (($assetmaintenance->asset) && ($assetmaintenance->asset->location)) ? [
|
||||
'id' => (int) $assetmaintenance->asset->location->id,
|
||||
|
|
|
@ -423,7 +423,10 @@
|
|||
}
|
||||
|
||||
function assetTagLinkFormatter(value, row) {
|
||||
return '<a href="{{ url('/') }}/hardware/' + row.asset.id + '"> ' + row.asset.asset_tag + '</a>';
|
||||
if ((row.asset) && (row.asset.id)) {
|
||||
return '<a href="{{ url('/') }}/hardware/' + row.asset.id + '"> ' + row.asset.asset_tag + '</a>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function assetNameLinkFormatter(value, row) {
|
||||
|
|
Loading…
Reference in a new issue