update foc and void for authorized

This commit is contained in:
Aung Myo
2017-11-27 13:54:21 +06:30
parent 87a27250b7
commit 20d580b2ab
2 changed files with 42 additions and 23 deletions

View File

@@ -276,8 +276,8 @@
<i class="material-icons">reply</i>
Back
</button>
<button type="button" class="btn bg-deep-purple btn-block" id="foc"> FOC </button>
<button type="button" class="btn bg-red btn-block" id="void"> Void </button>
<button type="button" class="btn bg-deep-purple btn-block" id="foc" active="<%= can? :foc, :payment %>"> FOC </button>
<button type="button" class="btn bg-red btn-block" id="void" active="<%= can? :overall_void, :void %>"> Void </button>
<!-- Waiter Buttons -->
</div>
@@ -431,20 +431,25 @@
});
$('#void').on('click',function () {
swal({
title: "Information!",
text: 'Are you sure want to Void !',
}, function () {
var sale_id = $('#sale_id').text();
var ajax_url = "/origami/sale/" + sale_id + '/void';
$.ajax({
type: 'POST',
url: ajax_url,
success: function () {
window.location.href = '/origami/';
}
})
});
if ($(this).attr('active') === "true") {
swal({
title: "Information!",
text: 'Are you sure want to Void !',
}, function () {
var sale_id = $('#sale_id').text();
var ajax_url = "/origami/sale/" + sale_id + '/void';
$.ajax({
type: 'POST',
url: ajax_url,
success: function () {
window.location.href = '/origami/';
}
})
});
}else{
swal("Opps","You are not authorized for void","warning")
}
});
});
@@ -463,19 +468,21 @@
}
$('#foc').click(function() {
$( "#loading_wrapper" ).show();
//$( "#loading_wrapper" ).show();
// payment
var cash = $('#amount_due').text();
var sub_total = $('#sub-total').text();
var sale_id = $('#sale_id').text();
var params = { 'cash':cash,'sale_id':sale_id,'sub_total':sub_total };
$.ajax({type: "POST",
if ($(this).attr('active')=== "true") {
$.ajax({
type: "POST",
url: "<%= origami_payment_foc_path %>",
data: params,
success:function(result){
$( "#loading_wrapper" ).hide();
//$( "#loading_wrapper" ).hide();
if (cash > 0) {
swal({
@@ -488,6 +495,9 @@
}
});
}else{
swal("Opps","You are not authorized for foc","warning")
}
});
function calculate_member_discount(sale_id) {