Merge pull request #10851 from inietov/fixes/licenses_assigned_to_assets_dont_follow_users

Fixes #10753 Licenses assigned to assets don't follow users
This commit is contained in:
snipe 2022-03-21 21:22:41 +00:00 committed by GitHub
commit 26cababc43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -111,6 +111,13 @@ class AssetCheckinController extends Controller
$checkin_at = $request->input('checkin_at'); $checkin_at = $request->input('checkin_at');
} }
if(!empty($asset->licenseseats->all())){
foreach ($asset->licenseseats as $seat){
$seat->assigned_to = null;
$seat->save();
}
}
// Get all pending Acceptances for this asset and delete them // Get all pending Acceptances for this asset and delete them
$acceptances = CheckoutAcceptance::pending()->whereHasMorph('checkoutable', $acceptances = CheckoutAcceptance::pending()->whereHasMorph('checkoutable',
[Asset::class], [Asset::class],

View file

@ -80,6 +80,15 @@ class AssetCheckoutController extends Controller
$asset->status_id = $request->get('status_id'); $asset->status_id = $request->get('status_id');
} }
if(!empty($asset->licenseseats->all())){
if(request('checkout_to_type') == 'user') {
foreach ($asset->licenseseats as $seat){
$seat->assigned_to = $target->id;
$seat->save();
}
}
}
if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, e($request->get('note')), $request->get('name'))) { if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, e($request->get('note')), $request->get('name'))) {
return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.checkout.success')); return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.checkout.success'));
} }