Merge pull request #12787 from Godmartinz/accessory_unavailable_message

Added unavailable message to prevent over-checkout of Accessories
This commit is contained in:
snipe 2023-04-06 15:05:18 -07:00 committed by GitHub
commit 383d48fd9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -77,6 +77,15 @@ class AccessoryCheckoutController extends Controller
'note' => $request->input('note'),
]);
$available= new Accessory();
if($available->numRemaining()<=0){
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.checkout.unavailable'));
}
DB::table('accessories_users')->where('assigned_to', '=', $accessory->assigned_to)->where('accessory_id', '=', $accessory->id)->first();
event(new CheckoutableCheckedOut($accessory, $user, Auth::user(), $request->input('note')));

View file

@ -24,6 +24,7 @@ return array(
'checkout' => array(
'error' => 'Accessory was not checked out, please try again',
'success' => 'Accessory checked out successfully.',
'unavailable' => 'Accessory is not available for checkout. Check quantity available',
'user_does_not_exist' => 'That user is invalid. Please try again.'
),