limit 10 marhun

This commit is contained in:
afiq
2021-02-10 09:41:33 +08:00
parent 369ba4b22f
commit 7f082e1185
2 changed files with 252 additions and 156 deletions
+82 -3
View File
@@ -538,6 +538,34 @@
$('#daftar_marhun').modal('hide'); $('#daftar_marhun').modal('hide');
} }
else{ else{
if(marhun == null){
Swal.fire({
icon: 'error',
title: 'Amaran!',
text: 'Sila Pilih Marhun'
});
event.preventDefault();
return false;
}else{
if(karat == null){
Swal.fire({
icon: 'error',
title: 'Amaran!',
text: 'Sila Pilih Karat'
});
event.preventDefault();
return false;
}else{
if($.isNumeric(berat_emas) == false){
Swal.fire({
icon: 'error',
title: 'Amaran!',
text: 'Sila Masukkan Berat Marhun'
});
event.preventDefault();
return false;
}else{
if(jumlah_marhun<10){
$.ajax({ $.ajax({
method:'POST', method:'POST',
url: api_url + '/api/marhun/'+kodcaw, url: api_url + '/api/marhun/'+kodcaw,
@@ -551,7 +579,7 @@
'harga' : harga, 'harga' : harga,
'nilai_marhun' : nilai_marhun 'nilai_marhun' : nilai_marhun
}, },
success:function(successdata){ success:function(data){
Swal.fire({ Swal.fire({
icon: 'success', icon: 'success',
title: 'Berjaya!', title: 'Berjaya!',
@@ -563,13 +591,13 @@
$('#berat_emas').val(""); $('#berat_emas').val("");
$('#harga').val(""); $('#harga').val("");
$('#nilai_marhun').val(""); $('#nilai_marhun').val("");
$('#daftar_marhun').modal('hide');
jumlah_marhun += 1; jumlah_marhun += 1;
jumlah_nilai_marhun += Number(nilai_marhun); jumlah_nilai_marhun += Number(nilai_marhun);
$('#bilangan_marhun').val(formatter.format(jumlah_marhun)); $('#bilangan_marhun').val(formatter.format(jumlah_marhun));
$('#jumlah_nilai_marhun').val(formatter.format(jumlah_nilai_marhun)); $('#jumlah_nilai_marhun').val(formatter.format(jumlah_nilai_marhun));
getMarhun(norujukan); getMarhun(norujukan);
$('#daftar_marhun').modal('hide');
}, },
error: function(xhRequest, ErrorText, thrownError){ error: function(xhRequest, ErrorText, thrownError){
Swal.fire({ Swal.fire({
@@ -580,6 +608,17 @@
console.log(xhRequest); console.log(xhRequest);
} }
}); });
}else{
Swal.fire({
icon: 'error',
title: 'Amaran!',
text: 'Hanya 10 Marhun dibenarkan dalam 1 SAG'
});
$('#daftar_marhun').modal('hide');
}
}
}
}
} }
}); });
@@ -593,12 +632,41 @@
var nilaimarhun = $('#nilai_marhun').val(); var nilaimarhun = $('#nilai_marhun').val();
var nilai_marhun = Number(nilaimarhun.replace(/[^0-9.-]+/g,"")); var nilai_marhun = Number(nilaimarhun.replace(/[^0-9.-]+/g,""));
var nota_array = $('#nota').val(); var nota_array = $('#nota').val();
console.log($.isNumeric(berat_emas));
if(nota_array != null){ if(nota_array != null){
var nota = nota_array.toString(); var nota = nota_array.toString();
}else{ }else{
var nota = ''; var nota = '';
} }
if(marhun == null){
Swal.fire({
icon: 'error',
title: 'Amaran!',
text: 'Sila Pilih Marhun'
});
event.preventDefault();
return false;
}else{
if(karat == null){
Swal.fire({
icon: 'error',
title: 'Amaran!',
text: 'Sila Pilih Karat'
});
event.preventDefault();
return false;
}else{
if($.isNumeric(berat_emas) == false){
Swal.fire({
icon: 'error',
title: 'Amaran!',
text: 'Sila Masukkan Berat Marhun'
});
event.preventDefault();
return false;
}else{
if(jumlah_marhun < 10){
$.ajax({ $.ajax({
method:'POST', method:'POST',
url: api_url + '/api/marhun/'+kodcaw, url: api_url + '/api/marhun/'+kodcaw,
@@ -640,7 +708,18 @@
console.log(xhRequest); console.log(xhRequest);
} }
}); });
}) }else{
Swal.fire({
icon: 'error',
title: 'Amaran!',
text: 'Hanya 10 Marhun dibenarkan dalam 1 SAG'
});
}
}
}
}
});
function verifyGadai(func){ function verifyGadai(func){
var kodcaw = $('#kodcaw').val(); var kodcaw = $('#kodcaw').val();
+17
View File
@@ -460,6 +460,7 @@
event.preventDefault(); event.preventDefault();
return false; return false;
}else{ }else{
if(jumlah_marhun<10){
$.ajax({ $.ajax({
method:'POST', method:'POST',
url: api_url + '/api/marhun/'+kodcaw, url: api_url + '/api/marhun/'+kodcaw,
@@ -502,6 +503,14 @@
console.log(xhRequest); console.log(xhRequest);
} }
}); });
}else{
Swal.fire({
icon: 'error',
title: 'Amaran!',
text: 'Hanya 10 Marhun dibenarkan dalam 1 SAG'
});
$('#daftar_marhun').modal('hide');
}
} }
} }
} }
@@ -552,6 +561,7 @@
event.preventDefault(); event.preventDefault();
return false; return false;
}else{ }else{
if(jumlah_marhun < 10){
$.ajax({ $.ajax({
method:'POST', method:'POST',
url: api_url + '/api/marhun/'+kodcaw, url: api_url + '/api/marhun/'+kodcaw,
@@ -593,6 +603,13 @@
console.log(xhRequest); console.log(xhRequest);
} }
}); });
}else{
Swal.fire({
icon: 'error',
title: 'Amaran!',
text: 'Hanya 10 Marhun dibenarkan dalam 1 SAG'
});
}
} }
} }
} }