Compare commits
9 Commits
main
...
d25364586a
| Author | SHA1 | Date | |
|---|---|---|---|
| d25364586a | |||
| 347d99d8bd | |||
| 9aee720bd0 | |||
| cdc28fb010 | |||
| a36cbcf930 | |||
| 011fbfe8b2 | |||
| 63d8c23785 | |||
| 045adcaf1a | |||
| 1d6baf3b1f |
+4
-1
@@ -47,4 +47,7 @@ MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
MYKAD_READER_PORT=8085
|
||||
MYKAD_READER_ENABLED_CAWANGAN='' # IF NO CAWANGAN STATED, ALL CAWANGAN IS ENABLED
|
||||
MYKAD_READER_ENABLED_CAWANGAN='' # IF NO CAWANGAN STATED, ALL CAWANGAN IS ENABLED
|
||||
|
||||
COMMODITY_SHORAKA_ENABLED=true
|
||||
COMMODITY_BSAS_ENABLED=true
|
||||
|
||||
+4
-1
@@ -53,4 +53,7 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
MYKAD_READER_PORT=8085
|
||||
MYKAD_READER_ENABLED_CAWANGAN='' # IF NO CAWANGAN STATED, ALL CAWANGAN IS ENABLED
|
||||
|
||||
INTERNAL_NOTIFICATION_SECRET=erahn-local-notification-secret
|
||||
INTERNAL_NOTIFICATION_SECRET=erahn-local-notification-secret
|
||||
|
||||
COMMODITY_SHORAKA_ENABLED=true
|
||||
COMMODITY_BSAS_ENABLED=true
|
||||
+4
-1
@@ -52,4 +52,7 @@ MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
MYKAD_READER_PORT=8085
|
||||
MYKAD_READER_ENABLED_CAWANGAN='' # IF NO CAWANGAN STATED, ALL CAWANGAN IS ENABLED
|
||||
MYKAD_READER_ENABLED_CAWANGAN='' # IF NO CAWANGAN STATED, ALL CAWANGAN IS ENABLED
|
||||
|
||||
COMMODITY_SHORAKA_ENABLED=true
|
||||
COMMODITY_BSAS_ENABLED=true
|
||||
|
||||
@@ -52,3 +52,8 @@ MYKAD_READER_ENABLED_CAWANGAN=''
|
||||
INTERNAL_NOTIFICATION_SECRET=
|
||||
|
||||
LOGVIEWER_PASSWORD=
|
||||
|
||||
# Commodity providers available when a teller submits gadai.
|
||||
# Turn either or both on. When both are true, the teller chooses on the form.
|
||||
COMMODITY_SHORAKA_ENABLED=true
|
||||
COMMODITY_BSAS_ENABLED=true
|
||||
|
||||
+4
-1
@@ -50,4 +50,7 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
MYKAD_READER_PORT=17321
|
||||
MYKAD_READER_ENABLED_CAWANGAN=''
|
||||
|
||||
INTERNAL_NOTIFICATION_SECRET="nIDTe(u@6[)VLJyd"
|
||||
INTERNAL_NOTIFICATION_SECRET="nIDTe(u@6[)VLJyd"
|
||||
|
||||
COMMODITY_SHORAKA_ENABLED=true
|
||||
COMMODITY_BSAS_ENABLED=true
|
||||
+4
-1
@@ -54,4 +54,7 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
MYKAD_READER_PORT=17321
|
||||
MYKAD_READER_ENABLED_CAWANGAN=''
|
||||
|
||||
INTERNAL_NOTIFICATION_SECRET=staging_noti_secret
|
||||
INTERNAL_NOTIFICATION_SECRET=staging_noti_secret
|
||||
|
||||
COMMODITY_SHORAKA_ENABLED=true
|
||||
COMMODITY_BSAS_ENABLED=true
|
||||
@@ -125,10 +125,10 @@ class AliranTunaiController extends Controller
|
||||
|
||||
$auth_user = Auth::user();
|
||||
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $auth_user['cawangan'] .'/' .$request->norujukan_gadai)->json();
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $auth_user['cawangan'] .'/' .$request->norujukan_gadai)->throw()->json();
|
||||
$gadai_detail = $gadai[0];
|
||||
|
||||
$getTunai2=Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/GetCurrentTunai/'.$auth_user['cawangan'],['kodlaluan' => $teller])->json();
|
||||
$getTunai2=Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/GetCurrentTunai/'.$auth_user['cawangan'],['kodlaluan' => $teller])->throw()->json();
|
||||
|
||||
$keluar = $getTunai2['keluar'];
|
||||
$bakiakhir = $getTunai2['baki'];
|
||||
@@ -143,7 +143,7 @@ class AliranTunaiController extends Controller
|
||||
'keluar' => $keluar,
|
||||
'masuk' => $masuk,
|
||||
'bakiakhir' => $bakiakhir
|
||||
]);
|
||||
])->throw();
|
||||
|
||||
return response()->json($updateTunai,201);
|
||||
|
||||
@@ -153,13 +153,13 @@ class AliranTunaiController extends Controller
|
||||
|
||||
$auth_user = Auth::user();
|
||||
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $auth_user['cawangan'] .'/' .$request->norujukan)->json();
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $auth_user['cawangan'] .'/' .$request->norujukan)->throw()->json();
|
||||
$gadai_detail = $gadai[0];
|
||||
|
||||
$tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/listpenebusanhistory/'. $auth_user['cawangan'],['norujukan' => $request->norujukan])->json();
|
||||
$tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/listpenebusanhistory/'. $auth_user['cawangan'],['norujukan' => $request->norujukan])->throw()->json();
|
||||
$tebus_detail = $tebus[0];
|
||||
|
||||
$getTunai2=Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/GetCurrentTunai/'.$auth_user['cawangan'],['kodlaluan' => $tebus_detail['teller']])->json();
|
||||
$getTunai2=Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/GetCurrentTunai/'.$auth_user['cawangan'],['kodlaluan' => $tebus_detail['teller']])->throw()->json();
|
||||
|
||||
$keluar=$getTunai2['keluar'];
|
||||
$baki=$getTunai2['baki'];
|
||||
@@ -181,7 +181,7 @@ class AliranTunaiController extends Controller
|
||||
'keluar'=>$keluar,
|
||||
'masuk'=>$masuk,
|
||||
'bakiakhir'=>$bakiakhir
|
||||
]);
|
||||
])->throw();
|
||||
|
||||
}else{
|
||||
|
||||
@@ -199,7 +199,7 @@ class AliranTunaiController extends Controller
|
||||
'keluar'=>$keluar,
|
||||
'masuk'=>$masuk,
|
||||
'bakiakhir'=>$bakiakhir
|
||||
]);
|
||||
])->throw();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -208,13 +208,13 @@ class AliranTunaiController extends Controller
|
||||
|
||||
$auth_user = Auth::user();
|
||||
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $auth_user['cawangan'] .'/' .$request->norujukan)->json();
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $auth_user['cawangan'] .'/' .$request->norujukan)->throw()->json();
|
||||
$gadai_detail = $gadai[0];
|
||||
|
||||
$tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/listpenebusanhistory/'. $auth_user['cawangan'],['norujukan' => $request->norujukan])->json();
|
||||
$tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/listpenebusanhistory/'. $auth_user['cawangan'],['norujukan' => $request->norujukan])->throw()->json();
|
||||
$tebus_detail = $tebus[0];
|
||||
|
||||
$getTunai2=Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/GetCurrentTunai/'.$auth_user['cawangan'],['kodlaluan' => $tebus_detail['teller']])->json();
|
||||
$getTunai2=Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/GetCurrentTunai/'.$auth_user['cawangan'],['kodlaluan' => $tebus_detail['teller']])->throw()->json();
|
||||
|
||||
$keluar=$getTunai2['keluar'];
|
||||
$baki=$getTunai2['baki'];
|
||||
@@ -228,7 +228,7 @@ class AliranTunaiController extends Controller
|
||||
'keluar'=>$keluar,
|
||||
'masuk'=>$masuk,
|
||||
'bakiakhir'=>$bakiakhir
|
||||
]);
|
||||
])->throw();
|
||||
}
|
||||
|
||||
public function alirantunaiUpahBknTawarruq(Request $request){
|
||||
|
||||
@@ -180,17 +180,17 @@ class GadaianController extends Controller
|
||||
Session::put('nopelanggan', $customer_info['nopelanggan']);
|
||||
Session::put('page_reload', true);
|
||||
Session::forget('borang_online_printed');
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url') . '/api/gadai/' . $auth_user['cawangan'], [
|
||||
Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url') . '/api/gadai/' . $auth_user['cawangan'], [
|
||||
'norujukan' => $norujukan,
|
||||
'nopelanggan' => $customer_info['nopelanggan'],
|
||||
'nokp' => $noic,
|
||||
'sirig' => $new_sirig
|
||||
]);
|
||||
'sirig' => $new_sirig,
|
||||
])->throw();
|
||||
} else {
|
||||
$norujukan = Session::get('norujukan');
|
||||
$nokp = Session::get('nokp');
|
||||
$nopelanggan = Session::get('nopelanggan');
|
||||
$gadai_session = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/check/sag', ['kodcaw' => $auth_user['cawangan'], 'norujukan' => $norujukan, 'nokp' => $nokp])->json();
|
||||
$gadai_session = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/check/sag', ['kodcaw' => $auth_user['cawangan'], 'norujukan' => $norujukan, 'nokp' => $nokp])->throw()->json();
|
||||
if ($gadai_session == null) {
|
||||
$gadai_transaction = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/' . $auth_user['cawangan'] . '/' . $current->toDateString())->json();
|
||||
if ($gadai_transaction) {
|
||||
@@ -205,12 +205,12 @@ class GadaianController extends Controller
|
||||
Session::put('nopelanggan', $nopelanggan);
|
||||
Session::put('page_reload', true);
|
||||
Session::forget('borang_online_printed');
|
||||
$gadai_baru = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url') . '/api/gadai/' . $auth_user['cawangan'], [
|
||||
Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url') . '/api/gadai/' . $auth_user['cawangan'], [
|
||||
'norujukan' => $norujukan_baru,
|
||||
'nopelanggan' => $nopelanggan,
|
||||
'nokp' => $nokp,
|
||||
'sirig' => $new_sirig
|
||||
]);
|
||||
'sirig' => $new_sirig,
|
||||
])->throw();
|
||||
$norujukan = $norujukan_baru;
|
||||
}
|
||||
}
|
||||
@@ -285,6 +285,24 @@ class GadaianController extends Controller
|
||||
public function store(Request $request)
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
if (!config('commodity.shoraka') && !config('commodity.bsas')) {
|
||||
return $this->gadaiStoreResult($request, false, 'Tiada pembekal komoditi diaktifkan.');
|
||||
}
|
||||
|
||||
$provider = $this->selectedCommodityProvider($request);
|
||||
if ($provider === null) {
|
||||
return $this->gadaiStoreResult($request, false, 'Sila pilih pembekal komoditi yang diaktifkan.');
|
||||
}
|
||||
|
||||
$shoraka = null;
|
||||
if ($provider === 'shoraka') {
|
||||
$shoraka = app(\App\Services\ShorakaFinancingService::class);
|
||||
if ($shoraka->hasOrder($request->norujukan_gadai)) {
|
||||
return $this->gadaiStoreResult($request, false, 'Order Shoraka telah dihantar. Jangan hantar semula.');
|
||||
}
|
||||
$shoraka->ensureReady();
|
||||
}
|
||||
|
||||
$caraTerima = strtoupper((string) $request->input('cara_terima', 'TUNAI'));
|
||||
$pinjamanAmt = round((float) $request->pinjaman, 2);
|
||||
|
||||
@@ -321,24 +339,25 @@ class GadaianController extends Controller
|
||||
|
||||
$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 ($provider === 'bsas') {
|
||||
$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);
|
||||
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);
|
||||
@@ -363,8 +382,43 @@ class GadaianController extends Controller
|
||||
'nokp' => $request->nokp,
|
||||
'kadar_rebate' => $this->parseMoney($request->kadar_rebate),
|
||||
'rebate' => $this->parseMoney($request->rebate),
|
||||
])->json();
|
||||
])->throw()->json();
|
||||
|
||||
if ($provider === 'shoraka') {
|
||||
return $shoraka->hold($request, $request->norujukan_gadai, 'gadai', [
|
||||
'cara_terima' => $caraTerima,
|
||||
'pinjaman' => $pinjamanAmt,
|
||||
'temporary_gadai' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
$error = $this->disburseGadai($request, $auth_user, $caraTerima, $pinjamanAmt);
|
||||
if ($error !== null) {
|
||||
return $this->gadaiStoreResult($request, false, $error);
|
||||
}
|
||||
|
||||
return $this->gadaiStoreResult($request, true);
|
||||
}
|
||||
|
||||
public function completeShorakaFinancing(Request $request)
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
$caraTerima = $request->cara_terima;
|
||||
$pinjamanAmt = round((float) $request->pinjaman, 2);
|
||||
$error = $this->disburseGadai($request, $auth_user, $caraTerima, $pinjamanAmt);
|
||||
if ($error !== null) {
|
||||
throw new \RuntimeException($error);
|
||||
}
|
||||
|
||||
return redirect()->route('customer_info');
|
||||
}
|
||||
|
||||
/**
|
||||
* Cash or online disbursement after the commodity order and gadai save.
|
||||
* Returns an error message, or null when disbursement succeeded.
|
||||
*/
|
||||
protected function disburseGadai(Request $request, $auth_user, string $caraTerima, float $pinjamanAmt): ?string
|
||||
{
|
||||
if ($caraTerima === 'ONLINE') {
|
||||
$online = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->asForm()
|
||||
@@ -384,10 +438,9 @@ class GadaianController extends Controller
|
||||
|
||||
if (!$online->successful()) {
|
||||
$body = $online->json();
|
||||
$msg = is_array($body) && isset($body['message'])
|
||||
return is_array($body) && isset($body['message'])
|
||||
? $body['message']
|
||||
: 'Gagal daftar pembiayaan online. Sila cuba lagi.';
|
||||
return $this->gadaiStoreResult($request, false, $msg);
|
||||
}
|
||||
|
||||
$this->notifyPcPembiayaanOnlinePending($auth_user, $request, $pinjamanAmt);
|
||||
@@ -401,17 +454,39 @@ class GadaianController extends Controller
|
||||
$request->session()->forget('norujukan');
|
||||
$request->session()->forget('borang_online_printed');
|
||||
$request->session()->flash('activate_tab', 'SAG_baru');
|
||||
if ($caraTerima === 'ONLINE') {
|
||||
$request->session()->flash('message', 'Gadai berjaya. Pembiayaan online menunggu semakan PC.');
|
||||
$request->session()->flash('message', $caraTerima === 'ONLINE'
|
||||
? 'Gadai berjaya. Pembiayaan online menunggu semakan PC.'
|
||||
: 'Pembiayaan berjaya dihantar.');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider chosen on the gadai form, limited to those enabled in config.
|
||||
*/
|
||||
protected function selectedCommodityProvider(Request $request): ?string
|
||||
{
|
||||
$enabled = array_values(array_filter([
|
||||
config('commodity.shoraka') ? 'shoraka' : null,
|
||||
config('commodity.bsas') ? 'bsas' : null,
|
||||
]));
|
||||
|
||||
if ($enabled === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->gadaiStoreResult($request, true);
|
||||
$selected = strtolower(trim((string) $request->input('commodity_provider', '')));
|
||||
if ($selected === '' && count($enabled) === 1) {
|
||||
return $enabled[0];
|
||||
}
|
||||
|
||||
return in_array($selected, $enabled, true) ? $selected : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON for AJAX Terima (BSAS progress UI); normal redirect otherwise.
|
||||
*/
|
||||
protected function gadaiStoreResult(Request $request, bool $ok, string $message = null)
|
||||
protected function gadaiStoreResult(Request $request, bool $ok, ?string $message = null)
|
||||
{
|
||||
if ($request->ajax() || $request->wantsJson()) {
|
||||
if (!$ok) {
|
||||
@@ -575,31 +650,55 @@ class GadaianController extends Controller
|
||||
$keuntungan6bulan = $keuntungan_sebln * 6;
|
||||
$keuntungan12bulan = $keuntungan_sebln * 12;
|
||||
$hargajualan = $request->pinjaman + $keuntungan12bulan;
|
||||
$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'],
|
||||
'nilaimarhun' => round($total_nilai_marhun, 2),
|
||||
'berat' => round($request->total_berat, 2),
|
||||
'pinjaman' => round($request->pinjaman, 2),
|
||||
'kadarupah' => round($kadarupah, 2),
|
||||
'marhun' => $request->marhun_detail,
|
||||
'percentpinj' => $margin_pinjaman,
|
||||
'teller' => $auth_user['name'],
|
||||
'upah6' => $keuntungan6bulan,
|
||||
'upah12' => $keuntungan12bulan,
|
||||
'hargajualan' => $hargajualan,
|
||||
'kuantiti_marhun' => $request->kuantiti_marhun,
|
||||
'transaction' => 'Ubah Gadai',
|
||||
'kadarujrah' => round($kadarupah, 2),
|
||||
'ujrah' => $ujrah,
|
||||
'onepercent' => $onepercent,
|
||||
'margin_semasa' => $margin_pinjaman,
|
||||
'kadar_rebate' => $this->parseMoney($request->kadar_rebate),
|
||||
'rebate' => $this->parseMoney($request->rebate),
|
||||
])->json();
|
||||
$update_komuditi = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/komuditi/update', [
|
||||
'unit_komuditi' => round($request->pinjaman, 2),
|
||||
'norujukan' => $request->norujukan_gadai
|
||||
])->json();
|
||||
try {
|
||||
$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'],
|
||||
'nilaimarhun' => round($total_nilai_marhun, 2),
|
||||
'berat' => round($request->total_berat, 2),
|
||||
'pinjaman' => round($request->pinjaman, 2),
|
||||
'kadarupah' => round($kadarupah, 2),
|
||||
'marhun' => $request->marhun_detail,
|
||||
'percentpinj' => $margin_pinjaman,
|
||||
'teller' => $auth_user['name'],
|
||||
'upah6' => $keuntungan6bulan,
|
||||
'upah12' => $keuntungan12bulan,
|
||||
'hargajualan' => $hargajualan,
|
||||
'kuantiti_marhun' => $request->kuantiti_marhun,
|
||||
'transaction' => 'Ubah Gadai',
|
||||
'kadarujrah' => round($kadarupah, 2),
|
||||
'ujrah' => $ujrah,
|
||||
'onepercent' => $onepercent,
|
||||
'margin_semasa' => $margin_pinjaman,
|
||||
'kadar_rebate' => $this->parseMoney($request->kadar_rebate),
|
||||
'rebate' => $this->parseMoney($request->rebate),
|
||||
]);
|
||||
} catch (\Illuminate\Http\Client\ConnectionException $exception) {
|
||||
return back()->withInput()->with('gadai_edit_error',
|
||||
'Sambungan terganggu. Semak rekod gadai sebelum mencuba semula.');
|
||||
}
|
||||
if (!$gadai->successful()) {
|
||||
$message = 'Ubah Gadai tidak berjaya. Sila semak dengan operasi.';
|
||||
if ($gadai->status() === 409 || $gadai->status() === 422) {
|
||||
$apiMessage = $gadai->json()['message'] ?? null;
|
||||
if (is_string($apiMessage) && $apiMessage !== '') {
|
||||
$message = $apiMessage;
|
||||
}
|
||||
}
|
||||
return back()->withInput()->with('gadai_edit_error', $message);
|
||||
}
|
||||
try {
|
||||
$update_komuditi = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/komuditi/update', [
|
||||
'unit_komuditi' => round($request->pinjaman, 2),
|
||||
'norujukan' => $request->norujukan_gadai
|
||||
]);
|
||||
} catch (\Illuminate\Http\Client\ConnectionException $exception) {
|
||||
return back()->with('gadai_edit_error',
|
||||
'Rekod gadai telah dikemas kini tetapi kemas kini komoditi tidak dapat disahkan. Sila semak dengan operasi.');
|
||||
}
|
||||
if (!$update_komuditi->successful()) {
|
||||
return back()->with('gadai_edit_error',
|
||||
'Rekod gadai telah dikemas kini tetapi kemas kini komoditi gagal. Sila semak dengan operasi.');
|
||||
}
|
||||
|
||||
event(new GadaiNotify('lulus', $auth_user['cawangan']));
|
||||
|
||||
@@ -613,7 +712,7 @@ class GadaianController extends Controller
|
||||
$norujukan = $request->norujukan;
|
||||
$auth_user = Auth::user();
|
||||
|
||||
Http::withOptions(['verify' => config('app.api_verify')])->delete(config('api.url') . '/api/gadai/batal/' . $auth_user['cawangan'] . '/' . $norujukan);
|
||||
Http::withOptions(['verify' => config('app.api_verify')])->delete(config('api.url') . '/api/gadai/batal/' . $auth_user['cawangan'] . '/' . $norujukan)->throw();
|
||||
$request->session()->forget('page_reload');
|
||||
$request->session()->forget('norujukan');
|
||||
$request->session()->forget('borang_online_printed');
|
||||
@@ -634,6 +733,7 @@ class GadaianController extends Controller
|
||||
|
||||
public function cetakSAG(Request $request)
|
||||
{
|
||||
app(\App\Services\ShorakaFinancingService::class)->printData($request->norujukan_modal);
|
||||
$auth_user = Auth::user();
|
||||
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/gadai/norujukan/cetak/' . $auth_user['cawangan'] . '/' . $request->norujukan_modal);
|
||||
@@ -654,6 +754,7 @@ class GadaianController extends Controller
|
||||
}
|
||||
|
||||
foreach ($arraynorujukan as $index => $norujukan) {
|
||||
app(\App\Services\ShorakaFinancingService::class)->printData($norujukan);
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/gadai/norujukan/serah/' . $auth_user['cawangan'] . '/' . $norujukan);
|
||||
|
||||
if ($gadai->failed()) {
|
||||
@@ -711,31 +812,11 @@ class GadaianController extends Controller
|
||||
// $pembayaran_segera = "https://spare.arrahn.com.my/pembayaransegera";
|
||||
$pembayaran_segera = "https://pay.arrahn.com.my";
|
||||
|
||||
$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',
|
||||
];
|
||||
}
|
||||
$commodityPrint = app(\App\Services\CommodityCertificate::class)
|
||||
->forReference($gadai_detail['norujukan'], $gadai_detail['pinjaman'] ?? 0);
|
||||
$komoditi = $commodityPrint['komoditi'];
|
||||
$product = $commodityPrint['product'];
|
||||
$kuantiti = $commodityPrint['kuantiti'];
|
||||
|
||||
if ($gadai_detail['tagbaru'] == 1) {
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
|
||||
@@ -585,37 +585,11 @@ class PembiayaanOnlineController extends Controller
|
||||
|
||||
$pembayaran_segera = 'https://pay.arrahn.com.my';
|
||||
|
||||
// Prefer per-Terima BSAS order; fall back to legacy daily KomuditiPurchase.
|
||||
$bsasSag = $this->api()
|
||||
->get($api_url . '/api/komuditi/bsas/order/norujukan/' . urlencode($norujukan));
|
||||
|
||||
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',
|
||||
];
|
||||
}
|
||||
$commodityPrint = app(\App\Services\CommodityCertificate::class)
|
||||
->forReference($gadai_detail['norujukan'], $gadai_detail['pinjaman'] ?? 0);
|
||||
$komoditi = $commodityPrint['komoditi'];
|
||||
$product = $commodityPrint['product'];
|
||||
$kuantiti = $commodityPrint['kuantiti'];
|
||||
|
||||
if (($gadai_detail['tagbaru'] ?? 0) == 1) {
|
||||
$cawangan_info = $this->api()
|
||||
|
||||
@@ -271,6 +271,7 @@ class PenebusanController extends Controller
|
||||
|
||||
public function tambahpinjaman(Request $request)
|
||||
{
|
||||
app(\App\Services\ShorakaFinancingService::class)->ensureReady();
|
||||
$api_url = config('api.url');
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
@@ -405,33 +406,16 @@ class PenebusanController extends Controller
|
||||
'upah12' => $keuntungan12bulan,
|
||||
'hargajualan' => $hargajualan,
|
||||
'kuantiti_marhun' => $request->kuantiti_marhun
|
||||
])->json();
|
||||
|
||||
$komuditi = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url').'/api/komuditi/transaksi',[
|
||||
'unit_komuditi' => round($request->pinjaman, 2),
|
||||
'norujukan' => $norujukanbaru,
|
||||
'kodcaw' => $auth_user['cawangan'],
|
||||
'teller' => $auth_user['name']
|
||||
]);
|
||||
|
||||
////////////////////////////
|
||||
////Update History Gadaian///
|
||||
////////////////////////////
|
||||
|
||||
$updatehistorygadaian = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url').'/api/gadai/updatehistory/'. $auth_user['cawangan'] .'/' . $norujukanbaru,[
|
||||
'historygadaian' => $request->norujukan,
|
||||
'jenistebus' => $request->jenistebus,
|
||||
])->json();
|
||||
|
||||
|
||||
event(new TebusNotify('lulus',Auth::user()->cawangan));
|
||||
event(new GadaiNotify('lulus',Auth::user()->cawangan));
|
||||
$this->AliranTunaiController->alirantunaiTebus($request);
|
||||
])->throw()->json();
|
||||
|
||||
return app(\App\Services\ShorakaFinancingService::class)->hold(
|
||||
$request, $norujukanbaru, 'refinance', ['update_history' => true]
|
||||
);
|
||||
}
|
||||
|
||||
public function tambahpinjaman_latest(Request $request)
|
||||
{
|
||||
app(\App\Services\ShorakaFinancingService::class)->ensureReady();
|
||||
$api_url = config('api.url');
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
@@ -475,17 +459,18 @@ class PenebusanController extends Controller
|
||||
])->json();
|
||||
|
||||
|
||||
if($updatetebus['result'] == 'success'){
|
||||
event(new TebusNotify('lulus',Auth::user()->cawangan));
|
||||
event(new GadaiNotify('lulus',Auth::user()->cawangan));
|
||||
$this->AliranTunaiController->alirantunaiTebus($request);
|
||||
if (($updatetebus['result'] ?? null) === 'success') {
|
||||
abort_unless(!empty($updatetebus['norujukan_baru']), 502, 'Rujukan gadaian baharu tidak diterima.');
|
||||
return app(\App\Services\ShorakaFinancingService::class)->hold(
|
||||
$request, $updatetebus['norujukan_baru'], 'refinance'
|
||||
);
|
||||
}
|
||||
return response()->json($updatetebus['result'],200);
|
||||
|
||||
return response()->json($updatetebus['result'] ?? 'error', 200);
|
||||
}
|
||||
|
||||
public function tebusautotawarruq(Request $request)
|
||||
{
|
||||
app(\App\Services\ShorakaFinancingService::class)->ensureReady();
|
||||
$auth_user = Auth::user();
|
||||
|
||||
////////////////////////
|
||||
@@ -515,17 +500,18 @@ class PenebusanController extends Controller
|
||||
"noic" => $request->noic,
|
||||
"jenisAT" => $request->jenisAT,
|
||||
])->json();
|
||||
if($updatetebus['result'] == 'success'){
|
||||
$alirantunai = new AliranTunaiController();
|
||||
event(new TebusNotify('lulus',Auth::user()->cawangan));
|
||||
event(new GadaiNotify('lulus',Auth::user()->cawangan));
|
||||
$alirantunai->alirantunaiTebusAutoTawarruq($request);
|
||||
if (($updatetebus['result'] ?? null) === 'success') {
|
||||
abort_unless(!empty($updatetebus['norujukan_baru']), 502, 'Rujukan gadaian baharu tidak diterima.');
|
||||
return app(\App\Services\ShorakaFinancingService::class)->hold(
|
||||
$request, $updatetebus['norujukan_baru'], 'autotawarruq'
|
||||
);
|
||||
}
|
||||
return response()->json($updatetebus['result'],200);
|
||||
return response()->json($updatetebus['result'] ?? 'error', 200);
|
||||
}
|
||||
|
||||
public function tebusseparuh(Request $request)
|
||||
{
|
||||
app(\App\Services\ShorakaFinancingService::class)->ensureReady();
|
||||
$api_url = config('api.url');
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
@@ -666,39 +652,13 @@ class PenebusanController extends Controller
|
||||
'upah12' => $keuntungan12bulan,
|
||||
'hargajualan' => $hargajualan,
|
||||
'kuantiti_marhun' => $request->kuantiti_marhun
|
||||
])->json();
|
||||
])->throw()->json();
|
||||
|
||||
$komuditi = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url').'/api/komuditi/transaksi',[
|
||||
'unit_komuditi' => round($request->pinjaman, 2),
|
||||
'norujukan' => $norujukanbaru,
|
||||
'kodcaw' => $auth_user['cawangan'],
|
||||
'teller' => $auth_user['name']
|
||||
]);
|
||||
|
||||
////////////////////////////
|
||||
////Update History Gadaian///
|
||||
////////////////////////////
|
||||
|
||||
$updatehistorygadaian = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url').'/api/gadai/updatehistory/'. $auth_user['cawangan'] .'/' . $norujukanbaru,[
|
||||
'historygadaian' => $request->norujukan,
|
||||
'jenistebus' => $request->jenistebus,
|
||||
])->json();
|
||||
|
||||
|
||||
$alirantunai = new AliranTunaiController();
|
||||
event(new TebusNotify('lulus',Auth::user()->cawangan));
|
||||
event(new GadaiNotify('lulus',Auth::user()->cawangan));
|
||||
|
||||
$alirantunai->alirantunaiTebus($request);
|
||||
|
||||
|
||||
return response()->json($updatemarhun,200);
|
||||
|
||||
return app(\App\Services\ShorakaFinancingService::class)->hold(
|
||||
$request, $norujukanbaru, 'refinance', ['update_history' => true]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//Wakil Function
|
||||
|
||||
public function getfirstWakil()
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\ShorakaFinancingService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Throwable;
|
||||
|
||||
class ShorakaController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$records = app(ShorakaFinancingService::class)->listForBranch(Auth::user()->cawangan);
|
||||
$cawangan_info = ['details_caw' => Auth::user()->cawangan, 'kodcaw' => Auth::user()->cawangan];
|
||||
return view('shoraka.index', compact('records', 'cawangan_info'));
|
||||
}
|
||||
|
||||
public function operasiIndex(Request $request)
|
||||
{
|
||||
abort_unless(in_array(Auth::user()->roles, ['operasi', 'pc', 'ppc'], true), 403);
|
||||
$isOperasi = Auth::user()->roles === 'operasi';
|
||||
$filters = $request->validate([
|
||||
'kodcaw' => 'nullable|string|max:30',
|
||||
'norujukan' => 'nullable|string|max:100',
|
||||
'status' => 'nullable|in:PENDING,Active,Completed,Cancelled,UNKNOWN,FAILED',
|
||||
'date_from' => 'nullable|date_format:Y-m-d',
|
||||
'date_to' => 'nullable|date_format:Y-m-d' . ($request->filled('date_from') ? '|after_or_equal:date_from' : ''),
|
||||
]);
|
||||
[$records, $branches] = app(ShorakaFinancingService::class)->search(
|
||||
$filters,
|
||||
$isOperasi ? null : Auth::user()->cawangan
|
||||
);
|
||||
$cawangan_info = ['details_caw' => Auth::user()->cawangan, 'kodcaw' => Auth::user()->cawangan];
|
||||
return view('shoraka.operasi', compact('records', 'branches', 'filters', 'isOperasi', 'cawangan_info'));
|
||||
}
|
||||
|
||||
public function pcIndex(Request $request)
|
||||
{
|
||||
abort_unless(in_array(Auth::user()->roles, ['pc', 'ppc'], true), 403);
|
||||
return $this->operasiIndex($request);
|
||||
}
|
||||
|
||||
public function show(string $norujukan, ShorakaFinancingService $service)
|
||||
{
|
||||
$data = null;
|
||||
$error = null;
|
||||
try {
|
||||
$data = $service->snapshot($norujukan);
|
||||
} catch (Throwable $exception) {
|
||||
$error = 'Maklumat Shoraka tidak dapat diambil. Bayaran dan SAG masih ditahan.';
|
||||
}
|
||||
$cawangan_info = ['details_caw' => Auth::user()->cawangan, 'kodcaw' => Auth::user()->cawangan];
|
||||
return view('shoraka.show', compact('norujukan', 'data', 'error', 'cawangan_info'));
|
||||
}
|
||||
|
||||
public function certificate(string $norujukan, ShorakaFinancingService $service)
|
||||
{
|
||||
$response = $service->api()->get($service->url($norujukan, '/certificate'))->throw();
|
||||
abort_unless(substr($response->body(), 0, 5) === '%PDF-', 502);
|
||||
return response($response->body(), 200, [
|
||||
'Content-Type' => 'application/pdf',
|
||||
'Content-Disposition' => 'attachment; filename="sijil-shoraka.pdf"',
|
||||
'Cache-Control' => 'private, no-store',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Throwable;
|
||||
|
||||
class CommodityCertificate
|
||||
{
|
||||
/**
|
||||
* Certificate fields for a SAG. Shoraka is used when that order exists,
|
||||
* otherwise the BSAS order, otherwise the legacy daily commodity stock.
|
||||
*/
|
||||
public function forReference(string $reference, $pinjaman = null): array
|
||||
{
|
||||
$shoraka = $this->shorakaPrint($reference);
|
||||
if ($shoraka) {
|
||||
return $this->normalize($shoraka['komoditi'], $shoraka['product'], $shoraka['kuantiti']);
|
||||
}
|
||||
|
||||
$bsas = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get(rtrim((string) config('api.url'), '/') . '/api/komuditi/bsas/order/norujukan/' . urlencode($reference));
|
||||
|
||||
if ($bsas->successful() && is_array($bsas->json())) {
|
||||
$payload = $bsas->json();
|
||||
return $this->normalize(
|
||||
$payload['komoditi'] ?? [],
|
||||
$payload['product'] ?? [],
|
||||
(float) ($payload['kuantiti'] ?? 0)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->legacy($pinjaman);
|
||||
}
|
||||
|
||||
private function shorakaPrint(string $reference): ?array
|
||||
{
|
||||
try {
|
||||
return app(ShorakaFinancingService::class)->printData($reference);
|
||||
} catch (HttpException $exception) {
|
||||
if ($exception->getStatusCode() === 409) {
|
||||
throw $exception;
|
||||
}
|
||||
return null;
|
||||
} catch (Throwable $exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private function legacy($pinjaman): array
|
||||
{
|
||||
$api = rtrim((string) config('api.url'), '/');
|
||||
$komoditi = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api . '/api/komuditi/check')
|
||||
->json();
|
||||
if (!is_array($komoditi)) {
|
||||
$komoditi = [];
|
||||
}
|
||||
|
||||
$product = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api . '/api/komuditi/description', [
|
||||
'kodproduk' => $komoditi['kodproduct'] ?? '',
|
||||
])
|
||||
->json();
|
||||
|
||||
$nilai = (float) ($komoditi['nilai'] ?? 0);
|
||||
$kuantiti = $nilai > 0 ? ((float) $pinjaman / $nilai) : 0;
|
||||
|
||||
return $this->normalize($komoditi, is_array($product) ? $product : [], $kuantiti);
|
||||
}
|
||||
|
||||
private function normalize($komoditi, $product, $kuantiti): array
|
||||
{
|
||||
if (!is_array($komoditi)) {
|
||||
$komoditi = [];
|
||||
}
|
||||
if (!is_array($product)) {
|
||||
$product = [];
|
||||
}
|
||||
|
||||
$code = $product['product_code'] ?? $product['kodproduk'] ?? ($komoditi['kodproduct'] ?? '');
|
||||
$product['product_code'] = $product['product_code'] ?? $code;
|
||||
$product['kodproduk'] = $product['kodproduk'] ?? $code;
|
||||
$product['description'] = $product['description'] ?? '';
|
||||
$product['unit'] = $product['unit'] ?? 'TAN';
|
||||
|
||||
return [
|
||||
'komoditi' => $komoditi,
|
||||
'product' => $product,
|
||||
'kuantiti' => $kuantiti,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Http\Controllers\GadaianController;
|
||||
use App\Http\Controllers\AliranTunaiController;
|
||||
use App\Events\Dashboard\GadaiNotify;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Throwable;
|
||||
|
||||
class ShorakaFinancingService
|
||||
{
|
||||
public function ensureReady(): void
|
||||
{
|
||||
$response = $this->api()->get(rtrim(config('api.url'), '/') . '/api/shoraka/readiness')->throw()->json();
|
||||
abort_unless(!empty($response['ready']), 503, 'Shoraka belum dikonfigurasi. Pembiayaan baharu ditahan.');
|
||||
}
|
||||
|
||||
public function api()
|
||||
{
|
||||
return Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->acceptJson()->timeout(75);
|
||||
}
|
||||
|
||||
public function url(string $reference, string $suffix = ''): string
|
||||
{
|
||||
return rtrim(config('api.url'), '/') . '/api/shoraka/gadai/'
|
||||
. rawurlencode(Auth::user()->cawangan) . '/' . rawurlencode($reference) . $suffix;
|
||||
}
|
||||
|
||||
public function hasOrder(string $reference): bool
|
||||
{
|
||||
$snapshot = $this->snapshot($reference);
|
||||
return !empty($snapshot['order']);
|
||||
}
|
||||
|
||||
public function snapshot(string $reference): array
|
||||
{
|
||||
$response = $this->api()->get($this->url($reference));
|
||||
if ($response->status() === 404) {
|
||||
return [];
|
||||
}
|
||||
if ($response->serverError()) {
|
||||
abort(503, 'Shoraka belum dikonfigurasi. Pembiayaan baharu ditahan.');
|
||||
}
|
||||
$response->throw();
|
||||
return $response->json()['data'] ?? [];
|
||||
}
|
||||
|
||||
public function listForBranch(string $branch)
|
||||
{
|
||||
$response = $this->api()->get(rtrim(config('api.url'), '/') . '/api/shoraka/transactions', [
|
||||
'kodcaw' => $branch,
|
||||
'per_page' => 100,
|
||||
])->throw()->json();
|
||||
return collect($response['data'] ?? []);
|
||||
}
|
||||
|
||||
public function search(array $filters, ?string $onlyBranch): array
|
||||
{
|
||||
$query = [
|
||||
'per_page' => 25,
|
||||
'page' => max(1, (int) request()->input('page', 1)),
|
||||
'with_branches' => 1,
|
||||
];
|
||||
if ($onlyBranch) {
|
||||
$query['kodcaw'] = $onlyBranch;
|
||||
$query['branch_scope'] = $onlyBranch;
|
||||
} elseif (!empty($filters['kodcaw'])) {
|
||||
$query['kodcaw'] = $filters['kodcaw'];
|
||||
}
|
||||
foreach (['norujukan', 'status', 'date_from', 'date_to'] as $field) {
|
||||
if (!empty($filters[$field])) {
|
||||
$query[$field] = $filters[$field];
|
||||
}
|
||||
}
|
||||
$response = $this->api()->get(rtrim(config('api.url'), '/') . '/api/shoraka/transactions', $query)->throw()->json();
|
||||
$items = collect($response['data'] ?? []);
|
||||
$records = new LengthAwarePaginator(
|
||||
$items,
|
||||
(int) ($response['total'] ?? 0),
|
||||
(int) ($response['per_page'] ?? 25),
|
||||
(int) ($response['current_page'] ?? 1),
|
||||
['path' => request()->url(), 'query' => request()->query()]
|
||||
);
|
||||
return [$records, collect($response['branches'] ?? [])];
|
||||
}
|
||||
|
||||
public function hold(Request $request, string $reference, string $action, array $extra = [])
|
||||
{
|
||||
if ($this->hasOrder($reference)) {
|
||||
return $this->failed($request, 'Order Shoraka telah dihantar. Jangan hantar semula.');
|
||||
}
|
||||
|
||||
$context = array_merge($request->except(['_token', 'password']), $extra, ['action' => $action]);
|
||||
try {
|
||||
$response = $this->api()->post($this->url($reference, '/submit'), [
|
||||
'teller' => Auth::user()->name,
|
||||
]);
|
||||
} catch (Throwable $exception) {
|
||||
if ($this->hasOrder($reference)) {
|
||||
return $this->failed($request, 'Order Shoraka telah dihantar. Jangan hantar semula.');
|
||||
}
|
||||
return $this->failed($request, 'Order Shoraka tidak berjaya dihantar. Gadaian tidak dihantar.');
|
||||
}
|
||||
|
||||
if (!$response->successful()) {
|
||||
$message = $response->json()['message'] ?? ($this->hasOrder($reference)
|
||||
? 'Order Shoraka telah dihantar. Jangan hantar semula.'
|
||||
: 'Order Shoraka tidak berjaya dihantar. Gadaian tidak dihantar.');
|
||||
return $this->failed($request, $message);
|
||||
}
|
||||
|
||||
$snapshot = $this->waitUntilCompleted($reference);
|
||||
$status = $snapshot['order']['status'] ?? null;
|
||||
if ($status !== 'Completed') {
|
||||
return $this->failed($request, 'Pengesahan Shoraka belum Completed. Jangan hantar semula.');
|
||||
}
|
||||
if (empty($snapshot['can_complete'])
|
||||
|| (array_key_exists('pinjaman', $context)
|
||||
&& number_format((float) $context['pinjaman'], 2, '.', '')
|
||||
!== number_format((float) ($snapshot['order_amount'] ?? 0), 2, '.', ''))) {
|
||||
return $this->failed($request, 'Amaun pembiayaan berubah. Bayaran tidak diproses.');
|
||||
}
|
||||
|
||||
return $this->complete($request, $reference, $context);
|
||||
}
|
||||
|
||||
private function waitUntilCompleted(string $reference): array
|
||||
{
|
||||
set_time_limit(150);
|
||||
$deadline = microtime(true) + 120;
|
||||
$snapshot = [];
|
||||
do {
|
||||
try {
|
||||
$this->api()->post($this->url($reference, '/refresh'))->throw();
|
||||
$snapshot = $this->snapshot($reference);
|
||||
} catch (Throwable $exception) {
|
||||
$snapshot = [];
|
||||
}
|
||||
$status = $snapshot['order']['status'] ?? null;
|
||||
if ($status === 'Completed' || in_array($status, ['Cancelled', 'FAILED', 'UNKNOWN'], true)) {
|
||||
return $snapshot;
|
||||
}
|
||||
if (microtime(true) >= $deadline) {
|
||||
return $snapshot;
|
||||
}
|
||||
sleep(2);
|
||||
} while (true);
|
||||
}
|
||||
|
||||
private function complete(Request $request, string $reference, array $context)
|
||||
{
|
||||
$branch = Auth::user()->cawangan;
|
||||
$saved = new Request($context);
|
||||
$saved->setLaravelSession($request->session());
|
||||
if (($context['action'] ?? null) === 'gadai') {
|
||||
return app(GadaianController::class)->completeShorakaFinancing($saved);
|
||||
}
|
||||
if (!empty($context['update_history'])) {
|
||||
$this->api()->put(rtrim(config('api.url'), '/') . '/api/gadai/updatehistory/'
|
||||
. rawurlencode($branch) . '/' . rawurlencode($reference), [
|
||||
'historygadaian' => $saved->norujukan,
|
||||
'jenistebus' => $saved->jenistebus,
|
||||
])->throw();
|
||||
}
|
||||
$cash = app(AliranTunaiController::class);
|
||||
if (($context['action'] ?? null) === 'autotawarruq') {
|
||||
$cash->alirantunaiTebusAutoTawarruq($saved);
|
||||
} else {
|
||||
$cash->alirantunaiTebus($saved);
|
||||
}
|
||||
event(new \App\Events\Dashboard\TebusNotify('lulus', $branch));
|
||||
event(new GadaiNotify('lulus', $branch));
|
||||
return redirect()->route('customer_info');
|
||||
}
|
||||
|
||||
public function printData(string $reference): ?array
|
||||
{
|
||||
$response = $this->api()->get($this->url($reference))->throw()->json()['data'];
|
||||
$order = $response['order'] ?? null;
|
||||
if (!$order) {
|
||||
return null;
|
||||
}
|
||||
abort_unless(!empty($response['can_complete']), 409, 'SAG ditahan: Shoraka belum Completed.');
|
||||
$details = $response['details'] ?? [];
|
||||
$certificateDetails = $details['certificateDetails1'] ?? '';
|
||||
if (is_array($certificateDetails)) {
|
||||
$certificateDetails = $certificateDetails[0] ?? '';
|
||||
}
|
||||
$certificate = is_string($certificateDetails) ? trim(explode('|', $certificateDetails)[0]) : '';
|
||||
abort_unless($certificate !== '' && isset($details['unit'], $details['volume'], $details['commodityType']),
|
||||
409, 'Maklumat sijil belum lengkap. Semak status Shoraka dahulu.');
|
||||
return [
|
||||
'komoditi' => ['no_sijil' => $certificate],
|
||||
'product' => [
|
||||
'kodproduk' => $details['commodityType'],
|
||||
'description' => $details['commodityType'] === '000-COPPER' ? 'Copper' : 'Plastic resin',
|
||||
'unit' => $details['unit'],
|
||||
],
|
||||
'kuantiti' => $details['volume'],
|
||||
];
|
||||
}
|
||||
|
||||
private function failed(Request $request, string $message)
|
||||
{
|
||||
if ($request->ajax() || $request->expectsJson()) {
|
||||
abort(502, $message);
|
||||
}
|
||||
return redirect()->back()->with('error', $message);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -2,13 +2,13 @@
|
||||
|
||||
if (!function_exists('api_url_for_browser')) {
|
||||
/**
|
||||
* Base URL for JavaScript in the browser, derived from API_URL (config api.url).
|
||||
* Base URL for JavaScript, using API_BROWSER_URL when configured.
|
||||
* Docker dev often uses host.docker.internal for PHP→host; browsers may not resolve it.
|
||||
* Same host-mapped port is reachable at 127.0.0.1. Production URLs are unchanged.
|
||||
*/
|
||||
function api_url_for_browser(): string
|
||||
{
|
||||
$url = rtrim((string) config('api.url'), '/');
|
||||
$url = rtrim((string) (config('api.browser_url') ?: config('api.url')), '/');
|
||||
|
||||
return str_ireplace('host.docker.internal', '127.0.0.1', $url);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
return [
|
||||
'url' => env('API_URL'),
|
||||
'browser_url' => env('API_BROWSER_URL'),
|
||||
'url_koop' => env('API_URL_KOOP','https://apiujrah.erahn.com.my'),
|
||||
'url_pkb' => env('API_URL_PKB','http://localhost:8000'),
|
||||
];
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
/*
|
||||
| Which commodity providers a teller may use when submitting gadai.
|
||||
| Set either or both to true. When both are true, the teller chooses.
|
||||
*/
|
||||
'shoraka' => filter_var(env('COMMODITY_SHORAKA_ENABLED', false), FILTER_VALIDATE_BOOLEAN),
|
||||
'bsas' => filter_var(env('COMMODITY_BSAS_ENABLED', false), FILTER_VALIDATE_BOOLEAN),
|
||||
];
|
||||
@@ -35,7 +35,9 @@ COPY docker/php/php.ini /usr/local/etc/php/conf.d/app.ini
|
||||
COPY docker/php/zz-clear-env.conf /usr/local/etc/php-fpm.d/zz-clear-env.conf
|
||||
COPY docker/php/entrypoint.sh /usr/local/bin/app-entrypoint.sh
|
||||
|
||||
RUN chmod +x /usr/local/bin/app-entrypoint.sh \
|
||||
# Normalize Windows checkout line endings before executing the script.
|
||||
RUN sed -i 's/\r$//' /usr/local/bin/app-entrypoint.sh \
|
||||
&& chmod +x /usr/local/bin/app-entrypoint.sh \
|
||||
&& usermod -u 1000 www-data && groupmod -g 1000 www-data
|
||||
|
||||
ENTRYPOINT ["app-entrypoint.sh"]
|
||||
|
||||
@@ -2814,25 +2814,25 @@
|
||||
|
||||
$.ajax({
|
||||
method:'get',
|
||||
url: api + '/api/komuditi/check',
|
||||
url: api + '/api/shoraka/readiness',
|
||||
success:function(komoditi){
|
||||
var check_komuditi = Object.keys(komoditi).length;
|
||||
if(check_komuditi == 0){
|
||||
if (!komoditi.ready){
|
||||
$("#terima_transaksi").prop('disabled', false);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Unit Komuditi Berbaki Minumum',
|
||||
text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi'
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}else{
|
||||
if(Number(komoditi['unit_komuditi']) < pinjaman_baru){
|
||||
if (!komoditi.ready){
|
||||
$("#terima_transaksi").prop('disabled', false);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Baki Unit Komuditi Tidak Mencukupi',
|
||||
text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi'
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
|
||||
@@ -461,25 +461,25 @@
|
||||
}else{
|
||||
$.ajax({
|
||||
method:'get',
|
||||
url: api_url + '/api/komuditi/check',
|
||||
url: api_url + '/api/shoraka/readiness',
|
||||
success:function(data){
|
||||
var check_komuditi = Object.keys(data).length;
|
||||
if(check_komuditi == 0){
|
||||
if (!data.ready){
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Unit Komoditi Berbaki Minima',
|
||||
text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komoditi'
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
$("#daftar_gadai").prop('disabled', false);
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}else{
|
||||
if(Number(data['unit_komuditi']) <= min_komoditi){
|
||||
if (!data.ready){
|
||||
$("#daftar_gadai").prop('disabled', false);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Unit Komoditi Berbaki Minima',
|
||||
text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komoditi'
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
|
||||
@@ -754,14 +754,57 @@
|
||||
event.preventDefault();
|
||||
return false;
|
||||
} else {
|
||||
// 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']]) }}";
|
||||
var commodityShoraka = @json((bool) config('commodity.shoraka'));
|
||||
var commodityBsas = @json((bool) config('commodity.bsas'));
|
||||
var openGadaian = function () {
|
||||
if (icbaru.length > 0) {
|
||||
window.location.href =
|
||||
"{{ route('gadaian', ['noic' => $customer_info['kpbaru']]) }}";
|
||||
} else {
|
||||
window.location.href =
|
||||
"{{ route('gadaian', ['noic' => $customer_info['kplama']]) }}";
|
||||
}
|
||||
};
|
||||
|
||||
if (!commodityShoraka && !commodityBsas) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Komoditi tidak diaktifkan',
|
||||
text: 'Tiada pembekal komoditi diaktifkan. Hubungi operasi.'
|
||||
});
|
||||
$("#daftar_gadai").prop('disabled', false);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (commodityShoraka && !commodityBsas) {
|
||||
$.ajax({
|
||||
method: 'get',
|
||||
url: api_url + '/api/shoraka/readiness',
|
||||
success: function (data) {
|
||||
if (!data || !data.ready) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
$("#daftar_gadai").prop('disabled', false);
|
||||
return false;
|
||||
}
|
||||
openGadaian();
|
||||
},
|
||||
error: function () {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
$("#daftar_gadai").prop('disabled', false);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
openGadaian();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
@section('content')
|
||||
@include('modal.editmarhun')
|
||||
<div class="container">
|
||||
@if(session('gadai_edit_error'))
|
||||
<div class="alert alert-danger" role="alert">{{ session('gadai_edit_error') }}</div>
|
||||
@endif
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-12 col-lg-12">
|
||||
<h3 class="text-center text-uppercase">Pembiayaan</h3>
|
||||
@@ -946,6 +949,7 @@
|
||||
text: `Komen : ${data.komen}`
|
||||
}).then(function(){
|
||||
$(func).attr("onSubmit","return true;");
|
||||
window.shorakaTrack(api_url + '/api/shoraka/gadai/' + encodeURIComponent($('#kodcaw').val()) + '/' + encodeURIComponent($('#norujukan').val()));
|
||||
$(func).submit();
|
||||
return true;
|
||||
});
|
||||
@@ -1058,6 +1062,7 @@
|
||||
}).then(function(){
|
||||
|
||||
$(func).attr("onSubmit","return true;");
|
||||
window.shorakaTrack(api_url + '/api/shoraka/gadai/' + encodeURIComponent($('#kodcaw').val()) + '/' + encodeURIComponent($('#norujukan').val()));
|
||||
$(func).submit();
|
||||
return true;
|
||||
|
||||
@@ -1092,11 +1097,7 @@
|
||||
return false;
|
||||
}
|
||||
else if(pinjaman < 10000 && pinjaman <= Number(pembiayaan_max_teller)){
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Berjaya!',
|
||||
text: 'Pembiayaan Berjaya Disimpan'
|
||||
});
|
||||
window.shorakaTrack(api_url + '/api/shoraka/gadai/' + encodeURIComponent($('#kodcaw').val()) + '/' + encodeURIComponent($('#norujukan').val()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -817,7 +817,32 @@
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}else{
|
||||
// Commodity purchase is done via BSAS on Terima (server-side).
|
||||
$.ajax({
|
||||
method:'get',
|
||||
url: api_url + '/api/shoraka/readiness',
|
||||
success:function(data){
|
||||
var check_komuditi = Object.keys(data).length;
|
||||
if (!data.ready){
|
||||
$("#terima_gadai").prop('disabled', false);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}else{
|
||||
if (!data.ready){
|
||||
$("#terima_gadai").prop('disabled', false);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
if(pinjaman >= 10000 && pinjaman <= Number(pembiyaan_max_pelulus)){
|
||||
|
||||
//new added
|
||||
@@ -1137,9 +1162,9 @@
|
||||
return false;
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Berjaya!',
|
||||
text: 'Pembiayaan Berjaya Disimpan'
|
||||
icon: 'info',
|
||||
title: 'Sedang diproses',
|
||||
text: 'Sedang menghantar pembiayaan untuk pengesahan Shoraka.'
|
||||
});
|
||||
|
||||
$(func).attr("onSubmit","return true;");
|
||||
@@ -1154,6 +1179,10 @@
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
@section('content')
|
||||
@include('modal.editmarhun')
|
||||
<div class="container">
|
||||
@if(session('gadai_edit_error'))
|
||||
<div class="alert alert-danger" role="alert">{{ session('gadai_edit_error') }}</div>
|
||||
@endif
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-12 col-lg-12">
|
||||
<h3 class="text-center text-uppercase">Pembiayaan</h3>
|
||||
@@ -1612,6 +1615,7 @@
|
||||
text: `Komen : ${data.komen}`
|
||||
}).then(function(){
|
||||
$(func).attr("onSubmit","return true;");
|
||||
window.shorakaTrack(api_url + '/api/shoraka/gadai/' + encodeURIComponent($('#kodcaw').val()) + '/' + encodeURIComponent($('#norujukan').val()));
|
||||
$(func).submit();
|
||||
return true;
|
||||
});
|
||||
@@ -1724,6 +1728,7 @@
|
||||
}).then(function(){
|
||||
|
||||
$(func).attr("onSubmit","return true;");
|
||||
window.shorakaTrack(api_url + '/api/shoraka/gadai/' + encodeURIComponent($('#kodcaw').val()) + '/' + encodeURIComponent($('#norujukan').val()));
|
||||
$(func).submit();
|
||||
return true;
|
||||
|
||||
@@ -1758,11 +1763,7 @@
|
||||
return false;
|
||||
}
|
||||
else if(pinjaman < 10000 && pinjaman <= Number(pembiayaan_max_teller)){
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Berjaya!',
|
||||
text: 'Pembiayaan Berjaya Disimpan'
|
||||
});
|
||||
window.shorakaTrack(api_url + '/api/shoraka/gadai/' + encodeURIComponent($('#kodcaw').val()) + '/' + encodeURIComponent($('#norujukan').val()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,6 +294,35 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12" id="commodity_provider_section">
|
||||
@php
|
||||
$commodityProviders = array_values(array_filter([
|
||||
config('commodity.shoraka') ? ['id' => 'shoraka', 'label' => 'Shoraka'] : null,
|
||||
config('commodity.bsas') ? ['id' => 'bsas', 'label' => 'BSAS'] : null,
|
||||
]));
|
||||
@endphp
|
||||
<div class="form-group row mb-2">
|
||||
<div class="col-md-3">Pembekal Komoditi</div>
|
||||
<div class="col-md-9">
|
||||
@if (count($commodityProviders) === 0)
|
||||
<span class="text-danger">Tiada pembekal komoditi diaktifkan.</span>
|
||||
@elseif (count($commodityProviders) === 1)
|
||||
<input type="hidden" name="commodity_provider" value="{{ $commodityProviders[0]['id'] }}">
|
||||
<span>{{ $commodityProviders[0]['label'] }}</span>
|
||||
@else
|
||||
@foreach ($commodityProviders as $provider)
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="radio" name="commodity_provider"
|
||||
id="commodity_provider_{{ $provider['id'] }}"
|
||||
value="{{ $provider['id'] }}">
|
||||
<label class="form-check-label" for="commodity_provider_{{ $provider['id'] }}">{{ $provider['label'] }}</label>
|
||||
</div>
|
||||
@endforeach
|
||||
<div class="text-muted small">Pilih pembekal sebelum tekan Terima.</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<input type="text" name="norujukan_gadai" id="norujukan_gadai" value="{{ $norujukan }}" hidden>
|
||||
<input type="text" name="marhun_detail" id="marhun_detail" value="" hidden>
|
||||
@@ -435,7 +464,6 @@
|
||||
text: @json(session('error'))
|
||||
});
|
||||
@endif
|
||||
|
||||
$.ajax({
|
||||
method:'GET',
|
||||
url: api_url + '/api/jemas',
|
||||
@@ -1682,6 +1710,63 @@
|
||||
}
|
||||
}
|
||||
|
||||
function selectedCommodityProvider() {
|
||||
var checked = $('input[name="commodity_provider"]:checked').val();
|
||||
if (checked) {
|
||||
return checked;
|
||||
}
|
||||
var hidden = $('input[name="commodity_provider"][type="hidden"]').val();
|
||||
return hidden || '';
|
||||
}
|
||||
|
||||
function submitGadaiByProvider(func) {
|
||||
var provider = selectedCommodityProvider();
|
||||
if (!provider) {
|
||||
$("#terima_gadai").prop('disabled', false);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Pembekal Komoditi',
|
||||
text: 'Sila pilih pembekal komoditi.'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
if (provider === 'shoraka') {
|
||||
$.ajax({
|
||||
method: 'get',
|
||||
url: api_url + '/api/shoraka/readiness',
|
||||
success: function (data) {
|
||||
if (!data || !data.ready) {
|
||||
$("#terima_gadai").prop('disabled', false);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
$(func).attr('onSubmit', 'return true;');
|
||||
if (typeof window.shorakaTrack === 'function') {
|
||||
window.shorakaTrack(api_url + '/api/shoraka/gadai/' + encodeURIComponent($('#kodcaw').val()) + '/' + encodeURIComponent($('#norujukan_gadai').val()));
|
||||
}
|
||||
$(func).submit();
|
||||
},
|
||||
error: function () {
|
||||
$("#terima_gadai").prop('disabled', false);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
submitGadaiWithBsasProgress(func);
|
||||
return true;
|
||||
}
|
||||
|
||||
async function verifyGadai(func){
|
||||
$("#terima_gadai").prop('disabled', true);
|
||||
if (typeof event !== 'undefined' && event && event.preventDefault) {
|
||||
@@ -1773,7 +1858,6 @@
|
||||
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({
|
||||
@@ -1880,7 +1964,7 @@
|
||||
title: 'Telah Disahkan',
|
||||
text: `Komen : ${data.komen}`
|
||||
}).then(function(){
|
||||
submitGadaiWithBsasProgress(func);
|
||||
submitGadaiByProvider(func);
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -2026,7 +2110,7 @@
|
||||
icon: 'success',
|
||||
title: 'Telah Disahkan'
|
||||
}).then(function(){
|
||||
submitGadaiWithBsasProgress(func);
|
||||
submitGadaiByProvider(func);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@@ -2088,7 +2172,7 @@
|
||||
return false;
|
||||
} else {
|
||||
//insert code asal
|
||||
submitGadaiWithBsasProgress(func);
|
||||
submitGadaiByProvider(func);
|
||||
return true;
|
||||
//end insert code asal
|
||||
}
|
||||
|
||||
@@ -268,6 +268,11 @@
|
||||
<a href="{{ route('khazanah.harga_emas') }}"
|
||||
class="btn btn-info btn-lg btn-block mb-3">Harga Emas</a>
|
||||
</div>
|
||||
@if(config('commodity.shoraka') && in_array(Auth::user()->roles, ['pc', 'ppc'], true))
|
||||
<div class="col-4 px-2">
|
||||
<a href="{{ route('pc.shoraka.index') }}" class="btn btn-info btn-lg btn-block mb-3">Komoditi Shoraka</a>
|
||||
</div>
|
||||
@endif
|
||||
@if(!empty(($cawangan_info['features'] ?? [])['pembiayaan_online']))
|
||||
<div class="col-4 px-2">
|
||||
<a href="{{ route('pembiayaan.online.pc') }}"
|
||||
@@ -282,10 +287,12 @@
|
||||
<a href="{{ route('khazanah.indexwakil') }}"
|
||||
class="btn btn-info btn-lg btn-block mb-3">Surat Wakil</a>
|
||||
</div>
|
||||
@if(config('commodity.bsas'))
|
||||
<div class="col-4 px-2">
|
||||
<a href="{{ route('khazanah.bsas') }}"
|
||||
class="btn btn-info btn-lg btn-block mb-3">Komoditi BSAS</a>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
<div class="card-body text-center">
|
||||
<a href="{{ route('operasi.kelulusananggota') }}" class="btn btn-info btn-lg d-inline-block m-1">Kelulusan Anggota</a>
|
||||
<a href="{{ route('operasi.kelulusan') }}" class="btn btn-info btn-lg d-inline-block m-1">Kelulusan</a>
|
||||
@if(config('commodity.shoraka'))
|
||||
<a href="{{ route('operasi.shoraka.index') }}" class="btn btn-info btn-lg d-inline-block m-1">Komoditi Shoraka</a>
|
||||
@endif
|
||||
<a href="{{ route('pembiayaan.online.operasi') }}" class="btn btn-info btn-lg d-inline-block m-1">Pembiayaan Online</a>
|
||||
<a href="{{ route('pembiayaan.online.operasi.topup') }}" class="btn btn-info btn-lg d-inline-block m-1">Modal Online</a>
|
||||
<a href="{{ route('pembiayaan.online.operasi.eod') }}" class="btn btn-info btn-lg d-inline-block m-1">EOD Modal Online</a>
|
||||
|
||||
@@ -1,16 +1,67 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<style>
|
||||
.teller-home-card {
|
||||
border: 0;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 8px 24px rgba(31, 45, 61, .12);
|
||||
}
|
||||
.teller-home-card .card-header {
|
||||
padding: 20px;
|
||||
border: 0;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.teller-home-menu {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
padding: 28px;
|
||||
}
|
||||
.teller-home-menu .btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 88px;
|
||||
padding: 18px 16px;
|
||||
border-radius: 8px;
|
||||
white-space: normal;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
letter-spacing: .3px;
|
||||
transition: background-color .15s ease, box-shadow .15s ease;
|
||||
}
|
||||
.teller-home-menu .btn:hover,
|
||||
.teller-home-menu .btn:focus-visible {
|
||||
box-shadow: 0 4px 12px rgba(23, 162, 184, .25);
|
||||
}
|
||||
@media (max-width: 575.98px) {
|
||||
.teller-home-menu {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 12px;
|
||||
padding: 20px;
|
||||
}
|
||||
.teller-home-menu .btn {
|
||||
min-height: 68px;
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<div class="container">
|
||||
<div class="row justify-content-center" style="margin-top:60px;">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-header bg-secondary text-center"><span style="font-weight:500;">{{ __('Paparan Utama') }}</span></div>
|
||||
<div class="card teller-home-card">
|
||||
<div class="card-header bg-secondary text-center">{{ __('Paparan Utama') }}</div>
|
||||
|
||||
<div class="card-body text-center">
|
||||
<div class="card-body teller-home-menu text-center">
|
||||
<a class="btn btn-info btn-lg" href="#" onclick="pelangganclick()">PELANGGAN</a>
|
||||
<a class="btn btn-info btn-lg" href="{{ url('/harga_emas') }}">HARGA EMAS</a>
|
||||
<a class="btn btn-info btn-lg" href="{{ url('/aliran_tunai') }}">ALIRAN TUNAI</a>
|
||||
@if(config('commodity.shoraka') && (in_array(Auth::user()->roles, ['teller', 'penilai', 'pc', 'ppc', 'admin', 'masteradmin', 'operasi']) || Auth::user()->role_harian === 'teller'))
|
||||
<a class="btn btn-info btn-lg" href="{{ route('shoraka.index') }}">KOMODITI SHORAKA</a>
|
||||
@endif
|
||||
{{-- <a class="btn btn-info btn-lg" href="#">TETAPAN</a> --}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -405,6 +405,7 @@
|
||||
@endif
|
||||
|
||||
<main class="py-4">
|
||||
@include('shoraka.navigation')
|
||||
@yield('content')
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@@ -2022,25 +2022,25 @@
|
||||
|
||||
$.ajax({
|
||||
method:'get',
|
||||
url: api + '/api/komuditi/check',
|
||||
url: api + '/api/shoraka/readiness',
|
||||
success:function(komoditi){
|
||||
var check_komuditi = Object.keys(komoditi).length;
|
||||
if(check_komuditi == 0){
|
||||
if (!komoditi.ready){
|
||||
$("#terima_transaksi").prop('disabled', false);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Unit Komuditi Berbaki Minumum',
|
||||
text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi'
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}else{
|
||||
if(Number(komoditi['unit_komuditi']) < pinjaman_baru){
|
||||
if (!komoditi.ready){
|
||||
$("#terima_transaksi").prop('disabled', false);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Baki Unit Komuditi Tidak Mencukupi',
|
||||
text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi'
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
|
||||
@@ -2258,25 +2258,25 @@
|
||||
|
||||
$.ajax({
|
||||
method:'get',
|
||||
url: api + '/api/komuditi/check',
|
||||
url: api + '/api/shoraka/readiness',
|
||||
success:function(komoditi){
|
||||
var check_komuditi = Object.keys(komoditi).length;
|
||||
if(check_komuditi == 0){
|
||||
if (!komoditi.ready){
|
||||
$("#terima_transaksi").prop('disabled', false);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Unit Komuditi Berbaki Minumum',
|
||||
text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi'
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}else{
|
||||
if(Number(komoditi['unit_komuditi']) < pinjaman_baru){
|
||||
if (!komoditi.ready){
|
||||
$("#terima_transaksi").prop('disabled', false);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Baki Unit Komuditi Tidak Mencukupi',
|
||||
text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi'
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
|
||||
@@ -2264,27 +2264,27 @@
|
||||
let komuditiblock = false;
|
||||
$.ajax({
|
||||
method:'get',
|
||||
url: api + '/api/komuditi/check',
|
||||
url: api + '/api/shoraka/readiness',
|
||||
async:false,
|
||||
success:function(komoditi){
|
||||
var check_komuditi = Object.keys(komoditi).length;
|
||||
if(check_komuditi == 0){
|
||||
if (!komoditi.ready){
|
||||
$("#terima_transaksi").prop('disabled', false);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Unit Komuditi Berbaki Minumum',
|
||||
text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi'
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
komuditiblock = true;
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}else{
|
||||
if(Number(komoditi['unit_komuditi']) < pinjaman_baru){
|
||||
if (!komoditi.ready){
|
||||
$("#terima_transaksi").prop('disabled', false);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Baki Unit Komuditi Tidak Mencukupi',
|
||||
text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi'
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
komuditiblock = true;
|
||||
event.preventDefault();
|
||||
@@ -2646,29 +2646,29 @@
|
||||
let komuditiblock = false;
|
||||
$.ajax({
|
||||
method:'get',
|
||||
url: api + '/api/komuditi/check',
|
||||
url: api + '/api/shoraka/readiness',
|
||||
async:false,
|
||||
success:function(komoditi){
|
||||
var check_komuditi = Object.keys(komoditi).length;
|
||||
if(check_komuditi == 0){
|
||||
if (!komoditi.ready){
|
||||
$("#terima_transaksi").prop('disabled', false);
|
||||
Swal.close();
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Unit Komuditi Berbaki Minumum',
|
||||
text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi'
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
komuditiblock = true;
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}else{
|
||||
if(Number(komoditi['unit_komuditi']) < pinjaman_baru){
|
||||
if (!komoditi.ready){
|
||||
$("#terima_transaksi").prop('disabled', false);
|
||||
Swal.close();
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Baki Unit Komuditi Tidak Mencukupi',
|
||||
text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi'
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
komuditiblock = true;
|
||||
event.preventDefault();
|
||||
@@ -3106,25 +3106,25 @@
|
||||
|
||||
$.ajax({
|
||||
method:'get',
|
||||
url: api + '/api/komuditi/check',
|
||||
url: api + '/api/shoraka/readiness',
|
||||
success:function(komoditi){
|
||||
var check_komuditi = Object.keys(komoditi).length;
|
||||
if(check_komuditi == 0){
|
||||
if (!komoditi.ready){
|
||||
$("#terima_transaksi").prop('disabled', false);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Unit Komuditi Berbaki Minumum',
|
||||
text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi'
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}else{
|
||||
if(Number(komoditi['unit_komuditi']) < pinjaman_baru){
|
||||
if (!komoditi.ready){
|
||||
$("#terima_transaksi").prop('disabled', false);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Baki Unit Komuditi Tidak Mencukupi',
|
||||
text: 'Sila Hubungi Operasi Untuk Membuat Pembelian Komuditi'
|
||||
title: 'Shoraka Belum Tersedia',
|
||||
text: 'Sila hubungi operasi untuk semakan sambungan Shoraka.'
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
|
||||
@@ -556,30 +556,11 @@
|
||||
</table>
|
||||
|
||||
@php
|
||||
$bsasSag = Http::withOptions(['verify' => config('app.api_verify')])->get($api_url . '/api/komuditi/bsas/order/norujukan/' . urlencode($gadai_detail['norujukan']));
|
||||
|
||||
$komuditi = [];
|
||||
$product = [];
|
||||
$kuantiti = 0;
|
||||
|
||||
if ($bsasSag->successful() && is_array($bsasSag->json())) {
|
||||
$bsasPayload = $bsasSag->json();
|
||||
$komuditi = $bsasPayload['komoditi'] ?? [];
|
||||
$product = $bsasPayload['product'] ?? [];
|
||||
$kuantiti = (float) ($bsasPayload['kuantiti'] ?? 0);
|
||||
}
|
||||
|
||||
if (!is_array($komuditi)) {
|
||||
$komuditi = [];
|
||||
}
|
||||
if (!is_array($product)) {
|
||||
$product = [
|
||||
'product_code' => $komuditi['kodproduct'] ?? '',
|
||||
'kodproduk' => $komuditi['kodproduct'] ?? '',
|
||||
'description' => '',
|
||||
'unit' => 'TAN',
|
||||
];
|
||||
}
|
||||
$commodityPrint = app(\App\Services\CommodityCertificate::class)
|
||||
->forReference($gadai_detail['norujukan'], $gadai_detail['pinjaman'] ?? 0);
|
||||
$komuditi = $commodityPrint['komoditi'];
|
||||
$product = $commodityPrint['product'];
|
||||
$kuantiti = $commodityPrint['kuantiti'];
|
||||
@endphp
|
||||
|
||||
<table style="margin-bottom:10px;" id="keuntungan">
|
||||
|
||||
@@ -654,13 +654,20 @@
|
||||
|
||||
|
||||
@php
|
||||
$komuditi = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
$shorakaPrint = app(\App\Services\ShorakaFinancingService::class)->printData($gadai_detail['norujukan']);
|
||||
if ($shorakaPrint) {
|
||||
$komuditi = $shorakaPrint['komoditi'];
|
||||
$product = $shorakaPrint['product'];
|
||||
$kuantiti = $shorakaPrint['kuantiti'];
|
||||
} else {
|
||||
$komuditi = 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' => $komuditi['kodproduct']])
|
||||
->json();
|
||||
$kuantiti = $gadai_detail['pinjaman'] / $komuditi['nilai'];
|
||||
}
|
||||
@endphp
|
||||
|
||||
<table style="margin-bottom:10px;" id="keuntungan">
|
||||
|
||||
@@ -713,13 +713,20 @@
|
||||
</tr>
|
||||
</table>
|
||||
@php
|
||||
$komuditi = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
$shorakaPrint = app(\App\Services\ShorakaFinancingService::class)->printData($gadai_detail['norujukan']);
|
||||
if ($shorakaPrint) {
|
||||
$komuditi = $shorakaPrint['komoditi'];
|
||||
$product = $shorakaPrint['product'];
|
||||
$kuantiti = $shorakaPrint['kuantiti'];
|
||||
} else {
|
||||
$komuditi = 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' => $komuditi['kodproduct']])
|
||||
->json();
|
||||
$kuantiti = $gadai_detail['pinjaman'] / $komuditi['nilai'];
|
||||
}
|
||||
@endphp
|
||||
|
||||
<table id="keuntungan" style="margin-bottom:10px;">
|
||||
|
||||
@@ -615,7 +615,7 @@
|
||||
<td>{{ $komoditi['no_sijil'] }}</td>
|
||||
<td class="text-center">4</td>
|
||||
<td>Kuantiti (Unit)</td>
|
||||
<td>{{ number_format($kuantiti, 2) }} TAN</td>
|
||||
<td>{{ $kuantiti }} TONNES</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center">2</td>
|
||||
@@ -1849,7 +1849,7 @@
|
||||
<td>{{ $komoditi['no_sijil'] }}</td>
|
||||
<td class="text-center">4</td>
|
||||
<td>Kuantiti</td>
|
||||
<td>{{ number_format($kuantiti, 2) }}</td>
|
||||
<td>{{ $kuantiti }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center">2</td>
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<style>
|
||||
.shoraka-list-card .table th,
|
||||
.shoraka-list-card .table td {
|
||||
vertical-align: middle;
|
||||
}
|
||||
.shoraka-list-card .status-badge {
|
||||
padding: 8px 12px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
white-space: normal;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-12">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb pb-3">
|
||||
<li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Komoditi Shoraka</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<div class="card shoraka-list-card">
|
||||
<div class="card-header bg-secondary d-flex flex-wrap align-items-center justify-content-between">
|
||||
<h5 class="mb-0 py-2">Komoditi Shoraka</h5>
|
||||
<a class="btn btn-info btn-sm my-1" href="{{ route('home') }}">
|
||||
<i class="fas fa-arrow-left mr-1" aria-hidden="true"></i> Kembali ke Paparan Utama
|
||||
</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p class="text-muted mb-4">Semak transaksi komoditi Shoraka cawangan ini.</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered table-hover mb-0">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th scope="col">No. rujukan</th>
|
||||
<th scope="col">Teller</th>
|
||||
<th scope="col">Status komoditi</th>
|
||||
<th scope="col" class="text-center">Tindakan</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse($records as $record)
|
||||
<tr>
|
||||
<td class="text-nowrap">{{ $record['norujukan'] }}</td>
|
||||
<td>{{ $record['teller'] ?: '—' }}</td>
|
||||
<td>
|
||||
<span class="badge badge-info status-badge">{{ $record['status'] ?: '—' }}</span>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a class="btn btn-info btn-sm" href="{{ route('shoraka.show', $record['norujukan']) }}" aria-label="Buka pembiayaan {{ $record['norujukan'] }}">Buka</a>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="4" class="text-center text-muted py-5">Tiada transaksi.</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,63 @@
|
||||
<div id="shoraka-modal" hidden style="position:fixed;inset:0;z-index:20000;background:rgba(0,0,0,.5);display:none;align-items:center;justify-content:center;padding:16px">
|
||||
<div role="dialog" aria-modal="true" aria-labelledby="shoraka-modal-title" tabindex="-1" style="background:#fff;border-radius:5px;padding:24px;max-width:460px;width:100%;text-align:center;box-shadow:0 8px 30px #0003">
|
||||
<h4 id="shoraka-modal-title">Pembelian Komoditi Shoraka</h4>
|
||||
<p id="shoraka-modal-message" role="status" aria-live="polite">Sedang memproses pembelian komoditi...</p>
|
||||
<ol style="text-align:left;padding-left:28px">
|
||||
<li data-shoraka-step="1">Menyimpan gadaian dan menghantar order</li>
|
||||
<li data-shoraka-step="2">Menunggu pengesahan Shoraka</li>
|
||||
<li data-shoraka-step="3">Menyelesaikan pembiayaan</li>
|
||||
</ol>
|
||||
<p class="text-muted small">Sila tunggu sehingga proses selesai. Jangan hantar transaksi semula.</p>
|
||||
<div id="shoraka-modal-spinner" class="spinner-border text-primary" role="status"><span class="sr-only">Sedang memproses</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
window.shorakaProgress = (function () {
|
||||
var modal = document.getElementById('shoraka-modal');
|
||||
var previousFocus;
|
||||
modal.addEventListener('keydown', function (event) {
|
||||
if (event.key === 'Tab') {
|
||||
event.preventDefault();
|
||||
modal.querySelector('[role="dialog"]').focus();
|
||||
}
|
||||
});
|
||||
return function (step, message, stopped) {
|
||||
if (stopped) {
|
||||
modal.hidden = true;
|
||||
modal.style.display = 'none';
|
||||
if (previousFocus) { previousFocus.focus(); }
|
||||
return;
|
||||
}
|
||||
if (modal.hidden) { previousFocus = document.activeElement; }
|
||||
modal.hidden = false;
|
||||
modal.style.display = 'flex';
|
||||
document.getElementById('shoraka-modal-message').textContent = message || 'Sedang memproses pembelian komoditi...';
|
||||
modal.querySelectorAll('[data-shoraka-step]').forEach(function (item) {
|
||||
var number = Number(item.getAttribute('data-shoraka-step'));
|
||||
item.className = number < step ? 'text-success' : (number === step ? 'text-primary font-weight-bold' : 'text-muted');
|
||||
if (number === step) { item.setAttribute('aria-current', 'step'); }
|
||||
else { item.removeAttribute('aria-current'); }
|
||||
});
|
||||
modal.querySelector('[role="dialog"]').focus();
|
||||
};
|
||||
}());
|
||||
window.shorakaTrack = function (statusUrl) {
|
||||
if (window.shorakaTrackTimer) { clearInterval(window.shorakaTrackTimer); }
|
||||
window.shorakaProgress(1, 'Menyimpan gadaian dan menghantar order...');
|
||||
window.shorakaTrackTimer = setInterval(function () {
|
||||
$.get(statusUrl).done(function (body) {
|
||||
var order = body && body.data && body.data.order;
|
||||
var status = order && order.status;
|
||||
if (status === 'Completed') {
|
||||
clearInterval(window.shorakaTrackTimer);
|
||||
window.shorakaProgress(3, 'Menyelesaikan pembiayaan...');
|
||||
} else if (status === 'Cancelled' || status === 'FAILED' || status === 'UNKNOWN') {
|
||||
clearInterval(window.shorakaTrackTimer);
|
||||
window.shorakaProgress(2, 'Transaksi Shoraka gagal. Sila tunggu...');
|
||||
} else if (status) {
|
||||
window.shorakaProgress(2, 'Menunggu pengesahan Shoraka...');
|
||||
}
|
||||
});
|
||||
}, 1500);
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,96 @@
|
||||
@extends($isOperasi ? 'layouts.app_operasi' : 'layouts.app')
|
||||
|
||||
@section('content')
|
||||
@php
|
||||
$listRoute = $isOperasi ? 'operasi.shoraka.index' : 'pc.shoraka.index';
|
||||
$statusLabels = ['PENDING' => 'PENDING', 'Active' => 'Active', 'Completed' => 'Completed', 'Cancelled' => 'Cancelled', 'UNKNOWN' => 'UNKNOWN', 'FAILED' => 'FAILED'];
|
||||
@endphp
|
||||
<div class="container-fluid">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Komoditi Shoraka — {{ $isOperasi ? 'Operasi' : strtoupper(Auth::user()->roles) }}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
<div class="card">
|
||||
<div class="card-header d-flex flex-wrap justify-content-between align-items-center">
|
||||
<h5 class="mb-0 py-2">Komoditi Shoraka — {{ $isOperasi ? 'Semua Cawangan' : Auth::user()->cawangan }}</h5>
|
||||
<a href="{{ route('home') }}" class="btn btn-info btn-sm">Kembali ke Paparan Utama</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p class="text-muted">Paparan transaksi komoditi Shoraka {{ $isOperasi ? 'semua cawangan' : 'cawangan sendiri' }}.</p>
|
||||
@if($errors->any())
|
||||
<div class="alert alert-danger" role="alert">{{ $errors->first() }}</div>
|
||||
@endif
|
||||
<form method="get" action="{{ route($listRoute) }}" class="mb-4">
|
||||
<div class="form-row align-items-end">
|
||||
@if($isOperasi)
|
||||
<div class="form-group col-md-3">
|
||||
<label for="shoraka-branch">Cawangan</label>
|
||||
<select id="shoraka-branch" name="kodcaw" class="form-control">
|
||||
<option value="">{{ $isOperasi ? 'Semua cawangan' : Auth::user()->cawangan }}</option>
|
||||
@foreach($branches as $branch)
|
||||
<option value="{{ $branch }}" {{ ($filters['kodcaw'] ?? '') === $branch ? 'selected' : '' }}>{{ $branch }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
@endif
|
||||
<div class="form-group col-md-3">
|
||||
<label for="shoraka-reference">No. rujukan penuh</label>
|
||||
<input id="shoraka-reference" name="norujukan" class="form-control" maxlength="100" value="{{ $filters['norujukan'] ?? '' }}">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="shoraka-status">Status komoditi</label>
|
||||
<select id="shoraka-status" name="status" class="form-control">
|
||||
<option value="">Semua status</option>
|
||||
@foreach($statusLabels as $status => $label)
|
||||
<option value="{{ $status }}" {{ ($filters['status'] ?? '') === $status ? 'selected' : '' }}>{{ $label }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="shoraka-date-from">Tarikh mula didaftarkan</label>
|
||||
<input type="date" id="shoraka-date-from" name="date_from" class="form-control" value="{{ $filters['date_from'] ?? '' }}">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="shoraka-date-to">Tarikh akhir didaftarkan</label>
|
||||
<input type="date" id="shoraka-date-to" name="date_to" class="form-control" value="{{ $filters['date_to'] ?? '' }}">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<button type="submit" class="btn btn-primary">Tapis</button>
|
||||
<a href="{{ route($listRoute) }}" class="btn btn-secondary">Reset</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<p>{{ $records->total() }} rekod</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered table-hover">
|
||||
<thead class="thead-dark"><tr>
|
||||
<th scope="col">Cawangan</th>
|
||||
<th scope="col">No. rujukan</th>
|
||||
<th scope="col">Teller</th>
|
||||
<th scope="col">Status komoditi</th>
|
||||
<th scope="col">Didaftarkan</th>
|
||||
<th scope="col">Dikemas kini</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
@forelse($records as $record)
|
||||
<tr>
|
||||
<td>{{ $record['kodcaw'] }}</td>
|
||||
<td class="text-nowrap">{{ $record['norujukan'] }}</td>
|
||||
<td>{{ $record['teller'] ?: '—' }}</td>
|
||||
<td><span class="badge badge-info p-2">{{ $record['status'] ?: '—' }}</span></td>
|
||||
<td class="text-nowrap">{{ !empty($record['created_at']) ? \Carbon\Carbon::parse($record['created_at'])->format('d/m/Y H:i') : '—' }}</td>
|
||||
<td class="text-nowrap">{{ !empty($record['updated_at']) ? \Carbon\Carbon::parse($record['updated_at'])->format('d/m/Y H:i') : '—' }}</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="6" class="text-center text-muted py-4">Tiada transaksi untuk tapisan ini.</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{ $records->links() }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,71 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-12">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb pb-3">
|
||||
<li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{ route('shoraka.index') }}">Komoditi Shoraka</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">{{ $norujukan }}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header bg-secondary d-flex flex-wrap align-items-center justify-content-between">
|
||||
<h5 class="mb-0 py-2">Komoditi Shoraka</h5>
|
||||
<a class="btn btn-info btn-sm my-1" href="{{ route('shoraka.index') }}">
|
||||
<i class="fas fa-arrow-left mr-1" aria-hidden="true"></i> Kembali ke senarai
|
||||
</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@if(!empty($data['simulation']))
|
||||
<div class="alert alert-warning">SIMULASI LOCAL — tiada transaksi sebenar dihantar ke Shoraka.</div>
|
||||
@endif
|
||||
@php
|
||||
$order = $data['order'] ?? null;
|
||||
$status = $order['status'] ?? 'Belum dihantar';
|
||||
$ready = !empty($data['can_complete']);
|
||||
@endphp
|
||||
@if($error)<div class="alert alert-danger">{{ $error }}</div>@endif
|
||||
<p class="text-muted mb-3">No. rujukan: <strong class="text-dark">{{ $norujukan }}</strong></p>
|
||||
<div class="table-responsive mb-4">
|
||||
<table class="table table-striped table-bordered mb-0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row" class="align-middle">Status komoditi</th>
|
||||
<td><span class="badge badge-info px-3 py-2">{{ $status }}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Order ID</th>
|
||||
<td>{{ $order['order_id'] ?? '—' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Pembiayaan</th>
|
||||
<td class="text-nowrap font-weight-bold">RM {{ number_format($data['order_amount'] ?? 0, 2) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Harga jualan</th>
|
||||
<td class="text-nowrap font-weight-bold">RM {{ number_format($data['murabaha_amount'] ?? 0, 2) }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@if(!$ready)
|
||||
<div class="alert alert-warning">Bayaran pembiayaan dan SAG ditahan sehingga transaksi komoditi Completed.</div>
|
||||
@endif
|
||||
@if(in_array($status, ['UNKNOWN', 'FAILED', 'PENDING']))
|
||||
<p>Jangan hantar order sekali lagi. Hubungi operasi untuk semakan dengan Shoraka.</p>
|
||||
@endif
|
||||
@if($ready)
|
||||
<div class="d-flex flex-wrap pt-3 mt-4 border-top">
|
||||
<a class="btn btn-secondary mb-2" href="{{ route('shoraka.certificate', $norujukan) }}">Muat Turun Sijil</a>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
+8
-1
@@ -424,6 +424,8 @@ Route::group(['middleware' => ['khazanah']], function() {
|
||||
Route::post('/barcodescanned',['as'=>'barcode.scanned','uses'=>'KhazanahController@barcodescanned'])->middleware('auth','khazanah');
|
||||
|
||||
//Operasi
|
||||
Route::get('/pc/shoraka', 'ShorakaController@pcIndex')->name('pc.shoraka.index')->middleware('auth', 'khazanah');
|
||||
Route::get('/operasi/shoraka', 'ShorakaController@operasiIndex')->name('operasi.shoraka.index')->middleware('auth', 'operasi');
|
||||
Route::get('/operasi/kelulusan','OperasiController@kelulusan')->name('operasi.kelulusan')->middleware('auth','operasi');
|
||||
Route::get('/operasi/kelulusan/anggota','OperasiController@kelulusanAnggota')->name('operasi.kelulusananggota')->middleware('auth','operasi');
|
||||
Route::post('/operasi/createkelulusan',['as'=>'operasi.createkelulusan','uses'=>'OperasiController@createkelulusan'])->middleware('auth','teller');
|
||||
@@ -611,4 +613,9 @@ Route::post('/pampasan/terima',['as' => 'pampasan.terima', 'uses' => 'KhazanahCo
|
||||
Route::get(('/pampasan/resit'), ['as' => 'pampasan.resit', 'uses' => 'KhazanahController@resitPampasan'])->middleware('auth', 'khazanah');
|
||||
|
||||
//Surat Pampasan
|
||||
Route::get('/pampasan/surat/{norujukan}', ['as' => 'pampasan.surat', 'uses' => 'KhazanahController@suratPampasan'])->middleware('auth', 'role:teller,khazanah');
|
||||
Route::get('/pampasan/surat/{norujukan}', ['as' => 'pampasan.surat', 'uses' => 'KhazanahController@suratPampasan'])->middleware('auth', 'role:teller,khazanah');
|
||||
Route::group(['prefix' => 'shoraka', 'middleware' => ['auth', 'role:teller,penilai,khazanah,admin,masteradmin,operasi']], function () {
|
||||
Route::get('/', 'ShorakaController@index')->name('shoraka.index');
|
||||
Route::get('/{norujukan}', 'ShorakaController@show')->name('shoraka.show');
|
||||
Route::get('/{norujukan}/certificate', 'ShorakaController@certificate')->name('shoraka.certificate');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user