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/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb index 45529dc6..df1184b7 100644 --- a/app/views/crm/customers/show.html.erb +++ b/app/views/crm/customers/show.html.erb @@ -41,7 +41,7 @@
-

Order Details

+

Order Items

@@ -70,6 +70,35 @@ <% end %>
+ +

Sale Items

+ + + + + + + + + + + + + + + <% @sale_items.each do |sale_item| %> + + + + + + + + + + <% end %> + +
Sale ID Menu ItemQTYUnit Price Tax PriceCreated At
<%= sale_item.sale_id %><%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.unit_price %><%= sale_item.taxable_price %><%= sale_item.created_at %>