From 30e1854969918f3a8f67ce5e272dc48612dfc492 Mon Sep 17 00:00:00 2001 From: Yan Date: Thu, 20 Jul 2017 17:42:02 +0630 Subject: [PATCH] fix discount with selected --- .../origami/discounts_controller.rb | 5 +- app/views/origami/discounts/index.html.erb | 99 +++++++++--------- dump.rdb | Bin 430 -> 522 bytes 3 files changed, 54 insertions(+), 50 deletions(-) diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index abe42c9d..030629bf 100644 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -124,7 +124,8 @@ class Origami::DiscountsController < BaseOrigamiController # Member Discount def member_discount sale_id = params[:sale_id] - account_types = JSON.parse(params[:account_types]) + # account_types = JSON.parse(params[:account_types]) + account_types = Account.where("discount=?",true) sub_total = params[:sub_total] sale = Sale.find(sale_id) price = SaleItem.calculate_price_by_accounts(sale.sale_items) @@ -133,7 +134,7 @@ class Origami::DiscountsController < BaseOrigamiController account_types.each do |at| price.each do |pc| - if pc[:name].to_s == at["name"].to_s && pc[:price]>0 + if pc[:name] == at.title && pc[:price]>0 str={type:pc[:name],amount:pc[:price]} arr.push(str) end diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index b0e324a5..c1250e39 100644 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -497,60 +497,63 @@ $(document).ready(function(){ var ajax_url = "/origami/" + sale_id + "/member_discount"; // Selected Account - var account_types = JSON.stringify(get_selected_account_types()); + //var account_types = JSON.stringify(get_selected_account_types()); - if($('.accounts-type').hasClass('selected-account') == true){ + // if($('.accounts-type').hasClass('selected-account') == true){ - var params = {'sale_id':sale_id, 'sub_total':sub_total, 'account_types':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){ + var params = {'sale_id':sale_id, 'sub_total':sub_total }; - if (result.status == "Success") { - type = 'green' - btn_color = 'btn-green' - }else{ - type = 'red' - btn_color = 'btn-red' + $.ajax({ + type: "POST", + url: ajax_url, + data: params, + success:function(result){ - } - - $.confirm({ - title: result.title, - content: result.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{ - $.alert({ - title: 'Alert!', - content: 'Please Select Account', - type: 'red', - typeAnimated: true, - btnClass: 'btn-danger', - }); + if (result.status == "Success") { + type = 'green' + btn_color = 'btn-green' + }else{ + type = 'red' + btn_color = 'btn-red' + + } + + $.confirm({ + title: result.title, + content: result.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{ + // $.alert({ + // title: 'Alert!', + // content: 'Please Select Account', + // type: 'red', + // typeAnimated: true, + // btnClass: 'btn-danger', + // }); - } + // } });//end member discount }); diff --git a/dump.rdb b/dump.rdb index f193e7b226525b7511a7cec99649aa333eeb2c76..1967e324a9015034ad0371eb8d18b1eeaa785db0 100644 GIT binary patch literal 522 zcmZ{gF-yZh9L2AiLaV4KSamWSj%~T5O)t%221Q(T5|MgI{ov6GG^)C?Mdnas(n@tD4p3aN<+&xRR+m%=?OW zVX$-F+Zh%T2|=X`-GO~Ii(b)lA%~WvV#?`>*aw+W$0P==5Lz)wipGjxy3CdOEOHED zn+?aSQ?NYZ`3;+*>7V`-q0&fcGamkm``;?2}tbh;sDw# z3Eh?X4nOF$dVA0Yu7O*uOjrr+?gwPc;vinlnbF>}I`LtyyN> PuiX?F2$7}| delta 267 zcmeBTS;suVz)ALAZsaeH(&E$<-Q3jNLk$t^4F4E@vobP>6_+HISfwRq=A@=r85tOw z>l&Er8d@A+VBiDG6cptrrxpYCO*|v7^GCB#Cp4Ckfq_M=GBMA}(7?>V*viPnGR?ps z)y%-a#EgX{GcPUwu)}(X9g{5?6^%tq4GfG;O-xOV^bAZbjg3uplnOFa6vR0|I(3vv z64MpTn2RflQWZ>CN{bTnN)+rT_c3~ePHM>ELoryXmL;jQxbgr4OHyiLiJ&3KTyrB+ p10y{nLvuq5W7fjb%+wOrw8Wg^R0eJ&KOJEB|B2^S?2)gmO98;NQV{?E