From 4dfabc907d7fcbfbe1626b3d70e494f99ea894d9 Mon Sep 17 00:00:00 2001 From: Hafifie PKB Date: Sun, 7 Jan 2024 11:45:56 +0800 Subject: [PATCH] fix rekod gadaian ps dan tebus --- resources/views/customers/v2/info.blade.php | 37 +++++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/resources/views/customers/v2/info.blade.php b/resources/views/customers/v2/info.blade.php index 77fe051..289697a 100644 --- a/resources/views/customers/v2/info.blade.php +++ b/resources/views/customers/v2/info.blade.php @@ -561,6 +561,26 @@ }) } + async function checkPS(norujukan){ + + let gadai_tawarruq = fetch(api_url + '/api/gadai/norujukan/' + norujukan ); + + return response = await gadai_tawarruq + .then(response => response.json()) + .then(response => response[0][0]) + .then(gadaian => { + return gadaian.historygadaian; + }) + .then(historygadaian => { + + if(historygadaian === '0' || historygadaian === null || historygadaian.length === 0) { + return false; + } + + return true; + }) + } + function checkserah(data){ var urlpenebusan = $(data).data("url"); var norujukan = $(data).data("norujukan"); @@ -1228,7 +1248,7 @@ }); }); - function histfunc(){ + async function histfunc(){ if($("input[name='options']:checked").val() == 'belum_tebus'){ let histid = $('input[name="belum"]:checked').val(); if(histid == null){ @@ -1248,6 +1268,7 @@ } }); + let checkps = await checkPS(histid); $.ajax({ method:'get', url:'{{ route("gadai.history") }}', @@ -1255,12 +1276,12 @@ success:function(data) { - historytebustable(data); + historytebustable(data,checkps); $.ajax({ method: 'get', url: api_url + '/api/transaction/' + histid, success: function(data){ - historybayarantable(data); + historybayarantable(data,checkps); $.ajax({ method:'get', @@ -1309,12 +1330,14 @@ } }); + let checkps = await checkPS(histid); + $.ajax({ method:'get', url:'{{ route("gadai.history") }}', data:{ "norujukan" : histid}, success:function(data){ - historytebustable(data); + historytebustable(data,checkps); $.ajax({ method: 'get', @@ -1397,7 +1420,7 @@ "ordering": false }); - function historytebustable(data){ + function historytebustable(data,checkps = false){ var counter = 1; historytebusbayaran.clear().draw(); @@ -1418,7 +1441,7 @@ }else{ - if(tebusaz['historygadaian'] != '' || tebusaz['historygadaian'] != 0 || tebusaz['historygadaian'] != null){ + if(checkps){ var urlroute = '{{ route("resit.autotawarruq", ":id") }}'; urlroute = urlroute.replace(':id', tebusaz['norujukan']); }else{ @@ -1447,7 +1470,7 @@ historytebusbayaran.row.add([ counter, tebusaz['norujukan'], - (tebusaz['historygadaian'] != '' || tebusaz['historygadaian'] != 0 || tebusaz['historygadaian'] != null) ? 'PS' : tebusaz['jenistebus'], + (checkps) ? 'PS' : tebusaz['jenistebus'], tebusaz['pinjaman'], tebusaz['jbg'], tebusaz['t_tebus'],