control to req bill and discount ui update
This commit is contained in:
@@ -352,13 +352,24 @@ $(document).ready(function(){
|
||||
url: ajax_url,
|
||||
data: params,
|
||||
success:function(result){
|
||||
alert("Successfully Discount!");
|
||||
if(result.table_type == "Table"){
|
||||
window.location.href = "/origami/table/" + result.table_id
|
||||
}
|
||||
else {
|
||||
window.location.href = "/origami/room/" + result.table_id
|
||||
}
|
||||
$.confirm({
|
||||
title: 'Infomation!',
|
||||
content: result.status,
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'Ok',
|
||||
btnClass: 'btn-green',
|
||||
action: function(){
|
||||
if(result.table_type == "Table"){
|
||||
window.location.href = "/origami/table/" + result.table_id
|
||||
}
|
||||
else {
|
||||
window.location.href = "/origami/room/" + result.table_id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -372,8 +383,19 @@ $(document).ready(function(){
|
||||
// Selected Items
|
||||
var sale_items = get_selected_sale_items();
|
||||
if(sale_items.length == 0){
|
||||
alert("You have no selected item!");
|
||||
return;
|
||||
$.confirm({
|
||||
title: 'Infomation!',
|
||||
content: "You have no selected item!",
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'Ok',
|
||||
btnClass: 'btn-green',
|
||||
action: function(){
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for(var i=0;i < sale_items.length;i++){
|
||||
@@ -381,8 +403,19 @@ $(document).ready(function(){
|
||||
discount_items.push(sale_items[i]);
|
||||
}
|
||||
else {
|
||||
alert("You have selected no discount item!");
|
||||
return;
|
||||
$.confirm({
|
||||
title: 'Infomation!',
|
||||
content: "You have selected no discount item!!",
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'Ok',
|
||||
btnClass: 'btn-green',
|
||||
action: function(){
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,13 +425,24 @@ $(document).ready(function(){
|
||||
url: "/origami/" + sale_id + "/remove_discount_items",
|
||||
data: params,
|
||||
success: function(result){
|
||||
alert('Removed Discount');
|
||||
if(result.table_type == "Table"){
|
||||
window.location.href = "/origami/table/" + result.table_id
|
||||
}
|
||||
else {
|
||||
window.location.href = "/origami/room/" + result.table_id
|
||||
}
|
||||
$.confirm({
|
||||
title: 'Infomation!',
|
||||
content: result.status,
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'Ok',
|
||||
btnClass: 'btn-green',
|
||||
action: function(){
|
||||
if(result.table_type == "Table"){
|
||||
window.location.href = "/origami/table/" + result.table_id
|
||||
}
|
||||
else {
|
||||
window.location.href = "/origami/room/" + result.table_id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -410,13 +454,24 @@ $(document).ready(function(){
|
||||
type: "GET",
|
||||
url: "/origami/" + sale_id + "/remove_all_discount",
|
||||
success: function(result){
|
||||
alert('Removed All Discount');
|
||||
if(result.table_type == "Table"){
|
||||
window.location.href = "/origami/table/" + result.table_id
|
||||
}
|
||||
else {
|
||||
window.location.href = "/origami/room/" + result.table_id
|
||||
}
|
||||
$.confirm({
|
||||
title: 'Infomation!',
|
||||
content: result.status,
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'Ok',
|
||||
btnClass: 'btn-green',
|
||||
action: function(){
|
||||
if(result.table_type == "Table"){
|
||||
window.location.href = "/origami/table/" + result.table_id
|
||||
}
|
||||
else {
|
||||
window.location.href = "/origami/room/" + result.table_id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -540,10 +595,23 @@ function calculate_overall_discount(type, amount){
|
||||
// For Percentage Pay
|
||||
if(type == 1){
|
||||
if(amount > 100 ){
|
||||
aler("Percentage Value over 100!");
|
||||
return;
|
||||
$.confirm({
|
||||
title: 'Infomation!',
|
||||
content: "Percentage Value over 100!",
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'Ok',
|
||||
btnClass: 'btn-green',
|
||||
action: function(){
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else{
|
||||
total_discount = (origin_sub_total * amount)/100;
|
||||
}
|
||||
total_discount = (origin_sub_total * amount)/100;
|
||||
}
|
||||
|
||||
$("#order-discount").text(total_discount);
|
||||
@@ -562,7 +630,7 @@ function calculate_item_discount(type, amount, sale_items, account_types){
|
||||
for(var i=0;i < sale_items.length;i++){
|
||||
if(account_types.length > 0){
|
||||
for(var j=0; j < account_types.length; j++){
|
||||
if(sale_items[i].account_id != account_types[j].id){
|
||||
if(sale_items[i].account_id == account_types[j].id){
|
||||
// Discount Items
|
||||
var discount_item_row = item_row_template(type, sale_items[i], dis_amount, amount);
|
||||
$("#order-items-table tbody").append(discount_item_row);
|
||||
@@ -604,34 +672,45 @@ function calculate_item_discount(type, amount, sale_items, account_types){
|
||||
// For Percentage Pay
|
||||
if(type == 1){
|
||||
if(amount > 100 ){
|
||||
aler("Percentage Value over 100!");
|
||||
return;
|
||||
$.confirm({
|
||||
title: 'Infomation!',
|
||||
content: "Percentage Value over 100!",
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'Ok',
|
||||
btnClass: 'btn-green',
|
||||
action: function(){
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Check sale items exists
|
||||
if(sale_items.length > 0){
|
||||
for(var i=0;i < sale_items.length;i++){
|
||||
if(account_types.length > 0){
|
||||
for(var j=0; j < account_types.length; j++){
|
||||
if(sale_items[i].account_id != account_types[j].id){
|
||||
// Discount Items
|
||||
dis_amount = 0 - ((sale_items[i].price * amount)/100);
|
||||
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
|
||||
$("#order-items-table tbody").append(discount_item_row);
|
||||
total_discount = total_discount + dis_amount;
|
||||
else{
|
||||
// Check sale items exists
|
||||
if(sale_items.length > 0){
|
||||
for(var i=0;i < sale_items.length;i++){
|
||||
if(account_types.length > 0){
|
||||
for(var j=0; j < account_types.length; j++){
|
||||
if(sale_items[i].account_id == account_types[j].id){
|
||||
// Discount Items
|
||||
dis_amount = 0 - ((sale_items[i].price * amount)/100);
|
||||
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
|
||||
$("#order-items-table tbody").append(discount_item_row);
|
||||
total_discount = total_discount + dis_amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
dis_amount = 0 - ((sale_items[i].price * amount)/100);
|
||||
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
|
||||
$("#order-items-table tbody").append(discount_item_row);
|
||||
total_discount = total_discount + dis_amount;
|
||||
}
|
||||
}
|
||||
else {
|
||||
dis_amount = 0 - ((sale_items[i].price * amount)/100);
|
||||
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
|
||||
$("#order-items-table tbody").append(discount_item_row);
|
||||
total_discount = total_discount + dis_amount;
|
||||
|
||||
}
|
||||
sub_total = origin_sub_total + total_discount;
|
||||
}
|
||||
}
|
||||
|
||||
// No Needs For Auto Selected
|
||||
// Check account types exists
|
||||
// if(account_types.length > 0){
|
||||
@@ -653,9 +732,7 @@ function calculate_item_discount(type, amount, sale_items, account_types){
|
||||
// else {
|
||||
// alert("No Items!");
|
||||
// }
|
||||
// }
|
||||
|
||||
sub_total = origin_sub_total + total_discount;
|
||||
// }
|
||||
}
|
||||
|
||||
$("#order-sub-total").text(sub_total);
|
||||
|
||||
Reference in New Issue
Block a user