From 28c51300cf6b076b80875f8a0507669b34d94228 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 11 Jul 2017 15:45:01 +0630 Subject: [PATCH] update discount message --- .../origami/discounts_controller.rb | 8 +- app/views/origami/discounts/index.html.erb | 92 ++++++++++++------- 2 files changed, 64 insertions(+), 36 deletions(-) diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index 9c79ea8e..2b6d4383 100644 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -185,10 +185,14 @@ class Origami::DiscountsController < BaseOrigamiController table_type = DiningFacility.find(table_id).type # Re-calc All Amount in Sale - if response["status"] == true + if response["status"] == true sale.compute_by_sale_items(sale_id, sale.sale_items, response["rebate_earned"].to_f,"member_discount") + result = {:status=> "Success", :table_id => table_id, :table_type => table_type,:table_type => table_type } end - result = {:status=> "Success", :table_id => table_id, :table_type => table_type,:table_type => table_type,:url_status => response[:status],:url_message => response[:message] } + + if response[:status] == false + result = {:status=> "Success", :table_id => table_id, :table_type => table_type,:table_type => table_type,:url_status => response[:status],:url_message => response[:message] } + end render :json => result.to_json end diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index 7667bab5..248223ed 100644 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -491,42 +491,66 @@ $(document).ready(function(){ // Selected Account var account_types = JSON.stringify(get_selected_account_types()); - var params = {'sale_id':sale_id, 'sub_total':sub_total, 'account_types':account_types }; - $.ajax({ - type: "POST", - url: ajax_url, - data: params, - success:function(result){ + if($('.accounts-type').hasClass('selected-account') == true){ - if (result.url_status == false) { - status = result.url_message - }else{ - status = result.status - } - - $.confirm({ - title: 'Infomation!', - content: 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 - } - } - } - } - }); - - } - }); - }); + var params = {'sale_id':sale_id, 'sub_total':sub_total, 'account_types':account_types }; + + $.ajax({ + type: "POST", + url: ajax_url, + data: params, + success:function(result){ + + if (result.url_status == false) { + status = result.url_message + type = 'red' + btn_color = 'btn-red' + }else{ + status = result.status + type = '' + btn_color = 'btn-green' + } + + $.confirm({ + title: 'Infomation!', + content: status, + columnClass: 'small', + type: type, + buttons: { + confirm: { + text: 'Ok', + btnClass: btn_color, + action: function(){ + if(result.table_type == "Table"){ + window.location.href = "/origami/table/" + result.table_id + } + else { + window.location.href = "/origami/room/" + result.table_id + } + } + } + } + }); + + } + }); + }else{ + $.confirm({ + title: 'Alert !', + content: 'Please Select Account', + type: 'red', + typeAnimated: true, + buttons: { + confirm: { + text: 'Ok', + btnClass: 'btn-danger', + } + } + }); + } + + });//end member discount }); /* Remove Selection */