From e1f8caa6990dd2e5f3fff4b88a8e31e3d55060d4 Mon Sep 17 00:00:00 2001 From: afrina Date: Wed, 21 Oct 2026 14:53:30 +0800 Subject: [PATCH 1/2] fix(pembiayaan-online): remove account name fields and show customer phone on batch approval form --- .../PembiayaanOnlineService.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/Services/PembiayaanOnline/PembiayaanOnlineService.php b/app/Services/PembiayaanOnline/PembiayaanOnlineService.php index 4151106..0081c2a 100644 --- a/app/Services/PembiayaanOnline/PembiayaanOnlineService.php +++ b/app/Services/PembiayaanOnline/PembiayaanOnlineService.php @@ -694,6 +694,26 @@ class PembiayaanOnlineService ->orderBy('id', 'asc') ->get(); + // Fetch customer phone numbers in one query for the batch approval form. + $identityNumbers = $lines->pluck('nokp')->filter()->unique()->values()->all(); + $phones = []; + if ($identityNumbers) { + $customers = Customer::on('mysql7')->select('kpbaru', 'kplama', 'telefon') + ->where(function ($query) use ($identityNumbers) { + $query->whereIn('kpbaru', $identityNumbers)->orWhereIn('kplama', $identityNumbers); + })->get(); + foreach ($customers as $customer) { + foreach ([$customer->kpbaru, $customer->kplama] as $identity) { + if ($identity !== null && $identity !== '') { + $phones[(string) $identity] = $customer->telefon; + } + } + } + } + foreach ($lines as $line) { + $line->setAttribute('telefon', $phones[(string) $line->nokp] ?? null); + } + return [ 'ok' => true, 'status' => 200, -- 2.52.0 From b9da2dd7dff1553e270c0ac780641cf568a901d8 Mon Sep 17 00:00:00 2001 From: afrina Date: Thu, 22 Oct 2026 11:31:18 +0800 Subject: [PATCH 2/2] feat(pembiayaan-online): let PC upload the signed gadai online confirmation form --- .../PembiayaanOnlineController.php | 9 +++ .../PembiayaanOnlineService.php | 72 +++++++++++++++++++ routes/web.php | 1 + 3 files changed, 82 insertions(+) diff --git a/app/Http/Controllers/PembiayaanOnlineController.php b/app/Http/Controllers/PembiayaanOnlineController.php index 547736f..86b6c21 100644 --- a/app/Http/Controllers/PembiayaanOnlineController.php +++ b/app/Http/Controllers/PembiayaanOnlineController.php @@ -62,6 +62,7 @@ class PembiayaanOnlineController extends Controller 'kodbank', 'noakaun', 'nama_bank', 'nama_akaun', 'nota', 'bukti_akaun_file_id', 'borang_file_id', 'update_customer_bank', 'bukti_akaun_data', 'bukti_akaun_filename', 'bukti_akaun_type', + 'borang_data', 'borang_filename', 'borang_type', ] as $key) { if ($request->has($key)) { $input[$key] = $request->input($key); @@ -214,6 +215,14 @@ class PembiayaanOnlineController extends Controller return $this->respond($this->service->getBuktiAkaun($kodcaw, $id)); } + /** + * GET /api/pembiayaan-online/{kodcaw}/lines/{id}/borang + */ + public function getBorang($kodcaw, $id) + { + return $this->respond($this->service->getBorang($kodcaw, $id)); + } + /** * GET /api/pembiayaan-online/{kodcaw}/paid?blast_sent=0 */ diff --git a/app/Services/PembiayaanOnline/PembiayaanOnlineService.php b/app/Services/PembiayaanOnline/PembiayaanOnlineService.php index 0081c2a..a5ed841 100644 --- a/app/Services/PembiayaanOnline/PembiayaanOnlineService.php +++ b/app/Services/PembiayaanOnline/PembiayaanOnlineService.php @@ -415,6 +415,19 @@ class PembiayaanOnlineService $fields['bukti_akaun_file_id'] = $saved['payload']['id']; } + if (!empty($input['borang_data'])) { + $saved = $this->storeBuktiFile([ + 'data' => $input['borang_data'], + 'filename' => $input['borang_filename'] ?? null, + 'type' => $input['borang_type'] ?? null, + ]); + if (!$saved['ok']) { + $saved['payload']['message'] = 'Borang pengesahan diperlukan: fail, nama fail dan jenis fail.'; + return $saved; + } + $fields['borang_file_id'] = $saved['payload']['id']; + } + if (empty($fields)) { return [ 'ok' => false, @@ -1759,6 +1772,65 @@ class PembiayaanOnlineService ]; } + /** + * Get attached signed online-financing confirmation form (borang_file_id). + * + * @return array{ok:bool,status:int,payload:mixed} + */ + public function getBorang($kodcaw, $id) + { + $resolved = $this->resolveMysql($kodcaw); + if (!$resolved['ok']) { + return $resolved; + } + + $line = PembiayaanOnline::on($resolved['mysql']) + ->where('kodcaw', $kodcaw) + ->where('id', $id) + ->first(); + + if (!$line) { + return [ + 'ok' => false, + 'status' => 404, + 'payload' => ['message' => 'Pembiayaan online tidak dijumpai'], + ]; + } + + if (empty($line->borang_file_id)) { + return [ + 'ok' => false, + 'status' => 404, + 'payload' => ['message' => 'Borang pengesahan belum dimuat naik'], + ]; + } + + $file = ARFiles::on('mysql7')->where('id', $line->borang_file_id)->first(); + if (!$file) { + return [ + 'ok' => false, + 'status' => 404, + 'payload' => ['message' => 'Fail borang pengesahan tidak dijumpai'], + ]; + } + + return [ + 'ok' => true, + 'status' => 200, + 'payload' => [ + 'pembiayaan_online_id' => $line->id, + 'norujukan' => $line->norujukan, + 'file' => [ + 'id' => $file->id, + 'filename' => $file->filename, + 'type' => $file->type, + 'tarikhmasa' => $file->tarikhmasa, + 'data' => $file->data, + ], + ], + ]; + } + /** * PC list of PAID lines awaiting blast / tally. * diff --git a/routes/web.php b/routes/web.php index ddaa2a7..982afc3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -723,6 +723,7 @@ $router->group(['prefix'=>'api'], function () use ($router){ $router->post('pembiayaan-online/{kodcaw}/lines/{id}/unverify', ['uses' => 'PembiayaanOnlineController@unverifyLine']); $router->get('pembiayaan-online/{kodcaw}/lines/{id}/bukti', ['uses' => 'PembiayaanOnlineController@getBukti']); $router->get('pembiayaan-online/{kodcaw}/lines/{id}/bukti-akaun', ['uses' => 'PembiayaanOnlineController@getBuktiAkaun']); + $router->get('pembiayaan-online/{kodcaw}/lines/{id}/borang', ['uses' => 'PembiayaanOnlineController@getBorang']); $router->get('pembiayaan-online/{kodcaw}/lines/{id}', ['uses' => 'PembiayaanOnlineController@showLine']); $router->get('pembiayaan-online/{kodcaw}/batches', ['uses' => 'PembiayaanOnlineController@listBatches']); $router->get('pembiayaan-online/{kodcaw}/batches/{batchId}', ['uses' => 'PembiayaanOnlineController@showBatch']); -- 2.52.0