Skip to content

Commit

Permalink
Merge pull request snipe#14018 from snipe/features/more_info_in_quick…
Browse files Browse the repository at this point in the history
…scan

Added model name and number to quickscan
  • Loading branch information
snipe authored Dec 12, 2023
2 parents bbe5c7c + 631dd58 commit 068f64a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
14 changes: 11 additions & 3 deletions app/Http/Controllers/Api/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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')));
Expand Down
16 changes: 11 additions & 5 deletions resources/views/hardware/quickscan-checkin.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
<thead>
<tr>
<th>{{ trans('general.asset_tag') }}</th>
<th>{{ trans('general.asset_model') }}</th>
<th>{{ trans('general.model_no') }}</th>
<th>{{ trans('general.quickscan_checkin_status') }}</th>
<th></th>
</tr>
Expand Down Expand Up @@ -126,7 +128,7 @@
data : formData,
success : function (data) {
if (data.status == 'success') {
$('#checkedin tbody').prepend("<tr class='success'><td>" + data.payload.asset + "</td><td>" + data.messages + "</td><td><i class='fas fa-check text-success'></i></td></tr>");
$('#checkedin tbody').prepend("<tr class='success'><td>" + data.payload.asset_tag + "</td><td>" + data.payload.model + "</td><td>" + data.payload.model_number + "</td><td>" + data.messages + "</td><td><i class='fas fa-check text-success'></i></td></tr>");
incrementOnSuccess();
} else {
handlecheckinFail(data);
Expand All @@ -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("<tr class='danger'><td>" + asset + "</td><td>" + messages + "</td><td><i class='fas fa-times text-danger'></i></td></tr>");
$('#checkedin tbody').prepend("<tr class='danger'><td>" + asset_tag + "</td><td>" + model + "</td><td>" + model_number + "</td><td>" + messages + "</td><td><i class='fas fa-times text-danger'></i></td></tr>");
}
function incrementOnSuccess() {
Expand Down

0 comments on commit 068f64a

Please sign in to comment.