Merged in izzati-feat-arcc-keuntungan (pull request #299)

update untuk paparan keuntungan arcc
This commit is contained in:
izzati zulkifli
2025-07-28 07:49:37 +00:00
3 changed files with 115 additions and 68 deletions
+71 -38
View File
@@ -841,50 +841,83 @@ class CallCenterController extends Controller
{ {
$auth_user = Auth::user(); $auth_user = Auth::user();
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $request->norujukan)->json(); $norujukan = $request->norujukan;
$gadai = Http::withOptions(['verify' => config('app.api_verify')])
->get(config('api.url') . '/api/gadai/norujukan/' . $norujukan)
->json();
if(sizeof($gadai) > 0)
{
$history = $gadai[0][0]['historygadaian'];
$dahtebus = $gadai[0][0]['sttebus'];
$norujukan = $gadai[0][0]['norujukan'];
}
$count = 0;
$arrayhist = []; $arrayhist = [];
while($history != "0" && $history != '' || $dahtebus == 'T') if (sizeof($gadai) > 0) {
{ $history = $gadai[0][0]['historygadaian'];
if($history != "0" && $history != '') $dahtebus = $gadai[0][0]['sttebus'];
{ $kodcaw = $gadai[0][0]['kodcaw'];
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $history)->json(); // Kalau belum ada history, ambil rekod asal sahaja
$tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/listpenebusanhistory/'. $gadai[0][0]['kodcaw'],[ if ($dahtebus == 'T') {
"norujukan" => $history
])->json(); $tebusList = Http::withOptions(['verify' => config('app.api_verify')])
->get(config('api.url') . '/api/listpenebusanhistory/' . $kodcaw, [
'norujukan' => $norujukan
])
->json();
if(sizeof($gadai) > 0) $tebus = collect($tebusList)->firstWhere('norujukan', $norujukan);
{
if($history == $gadai[0][0]['historygadaian']) $arrayhist[] = [
$history = 0; "tagbaru" => $gadai[0][0]['tagbaru'] ?? 0,
else{ "hargajualan" => $gadai[0][0]['hargajualan'] ?? '',
array_push($arrayhist,["tagbaru" => ((isset($gadai[0][0]['tagbaru'])) ? $gadai[0][0]['tagbaru'] : 0),"hargajualan" => ((isset($gadai[0][0]['hargajualan'])) ? $gadai[0][0]['hargajualan'] : ''), "pinjaman" => ((isset($tebus[0])) ? $tebus[0]['pinjaman'] : 0),"norujukan" => $history,"jenistebus" => ((isset($tebus[0])) ? $tebus[0]['jenistebus'] : 0),"jbg" => ((isset($tebus[0])) ? $tebus[0]['jbg'] : 0),"t_tebus" => ((isset($tebus[0])) ? $tebus[0]['t_tebus'] : 0)]); "pinjaman" => $tebus['pinjaman'] ?? 0,
$history = $gadai[0][0]['historygadaian']; "norujukan" => $norujukan,
"jenistebus" => $tebus['jenistebus'] ?? 0,
"jbg" => $tebus['jbg'] ?? 0,
"t_tebus" => $tebus['t_tebus'] ?? 0,
"bayaran_keuntungan" => $tebus['bayaran_keuntungan'] ?? 0,
"bayaran_pembiayaan" => $tebus['bayaran_pembiayaan'] ?? 0,
"duit_masuk" => $tebus['duit_masuk'] ?? 0,
"trans_type" => $tebus['trans_type'] ?? 0,
];
} else {
// Loop ke belakang (rekod lepas-lepas)
while ($history != "0" && $history != '') {
$prevGadai = Http::withOptions(['verify' => config('app.api_verify')])
->get(config('api.url') . '/api/gadai/norujukan/' . $history)
->json();
$prevKodcaw = $prevGadai[0][0]['kodcaw'] ?? null;
if (!$prevKodcaw) break;
$tebusList = Http::withOptions(['verify' => config('app.api_verify')])
->get(config('api.url') . '/api/listpenebusanhistory/' . $prevKodcaw, [
'norujukan' => $history
])
->json();
$tebus = collect($tebusList)->firstWhere('norujukan', $history);
$arrayhist[] = [
"tagbaru" => $prevGadai[0][0]['tagbaru'] ?? 0,
"hargajualan" => $prevGadai[0][0]['hargajualan'] ?? '',
"pinjaman" => $tebus['pinjaman'] ?? 0,
"norujukan" => $history,
"jenistebus" => $tebus['jenistebus'] ?? 0,
"jbg" => $tebus['jbg'] ?? 0,
"t_tebus" => $tebus['t_tebus'] ?? 0,
"bayaran_keuntungan" => $tebus['bayaran_keuntungan'] ?? 0,
"bayaran_pembiayaan" => $tebus['bayaran_pembiayaan'] ?? 0,
"duit_masuk" => $tebus['duit_masuk'] ?? 0,
"trans_type" => $tebus['trans_type'] ?? 0,
];
$nextHistory = $prevGadai[0][0]['historygadaian'] ?? '0';
// Elakkan infinite loop
if ($nextHistory == $history) {
break;
} }
$history = $nextHistory;
} }
$count++;
}
else{
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $norujukan)->json();
$tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/listpenebusanhistory/'. $gadai[0][0]['kodcaw'],[
"norujukan" => $norujukan
])->json();
array_push($arrayhist,["tagbaru" => ((isset($gadai[0][0]['tagbaru'])) ? $gadai[0][0]['tagbaru'] : 0), "hargajualan" => ((isset($gadai[0][0]['hargajualan'])) ? $gadai[0][0]['hargajualan'] : ''),"pinjaman" => ((isset($tebus[0])) ? $tebus[0]['pinjaman'] : 0),"norujukan" => $norujukan,"jenistebus" => ((isset($tebus[0])) ? $tebus[0]['jenistebus'] : 0),"jbg" => ((isset($tebus[0])) ? $tebus[0]['jbg'] : 0),"t_tebus" => ((isset($tebus[0])) ? $tebus[0]['t_tebus'] : 0)]);
break;
} }
} }
+30 -27
View File
@@ -1304,10 +1304,10 @@
$.ajax({ $.ajax({
method:'get', method:'get',
url:'{{ route("arcc.history") }}', url: '{{ route("arcc.history", ":kodcaw") }}'.replace(':kodcaw', kodcaw),
data:{ "norujukan" : histid}, data:{ "norujukan" : histid},
success:function(data){ success:function(data){
historytebustable(data); historytebustable(data,histid);
$.ajax({ $.ajax({
method: 'get', method: 'get',
@@ -1386,7 +1386,10 @@
urlroute = urlroute.replace(':id', bayaran['id']); urlroute = urlroute.replace(':id', bayaran['id']);
historybayarandatatable.row.add([ historybayarandatatable.row.add([
counter, counter,
bayaran['norujukan'],
bayaran['created_at'], bayaran['created_at'],
"RM " + bayaran['bayaran_pembiayaan'],
"RM " + bayaran['bayaran_keuntungan'],
"RM " + bayaran['duit_masuk'], "RM " + bayaran['duit_masuk'],
bayaranteller, bayaranteller,
bayaran['trans_type'], bayaran['trans_type'],
@@ -1400,54 +1403,54 @@
"ordering": false "ordering": false
}); });
function historytebustable(data){ function historytebustable(data, histid)
{
console.log("Full data returned tebus:", histid); // Debug
var counter = 1; var counter = 1;
historytebusbayaran.clear().draw(); historytebusbayaran.clear().draw();
$.each(data,function(index,tebusaz){ // TAPIS hanya entry yang sama dengan norujukan klik user
let filtered = data.filter(tebusaz => tebusaz.norujukan === histid);
$.each(filtered, function(index, tebusaz){
console.log("Tebus untuk:", tebusaz.norujukan);
var urlroute = '';
switch(tebusaz['jenistebus']) { switch(tebusaz['jenistebus']) {
case 'P': case 'P':
var urlroute = '{{ route("resit.tambahpinjam", ":id") }}'; urlroute = '{{ route("resit.tambahpinjam", ":id") }}'.replace(':id', tebusaz['norujukan']);
urlroute = urlroute.replace(':id', tebusaz['norujukan']);
break; break;
case 'T': case 'T':
urlroute = (tebusaz['hargajualan'] === '')
if(tebusaz['hargajualan'] === '') ? '{{ route("resit.belumtebus", ":id") }}'.replace(':id', tebusaz['norujukan'])
{ : '{{ route("resit.tebus", ":id") }}'.replace(':id', tebusaz['norujukan']);
var urlroute = '{{ route("resit.belumtebus", ":id") }}';
urlroute = urlroute.replace(':id', tebusaz['norujukan']);
}else{
var urlroute = '{{ route("resit.tebus", ":id") }}';
urlroute = urlroute.replace(':id', tebusaz['norujukan']);
}
break; break;
case 'A': case 'A':
var urlroute = '{{ route("resit.belumansurans", ":id") }}'; urlroute = '{{ route("resit.belumansurans", ":id") }}'.replace(':id', tebusaz['norujukan']);
urlroute = urlroute.replace(':id', tebusaz['norujukan']);
break; break;
case 'S': case 'S':
var urlroute = '{{ route("resit.tebusseparuh", ":id") }}'; urlroute = '{{ route("resit.tebusseparuh", ":id") }}'.replace(':id', tebusaz['id']);
urlroute = urlroute.replace(':id', tebusaz['norujukan']); break;
break; }
}
historytebusbayaran.row.add([ historytebusbayaran.row.add([
counter, counter,
tebusaz['norujukan'], histid,
tebusaz['jenistebus'], tebusaz['trans_type'],
tebusaz['pinjaman'], "RM " + tebusaz['bayaran_pembiayaan'],
"RM " + tebusaz['bayaran_keuntungan'],
"RM " + tebusaz['duit_masuk'],
tebusaz['jbg'], tebusaz['jbg'],
tebusaz['t_tebus'], tebusaz['t_tebus'],
'' ''
]).draw(); ]).draw();
counter = counter + 1;
counter++;
}); });
} }
function daftarwakil() function daftarwakil()
{ {
let nopelanggan = $('#nopelangganwakil').val(); let nopelanggan = $('#nopelangganwakil').val();
+14 -3
View File
@@ -1,6 +1,12 @@
<style>
.modal-custom-size {
max-width: 95%; /* atau 100% */
}
</style>
<!-- Modal HistoryBayaran --> <!-- Modal HistoryBayaran -->
<div class="modal fade" id="historytebusModal" tabindex="-1" role="dialog" aria-labelledby="ModalCenterTitle" aria-hidden="true"> <div class="modal fade" id="historytebusModal" tabindex="-1" role="dialog" aria-labelledby="ModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document"> <!-- <div class="modal-dialog modal-dialog-centered modal-lg" role="document"> -->
<div class="modal-dialog modal-dialog-centered modal-xl" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
{{-- <h5 class="modal-title" id="ModalTitle">Rekod Tebus</h5> --}} {{-- <h5 class="modal-title" id="ModalTitle">Rekod Tebus</h5> --}}
@@ -41,8 +47,11 @@
<thead class="thead-dark"> <thead class="thead-dark">
<tr> <tr>
<th>Bil</th> <th>Bil</th>
<th>Norujukan</th>
<th>Tarikh Bayaran</th> <th>Tarikh Bayaran</th>
<th>Bayaran</th> <th>Pembiayaan</th>
<th>Keuntungan</th>
<th>Jumlah Bayaran</th>
<th>Jenis Bayaran</th> <th>Jenis Bayaran</th>
<th>Tindakan</th> <th>Tindakan</th>
</tr> </tr>
@@ -74,7 +83,9 @@
<th>Bil</th> <th>Bil</th>
<th>No Rujukan</th> <th>No Rujukan</th>
<th>Jenis Penyelesaian<br>Pembiayaan</th> <th>Jenis Penyelesaian<br>Pembiayaan</th>
<th>Pembiayaan Asal</th> <th>Bayaran Pembiayaan</th>
<th>Keuntungan</th>
<th>Jumlah Penyelesaian<br>Pembiayaan</th>
<th>JBG</th> <th>JBG</th>
<th>Tarikh Penyelesaian<br>Pembiayaan</th> <th>Tarikh Penyelesaian<br>Pembiayaan</th>
<th>Tindakan</th> <th>Tindakan</th>