fix minus addorder.js and void and other origami

This commit is contained in:
Yan
2017-11-26 22:23:37 +06:30
parent 6eb3d9399e
commit 87a27250b7
7 changed files with 111 additions and 99 deletions

View File

@@ -359,95 +359,94 @@
});
$( document ).ready(function() {
// Disable click event cash to prevent
$(".payment .cash-color").off('click');
// Disable click event cash to prevent
$(".payment .cash-color").off('click');
$('#credit_payment').click(function() {
var sale_id = $('#sale_id').text();
window.location.href = '/origami/sale/'+ sale_id + "/payment/credit_payment"
return false;
});
$('#card_payment').click(function() {
localStorage.setItem("cash",$('#cash').text() );
var sale_id = $('#sale_id').text();
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment"
return false;
});
$('#pay').click(function() {
$('#pay').text("Processing, Please wait!")
$( "#loading_wrapper" ).show();
if($('#balance').text() > 0){
swal ( "Oops" , "Insufficient Amount!" , "error" );
$( "#loading_wrapper" ).hide();
}else{
var sale_id = $('#sale_id').text();
var item_row = $('.is_card');
if (item_row.length < 1) {
calculate_member_discount(sale_id);
}
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
$.ajax({type: "POST",
url: "<%= origami_payment_cash_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id,
async: false,
success:function(result){
localStorage.removeItem("cash");
if (result.status) {
var msg = result.message;
}
else{
var msg = '';
}
$( "#loading_wrapper" ).hide();
if($('#balance').text() < 0){
swal({
title: "Information!",
text: 'Changed amount ' + $('#balance').text() * (-1),
}, function () {
window.location.href = '/origami';
});
}else{
$('#pay').text("Pay");
swal({
title: "Information!",
text: 'Thank You !',
}, function () {
window.location.href = '/origami';
});
}
}
});
}
$('#credit_payment').click(function() {
var sale_id = $('#sale_id').text();
window.location.href = '/origami/sale/'+ sale_id + "/payment/credit_payment"
return false;
});
$('#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/';
}
})
});
});
$('#card_payment').click(function() {
localStorage.setItem("cash",$('#cash').text() );
var sale_id = $('#sale_id').text();
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment"
return false;
});
});
$('#pay').click(function() {
$('#pay').text("Processing, Please wait!")
$( "#loading_wrapper" ).show();
if($('#balance').text() > 0){
swal ( "Oops" , "Insufficient Amount!" , "error" );
$( "#loading_wrapper" ).hide();
}else{
var sale_id = $('#sale_id').text();
var item_row = $('.is_card');
if (item_row.length < 1) {
calculate_member_discount(sale_id);
}
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
$.ajax({type: "POST",
url: "<%= origami_payment_cash_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id,
async: false,
success:function(result){
localStorage.removeItem("cash");
if (result.status) {
var msg = result.message;
}
else{
var msg = '';
}
$( "#loading_wrapper" ).hide();
if($('#balance').text() < 0){
swal({
title: "Information!",
text: 'Changed amount ' + $('#balance').text() * (-1),
}, function () {
window.location.href = '/origami';
});
}else{
$('#pay').text("Pay");
swal({
title: "Information!",
text: 'Thank You !',
}, function () {
window.location.href = '/origami';
});
}
}
});
}
});
$('#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/';
}
})
});
});
});
function update_balance(){
var cash = $('#cash').text();