From d5e4818a1459cb1cd3ff945f9dd5094ce773bdba Mon Sep 17 00:00:00 2001 From: hafifierahman Date: Thu, 27 Feb 2025 01:29:42 +0800 Subject: [PATCH 1/7] added function kelulusan --- .../Controllers/AutoSerahanController.php | 15 ++++ resources/views/autoserahan/index.blade.php | 81 +++++++++++++++++++ resources/views/layouts/sidebar.blade.php | 12 +++ routes/web.php | 4 + 4 files changed, 112 insertions(+) create mode 100644 app/Http/Controllers/AutoSerahanController.php create mode 100644 resources/views/autoserahan/index.blade.php diff --git a/app/Http/Controllers/AutoSerahanController.php b/app/Http/Controllers/AutoSerahanController.php new file mode 100644 index 0000000..697f7d7 --- /dev/null +++ b/app/Http/Controllers/AutoSerahanController.php @@ -0,0 +1,15 @@ + +
+
+
+ + +

Kelulusan Serahan

+ + + + + + + + + + + + + + + + + + + +
+ Bil + + Nama + + IC + + Nota + + Action +
+
+
+

+

+
+
+
+
+
+

+

+
+
+
+
+
+

+

+
+
+
+
+
+

+

+
+
+
+
+
+ +
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/layouts/sidebar.blade.php b/resources/views/layouts/sidebar.blade.php index 841dde3..7c155e2 100644 --- a/resources/views/layouts/sidebar.blade.php +++ b/resources/views/layouts/sidebar.blade.php @@ -205,6 +205,8 @@ + + {{-- @@ -245,6 +247,16 @@ --}} + +
  • +
    + + + + Auto-Serahan +
    +
  • +
  • diff --git a/routes/web.php b/routes/web.php index 008f7aa..75bdcdf 100644 --- a/routes/web.php +++ b/routes/web.php @@ -6,6 +6,7 @@ use App\Http\Controllers\OnlineTransactionController; use App\Http\Controllers\OnlineTransactionGadaianController; use App\Http\Controllers\OnlineTransactionLogController; use App\Http\Controllers\OnlineTransactionTrailController; +use App\Http\Controllers\AutoSerahanController; use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Http; @@ -185,6 +186,9 @@ Route::get('/transaction/online/log', [OnlineTransactionLogController::class, 'i Route::get('/transaction/online/log/{bill_id}', [OnlineTransactionLogController::class, 'show'])->name('transaction.online.log.show'); Route::get('/transaction/online/gadaian/{norujukan}', OnlineTransactionGadaianController::class)->name('transaction.online.gadaian'); +//Auto-Serahan +Route::get('/autoserahan/home', [AutoSerahanController::class,'index'])->name('autoserahan'); + Route::get('{any}', function () { return view('home'); From a2331b0bed21aa83660f7867c15c2c4293f6f07f Mon Sep 17 00:00:00 2001 From: hafifierahman Date: Sun, 2 Mar 2025 09:03:00 +0800 Subject: [PATCH 2/7] added event and add blade url --- app/Events/AutoSerahan.php | 36 ++++++ .../Controllers/AutoSerahanController.php | 62 ++++++++- resources/views/autoserahan/index.blade.php | 121 ++++++++---------- routes/web.php | 3 +- 4 files changed, 151 insertions(+), 71 deletions(-) create mode 100644 app/Events/AutoSerahan.php 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 @@ @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'); From 5ee3d492fc10e27d9c66fd6dfb584badb717aa48 Mon Sep 17 00:00:00 2001 From: Hafifie PKB Date: Mon, 17 Mar 2025 11:39:56 +0800 Subject: [PATCH 3/7] added autoserahan --- .../Controllers/AutoSerahanController.php | 68 ++++++++++- resources/views/autoserahan/index.blade.php | 113 +++++++++++++++--- resources/views/layouts/app.blade.php | 2 +- 3 files changed, 164 insertions(+), 19 deletions(-) diff --git a/app/Http/Controllers/AutoSerahanController.php b/app/Http/Controllers/AutoSerahanController.php index 9d7f896..38dc31f 100644 --- a/app/Http/Controllers/AutoSerahanController.php +++ b/app/Http/Controllers/AutoSerahanController.php @@ -5,7 +5,7 @@ use App\Events\AutoSerahan; use Illuminate\Http\Request; use Illuminate\Support\Facades\Http; use Illuminate\Pagination\LengthAwarePaginator; - +use Illuminate\Support\Facades\Log; class AutoSerahanController extends Controller { public function index(Request $request) @@ -15,12 +15,18 @@ class AutoSerahanController extends Controller 'page' => 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 + $items = array_map(function ($item) { + $item['cawangan_name'] = $this->CawanganKod($item['kodcaw']); + return $item; + }, $items); + // Create Laravel paginator $list = new LengthAwarePaginator($items, $total, $perPage, $currentPage, [ 'path' => request()->url(), // Current URL @@ -39,6 +45,59 @@ class AutoSerahanController extends Controller 'sendApproval' => 'ACCEPTED', 'operasi_name' => auth()->user()->name, ])->json(); + Log::debug($response); + if($response['approve_status'] == 'approved'){ + $approvalserahan = Http::get(config('api.url_koop') . '/api/autoserahan/get', [ + 'id' => $request->id, + 'kodcaw' => $request->kodcaw + ])->json(); + + if($approvalserahan['action'] == 'create'){ + $pendahuluan = Http::put(config('api.url_koop') . '/api/autoserahan/pendahuluan', [ + 'id' => $request->id, + 'kodcaw' => $request->kodcaw, + 'teller' => $request->teller, + 'amaun' => $request->amaun, + 'denopendser_id' => $approvalserahan['denopendser_id_v3'] + ])->json(); + + $serahan = Http::put(config('api.url_pkb') . '/api/autoserahan/serahan', [ + 'id' => $request->id, + 'kodcaw' => $request->kodcaw, + 'teller' => $request->teller, + 'amaun' => $request->amaun, + 'denopendser_id' => $approvalserahan['denopendser_id_v2'] + ])->json(); + Log::error($serahan); + + $call_set_approval_v3 = Http::withOptions(['verify' => config('app.api_verify')]) + ->put(config('api.url_koop') . '/api/autoserahan/setapproval', [ + 'id' => $request->id, + 'jenis' => 'rewrite', + 'gldetail_id' => $serahan['gldetail_id'] + ])->json(); + }else{ + $pendahuluan = Http::put(config('api.url_koop') . '/api/autoserahan/delete/pendahuluan', [ + 'array_approval' => $approvalserahan, + 'kodcaw' => $request->kodcaw, + 'teller' => $request->teller, + 'amaun' => $request->amaun, + ])->json(); + + Log::info($pendahuluan); + + $serahan = Http::put(config('api.url_pkb') . '/api/autoserahan/delete/serahan', [ + 'array_approval' => $approvalserahan, + 'kodcaw' => $request->kodcaw, + 'teller' => $request->teller, + 'amaun' => $request->amaun, + ])->json(); + + Log::info($serahan); + } + + + } if($response['status'] == 'success'){ event(new AutoSerahan("Lulus",$request->id,$request->kodcaw,$request->teller)); @@ -68,4 +127,11 @@ class AutoSerahanController extends Controller return redirect()->route('autoserahan')->with('error', 'Serahan rejected failed'); } } + + +private function CawanganKod($kodcaw) { + $cawangan = Http::get(config('api.url_koop') . '/api/cawangan/' . $kodcaw)->json(); + + return $cawangan['details_caw'] ?? 'Undefined'; +} } diff --git a/resources/views/autoserahan/index.blade.php b/resources/views/autoserahan/index.blade.php index ab4d2b1..ae925b2 100644 --- a/resources/views/autoserahan/index.blade.php +++ b/resources/views/autoserahan/index.blade.php @@ -24,28 +24,44 @@ - - - - - + + + + + + @if ($list->count() > 0) @foreach($list as $item) - - - - - + + + + + @@ -53,7 +69,7 @@ @else - + @endif @@ -65,4 +81,67 @@ + + + + @include('layouts.footer') + + +@push('additional_scripts') + +@endpush @endsection \ No newline at end of file diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index c50cfd5..4e7fc7e 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -32,7 +32,7 @@ - +
    BilCawanganPemohonAmaunTindakanBilCawanganTindakanPemohonAmaunTindakan
    {{ $item['id'] }}{{ $item['kodcaw'] }}{{ $item['pc_name'] }}{{ number_format($item['amount'], 2) }} - - Lulus - - - Tolak - + {{ $item['id'] }}{{ $item['cawangan_name'] }} + @if($item['action'] === 'create') + + Create + + @elseif($item['action'] === 'delete') + + Delete + + @endif + {{ $item['pc_name'] }}{{ number_format($item['amount'], 2) }} + + Lulus + + + Tolak +
    Tiada dataTiada data