diff --git a/app/Events/AutoSerahan.php b/app/Events/AutoSerahan.php new file mode 100644 index 0000000..a618636 --- /dev/null +++ b/app/Events/AutoSerahan.php @@ -0,0 +1,36 @@ +pengesahan = $pengesahan; + $this->id = $id; + $this->cawangan = $cawangan; + $this->kodlaluan = $kodlaluan; + } + + public function broadcastOn() + { + return ['autoserahan-notice']; + } + + public function broadcastAs() + { + return 'autoserahan-event'; + } +} \ No newline at end of file diff --git a/app/Http/Controllers/AutoSerahanController.php b/app/Http/Controllers/AutoSerahanController.php index 697f7d7..9d7f896 100644 --- a/app/Http/Controllers/AutoSerahanController.php +++ b/app/Http/Controllers/AutoSerahanController.php @@ -1,15 +1,71 @@ request('page', 1) // Get current page from request + ])->json(); + + // Extract pagination details + $items = $response['data'] ?? []; // Data array + $total = $response['total'] ?? 0; // Total items + $perPage = $response['per_page'] ?? 10; // Items per page + $currentPage = $response['current_page'] ?? 1; // Current page + + // Create Laravel paginator + $list = new LengthAwarePaginator($items, $total, $perPage, $currentPage, [ + 'path' => request()->url(), // Current URL + 'query' => request()->query(), // Append other query params + ]); + return view('autoserahan.index', compact('list')); + } + + public function approve(Request $request) + { + $response = Http::put(config('api.url') . '/api/autoserahan/approve', [ + 'id' => $request->id, + 'kodcaw' => $request->kodcaw, + 'teller' => $request->teller, + 'amaun' => $request->amaun, + 'sendApproval' => 'ACCEPTED', + 'operasi_name' => auth()->user()->name, + ])->json(); + + if($response['status'] == 'success'){ + event(new AutoSerahan("Lulus",$request->id,$request->kodcaw,$request->teller)); + return redirect()->route('autoserahan')->with('success', 'Serahan approved successfully'); + }else{ + event(new AutoSerahan("Error",$request->id,$request->kodcaw,$request->teller)); + return redirect()->route('autoserahan')->with('error', 'Serahan approved failed'); + } + } + + public function reject(Request $request) + { + $response = Http::put(config('api.url') . '/api/autoserahan/approve', [ + 'id' => $request->id, + 'kodcaw' => $request->kodcaw, + 'teller' => $request->teller, + 'amaun' => $request->amaun, + 'sendApproval' => 'REJECTED', + 'operasi_name' => auth()->user()->name, + ])->json(); + + if($response['status'] == 'success'){ + event(new AutoSerahan("Batal",$request->id,$request->kodcaw,$request->teller)); + return redirect()->route('autoserahan')->with('success', 'Serahan rejected successfully'); + }else{ + event(new AutoSerahan("Error",$request->id,$request->kodcaw,$request->teller)); + return redirect()->route('autoserahan')->with('error', 'Serahan rejected failed'); + } } } diff --git a/resources/views/autoserahan/index.blade.php b/resources/views/autoserahan/index.blade.php index dd4778d..ab4d2b1 100644 --- a/resources/views/autoserahan/index.blade.php +++ b/resources/views/autoserahan/index.blade.php @@ -7,75 +7,62 @@
+ @if (session('success')) +
+ {{ session('success') }} + +
+ @endif + @if (session('error')) +
+ {{ session('error') }} + +
+ @endif +

Kelulusan Serahan

- - - - - - - - - - - - - - - - - - -
- Bil - - Nama - - IC - - Nota - - Action -
-
-
-

-

-
-
-
-
-
-

-

-
-
-
-
-
-

-

-
-
-
-
-
-

-

-
-
-
-
-
- -
-
-
+ + + Bil + Cawangan + Pemohon + Amaun + Tindakan + + + @if ($list->count() > 0) + @foreach($list as $item) + + + {{ $item['id'] }} + {{ $item['kodcaw'] }} + {{ $item['pc_name'] }} + {{ number_format($item['amount'], 2) }} + + + Lulus + + + Tolak + + + + + @endforeach + @else + + + Tiada data + + + @endif + + + +
+ {{ $list->links() }} +
@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 75bdcdf..f296780 100644 --- a/routes/web.php +++ b/routes/web.php @@ -188,7 +188,8 @@ Route::get('/transaction/online/gadaian/{norujukan}', OnlineTransactionGadaianCo //Auto-Serahan Route::get('/autoserahan/home', [AutoSerahanController::class,'index'])->name('autoserahan'); - +Route::get('/autoserahan/approve', [AutoSerahanController::class,'approve'])->name('autoserahan.approve'); +Route::get('/autoserahan/reject', [AutoSerahanController::class,'reject'])->name('autoserahan.reject'); Route::get('{any}', function () { return view('home');