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

@@ -21,6 +21,7 @@
<div class="card" style="margin-top:10px;padding:20px;">
<div class="card-block">
<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>
@@ -30,7 +31,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>
@@ -123,26 +124,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_mpu %>") - parseFloat(localStorage.getItem("cash")));
}
if(typeof code2lab != 'undefined'){
code2lab.getCommPorts(); //get comportlists from jade
}else{
swal({
title: 'Oops',
text: 'MPU 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: 'MPU 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";
});
}
}
});
@@ -194,6 +197,7 @@
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
@@ -210,7 +214,28 @@
// });
// }
//end member discount
pay_withBank("SALE", "mpu", amount, sale_id, receipt_no);
if(bank_integration == '1'){
pay_withBank("SALE", "mpu", amount, sale_id, receipt_no);
}else{
$.ajax({type: "POST",
url: "<%= origami_payment_mpu_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) {