Validate required for reference no: in other payment amount

This commit is contained in:
San Wai Lwin
2018-02-22 16:43:53 +06:30
parent c3af21d71c
commit ce644e304c
5 changed files with 257 additions and 218 deletions

View File

@@ -51,7 +51,8 @@
<div class="row"> <div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12"> <div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>Reference Number</label> <label>Reference Number</label>
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value=""> <input type="text" name="reference_no" id="reference_no" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
<br><span id="reference_no_Err" style="color:red;"></span>
</div> </div>
<hr> <hr>
</div> </div>
@@ -194,53 +195,60 @@ $(document).on('click', '.cashier_number', function(event){
$('#jcb_pay').on('click',function(){ $('#jcb_pay').on('click',function(){
var amount = $('#amount').text(); var amount = $('#amount').text();
var reference_no = $('#reference_no').val();
var sale_id = "<%= @sale_id %>"; var sale_id = "<%= @sale_id %>";
var receipt_no = "<%= @receipt_no %>"; var receipt_no = "<%= @receipt_no %>";
var bank_integration = "<%= @bank_integration %>"; var bank_integration = "<%= @bank_integration %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){ $("#reference_no_Err").html("");
$(this).off("click"); if(reference_no.length > 0){
//start member discount 5% by pay card if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
// var sub_total = $('#sub-total').text(); $(this).off("click");
// var member_id = $('#membership_id').text(); //start member discount 5% by pay card
// var member_discount = $('#member_discount').text(); // var sub_total = $('#sub-total').text();
// if (member_id && member_discount) { // var member_id = $('#membership_id').text();
// $.ajax({ // var member_discount = $('#member_discount').text();
// type: "POST", // if (member_id && member_discount) {
// url: "/origami/" + sale_id + "/member_discount", // $.ajax({
// data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true }, // type: "POST",
// success:function(result){ // url: "/origami/" + sale_id + "/member_discount",
// } // data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// }); // success:function(result){
// } // }
//end member discount // });
if(bank_integration == '1'){ // }
pay_withBank("SALE", "jcb", amount, sale_id, receipt_no); //end member discount
if(bank_integration == '1'){
$("#reference_no").val("");
pay_withBank("SALE", "jcb", amount, sale_id, receipt_no);
}else{
$.ajax({type: "POST",
url: "<%= origami_payment_jcb_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
swal({
title: "Information!",
text: "Payment Successfully",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment";
});
}
}
});
}
}else{ }else{
$.ajax({type: "POST", if (amount>0) {
url: "<%= origami_payment_jcb_path %>", swal ( "Oops" , "Paid Amount is over!" , "error" );
data: "amount="+ amount + "&sale_id="+ sale_id, }else{
success:function(result){ swal ( "Oops" , "Enter Amount!" , "error" );
if(result){ }
swal({
title: "Information!",
text: "Payment Successfully",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment";
});
}
}
});
} }
}else{ }else{
if (amount>0) { $("#reference_no_Err").html("can't be blank");
swal ( "Oops" , "Paid Amount is over!" , "error" );
}else{
swal ( "Oops" , "Enter Amount!" , "error" );
}
} }
}) })
</script> </script>

View File

@@ -52,7 +52,8 @@
<div class="row"> <div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12"> <div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>Reference Number</label> <label>Reference Number</label>
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value=""> <input type="text" name="reference_no" id="reference_no" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
<br><span id="reference_no_Err" style="color:red;"></span>
</div> </div>
<hr> <hr>
</div> </div>
@@ -192,53 +193,60 @@
}); });
$('#master_pay').on('click',function(){ $('#master_pay').on('click',function(){
var amount = $('#amount').text(); var amount = $('#amount').text();
var reference_no = $('#reference_no').val();
var sale_id = "<%= @sale_id %>"; var sale_id = "<%= @sale_id %>";
var receipt_no = "<%= @receipt_no %>"; var receipt_no = "<%= @receipt_no %>";
var bank_integration = "<%= @bank_integration %>"; var bank_integration = "<%= @bank_integration %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){ $("#reference_no_Err").html("");
$(this).off("click"); if(reference_no.length > 0){
//start member discount 5% by pay card if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
// var sub_total = $('#sub-total').text(); $(this).off("click");
// var member_id = $('#membership_id').text(); //start member discount 5% by pay card
// var member_discount = $('#member_discount').text(); // var sub_total = $('#sub-total').text();
// if (member_id && member_discount) { // var member_id = $('#membership_id').text();
// $.ajax({ // var member_discount = $('#member_discount').text();
// type: "POST", // if (member_id && member_discount) {
// url: "/origami/" + sale_id + "/member_discount", // $.ajax({
// data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true }, // type: "POST",
// // success:function(result){ // url: "/origami/" + sale_id + "/member_discount",
// // } // data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// }); // // success:function(result){
// } // // }
//end member discount // });
if(bank_integration == '1'){ // }
pay_withBank("SALE", "master", amount, sale_id, receipt_no); //end member discount
}else{ if(bank_integration == '1'){
$.ajax({type: "POST", $("#reference_no").val("");
url: "<%= origami_payment_master_path %>", pay_withBank("SALE", "master", amount, sale_id, receipt_no);
data: "amount="+ amount + "&sale_id="+ sale_id, }else{
success:function(result){ $.ajax({type: "POST",
if(result){ url: "<%= origami_payment_master_path %>",
swal({ data: "amount="+ amount + "&sale_id="+ sale_id,
title: "Information!", success:function(result){
text: "Payment Successfully", if(result){
html: true, swal({
closeOnConfirm: false, title: "Information!",
closeOnCancel: false, text: "Payment Successfully",
allowOutsideClick: false html: true,
}, function () { closeOnConfirm: false,
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"; closeOnCancel: false,
}); allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment";
});
}
} }
} });
}); }
}else{
if (amount>0) {
swal ( "Oops" , "Paid Amount is over!" , "error" );
}else{
swal ( "Oops" , "Enter Amount!" , "error" );
}
} }
}else{ }else{
if (amount>0) { $("#reference_no_Err").html("can't be blank");
swal ( "Oops" , "Paid Amount is over!" , "error" );
}else{
swal ( "Oops" , "Enter Amount!" , "error" );
}
} }
}) })
</script> </script>

View File

@@ -52,7 +52,8 @@
<div class="row"> <div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12"> <div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>Reference Number</label> <label>Reference Number</label>
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value=""> <input type="text" name="reference_no" id="reference_no" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
<br><span id="reference_no_Err" style="color:red;"></span>
</div> </div>
<hr> <hr>
</div> </div>
@@ -196,56 +197,62 @@
$('#mpu_pay').on('click',function(){ $('#mpu_pay').on('click',function(){
var amount = $('#amount').text(); var amount = $('#amount').text();
var reference_no = $('#reference_no').val();
var sale_id = "<%= @sale_id %>"; var sale_id = "<%= @sale_id %>";
var receipt_no = "<%= @receipt_no %>"; var receipt_no = "<%= @receipt_no %>";
var bank_integration = "<%= @bank_integration %>"; var bank_integration = "<%= @bank_integration %>";
var cashier_type = "<%= @cashier_type %>"; var cashier_type = "<%= @cashier_type %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){ $("#reference_no_Err").html("");
$(this).off("click"); if(reference_no.length > 0){
//start member discount 5% by pay card if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
// var sub_total = $('#sub-total').text(); $(this).off("click");
// var member_id = $('#membership_id').text(); //start member discount 5% by pay card
// var member_discount = $('#member_discount').text(); // var sub_total = $('#sub-total').text();
// if (member_id && member_discount) { // var member_id = $('#membership_id').text();
// $.ajax({ // var member_discount = $('#member_discount').text();
// type: "POST", // if (member_id && member_discount) {
// url: "/origami/" + sale_id + "/member_discount", // $.ajax({
// data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true }, // type: "POST",
// success:function(result){ // url: "/origami/" + sale_id + "/member_discount",
// } // data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// }); // success:function(result){
// } // }
//end member discount // });
if(bank_integration == '1'){ // }
pay_withBank("SALE", "mpu", amount, sale_id, receipt_no); //end member discount
}else{ if(bank_integration == '1'){
$.ajax({type: "POST", $("#reference_no").val("");
url: "<%= origami_payment_mpu_path %>", pay_withBank("SALE", "mpu", amount, sale_id, receipt_no);
data: "amount="+ amount + "&sale_id="+ sale_id, }else{
success:function(result){ $.ajax({type: "POST",
if(result){ url: "<%= origami_payment_mpu_path %>",
swal({ data: "amount="+ amount + "&sale_id="+ sale_id,
title: "Information!", success:function(result){
text: "Payment Successfully", if(result){
html: true, swal({
closeOnConfirm: false, title: "Information!",
closeOnCancel: false, text: "Payment Successfully",
allowOutsideClick: false html: true,
}, function () { closeOnConfirm: false,
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/payment"; closeOnCancel: false,
}); allowOutsideClick: false
} }, function () {
} window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/payment";
}); });
} }
}
}else{ });
if (amount>0) { }
swal ( "Oops" , "Paid Amount is over!" , "error" );
}else{ }else{
swal ( "Oops" , "Enter Amount!" , "error" ); if (amount>0) {
swal ( "Oops" , "Paid Amount is over!" , "error" );
}else{
swal ( "Oops" , "Enter Amount!" , "error" );
}
} }
} }else{
}) $("#reference_no_Err").html("can't be blank");
}
})
</script> </script>

View File

@@ -52,7 +52,8 @@
<div class="row"> <div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12"> <div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>Reference Number</label> <label>Reference Number</label>
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value=""> <input type="text" name="reference_no" id="reference_no" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
<br><span id="reference_no_Err" style="color:red;"></span>
</div> </div>
<hr> <hr>
</div> </div>
@@ -196,54 +197,61 @@
}); });
$('#unionpay_pay').on('click',function(){ $('#unionpay_pay').on('click',function(){
var amount = $('#amount').text(); var amount = $('#amount').text();
var reference_no = $('#reference_no').val();
var sale_id = "<%= @sale_id %>"; var sale_id = "<%= @sale_id %>";
var receipt_no = "<%= @receipt_no %>"; var receipt_no = "<%= @receipt_no %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){ $("#reference_no_Err").html("");
$(this).off("click"); if(reference_no.length > 0){
//start member discount 5% by pay card if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
// var sub_total = $('#sub-total').text(); $(this).off("click");
// var member_id = $('#membership_id').text(); //start member discount 5% by pay card
// var member_discount = $('#member_discount').text(); // var sub_total = $('#sub-total').text();
// if (member_id && member_discount) { // var member_id = $('#membership_id').text();
// $.ajax({ // var member_discount = $('#member_discount').text();
// type: "POST", // if (member_id && member_discount) {
// url: "/origami/" + sale_id + "/member_discount", // $.ajax({
// data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true }, // type: "POST",
// success:function(result){ // url: "/origami/" + sale_id + "/member_discount",
// } // data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// }); // success:function(result){
// } // }
//end member discount // });
var bank_integration = "<%= @bank_integration %>"; // }
if(bank_integration == '1'){ //end member discount
pay_withBank("SALE", "unionpay", amount, sale_id, receipt_no); var bank_integration = "<%= @bank_integration %>";
} if(bank_integration == '1'){
else{ $("#reference_no").val("");
$.ajax({type: "POST", pay_withBank("SALE", "unionpay", amount, sale_id, receipt_no);
url: "<%= origami_payment_unionpay_path %>", }
data: "amount="+ amount + "&sale_id="+ sale_id, else{
success:function(result){ $.ajax({type: "POST",
if(result){ url: "<%= origami_payment_unionpay_path %>",
swal({ data: "amount="+ amount + "&sale_id="+ sale_id,
title: "Information!", success:function(result){
text: "Payment Successfully", if(result){
html: true, swal({
closeOnConfirm: false, title: "Information!",
closeOnCancel: false, text: "Payment Successfully",
allowOutsideClick: false html: true,
}, function () { closeOnConfirm: false,
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"; closeOnCancel: false,
}); allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment";
});
}
} }
} });
}); }
}else{
if (amount>0) {
swal ( "Oops" , "Paid Amount is over!" , "error" );
}else{
swal ( "Oops" , "Enter Amount!" , "error" );
}
} }
}else{ }else{
if (amount>0) { $("#reference_no_Err").html("can't be blank");
swal ( "Oops" , "Paid Amount is over!" , "error" );
}else{
swal ( "Oops" , "Enter Amount!" , "error" );
}
} }
}) })
</script> </script>

View File

@@ -52,7 +52,8 @@
<div class="row"> <div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12"> <div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>Reference Number</label> <label>Reference Number</label>
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value=""> <input type="text" name="reference_no" id="reference_no" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
<br><span id="reference_no_Err" style="color:red;"></span>
</div> </div>
<hr> <hr>
</div> </div>
@@ -195,56 +196,63 @@
}); });
$('#visa_pay').on('click',function(){ $('#visa_pay').on('click',function(){
var amount = $('#amount').text(); var amount = $('#amount').text();
var reference_no = $('#reference_no').val();
var sale_id = "<%= @sale_id %>"; var sale_id = "<%= @sale_id %>";
var receipt_no = "<%= @receipt_no %>"; var receipt_no = "<%= @receipt_no %>";
console.log(amount); console.log(amount);
console.log($("#validamount").attr("value")); console.log($("#validamount").attr("value"));
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){ $("#reference_no_Err").html("");
$(this).off("click"); if(reference_no.length > 0){
//start member discount 5% by pay card if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
// var sub_total = $('#sub-total').text(); $(this).off("click");
// var member_id = $('#membership_id').text(); //start member discount 5% by pay card
// var member_discount = $('#member_discount').text(); // var sub_total = $('#sub-total').text();
// if (member_id && member_discount) { // var member_id = $('#membership_id').text();
// $.ajax({ // var member_discount = $('#member_discount').text();
// type: "POST", // if (member_id && member_discount) {
// url: "/origami/" + sale_id + "/member_discount", // $.ajax({
// data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true }, // type: "POST",
// success:function(result){ // url: "/origami/" + sale_id + "/member_discount",
// } // data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// }); // success:function(result){
// } // }
//end member discount // });
var bank_integration = "<%= @bank_integration %>"; // }
if(bank_integration == '1'){ //end member discount
pay_withBank("SALE", "visa", amount, sale_id, receipt_no); var bank_integration = "<%= @bank_integration %>";
} if(bank_integration == '1'){
else{ $("#reference_no").val("");
$.ajax({type: "POST", pay_withBank("SALE", "visa", amount, sale_id, receipt_no);
url: "<%= origami_payment_visa_path %>", }
data: "amount="+ amount + "&sale_id="+ sale_id, else{
success:function(result){ $.ajax({type: "POST",
if(result){ url: "<%= origami_payment_visa_path %>",
swal({ data: "amount="+ amount + "&sale_id="+ sale_id,
title: "Information!", success:function(result){
text: "Payment Successfully", if(result){
html: true, swal({
closeOnConfirm: false, title: "Information!",
closeOnCancel: false, text: "Payment Successfully",
allowOutsideClick: false html: true,
}, function () { closeOnConfirm: false,
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"; closeOnCancel: false,
}); allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment";
});
}
} }
} });
}); }
}else{
if (amount>0) {
swal ( "Oops" , "Paid Amount is over!" , "error" );
}else{
swal ( "Oops" , "Enter Amount!" , "error" );
}
} }
}else{ }else{
if (amount>0) { $("#reference_no_Err").html("can't be blank");
swal ( "Oops" , "Paid Amount is over!" , "error" );
}else{
swal ( "Oops" , "Enter Amount!" , "error" );
}
} }
}) })
</script> </script>