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){
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'],