From 3052644909a76b7b0b8ba2214cf3403d8dd3bc75 Mon Sep 17 00:00:00 2001 From: Hafifie PKB Date: Sun, 26 Jan 2025 16:29:46 +0800 Subject: [PATCH] added resit for v3 and make it not allowed if it open other norujukan from other nokp --- app/Http/Controllers/SemakController.php | 17 +++++-- app/Services/BayaranHistoryService.php | 4 +- resources/views/modal/marhun.blade.php | 59 ++++++++---------------- routes/web.php | 2 +- 4 files changed, 36 insertions(+), 46 deletions(-) diff --git a/app/Http/Controllers/SemakController.php b/app/Http/Controllers/SemakController.php index e08c346..eeeda6f 100644 --- a/app/Http/Controllers/SemakController.php +++ b/app/Http/Controllers/SemakController.php @@ -154,22 +154,31 @@ class SemakController extends Controller return view('resit.resittebus',compact('transaction','gadai','cawangan_info','customers_info','penebusan','wakil','totaltransaction','totalBayaranAnsuran')); } - public function resit($id) + public function resit($id,$company) { + $setapi = $company == 1 + ? config('api.url') + : config('api.url_koop'); + $totaltransaction = 0; - $transaction = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/transaction/id/'. $id)->json(); + $transaction = Http::withOptions(['verify' => config('app.api_verify')])->get($setapi . '/api/transaction/id/'. $id)->json(); if(sizeof($transaction) != 0) $transaction = $transaction[0]; - $gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $transaction['norujukan'])->json(); + if($transaction['nokp'] != Auth::user()->icno) + { + return response('not allowed', 403); + } + + $gadai = Http::withOptions(['verify' => config('app.api_verify')])->get($setapi . '/api/gadai/norujukan/'. $transaction['norujukan'])->json(); if(sizeof($gadai) != 0) $gadai = $gadai[0][0]; - $customers_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customers/'. $gadai['nokp'])->json(); + $customers_info = Http::withOptions(['verify' => config('app.api_verify')])->get($setapi . '/api/customers/'. $gadai['nokp'])->json(); // if(sizeof($customers_info) != 0) // $customers_info = $customers_info[0]; diff --git a/app/Services/BayaranHistoryService.php b/app/Services/BayaranHistoryService.php index e39af37..b1c86ff 100644 --- a/app/Services/BayaranHistoryService.php +++ b/app/Services/BayaranHistoryService.php @@ -23,13 +23,13 @@ class BayaranHistoryService $bayaranHistory = $CallableHttp->get('/api/transaction/'. $this->norujukan)->json(); - $formatBayaranHistoryData = function ($x) { + $formatBayaranHistoryData = function ($x) use($tagsyarikat) { if (sizeof($x) === 0) { return $x; } $formatDate = fn($x) => Carbon::parse($x)->format('d/m/Y'); - $setResitAnsuranLink = fn($x) => route("resit.ansuran", $x); + $setResitAnsuranLink = fn($x) => route("resit.ansuran", ['id' => $x, 'company' => $tagsyarikat]); return array_map(function ($y) use ($formatDate, $setResitAnsuranLink) { $y['created_at'] = $formatDate($y['created_at']); diff --git a/resources/views/modal/marhun.blade.php b/resources/views/modal/marhun.blade.php index 3b5fa42..61cd5e0 100644 --- a/resources/views/modal/marhun.blade.php +++ b/resources/views/modal/marhun.blade.php @@ -208,28 +208,18 @@ @push('additional_js_scripts')