@@ -595,9 +595,12 @@ public function postCheckin(AssetCheckinRequest $request, $assetId = null, $back
595595 */
596596 public function show ($ assetId = null )
597597 {
598+
598599 $ asset = Asset::withTrashed ()->find ($ assetId );
599- $ settings = Setting::getSettings ();
600600 $ this ->authorize ('view ' , $ asset );
601+ $ settings = Setting::getSettings ();
602+ $ audit_log = Actionlog::where ('action_type ' ,'= ' ,'audit ' )->where ('item_id ' ,'= ' ,$ assetId )->where ('item_type ' ,'= ' ,Asset::class)->orderBy ('created_at ' ,'DESC ' )->first ();
603+
601604
602605 if (isset ($ asset )) {
603606
@@ -617,7 +620,8 @@ public function show($assetId = null)
617620 'url ' => route ('qr_code/hardware ' , $ asset ->id )
618621 );
619622
620- return view ('hardware/view ' , compact ('asset ' , 'qr_code ' , 'settings ' ))->with ('use_currency ' , $ use_currency );
623+ return view ('hardware/view ' , compact ('asset ' , 'qr_code ' , 'settings ' ))
624+ ->with ('use_currency ' , $ use_currency )->with ('audit_log ' ,$ audit_log );
621625 }
622626
623627 return redirect ()->route ('hardware.index ' )->with ('error ' , trans ('admin/hardware/message.does_not_exist ' , compact ('id ' )));
@@ -1233,4 +1237,29 @@ public function postBulkCheckout(Request $request)
12331237 // Redirect to the asset management page with error
12341238 return redirect ()->to ("hardware/bulk-checkout " )->with ('error ' , trans ('admin/hardware/message.checkout.error ' ))->withErrors ($ errors );
12351239 }
1240+
1241+ public function audit (Request $ request , $ id )
1242+ {
1243+ $ this ->authorize ('audit ' , Asset::class);
1244+
1245+ $ dt = Carbon::now ()->addMonths (12 )->toDateString ();
1246+
1247+ $ asset = Asset::findOrFail ($ id );
1248+ return view ('hardware/audit ' )->with ('asset ' , $ asset )->with ('next_audit_date ' , $ dt );
1249+ }
1250+
1251+ public function auditStore (Request $ request , $ id )
1252+ {
1253+ $ this ->authorize ('audit ' , Asset::class);
1254+
1255+ $ asset = Asset::findOrFail ($ id );
1256+ $ asset ->next_audit_date = $ request ->input ('next_audit_date ' );
1257+
1258+ if ($ asset ->save ()) {
1259+ $ asset ->logAudit (request ('note ' ));
1260+ return redirect ()->to ("hardware " )->with ('success ' , trans ('admin/hardware/message.audit.success ' ));
1261+ }
1262+ }
1263+
1264+
12361265}
0 commit comments