add code unable add marhun

This commit is contained in:
nurulnisha
2024-07-02 14:56:29 +08:00
parent bca25ed58d
commit 44f6946836
2 changed files with 181 additions and 80 deletions
+127 -80
View File
@@ -507,47 +507,70 @@
return false; return false;
}else{ }else{
if(bilangan_marhun_daftar<10){ if(bilangan_marhun_daftar<10){
$.ajax({
method:'POST',
url: api_url + '/api/marhun/'+kodcaw,
dataType:'json',
data:{
'norujukan': norujukan,
'marhun' : marhun,
'nota':nota,
'karat' : karat,
'berat_emas' :berat_emas,
'harga' : harga,
'nilai_marhun' : nilai_marhun,
'teller' : "{{ Auth::user()->name }}"
},
success:function(data){
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
$('#nota').val('').trigger("change");
$('#marhun').val(0);
$('#karat').val(0);
$('#berat_emas').val("");
$('#harga').val("");
$('#nilai_marhun').val("");
$('#daftar_marhun').modal('hide');
jumlah_marhun += 1; //new added 190624 filter if gadaian already exist pinjaman not null
jumlah_nilai_marhun += Number(nilai_marhun); $.ajax({
$('#bilangan_marhun').val(formatter.format(jumlah_marhun)); method:'get',
$('#jumlah_nilai_marhun').val(formatter.format(jumlah_nilai_marhun)); url: api_url + '/api/gadai/norujukan/' + kodcaw + '/' + norujukan,
getMarhun(norujukan); success:function(data)
}, {
error: function(xhRequest, ErrorText, thrownError){ var checking = Object.keys(data[0]).length;
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false); if (data[0]['pinjaman'] > 0) {
Swal.fire({ $("#tambah_marhun").prop('disabled', false);
icon: 'error', $("#terima_marhun").prop('disabled', false);
title: 'Amaran!', Swal.fire({
text: 'Tambah Marhun Tidak Berjaya' icon: 'error',
}); title: 'Tidak Berjaya',
console.log(xhRequest); text: 'Maklumat Gadaian Telah Wujud. Sila Tekan Batal.'
} });
event.preventDefault();
return false;
} else {
$.ajax({
method:'POST',
url: api_url + '/api/marhun/'+kodcaw,
dataType:'json',
data:{
'norujukan': norujukan,
'marhun' : marhun,
'nota':nota,
'karat' : karat,
'berat_emas' :berat_emas,
'harga' : harga,
'nilai_marhun' : nilai_marhun,
'teller' : "{{ Auth::user()->name }}"
},
success:function(data){
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
$('#nota').val('').trigger("change");
$('#marhun').val(0);
$('#karat').val(0);
$('#berat_emas').val("");
$('#harga').val("");
$('#nilai_marhun').val("");
$('#daftar_marhun').modal('hide');
jumlah_marhun += 1;
jumlah_nilai_marhun += Number(nilai_marhun);
$('#bilangan_marhun').val(formatter.format(jumlah_marhun));
$('#jumlah_nilai_marhun').val(formatter.format(jumlah_nilai_marhun));
getMarhun(norujukan);
},
error: function(xhRequest, ErrorText, thrownError){
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
Swal.fire({
icon: 'error',
title: 'Amaran!',
text: 'Tambah Marhun Tidak Berjaya'
});
console.log(xhRequest);
}
});
}
}
}); });
}else{ }else{
$("#tambah_marhun").prop('disabled', false); $("#tambah_marhun").prop('disabled', false);
@@ -619,47 +642,71 @@
return false; return false;
}else{ }else{
if(bilangan_marhun_daftar < 10){ if(bilangan_marhun_daftar < 10){
$.ajax({
method:'POST',
url: api_url + '/api/marhun/'+kodcaw,
dataType:'json',
data:{
'norujukan': norujukan,
'marhun' : marhun,
'nota':nota,
'karat' : karat,
'berat_emas' :berat_emas,
'harga' : harga,
'nilai_marhun' : nilai_marhun,
'teller' : "{{ Auth::user()->name }}"
},
success:function(data){
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
$('#nota').val('').trigger("change");
$('#marhun').val(0);
$('#karat').val(0);
$('#berat_emas').val("");
$('#harga').val("");
$('#nilai_marhun').val("");
jumlah_marhun += 1; //new added 190624 filter if gadaian already registered pinjaman > 0
jumlah_nilai_marhun += Number(nilai_marhun); $.ajax({
$('#bilangan_marhun').val(formatter.format(jumlah_marhun)); method:'get',
$('#jumlah_nilai_marhun').val(formatter.format(jumlah_nilai_marhun)); url: api_url + '/api/gadai/norujukan/' + kodcaw + '/' + norujukan,
getMarhun(norujukan); success:function(data)
}, {
error: function(xhRequest, ErrorText, thrownError){ var checking = Object.keys(data[0]).length;
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false); if (data[0]['pinjaman'] > 0) {
Swal.fire({ $("#tambah_marhun").prop('disabled', false);
icon: 'error', $("#terima_marhun").prop('disabled', false);
title: 'Amaran!', Swal.fire({
text: 'Tambah Marhun Tidak Berjaya' icon: 'error',
}); title: 'Tidak Berjaya',
console.log(xhRequest); text: 'Maklumat Gadaian Telah Wujud. Sila Tekan Batal.'
} });
}); event.preventDefault();
return false;
} else {
$.ajax({
method:'POST',
url: api_url + '/api/marhun/'+kodcaw,
dataType:'json',
data:{
'norujukan': norujukan,
'marhun' : marhun,
'nota':nota,
'karat' : karat,
'berat_emas' :berat_emas,
'harga' : harga,
'nilai_marhun' : nilai_marhun,
'teller' : "{{ Auth::user()->name }}"
},
success:function(data){
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
$('#nota').val('').trigger("change");
$('#marhun').val(0);
$('#karat').val(0);
$('#berat_emas').val("");
$('#harga').val("");
$('#nilai_marhun').val("");
jumlah_marhun += 1;
jumlah_nilai_marhun += Number(nilai_marhun);
$('#bilangan_marhun').val(formatter.format(jumlah_marhun));
$('#jumlah_nilai_marhun').val(formatter.format(jumlah_nilai_marhun));
getMarhun(norujukan);
},
error: function(xhRequest, ErrorText, thrownError){
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
Swal.fire({
icon: 'error',
title: 'Amaran!',
text: 'Tambah Marhun Tidak Berjaya'
});
console.log(xhRequest);
}
});
}
}
});
//end new added 190624
}else{ }else{
$("#tambah_marhun").prop('disabled', false); $("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false); $("#terima_marhun").prop('disabled', false);
@@ -723,7 +723,28 @@
} }
if(bilangan_marhun_daftar<10){ if(bilangan_marhun_daftar<10){
//new added 190624 filter if gadaian already exist pinjaman not null
$.ajax({ $.ajax({
method:'get',
url: api_url + '/api/gadai/norujukan/' + kodcaw + '/' + norujukan,
success:function(data)
{
var checking = Object.keys(data[0]).length;
if (data[0]['pinjaman'] > 0) {
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
Swal.fire({
icon: 'error',
title: 'Tidak Berjaya',
text: 'Maklumat Gadaian Telah Wujud. Sila Tekan Batal.'
});
event.preventDefault();
return false;
} else {
$.ajax({
method:'POST', method:'POST',
url: api_url + '/api/marhun/'+kodcaw, url: api_url + '/api/marhun/'+kodcaw,
dataType:'json', dataType:'json',
@@ -776,6 +797,12 @@
console.log(xhRequest); console.log(xhRequest);
} }
}); });
}
}
});
//end new added 190624
}else{ }else{
$("#tambah_marhun").prop('disabled', false); $("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false); $("#terima_marhun").prop('disabled', false);
@@ -871,7 +898,28 @@
} }
if(bilangan_marhun_daftar < 10){ if(bilangan_marhun_daftar < 10){
//new added 190624 filter if gadaian already registered pinjaman > 0
$.ajax({ $.ajax({
method:'get',
url: api_url + '/api/gadai/norujukan/' + kodcaw + '/' + norujukan,
success:function(data)
{
var checking = Object.keys(data[0]).length;
if (data[0]['pinjaman'] > 0) {
$("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false);
Swal.fire({
icon: 'error',
title: 'Tidak Berjaya',
text: 'Maklumat Gadaian Telah Wujud. Sila Tekan Batal.'
});
event.preventDefault();
return false;
} else {
$.ajax({
method:'POST', method:'POST',
url: api_url + '/api/marhun/'+kodcaw, url: api_url + '/api/marhun/'+kodcaw,
dataType:'json', dataType:'json',
@@ -926,6 +974,12 @@
console.log(xhRequest); console.log(xhRequest);
} }
}); });
}
}
});
//end new added 190624
}else{ }else{
$("#tambah_marhun").prop('disabled', false); $("#tambah_marhun").prop('disabled', false);
$("#terima_marhun").prop('disabled', false); $("#terima_marhun").prop('disabled', false);