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();
$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 = [];
while($history != "0" && $history != '' || $dahtebus == 'T')
{
if($history != "0" && $history != '')
{
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $history)->json();
$tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/listpenebusanhistory/'. $gadai[0][0]['kodcaw'],[
"norujukan" => $history
])->json();
if (sizeof($gadai) > 0) {
$history = $gadai[0][0]['historygadaian'];
$dahtebus = $gadai[0][0]['sttebus'];
$kodcaw = $gadai[0][0]['kodcaw'];
// Kalau belum ada history, ambil rekod asal sahaja
if ($dahtebus == 'T') {
$tebusList = Http::withOptions(['verify' => config('app.api_verify')])
->get(config('api.url') . '/api/listpenebusanhistory/' . $kodcaw, [
'norujukan' => $norujukan
])
->json();
if(sizeof($gadai) > 0)
{
if($history == $gadai[0][0]['historygadaian'])
$history = 0;
else{
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)]);
$history = $gadai[0][0]['historygadaian'];
$tebus = collect($tebusList)->firstWhere('norujukan', $norujukan);
$arrayhist[] = [
"tagbaru" => $gadai[0][0]['tagbaru'] ?? 0,
"hargajualan" => $gadai[0][0]['hargajualan'] ?? '',
"pinjaman" => $tebus['pinjaman'] ?? 0,
"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({
method:'get',
url:'{{ route("arcc.history") }}',
url: '{{ route("arcc.history", ":kodcaw") }}'.replace(':kodcaw', kodcaw),
data:{ "norujukan" : histid},
success:function(data){
historytebustable(data);
historytebustable(data,histid);
$.ajax({
method: 'get',
@@ -1386,7 +1386,10 @@
urlroute = urlroute.replace(':id', bayaran['id']);
historybayarandatatable.row.add([
counter,
bayaran['norujukan'],
bayaran['created_at'],
"RM " + bayaran['bayaran_pembiayaan'],
"RM " + bayaran['bayaran_keuntungan'],
"RM " + bayaran['duit_masuk'],
bayaranteller,
bayaran['trans_type'],
@@ -1400,54 +1403,54 @@
"ordering": false
});
function historytebustable(data){
function historytebustable(data, histid)
{
console.log("Full data returned tebus:", histid); // Debug
var counter = 1;
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']) {
case 'P':
var urlroute = '{{ route("resit.tambahpinjam", ":id") }}';
urlroute = urlroute.replace(':id', tebusaz['norujukan']);
urlroute = '{{ route("resit.tambahpinjam", ":id") }}'.replace(':id', tebusaz['norujukan']);
break;
case 'T':
if(tebusaz['hargajualan'] === '')
{
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']);
}
urlroute = (tebusaz['hargajualan'] === '')
? '{{ route("resit.belumtebus", ":id") }}'.replace(':id', tebusaz['norujukan'])
: '{{ route("resit.tebus", ":id") }}'.replace(':id', tebusaz['norujukan']);
break;
case 'A':
var urlroute = '{{ route("resit.belumansurans", ":id") }}';
urlroute = urlroute.replace(':id', tebusaz['norujukan']);
urlroute = '{{ route("resit.belumansurans", ":id") }}'.replace(':id', tebusaz['norujukan']);
break;
case 'S':
var urlroute = '{{ route("resit.tebusseparuh", ":id") }}';
urlroute = urlroute.replace(':id', tebusaz['norujukan']);
break;
}
urlroute = '{{ route("resit.tebusseparuh", ":id") }}'.replace(':id', tebusaz['id']);
break;
}
historytebusbayaran.row.add([
counter,
tebusaz['norujukan'],
tebusaz['jenistebus'],
tebusaz['pinjaman'],
histid,
tebusaz['trans_type'],
"RM " + tebusaz['bayaran_pembiayaan'],
"RM " + tebusaz['bayaran_keuntungan'],
"RM " + tebusaz['duit_masuk'],
tebusaz['jbg'],
tebusaz['t_tebus'],
''
]).draw();
counter = counter + 1;
counter++;
});
}
function daftarwakil()
{
let nopelanggan = $('#nopelangganwakil').val();
+14 -3
View File
@@ -1,6 +1,12 @@
<style>
.modal-custom-size {
max-width: 95%; /* atau 100% */
}
</style>
<!-- Modal HistoryBayaran -->
<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-header">
{{-- <h5 class="modal-title" id="ModalTitle">Rekod Tebus</h5> --}}
@@ -41,8 +47,11 @@
<thead class="thead-dark">
<tr>
<th>Bil</th>
<th>Norujukan</th>
<th>Tarikh Bayaran</th>
<th>Bayaran</th>
<th>Pembiayaan</th>
<th>Keuntungan</th>
<th>Jumlah Bayaran</th>
<th>Jenis Bayaran</th>
<th>Tindakan</th>
</tr>
@@ -74,7 +83,9 @@
<th>Bil</th>
<th>No Rujukan</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>Tarikh Penyelesaian<br>Pembiayaan</th>
<th>Tindakan</th>