change process flow for cb with bank_integration in lookups

This commit is contained in:
phyusin
2018-01-10 18:57:14 +06:30
parent 903dddd8cc
commit 58e779862f
8 changed files with 198 additions and 66 deletions

View File

@@ -20,6 +20,7 @@
<span class="hidden" id="sub-total"><%= @sub_total%></span>
<div class="card m-l-10 m-t-10" style="padding:0px 20px;">
<div class="rebate-form">
<% if @bank_integration == '1' %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label for="com_port_name">Select Device</label>
@@ -29,7 +30,7 @@
</div>
<hr>
</div>
<% end %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>You can pay up to </label>
@@ -120,25 +121,28 @@
<script>
$(document).ready(function() {
var sale_id = "<%= @sale_id %>";
var bank_integration = "<%= @bank_integration %>";
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_jcb %>") - parseFloat(localStorage.getItem("cash")));
}
if(typeof code2lab != 'undefined'){
code2lab.getCommPorts(); //get comportlists from jade
}else{
swal({
title: 'Oops',
text: 'JCB is not available in here!',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment";
});
if(bank_integration == '1'){
if(typeof code2lab != 'undefined'){
code2lab.getCommPorts(); //get comportlists from jade
}else{
swal({
title: 'Oops',
text: 'JCB is not available in here!',
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment";
});
}
}
});
// number key pad
@@ -191,6 +195,7 @@ $('#jcb_pay').on('click',function(){
var amount = $('#amount').text();
var sale_id = "<%= @sale_id %>";
var receipt_no = "<%= @receipt_no %>";
var bank_integration = "<%= @bank_integration %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click");
//start member discount 5% by pay card
@@ -207,7 +212,28 @@ $('#jcb_pay').on('click',function(){
// });
// }
//end member discount
pay_withBank("SALE", "jcb", amount, sale_id, receipt_no);
if(bank_integration == '1'){
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 + "/payment";
});
}
}
});
}
}else{
if (amount>0) {
swal ( "Oops" , "Paid Amount is over!" , "error" );