diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 24152670eedc..79e55befb98f 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -885,13 +885,17 @@ public function checkout(AssetCheckoutRequest $request, $asset_id) public function checkin(Request $request, $asset_id) { $this->authorize('checkin', Asset::class); - $asset = Asset::findOrFail($asset_id); + $asset = Asset::with('model')->findOrFail($asset_id); $this->authorize('checkin', $asset); $target = $asset->assignedTo; if (is_null($target)) { - return response()->json(Helper::formatStandardApiResponse('error', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkin.already_checked_in'))); + return response()->json(Helper::formatStandardApiResponse('error', [ + 'asset_tag'=> e($asset->asset_tag), + 'model' => e($asset->model->name), + 'model_number' => e($asset->model->model_number) + ], trans('admin/hardware/message.checkin.already_checked_in'))); } $asset->expected_checkin = null; @@ -925,7 +929,11 @@ public function checkin(Request $request, $asset_id) if ($asset->save()) { event(new CheckoutableCheckedIn($asset, $target, Auth::user(), $request->input('note'), $checkin_at, $originalValues)); - return response()->json(Helper::formatStandardApiResponse('success', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkin.success'))); + return response()->json(Helper::formatStandardApiResponse('success', [ + 'asset_tag'=> e($asset->asset_tag), + 'model' => e($asset->model->name), + 'model_number' => e($asset->model->model_number) + ], trans('admin/hardware/message.checkin.success'))); } return response()->json(Helper::formatStandardApiResponse('error', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkin.error'))); diff --git a/resources/views/hardware/quickscan-checkin.blade.php b/resources/views/hardware/quickscan-checkin.blade.php index 677e0c0f155c..5ab273bffd89 100644 --- a/resources/views/hardware/quickscan-checkin.blade.php +++ b/resources/views/hardware/quickscan-checkin.blade.php @@ -81,6 +81,8 @@ {{ trans('general.asset_tag') }} + {{ trans('general.asset_model') }} + {{ trans('general.model_no') }} {{ trans('general.quickscan_checkin_status') }} @@ -126,7 +128,7 @@ data : formData, success : function (data) { if (data.status == 'success') { - $('#checkedin tbody').prepend("" + data.payload.asset + "" + data.messages + ""); + $('#checkedin tbody').prepend("" + data.payload.asset_tag + "" + data.payload.model + "" + data.payload.model_number + "" + data.messages + ""); incrementOnSuccess(); } else { handlecheckinFail(data); @@ -146,17 +148,21 @@ }); function handlecheckinFail (data) { - if (data.payload.asset) { - var asset = data.payload.asset; + if (data.payload.asset_tag) { + var asset_tag = data.payload.asset_tag; + var model = data.payload.model; + var model_number = data.payload.model_number; } else { - var asset = ''; + var asset_tag = ''; + var model = ''; + var model_number = ''; } if (data.messages) { var messages = data.messages; } else { var messages = ''; } - $('#checkedin tbody').prepend("" + asset + "" + messages + ""); + $('#checkedin tbody').prepend("" + asset_tag + "" + model + "" + model_number + "" + messages + ""); } function incrementOnSuccess() {