Merge pull request #11212 from inietov/fixes/checkout_logs_require_target

Fixes Exception checkout logs require target
This commit is contained in:
snipe 2022-05-28 06:12:55 -07:00 committed by GitHub
commit 4909cf2a9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 59 deletions

View file

@ -116,16 +116,20 @@ class LicenseSeatsController extends Controller
return response()->json(Helper::formatStandardApiResponse('success', $licenseSeat, trans('admin/licenses/message.update.success')));
}
// the logging functions expect only one "target". if both asset and user are present in the request,
// we simply let assets take precedence over users...
if ($licenseSeat->isDirty('assigned_to')) {
$target = $is_checkin ? $oldUser : User::find($licenseSeat->assigned_to);
}
if ($licenseSeat->isDirty('asset_id')) {
$target = $is_checkin ? $oldAsset : Asset::find($licenseSeat->asset_id);
}
if (is_null($target)){
return response()->json(Helper::formatStandardApiResponse('error', null, 'Target not found'));
}
if ($licenseSeat->save()) {
// the logging functions expect only one "target". if both asset and user are present in the request,
// we simply let assets take precedence over users...
$changes = $licenseSeat->getChanges();
if (array_key_exists('assigned_to', $changes)) {
$target = $is_checkin ? $oldUser : User::find($changes['assigned_to']);
}
if (array_key_exists('asset_id', $changes)) {
$target = $is_checkin ? $oldAsset : Asset::find($changes['asset_id']);
}
if ($is_checkin) {
$licenseSeat->logCheckin($target, $request->input('note'));

View file

@ -1,50 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>
Snipe-IT Setup
</title>
<style>
td, th {
font-size: 14px;
}
.preflight-success {
color: green;
}
.preflight-error {
color: red;
}
.preflight-warning {
color: orange;
}
.page-header {
font-size: 280%;
}
h3 {
font-size: 250%;
}
.alert {
font-size: 16px;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-lg-11 col-lg-offset-1">
<h1>D'oh. If you're seeing this, your DocumentRoot is set incorrectly. It should be set to the <code>public</code> directory.
</div>
</div>
</div>
</body>
</html>