@@ -530,6 +530,8 @@ public function postCheckout(AssetCheckoutRequest $request, $assetId)
530530 return redirect ()->to ('hardware ' )->with ('error ' , trans ('admin/hardware/message.does_not_exist ' ));
531531 } elseif (!Company::isCurrentUserHasAccess ($ asset )) {
532532 return redirect ()->to ('hardware ' )->with ('error ' , trans ('general.insufficient_permissions ' ));
533+ } elseif (!$ asset ->availableForCheckout ()) {
534+ return redirect ()->to ('hardware ' )->with ('error ' , trans ('admin/hardware/message.checkout.not_available ' ));
533535 }
534536
535537 $ user = User::find (e (Input::get ('assigned_to ' )));
@@ -1725,19 +1727,17 @@ public function getDatatable($status = null)
17251727 $ actions = '<a href=" ' .route ('restore/hardware ' , $ asset ->id ).'" title="Restore asset" data-toggle="tooltip" class="btn btn-warning btn-sm"><i class="fa fa-recycle icon-white"></i></a> ' ;
17261728 }
17271729
1728- if ($ asset ->assetstatus ) {
1729- if (($ asset ->assetstatus ->deployable != 0 ) && ($ asset ->deleted_at =='' )) {
1730- if (($ asset ->assigned_to !='' ) && ($ asset ->assigned_to > 0 )) {
1731- if (Gate::allows ('assets.checkin ' )) {
1732- $ inout = '<a href=" ' . route ('checkin/hardware ' ,
1733- $ asset ->id ) . '" class="btn btn-primary btn-sm" title="Checkin this asset" data-toggle="tooltip"> ' . trans ('general.checkin ' ) . '</a> ' ;
1734- }
1735- } else {
1736- if (Gate::allows ('assets.checkout ' )) {
1737- $ inout = '<a href=" ' . route ('checkout/hardware ' ,
1738- $ asset ->id ) . '" class="btn btn-info btn-sm" title="Checkout this asset to a user" data-toggle="tooltip"> ' . trans ('general.checkout ' ) . '</a> ' ;
1739- }
1740- }
1730+ if (($ asset ->availableForCheckout ()))
1731+ {
1732+ if (Gate::allows ('assets.checkout ' )) {
1733+ $ inout = '<a href=" ' . route ('checkout/hardware ' ,
1734+ $ asset ->id ) . '" class="btn btn-info btn-sm" title="Checkout this asset to a user" data-toggle="tooltip"> ' . trans ('general.checkout ' ) . '</a> ' ;
1735+ }
1736+
1737+ } else {
1738+ if (Gate::allows ('assets.checkin ' )) {
1739+ $ inout = '<a href=" ' . route ('checkin/hardware ' ,
1740+ $ asset ->id ) . '" class="btn btn-primary btn-sm" title="Checkin this asset" data-toggle="tooltip"> ' . trans ('general.checkin ' ) . '</a> ' ;
17411741 }
17421742 }
17431743
0 commit comments