update unsuccessfully rebate and alert

This commit is contained in:
Aung Myo
2017-07-05 14:42:40 +06:30
parent 6ee4d19e99
commit 7cee40746d
3 changed files with 54 additions and 27 deletions

View File

@@ -341,28 +341,58 @@ $( document ).ready(function() {
if($('#balance').text() > 0){
alert(" Insufficient Amount!")
}else{
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
var sale_id = $('#sale_id').text();
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
var sale_id = $('#sale_id').text();
$.ajax({type: "POST",
url: "<%= origami_payment_cash_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id,
success:function(result){
localStorage.removeItem("cash");
if($('#balance').text() < 0){
alert("Changed amount " + $('#balance').text() * (-1) )
}else{
$('#pay').text("Pay")
alert("Thank you")
$.ajax({type: "POST",
url: "<%= origami_payment_cash_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id,
success:function(result){
localStorage.removeItem("cash");
if (result.status) {
var msg = result.message;
}else{
var msg = '';
}
if($('#balance').text() < 0){
$.confirm({
title: 'Hi!',
content: 'Changed amount ' + $('#balance').text() * (-1) + '\n\n' + msg,
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
window.location.href = '/origami';
}
}
}
});
}else{
$('#pay').text("Pay")
$.confirm({
title: 'Hi!',
content: 'Thank you !'+'\n\n'+msg,
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
window.location.href = '/origami';
}
}
}
});
}
}
window.location.href = '/origami';
}
});
}
});
}
});
$('#void').on('click',function () {