Merge pull request #14018 from snipe/features/more_info_in_quickscan

Added model name and number to quickscan
This commit is contained in:
snipe 2023-12-12 04:30:11 +00:00 committed by GitHub
commit 068f64a78e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 8 deletions

View file

@ -885,13 +885,17 @@ class AssetsController extends Controller
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 @@ class AssetsController extends Controller
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')));

View file

@ -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>
@ -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);
@ -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() {