diff --git a/Gemfile b/Gemfile index 53d6f963..36be43b7 100644 --- a/Gemfile +++ b/Gemfile @@ -45,6 +45,7 @@ gem 'to_xls-rails' # Use jquery as the JavaScript library gem 'jquery-rails' +gem 'jquery-ui-rails' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder diff --git a/Gemfile.lock b/Gemfile.lock index 3fabf983..a4441893 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -87,6 +87,8 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) + jquery-ui-rails (6.0.1) + railties (>= 3.2.16) kaminari (0.16.3) actionpack (>= 3.0.0) activesupport (>= 3.0.0) @@ -244,6 +246,7 @@ DEPENDENCIES httparty (~> 0.15.5) jbuilder (~> 2.5) jquery-rails + jquery-ui-rails kaminari (~> 0.16.3) listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) diff --git a/app/assets/javascripts/CRM.js b/app/assets/javascripts/CRM.js index 66f161af..ee1c6a41 100644 --- a/app/assets/javascripts/CRM.js +++ b/app/assets/javascripts/CRM.js @@ -14,4 +14,6 @@ //= require bootstrap //= require jquery_ujs //= require turbolinks -//= require cable \ No newline at end of file +//= require cable +//= require jquery-ui +//= require bootstrap-datepicker \ No newline at end of file diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index f4ee96ab..a05ea4ee 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -17,7 +17,7 @@ //= require turbolinks //= require cable //= require settings/processing_items -//= require bootstrap-datepicker + diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 70594497..0079142f 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -15,6 +15,8 @@ //= require jquery_ujs //= require turbolinks //= require cable +//= require jquery-ui +//= require bootstrap-datepicker $(document).ready(function(){ // Enable/Disable Button diff --git a/app/assets/stylesheets/CRM.scss b/app/assets/stylesheets/CRM.scss index f43cc3f9..a88efe96 100644 --- a/app/assets/stylesheets/CRM.scss +++ b/app/assets/stylesheets/CRM.scss @@ -1,6 +1,8 @@ @import "bootstrap"; @import "font-awesome"; @import "theme"; +@import "jquery-ui"; +@import "bootstrap-datepicker3"; /* Show it is fixed to the top */ // body { diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index c3030dfb..6097a890 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -2,7 +2,7 @@ @import "bootstrap"; @import "font-awesome"; @import "theme"; -@import "bootstrap-datepicker"; + /* Show it is fixed to the top */ // body { diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 1ea32844..71a9915e 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -1,6 +1,8 @@ @import "bootstrap"; @import "font-awesome"; @import "theme"; +@import "jquery-ui"; +@import "bootstrap-datepicker3"; /* Show it is fixed to the top */ // body { diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index ae6820df..1f35da76 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -31,13 +31,19 @@ class Crm::CustomersController < BaseCrmController # GET /crm/customers/1.json def show @orders = Order.where("customer_id=?", params[:id]) + @sales = Sale.where("customer_id=?", params[:id]) if @orders @order_items = [] - @orders.each do |bo| - @order_items = @order_items + bo.order_items + @orders.each do |order| + @order_items = @order_items + order.order_items + end + end + if @sales + @sale_items = [] + @sales.each do |sale| + @sale_items = @sale_items + sale.sale_items end - end end diff --git a/app/controllers/crm/home_controller.rb b/app/controllers/crm/home_controller.rb index d1ee475b..c05e7cf3 100644 --- a/app/controllers/crm/home_controller.rb +++ b/app/controllers/crm/home_controller.rb @@ -43,18 +43,18 @@ class Crm::HomeController < BaseCrmController end - def update_sale_by_customer + # def update_sale_by_customer - sale = Sale.find(params[:sale_id]) - status = sale.update_attributes(customer_id: params[:customer_id]) + # sale = Sale.find(params[:sale_id]) + # status = sale.update_attributes(customer_id: params[:customer_id]) - if status == true - render json: JSON.generate({:status => true}) - else - render json: JSON.generate({:status => false, :error_message => "Record not found"}) + # if status == true + # render json: JSON.generate({:status => true}) + # else + # render json: JSON.generate({:status => false, :error_message => "Record not found"}) - end - end + # end + # end end diff --git a/app/controllers/origami/redeem_payments_controller.rb b/app/controllers/origami/redeem_payments_controller.rb index b68fd30a..1f650e36 100644 --- a/app/controllers/origami/redeem_payments_controller.rb +++ b/app/controllers/origami/redeem_payments_controller.rb @@ -4,7 +4,25 @@ class Origami::RedeemPaymentsController < BaseOrigamiController payment_method = params[:payment_method] @membership_rebate_balance=0 sale_data = Sale.find_by_sale_id(@sale_id) - @food_prices, @beverage_prices = SaleItem.calculate_food_beverage(sale_data.sale_items) + + # limit redeem_amount + food_prices, beverage_prices = SaleItem.calculate_food_beverage(sale_data.sale_items) + @payparcount = 0 + others = 0 + sale_data.sale_payments.each do |sale_payment| + if sale_payment.payment_method == "paypar" + @payparcount = @payparcount + sale_payment.payment_amount + else + others = others + sale_payment.payment_amount + end + end + is_bervage_exceed = others - (beverage_prices + sale_data.total_tax) + if is_bervage_exceed < 0 + @food_prices = food_prices - @payparcount + else + @food_prices = food_prices - @payparcount -is_bervage_exceed + end + if sale_data if sale_data.customer_id customer_data= Customer.find_by_customer_id(sale_data.customer_id) diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index ba36500c..d72c6a38 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -92,12 +92,13 @@
You can rebate upto <%= @food_prices %>
+ <% if @payparcount > 0 %> +Last time rebate amount is <%= @payparcount %>
+ <% end %> +You can rebate upto <%= @food_prices %>