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 @@
| - Bil - | -- Nama - | -- IC - | -- Nota - | -- Action - | -
|---|---|---|---|---|
|
-
-
-
-
- - - |
-
-
-
-
-
- - - |
-
-
-
-
-
- - - |
-
-
-
-
-
- - - |
-
-
-
-
-
-
- |
-