diff --git a/app/Http/Controllers/PembiayaanOnlineController.php b/app/Http/Controllers/PembiayaanOnlineController.php index 4315e0a6..a8a24bfb 100644 --- a/app/Http/Controllers/PembiayaanOnlineController.php +++ b/app/Http/Controllers/PembiayaanOnlineController.php @@ -173,6 +173,19 @@ class PembiayaanOnlineController extends Controller $payload['bukti_akaun_type'] = $file->getMimeType() ?: 'application/octet-stream'; } + if ($request->hasFile('borang')) { + $file = $request->file('borang'); + if (!$file->isValid()) { + return redirect()->back()->with('error', 'Fail borang pengesahan tidak sah.'); + } + if ($file->getSize() > 4 * 1024 * 1024) { + return redirect()->back()->with('error', 'Saiz fail maksimum 4MB.'); + } + $payload['borang_data'] = base64_encode(file_get_contents($file->getRealPath())); + $payload['borang_filename'] = $file->getClientOriginalName(); + $payload['borang_type'] = $file->getMimeType() ?: 'application/octet-stream'; + } + $res = $this->api() ->asForm() ->put($api_url . '/api/pembiayaan-online/' . $kodcaw . '/lines/' . $id, $payload); @@ -393,6 +406,22 @@ class PembiayaanOnlineController extends Controller return $this->streamBase64File($file, 'slip-bank-' . $id); } + /** + * PC: view uploaded Borang Pengesahan Penerimaan Pembiayaan Secara Atas Talian. + */ + public function viewBorang($id) + { + $this->abortUnlessPembiayaanOnline(); + return $this->streamLineFile( + $this->kodcaw(), + $id, + '/borang', + 'Borang pengesahan tidak dijumpai.', + 'Fail borang pengesahan kosong.', + 'borang-pengesahan-' . $id + ); + } + /** * PC: view SAG for a queue line (does not mark SAG as printed). */ @@ -425,6 +454,21 @@ class PembiayaanOnlineController extends Controller return $this->streamBase64File($file, 'slip-bank-' . $id); } + /** + * Operasi: view uploaded Borang Pengesahan Penerimaan Pembiayaan Secara Atas Talian. + */ + public function operasiViewBorang($kodcaw, $id) + { + return $this->streamLineFile( + $kodcaw, + $id, + '/borang', + 'Borang pengesahan tidak dijumpai.', + 'Fail borang pengesahan kosong.', + 'borang-pengesahan-' . $id + ); + } + /** * Operasi: view SAG for a batch line. */ @@ -433,6 +477,26 @@ class PembiayaanOnlineController extends Controller return $this->renderLineSag($kodcaw, $id); } + protected function streamLineFile($kodcaw, $id, $path, $missingMessage, $emptyMessage, $fallbackName) + { + $res = $this->api() + ->get(config('api.url') . '/api/pembiayaan-online/' . $kodcaw . '/lines/' . $id . $path); + + if (!$res->successful()) { + $body = $res->json(); + $msg = is_array($body) && isset($body['message']) ? $body['message'] : $missingMessage; + return redirect()->back()->with('error', $msg); + } + + $payload = $res->json(); + $file = $payload['file'] ?? null; + if (!$file || empty($file['data'])) { + return redirect()->back()->with('error', $emptyMessage); + } + + return $this->streamBase64File($file, $fallbackName); + } + protected function streamBase64File(array $file, $fallbackName) { $raw = $file['data']; diff --git a/resources/views/pembiayaan_online/operasi/batch.blade.php b/resources/views/pembiayaan_online/operasi/batch.blade.php index 4ec42922..62ca9d12 100644 --- a/resources/views/pembiayaan_online/operasi/batch.blade.php +++ b/resources/views/pembiayaan_online/operasi/batch.blade.php @@ -112,6 +112,13 @@ @else Tiada slip @endif + @if(!empty($line['borang_file_id'])) + + Borang Pengesahan + + @endif @if(in_array($st, ['IN_BATCH', 'OPS_REVIEW'], true)) diff --git a/resources/views/pembiayaan_online/pc/batch.blade.php b/resources/views/pembiayaan_online/pc/batch.blade.php index c7245caa..b6105b3e 100644 --- a/resources/views/pembiayaan_online/pc/batch.blade.php +++ b/resources/views/pembiayaan_online/pc/batch.blade.php @@ -70,6 +70,13 @@ @else Tiada slip @endif + @if(!empty($line['borang_file_id'])) + + Borang Pengesahan + + @endif @endforeach diff --git a/resources/views/pembiayaan_online/pc/senarai.blade.php b/resources/views/pembiayaan_online/pc/senarai.blade.php index d60f3631..d2bff4df 100644 --- a/resources/views/pembiayaan_online/pc/senarai.blade.php +++ b/resources/views/pembiayaan_online/pc/senarai.blade.php @@ -277,7 +277,8 @@ data-pinjaman="{{ number_format((float)($line['pinjaman'] ?? 0), 2) }}" data-nota="{{ $line['nota'] ?? '' }}" data-sebab="{{ $line['reject_reason'] ?? '' }}" - data-bukti-akaun="{{ $line['bukti_akaun_file_id'] ?? '' }}"> + data-bukti-akaun="{{ $line['bukti_akaun_file_id'] ?? '' }}" + data-borang-file="{{ $line['borang_file_id'] ?? '' }}"> Semak @endif @@ -288,7 +289,8 @@ data-namabank="{{ $line['nama_bank'] ?? '' }}" data-nota="{{ $line['nota'] ?? '' }}" data-norujukan="{{ $line['norujukan'] ?? '' }}" - data-bukti-akaun="{{ $line['bukti_akaun_file_id'] ?? '' }}"> + data-bukti-akaun="{{ $line['bukti_akaun_file_id'] ?? '' }}" + data-borang-file="{{ $line['borang_file_id'] ?? '' }}"> Edit @@ -399,6 +401,17 @@ PDF / imej slip akaun bank pelanggan (maks 4MB) +
+ + + + PDF / imej borang yang ditandatangani pelanggan (maks 4MB). Kosongkan jika tidak mahu ganti fail sedia ada. +
@@ -475,9 +488,12 @@ Saya sahkan maklumat pelanggan, bank dan amaun adalah betul.
- +
@@ -581,6 +597,11 @@ } else { $('#verifyBuktiAkaunLink').hide(); } + if ($(this).data('borangFile')) { + $('#verifyBorangLink').attr('href', "{{ url('/pembiayaan-online/pc/lines') }}/" + id + "/borang").show(); + } else { + $('#verifyBorangLink').hide(); + } $('#verifyModal').modal('show'); }); @@ -597,6 +618,7 @@ $('#editNamabank').val($(this).data('namabank')); $('#editNota').val($(this).data('nota')); $('#editBuktiAkaun').val(''); + $('#editBorang').val(''); $('#editSagFrame').attr('src', "{{ url('/pembiayaan-online/pc/lines') }}/" + id + "/sag"); if ($(this).data('buktiAkaun')) { $('#editBuktiAkaunLink').attr('href', "{{ url('/pembiayaan-online/pc/lines') }}/" + id + "/bukti-akaun"); @@ -604,6 +626,12 @@ } else { $('#editBuktiAkaunExisting').hide(); } + if ($(this).data('borangFile')) { + $('#editBorangLink').attr('href', "{{ url('/pembiayaan-online/pc/lines') }}/" + id + "/borang"); + $('#editBorangExisting').show(); + } else { + $('#editBorangExisting').hide(); + } $('#editModal').modal('show'); }); diff --git a/routes/web.php b/routes/web.php index 64bf6c4c..55286f3f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -212,6 +212,7 @@ Route::put('/pembiayaan-online/pc/lines/{id}',['as'=>'pembiayaan.online.pc.updat Route::post('/pembiayaan-online/pc/lines/{id}/verify',['as'=>'pembiayaan.online.pc.verify','uses'=>'PembiayaanOnlineController@verifyLine'])->middleware('auth','khazanah'); Route::post('/pembiayaan-online/pc/lines/{id}/unverify',['as'=>'pembiayaan.online.pc.unverify','uses'=>'PembiayaanOnlineController@unverifyLine'])->middleware('auth','khazanah'); Route::get('/pembiayaan-online/pc/lines/{id}/bukti-akaun',['as'=>'pembiayaan.online.pc.bukti.akaun','uses'=>'PembiayaanOnlineController@viewBuktiAkaun'])->middleware('auth','khazanah'); +Route::get('/pembiayaan-online/pc/lines/{id}/borang',['as'=>'pembiayaan.online.pc.borang','uses'=>'PembiayaanOnlineController@viewBorang'])->middleware('auth','khazanah'); Route::get('/pembiayaan-online/pc/lines/{id}/sag',['as'=>'pembiayaan.online.pc.sag','uses'=>'PembiayaanOnlineController@viewSag'])->middleware('auth','khazanah'); Route::post('/pembiayaan-online/pc/batches/submit',['as'=>'pembiayaan.online.pc.submit','uses'=>'PembiayaanOnlineController@submitBatch'])->middleware('auth','khazanah'); Route::get('/pembiayaan-online/pc/batches/{batchId}',['as'=>'pembiayaan.online.pc.batch','uses'=>'PembiayaanOnlineController@showBatch'])->middleware('auth','khazanah'); @@ -238,6 +239,7 @@ Route::post('/pembiayaan-online/operasi/{kodcaw}/batches/{batchId}/approve',['as Route::post('/pembiayaan-online/operasi/{kodcaw}/lines/{id}/paid',['as'=>'pembiayaan.online.operasi.paid','uses'=>'PembiayaanOnlineController@operasiMarkPaid'])->middleware('auth','operasi'); Route::post('/pembiayaan-online/operasi/{kodcaw}/batches/{batchId}/paid',['as'=>'pembiayaan.online.operasi.paid.batch','uses'=>'PembiayaanOnlineController@operasiMarkPaidBatch'])->middleware('auth','operasi'); Route::get('/pembiayaan-online/operasi/{kodcaw}/lines/{id}/bukti-akaun',['as'=>'pembiayaan.online.operasi.bukti.akaun','uses'=>'PembiayaanOnlineController@operasiViewBuktiAkaun'])->middleware('auth','operasi'); +Route::get('/pembiayaan-online/operasi/{kodcaw}/lines/{id}/borang',['as'=>'pembiayaan.online.operasi.borang','uses'=>'PembiayaanOnlineController@operasiViewBorang'])->middleware('auth','operasi'); Route::get('/pembiayaan-online/operasi/{kodcaw}/lines/{id}/sag',['as'=>'pembiayaan.online.operasi.sag','uses'=>'PembiayaanOnlineController@operasiViewSag'])->middleware('auth','operasi'); Route::get('/permohonan/rekod',['as'=>'permohonan.rekod','uses' => 'KhazanahController@RekodPermohonan'])->middleware('auth','khazanah'); Route::post('/permohonan/simpan',['as'=>'permohonan.simpan','uses' => 'KhazanahController@SimpanPermohonan'])->middleware('auth','khazanah');