fix rekod gadaian ps dan tebus

This commit is contained in:
Hafifie PKB
2024-01-07 11:45:56 +08:00
parent d77b3a7346
commit 4dfabc907d
+30 -7
View File
@@ -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){ function checkserah(data){
var urlpenebusan = $(data).data("url"); var urlpenebusan = $(data).data("url");
var norujukan = $(data).data("norujukan"); var norujukan = $(data).data("norujukan");
@@ -1228,7 +1248,7 @@
}); });
}); });
function histfunc(){ async function histfunc(){
if($("input[name='options']:checked").val() == 'belum_tebus'){ if($("input[name='options']:checked").val() == 'belum_tebus'){
let histid = $('input[name="belum"]:checked').val(); let histid = $('input[name="belum"]:checked').val();
if(histid == null){ if(histid == null){
@@ -1248,6 +1268,7 @@
} }
}); });
let checkps = await checkPS(histid);
$.ajax({ $.ajax({
method:'get', method:'get',
url:'{{ route("gadai.history") }}', url:'{{ route("gadai.history") }}',
@@ -1255,12 +1276,12 @@
success:function(data) success:function(data)
{ {
historytebustable(data); historytebustable(data,checkps);
$.ajax({ $.ajax({
method: 'get', method: 'get',
url: api_url + '/api/transaction/' + histid, url: api_url + '/api/transaction/' + histid,
success: function(data){ success: function(data){
historybayarantable(data); historybayarantable(data,checkps);
$.ajax({ $.ajax({
method:'get', method:'get',
@@ -1309,12 +1330,14 @@
} }
}); });
let checkps = await checkPS(histid);
$.ajax({ $.ajax({
method:'get', method:'get',
url:'{{ route("gadai.history") }}', url:'{{ route("gadai.history") }}',
data:{ "norujukan" : histid}, data:{ "norujukan" : histid},
success:function(data){ success:function(data){
historytebustable(data); historytebustable(data,checkps);
$.ajax({ $.ajax({
method: 'get', method: 'get',
@@ -1397,7 +1420,7 @@
"ordering": false "ordering": false
}); });
function historytebustable(data){ function historytebustable(data,checkps = false){
var counter = 1; var counter = 1;
historytebusbayaran.clear().draw(); historytebusbayaran.clear().draw();
@@ -1418,7 +1441,7 @@
}else{ }else{
if(tebusaz['historygadaian'] != '' || tebusaz['historygadaian'] != 0 || tebusaz['historygadaian'] != null){ if(checkps){
var urlroute = '{{ route("resit.autotawarruq", ":id") }}'; var urlroute = '{{ route("resit.autotawarruq", ":id") }}';
urlroute = urlroute.replace(':id', tebusaz['norujukan']); urlroute = urlroute.replace(':id', tebusaz['norujukan']);
}else{ }else{
@@ -1447,7 +1470,7 @@
historytebusbayaran.row.add([ historytebusbayaran.row.add([
counter, counter,
tebusaz['norujukan'], tebusaz['norujukan'],
(tebusaz['historygadaian'] != '' || tebusaz['historygadaian'] != 0 || tebusaz['historygadaian'] != null) ? 'PS' : tebusaz['jenistebus'], (checkps) ? 'PS' : tebusaz['jenistebus'],
tebusaz['pinjaman'], tebusaz['pinjaman'],
tebusaz['jbg'], tebusaz['jbg'],
tebusaz['t_tebus'], tebusaz['t_tebus'],