From 060f7a22cdae8fb76b228d0720b1cbd5ebe60b01 Mon Sep 17 00:00:00 2001 From: ISMAIL MASSERAN Date: Sun, 18 Oct 2026 11:46:48 +0800 Subject: [PATCH] DONE: bsas integration first stage --- app/Http/Controllers/GadaianController.php | 92 +++- app/Http/Controllers/KomuditiController.php | 118 +++++ .../PembiayaanOnlineController.php | 38 +- docker/php/Dockerfile | 9 +- public/img/svg/logo-arrahn-new.svg | 5 + .../logo-arrahn-old.svg} | 0 public/img/svg/logo-kopkb.svg | 161 +++++++ .../components/print/bsas/footer.blade.php | 50 +++ .../components/print/bsas/header.blade.php | 63 +++ .../components/print/bsas/watermark.blade.php | 35 ++ resources/views/customers/v2/info.blade.php | 46 +- resources/views/gadaian/v1/index.blade.php | 31 +- resources/views/gadaian/v2/index.blade.php | 170 +++++-- resources/views/khazanah/v2/info.blade.php | 126 ++---- .../views/operasi/komuditi/index.blade.php | 238 ++++++++-- .../views/operasi/margin_pembiayaan.blade.php | 1 + resources/views/print/bsas_ecert.blade.php | 415 ++++++++++++++++++ resources/views/print/sag.blade.php | 29 +- resources/views/print/sag_ujrah_3.blade.php | 4 +- routes/web.php | 2 + 20 files changed, 1371 insertions(+), 262 deletions(-) create mode 100644 public/img/svg/logo-arrahn-new.svg rename public/img/{logo-arrahn.svg => svg/logo-arrahn-old.svg} (100%) create mode 100644 public/img/svg/logo-kopkb.svg create mode 100644 resources/views/components/print/bsas/footer.blade.php create mode 100644 resources/views/components/print/bsas/header.blade.php create mode 100644 resources/views/components/print/bsas/watermark.blade.php create mode 100644 resources/views/print/bsas_ecert.blade.php diff --git a/app/Http/Controllers/GadaianController.php b/app/Http/Controllers/GadaianController.php index 128855f2..57787a7f 100644 --- a/app/Http/Controllers/GadaianController.php +++ b/app/Http/Controllers/GadaianController.php @@ -298,7 +298,7 @@ class GadaianController extends Controller } if ($caraTerima === 'ONLINE' && !$this->hasMatchingBorangOnlinePrint($request)) { - return redirect()->back()->with('error', 'Sila cetak borang pengesahan pelanggan sebelum tekan Terima.'); + return $this->gadaiStoreResult($request, false, 'Sila cetak borang pengesahan pelanggan sebelum tekan Terima.'); } //$total_nilai_marhun = $request->total_nilai_marhun; @@ -320,6 +320,27 @@ class GadaianController extends Controller $keuntungan12bulan = $keuntungan_sebln * 12; $hargajualan = $request->pinjaman + $keuntungan12bulan; + + // BSAS commodity order must succeed before finalizing gadai. + $bsas = Http::withOptions(['verify' => config('app.api_verify')]) + ->timeout(60) + ->post(config('api.url') . '/api/komuditi/bsas/order', [ + 'norujukan' => $request->norujukan_gadai, + 'kodcaw' => $auth_user['cawangan'], + 'pinjaman' => round((float) $request->pinjaman, 2), + 'hargajualan' => round((float) $hargajualan, 2), + 'nama_pelanggan' => $request->nama_pelanggan ?: $request->nama_akaun, + 'teller' => $auth_user['name'], + ]); + + if (!$bsas->successful()) { + $body = $bsas->json(); + $msg = is_array($body) && isset($body['message']) + ? $body['message'] + : 'Gagal pembelian komoditi BSAS. Sila cuba lagi.'; + return $this->gadaiStoreResult($request, false, $msg); + } + //Log::info('DEBUG NOKP:' . $request->nokp); $gadai = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/gadai/norujukan/' . $auth_user['cawangan'] . '/' . $request->norujukan_gadai, [ 'kodcaw' => $auth_user['cawangan'], @@ -344,14 +365,6 @@ class GadaianController extends Controller 'rebate' => $this->parseMoney($request->rebate), ])->json(); - - $komuditi = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/komuditi/transaksi', [ - 'unit_komuditi' => round($request->pinjaman, 2), - 'norujukan' => $request->norujukan_gadai, - 'kodcaw' => $auth_user['cawangan'], - 'teller' => $auth_user['name'] - ]); - if ($caraTerima === 'ONLINE') { $online = Http::withOptions(['verify' => config('app.api_verify')]) ->asForm() @@ -374,7 +387,7 @@ class GadaianController extends Controller $msg = is_array($body) && isset($body['message']) ? $body['message'] : 'Gagal daftar pembiayaan online. Sila cuba lagi.'; - return redirect()->back()->with('error', $msg); + return $this->gadaiStoreResult($request, false, $msg); } $this->notifyPcPembiayaanOnlinePending($auth_user, $request, $pinjamanAmt); @@ -392,6 +405,33 @@ class GadaianController extends Controller $request->session()->flash('message', 'Gadai berjaya. Pembiayaan online menunggu semakan PC.'); } + return $this->gadaiStoreResult($request, true); + } + + /** + * JSON for AJAX Terima (BSAS progress UI); normal redirect otherwise. + */ + protected function gadaiStoreResult(Request $request, bool $ok, string $message = null) + { + if ($request->ajax() || $request->wantsJson()) { + if (!$ok) { + return response()->json([ + 'ok' => false, + 'message' => $message ?: 'Gadai tidak berjaya.', + ], 422); + } + + return response()->json([ + 'ok' => true, + 'message' => $message ?: 'Gadai berjaya.', + 'redirect' => route('customer_info'), + ]); + } + + if (!$ok) { + return redirect()->back()->with('error', $message ?: 'Gadai tidak berjaya.'); + } + return redirect()->route('customer_info'); } @@ -671,13 +711,31 @@ class GadaianController extends Controller // $pembayaran_segera = "https://spare.arrahn.com.my/pembayaransegera"; $pembayaran_segera = "https://pay.arrahn.com.my"; - $komoditi = Http::withOptions(['verify' => config('app.api_verify')]) - ->get($api_url . '/api/komuditi/check') - ->json(); - $product = Http::withOptions(['verify' => config('app.api_verify')]) - ->get($api_url . '/api/komuditi/description', ['kodproduk' => $komoditi['kodproduct']]) - ->json(); - $kuantiti = $gadai_detail['pinjaman'] / $komoditi['nilai']; + $bsasSag = Http::withOptions(['verify' => config('app.api_verify')]) + ->get($api_url . '/api/komuditi/bsas/order/norujukan/' . urlencode($norujukan)); + + $komoditi = []; + $product = []; + $kuantiti = 0; + + if ($bsasSag->successful() && is_array($bsasSag->json())) { + $bsasPayload = $bsasSag->json(); + $komoditi = $bsasPayload['komoditi'] ?? []; + $product = $bsasPayload['product'] ?? []; + $kuantiti = (float) ($bsasPayload['kuantiti'] ?? 0); + } + + if (!is_array($komoditi)) { + $komoditi = []; + } + if (!is_array($product)) { + $product = [ + 'product_code' => $komoditi['kodproduct'] ?? '', + 'kodproduk' => $komoditi['kodproduct'] ?? '', + 'description' => '', + 'unit' => 'TAN', + ]; + } if ($gadai_detail['tagbaru'] == 1) { $cawangan_info = Http::withOptions(['verify' => config('app.api_verify')]) diff --git a/app/Http/Controllers/KomuditiController.php b/app/Http/Controllers/KomuditiController.php index 72474dbf..8c672266 100644 --- a/app/Http/Controllers/KomuditiController.php +++ b/app/Http/Controllers/KomuditiController.php @@ -55,4 +55,122 @@ class KomuditiController extends Controller return redirect()->route('komuditi'); } + + /** + * Dummy BSAS eCert layout preview (2-page A4). + */ + public function previewBsasEcert() + { + $cert = [ + 'ecert_no' => 'CPO13OCT26-0000136-025', + 'seller' => 'KOPERASI PERMODALAN KELANTAN BERHAD', + 'buyer' => 'WAN MOHAMAD AIMAN', + 'bid_no' => '1', + 'report_time' => '13:39:23.751', + 'report_date' => '13 OCTOBER 2026', + 'value_date' => '13 OCTOBER 2026', + 'product' => 'CPO-MSIA-09', + 'unit' => 'Tonnage', + 'volume' => '.72562358', + 'currency' => 'MYR', + 'price' => '5,256.72', + 'price_myr' => '5,256.72', + 'value' => '3,200.00', + 'txn_type' => '-', + 'murabaha' => '3,814.40', + 'lines' => [ + [ + 'supplier' => 'POA RESOURCES BERHAD', + 'volume' => '.72562358', + ], + ], + ]; + + return view('print.bsas_ecert', [ + 'cert' => $cert, + 'isDummy' => true, + ]); + } + + /** + * Live BSAS eCert from stored bsas_orders.ecert_response. + */ + public function showBsasEcert($uuid) + { + $response = Http::withOptions(['verify' => config('app.api_verify')]) + ->get(config('api.url') . '/api/komuditi/bsas/order/' . urlencode($uuid) . '/ecert'); + + if ($response->status() === 404) { + abort(404, $response->json('message') ?: 'eCert tidak dijumpai.'); + } + + if (!$response->successful()) { + abort(502, 'Gagal memuatkan eCert BSAS.'); + } + + $payload = $response->json(); + $ecert = $payload['ecert'] ?? null; + + if (!is_array($ecert) || empty($ecert)) { + abort(404, 'eCert belum tersedia untuk order ini.'); + } + + return view('print.bsas_ecert', [ + 'cert' => $this->mapBsasEcertToView($ecert, $payload), + 'isDummy' => false, + ]); + } + + /** + * Map stored otcXML / eCert JSON into print view fields. + */ + protected function mapBsasEcertToView(array $ecert, array $orderMeta = []): array + { + $reporting = trim((string) ($ecert['REPORTINGTIMEDATE'] ?? '')); + $reportTime = '-'; + $reportDate = '-'; + if ($reporting !== '') { + $parts = explode(' ', $reporting, 2); + $reportTime = $parts[0] ?? '-'; + $reportDate = isset($parts[1]) ? strtoupper($parts[1]) : '-'; + } + + $lines = []; + foreach (($ecert['LINE'] ?? []) as $line) { + if (!is_array($line)) { + continue; + } + $lines[] = [ + 'supplier' => $line['SUPPLIER'] ?? '-', + 'volume' => $line['VOLUME'] ?? ($ecert['PVOLUME'] ?? '-'), + ]; + } + + if (empty($lines)) { + $lines[] = [ + 'supplier' => '-', + 'volume' => $ecert['PVOLUME'] ?? '-', + ]; + } + + return [ + 'ecert_no' => $ecert['ECERTNO'] ?? ($orderMeta['e_cert_no'] ?? '-'), + 'seller' => $ecert['SELLER'] ?? 'KOPERASI PERMODALAN KELANTAN BERHAD', + 'buyer' => $ecert['BUYER'] ?? ($orderMeta['otc_counter_party'] ?? '-'), + 'bid_no' => $orderMeta['serial_number'] ?? '1', + 'report_time' => $reportTime, + 'report_date' => $reportDate, + 'value_date' => isset($ecert['VALUEDATE']) ? strtoupper((string) $ecert['VALUEDATE']) : '-', + 'product' => $ecert['PNAME'] ?? ($orderMeta['product_code'] ?? '-'), + 'unit' => 'Tonnage', + 'volume' => $ecert['PVOLUME'] ?? '-', + 'currency' => $ecert['CURRENCY'] ?? 'MYR', + 'price' => $ecert['PRICE'] ?? '-', + 'price_myr' => $ecert['PRICE_MYR_EQUIVALENT'] ?? ($ecert['PRICE'] ?? '-'), + 'value' => $ecert['TOTALVALUE'] ?? '-', + 'txn_type' => '-', + 'murabaha' => $ecert['MURABAHAVALUE'] ?? ($orderMeta['otc_murabaha_value'] ?? '-'), + 'lines' => $lines, + ]; + } } diff --git a/app/Http/Controllers/PembiayaanOnlineController.php b/app/Http/Controllers/PembiayaanOnlineController.php index a8a24bfb..d4ed7e13 100644 --- a/app/Http/Controllers/PembiayaanOnlineController.php +++ b/app/Http/Controllers/PembiayaanOnlineController.php @@ -585,15 +585,37 @@ class PembiayaanOnlineController extends Controller $pembayaran_segera = 'https://pay.arrahn.com.my'; - $komoditi = $this->api()->get($api_url . '/api/komuditi/check')->json(); - $product = $this->api() - ->get($api_url . '/api/komuditi/description', [ - 'kodproduk' => is_array($komoditi) ? ($komoditi['kodproduct'] ?? '') : '', - ]) - ->json(); + // Prefer per-Terima BSAS order; fall back to legacy daily KomuditiPurchase. + $bsasSag = $this->api() + ->get($api_url . '/api/komuditi/bsas/order/norujukan/' . urlencode($norujukan)); - $nilai = is_array($komoditi) ? (float) ($komoditi['nilai'] ?? 0) : 0; - $kuantiti = $nilai > 0 ? ((float) ($gadai_detail['pinjaman'] ?? 0) / $nilai) : 0; + if ($bsasSag->successful() && is_array($bsasSag->json())) { + $bsasPayload = $bsasSag->json(); + $komoditi = $bsasPayload['komoditi'] ?? []; + $product = $bsasPayload['product'] ?? []; + $kuantiti = (float) ($bsasPayload['kuantiti'] ?? 0); + } else { + $komoditi = $this->api()->get($api_url . '/api/komuditi/check')->json(); + $product = $this->api() + ->get($api_url . '/api/komuditi/description', [ + 'kodproduk' => is_array($komoditi) ? ($komoditi['kodproduct'] ?? '') : '', + ]) + ->json(); + + $nilai = is_array($komoditi) ? (float) ($komoditi['nilai'] ?? 0) : 0; + $kuantiti = $nilai > 0 ? ((float) ($gadai_detail['pinjaman'] ?? 0) / $nilai) : 0; + } + + if (!is_array($komoditi)) { + $komoditi = []; + } + if (!is_array($product)) { + $product = [ + 'kodproduk' => $komoditi['kodproduct'] ?? '', + 'description' => '', + 'unit' => 'TAN', + ]; + } if (($gadai_detail['tagbaru'] ?? 0) == 1) { $cawangan_info = $this->api() diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile index e2a2c4f8..6e3300d6 100644 --- a/docker/php/Dockerfile +++ b/docker/php/Dockerfile @@ -2,7 +2,14 @@ FROM php:7.4-fpm AS base WORKDIR /var/www/html -RUN apt-get update \ +# php:7.4-fpm is Debian 11 (bullseye); after LTS end, packages live on archive.debian.org +RUN sed -i \ + -e 's|http://deb.debian.org/debian|http://archive.debian.org/debian|g' \ + -e 's|http://security.debian.org/debian-security|http://archive.debian.org/debian-security|g' \ + -e 's|http://deb.debian.org/debian-security|http://archive.debian.org/debian-security|g' \ + /etc/apt/sources.list \ + && printf 'Acquire::Check-Valid-Until "false";\n' > /etc/apt/apt.conf.d/99no-check-valid-until \ + && apt-get update \ && apt-get install -y --no-install-recommends \ git \ pkg-config \ diff --git a/public/img/svg/logo-arrahn-new.svg b/public/img/svg/logo-arrahn-new.svg new file mode 100644 index 00000000..149be9fa --- /dev/null +++ b/public/img/svg/logo-arrahn-new.svg @@ -0,0 +1,5 @@ + +Vectorized Arabic calligraphy logo + + + \ No newline at end of file diff --git a/public/img/logo-arrahn.svg b/public/img/svg/logo-arrahn-old.svg similarity index 100% rename from public/img/logo-arrahn.svg rename to public/img/svg/logo-arrahn-old.svg diff --git a/public/img/svg/logo-kopkb.svg b/public/img/svg/logo-kopkb.svg new file mode 100644 index 00000000..5c3ea85b --- /dev/null +++ b/public/img/svg/logo-kopkb.svg @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/views/components/print/bsas/footer.blade.php b/resources/views/components/print/bsas/footer.blade.php new file mode 100644 index 00000000..a914fef2 --- /dev/null +++ b/resources/views/components/print/bsas/footer.blade.php @@ -0,0 +1,50 @@ +@props([ + 'note' => '', + 'page' => null, + 'total' => null, +]) + + + + diff --git a/resources/views/components/print/bsas/header.blade.php b/resources/views/components/print/bsas/header.blade.php new file mode 100644 index 00000000..724754a1 --- /dev/null +++ b/resources/views/components/print/bsas/header.blade.php @@ -0,0 +1,63 @@ +@props([ + 'company' => 'Koperasi Permodalan Kelantan Berhad', + 'leftLogo' => null, + 'rightLogo' => null, +]) + +@php + $leftLogo = $leftLogo ?? asset('img/svg/logo-kopkb.svg'); + $rightLogo = $rightLogo ?? asset('img/svg/logo-arrahn-new.svg'); +@endphp + + + +
merge(['class' => 'bsas-ecert-header']) }}> +
+
+ KPKB +
+
+ Ar-Rahn +
+
+
+

{{ $company }}

+
+
diff --git a/resources/views/components/print/bsas/watermark.blade.php b/resources/views/components/print/bsas/watermark.blade.php new file mode 100644 index 00000000..a991f359 --- /dev/null +++ b/resources/views/components/print/bsas/watermark.blade.php @@ -0,0 +1,35 @@ +@props([ + 'leftLogo' => null, + 'rightLogo' => null, +]) + +@php + $leftLogo = $leftLogo ?? asset('img/svg/logo-kopkb.svg'); + $rightLogo = $rightLogo ?? asset('img/logo-arrahn.jpeg'); +@endphp + + + +
merge(['class' => 'bsas-ecert-watermark']) }} aria-hidden="true"> + + +
diff --git a/resources/views/customers/v2/info.blade.php b/resources/views/customers/v2/info.blade.php index 9ab201a7..8bb612ae 100644 --- a/resources/views/customers/v2/info.blade.php +++ b/resources/views/customers/v2/info.blade.php @@ -716,8 +716,6 @@ var api_url = "{{ api_url_for_browser() }}"; var kodcaw = "{{ $cawangan_info['kodcaw'] }}"; var tagarrahnbid = "{{ $cawangan_info['tagarrahnbid'] }}"; - var min_komoditi = "{{ $min_komoditi }}"; - console.log('test api_arrahnbid: ', api_arrahnbid); $('#daftar_gadai').on('click', async function(event) { event.preventDefault(); if ($(this).prop('disabled')) { @@ -756,42 +754,14 @@ event.preventDefault(); return false; } else { - $.ajax({ - method: 'get', - url: api_url + '/api/komuditi/check', - success: function(data) { - var check_komuditi = Object.keys(data).length; - if (check_komuditi == 0) { - Swal.fire({ - icon: 'error', - title: 'Unit Komoditi Berbaki Minima', - text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komoditi' - }); - $("#daftar_gadai").prop('disabled', false); - event.preventDefault(); - return false; - } else { - if (Number(data['unit_komuditi']) <= min_komoditi) { - $("#daftar_gadai").prop('disabled', false); - Swal.fire({ - icon: 'error', - title: 'Unit Komoditi Berbaki Minima', - text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komoditi' - }); - event.preventDefault(); - return false; - } else { - if (icbaru.length > 0) { - window.location.href = - "{{ route('gadaian', ['noic' => $customer_info['kpbaru']]) }}"; - } else { - window.location.href = - "{{ route('gadaian', ['noic' => $customer_info['kplama']]) }}"; - } - } - } - } - }); + // Commodity is purchased via BSAS on Terima; no bulk stock gate. + if (icbaru.length > 0) { + window.location.href = + "{{ route('gadaian', ['noic' => $customer_info['kpbaru']]) }}"; + } else { + window.location.href = + "{{ route('gadaian', ['noic' => $customer_info['kplama']]) }}"; + } } }); diff --git a/resources/views/gadaian/v1/index.blade.php b/resources/views/gadaian/v1/index.blade.php index a4be210d..692ce527 100644 --- a/resources/views/gadaian/v1/index.blade.php +++ b/resources/views/gadaian/v1/index.blade.php @@ -817,32 +817,7 @@ event.preventDefault(); return false; }else{ - $.ajax({ - method:'get', - url: api_url + '/api/komuditi/check', - success:function(data){ - var check_komuditi = Object.keys(data).length; - if(check_komuditi == 0){ - $("#terima_gadai").prop('disabled', false); - Swal.fire({ - icon: 'error', - title: 'Unit Komuditi Berbaki Minumum', - text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi' - }); - event.preventDefault(); - return false; - }else{ - if(Number(data['unit_komuditi']) < pinjaman){ - $("#terima_gadai").prop('disabled', false); - Swal.fire({ - icon: 'error', - title: 'Baki Unit Komuditi Tidak Mencukupi', - text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi' - }); - event.preventDefault(); - return false; - } - else{ + // Commodity purchase is done via BSAS on Terima (server-side). if(pinjaman >= 10000 && pinjaman <= Number(pembiyaan_max_pelulus)){ //new added @@ -1179,10 +1154,6 @@ } - } - } - } - }); } } diff --git a/resources/views/gadaian/v2/index.blade.php b/resources/views/gadaian/v2/index.blade.php index 57a5ae45..d346d649 100644 --- a/resources/views/gadaian/v2/index.blade.php +++ b/resources/views/gadaian/v2/index.blade.php @@ -1562,6 +1562,126 @@ return true; } + function bsasProgressHtml() { + return '' + + '
' + + '

Sedang memproses pembelian komoditi...

' + + '
    ' + + '
  1. ' + + '○' + + '1. Menghantar order ke BSAS' + + '
    ' + + '
  2. ' + + '
  3. ' + + '○' + + '2. Menunggu keputusan (long poll)' + + '
    ' + + '
  4. ' + + '
  5. ' + + '○' + + '3. Mengambil e-Cert & simpan gadai' + + '
    ' + + '
  6. ' + + '
' + + '

Sila tunggu, proses ini boleh mengambil masa 10–30 saat.

' + + '
'; + } + + function setBsasStep(step, state, remark) { + var $el = $('#bsas-step-' + step); + if (!$el.length) { + return; + } + var icon = '○'; + var color = 'text-muted'; + if (state === 'active') { + icon = '●'; + color = 'text-primary font-weight-bold'; + } else if (state === 'done') { + icon = '✓'; + color = 'text-success'; + } else if (state === 'error') { + icon = '✕'; + color = 'text-danger'; + } + $el.attr('data-state', state) + .removeClass('text-muted text-primary text-success text-danger font-weight-bold') + .addClass(color); + $el.find('.bsas-step-icon').text(icon); + $el.find('.bsas-step-remark').text(remark || ''); + } + + function delayMs(ms) { + return new Promise(function (resolve) { + setTimeout(resolve, ms); + }); + } + + async function submitGadaiWithBsasProgress(func) { + $("#terima_gadai").prop('disabled', true); + + Swal.fire({ + title: 'Pembelian Komoditi BSAS', + html: bsasProgressHtml(), + allowOutsideClick: false, + allowEscapeKey: false, + showConfirmButton: false, + didOpen: function () { + Swal.showLoading(); + } + }); + + try { + setBsasStep(1, 'active', 'Menyediakan & menghantar order...'); + await delayMs(1200); + setBsasStep(1, 'done', 'Order dihantar.'); + + setBsasStep(2, 'active', 'Menunggu padanan BSAS...'); + await delayMs(800); + + var response = await $.ajax({ + url: $(func).attr('action'), + method: 'POST', + data: $(func).serialize(), + dataType: 'json', + headers: { + 'Accept': 'application/json', + 'X-Requested-With': 'XMLHttpRequest' + }, + timeout: 90000 + }); + + setBsasStep(2, 'done', 'Keputusan diterima.'); + setBsasStep(3, 'active', 'Mengambil e-Cert & menyimpan gadai...'); + await delayMs(1000); + setBsasStep(3, 'done', 'Selesai.'); + await delayMs(600); + + window.location.href = (response && response.redirect) + ? response.redirect + : "{{ route('customer_info') }}"; + } catch (err) { + var msg = 'Gagal pembelian komoditi BSAS. Sila cuba lagi.'; + if (err && err.responseJSON && err.responseJSON.message) { + msg = err.responseJSON.message; + } else if (err && err.statusText === 'timeout') { + msg = 'Proses BSAS tamat masa. Sila semak rekod BSAS / cuba semula.'; + } + + var activeStep = $('#bsas-progress-box li[data-state="active"]').attr('id'); + var stepNum = activeStep ? parseInt(activeStep.replace('bsas-step-', ''), 10) : 2; + setBsasStep(stepNum, 'error', msg); + + Swal.fire({ + icon: 'error', + title: 'Tidak Berjaya', + text: msg + }).then(function () { + $("#terima_gadai").prop('disabled', false); + }); + } + } + async function verifyGadai(func){ $("#terima_gadai").prop('disabled', true); if (typeof event !== 'undefined' && event && event.preventDefault) { @@ -1653,32 +1773,7 @@ event.preventDefault(); return false; }else{ - $.ajax({ - method:'get', - url: api_url + '/api/komuditi/check', - success:function(data){ - var check_komuditi = Object.keys(data).length; - if(check_komuditi == 0){ - $("#terima_gadai").prop('disabled', false); - Swal.fire({ - icon: 'error', - title: 'Unit Komuditi Berbaki Minumum', - text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi' - }); - event.preventDefault(); - return false; - }else{ - if(Number(data['unit_komuditi']) < pinjaman){ - $("#terima_gadai").prop('disabled', false); - Swal.fire({ - icon: 'error', - title: 'Baki Unit Komuditi Tidak Mencukupi', - text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi' - }); - event.preventDefault(); - return false; - } - else{ + // Commodity purchase is done via BSAS on Terima (server-side). if(pinjaman >= 10000 && pinjaman <= Number(pembiyaan_max_pelulus)){ //new added $.ajax({ @@ -1785,9 +1880,7 @@ title: 'Telah Disahkan', text: `Komen : ${data.komen}` }).then(function(){ - - $(func).attr("onSubmit","return true;"); - $(func).submit(); + submitGadaiWithBsasProgress(func); return true; }); @@ -1933,12 +2026,8 @@ icon: 'success', title: 'Telah Disahkan' }).then(function(){ - - - $(func).attr("onSubmit","return true;"); - $(func).submit(); + submitGadaiWithBsasProgress(func); return true; - }); } else if(data.kelulusan == 'batal') @@ -1999,14 +2088,7 @@ return false; } else { //insert code asal - Swal.fire({ - icon: 'success', - title: 'Berjaya!', - text: 'Pembiayaan Berjaya Disimpan' - }); - - $(func).attr("onSubmit","return true;"); - $(func).submit(); + submitGadaiWithBsasProgress(func); return true; //end insert code asal } @@ -2018,10 +2100,6 @@ } - } - } - } - }); } } diff --git a/resources/views/khazanah/v2/info.blade.php b/resources/views/khazanah/v2/info.blade.php index ffab81ba..4bc5fe21 100644 --- a/resources/views/khazanah/v2/info.blade.php +++ b/resources/views/khazanah/v2/info.blade.php @@ -25,6 +25,18 @@ + @if(!empty($customer_info['photo_base64'])) +
+
+ Gambar MyKad +
+
+ @endif +
@@ -154,7 +166,7 @@ {{-- Sudah Tebus --}} - - - - - - - - - - - -
BilNo RujukanTarikh Penyelesaian PembiayaanBaki PembiayaanMarginTempoh
+ {{-- Lelong --}} - - - - - - - - - - - - - - -
BilNo RujukanTarikh LelongTarikh TuntutPembiayaanHarga JualJum Tuntut/BayarKeuntunganCaj Lelong
+
@@ -504,21 +473,15 @@ - var tablegadai = $('#myTable').DataTable({ - "scrollX": true, - order: [[1,'desc']] + var tablegadai = initErahnDatatable('#myTable', { + order: [[1, 'desc']] }); - var xtawarruq = $('#xtawarruq').DataTable({ - "scrollX": true, - }); + var xtawarruq = initErahnDatatable('#xtawarruq'); - var tabledahtebus = $('#dahtebusTable').DataTable({ - }); + var tabledahtebus = initErahnDatatable('#dahtebusTable'); - var tablelelong = $('#lelongTable').DataTable({ - "scrollX": true - }); + var tablelelong = initErahnDatatable('#lelongTable'); var historybayarandatatable = $('#tablehistorybayaran').DataTable({ "ordering": false @@ -960,6 +923,9 @@ success: function(data){ $('#myTable').parents('div.dataTables_wrapper').first().show(); gadaiTable(data,"belum_tebus"); + if (typeof adjustErahnDatatables === 'function') { + adjustErahnDatatables(); + } } }); @@ -1493,6 +1459,9 @@ url: api_url + "/api/customers/"+noic+"/gadai/belum_tebus/"+kodcaw, success: function(data){ gadaiTable(data,"belum_tebus"); + if (typeof adjustErahnDatatables === 'function') { + adjustErahnDatatables(); + } } }); } @@ -1741,9 +1710,10 @@ }); document.addEventListener('DOMContentLoaded', function(){ - $('a[data-toggle="tab"]').on('shown.bs.tab', function(e){ - $($.fn.dataTable.tables(true)).DataTable() - .columns.adjust(); + $('a[data-toggle="tab"]').on('shown.bs.tab', function(){ + if (typeof adjustErahnDatatables === 'function') { + adjustErahnDatatables(); + } }); }); diff --git a/resources/views/operasi/komuditi/index.blade.php b/resources/views/operasi/komuditi/index.blade.php index a755c4d6..2118b901 100644 --- a/resources/views/operasi/komuditi/index.blade.php +++ b/resources/views/operasi/komuditi/index.blade.php @@ -73,43 +73,81 @@
-
{{ __('Rekod Pembelian/Penjualan Komoditi') }}
+
{{ __('Rekod Komoditi') }}
-
-
-
- - -
+ +
+
+
+
+
+ + +
+
+
+ +
+
+
+
+
+ Loading... +
+ +
+
-
- -
-
-
-
-
- Loading... -
- - - - - - - - - - - - -
BilNo SijilTarikhMasaNilai KomoditiTransaksi OlehTransaksi
+
+
+
+
+ + +
+
+
+ +
+
+
+
+ + +
+
@@ -239,15 +277,44 @@