From 0f36e44d1c2806a7a50d65d903355c5c519ba58a Mon Sep 17 00:00:00 2001 From: phyusin Date: Mon, 26 Feb 2018 11:33:51 +0630 Subject: [PATCH] check route in product sale --- .../reports/product_sale_controller.rb | 7 +- app/views/reports/product_sale/index.html.erb | 193 +++++++++--------- 2 files changed, 94 insertions(+), 106 deletions(-) diff --git a/app/controllers/reports/product_sale_controller.rb b/app/controllers/reports/product_sale_controller.rb index a2ba1c7f..748c8716 100644 --- a/app/controllers/reports/product_sale_controller.rb +++ b/app/controllers/reports/product_sale_controller.rb @@ -2,11 +2,8 @@ class Reports::ProductSaleController < BaseReportController authorize_resource :class => false def index - @order_by = 'desc' - if !params[:order_by].nil? - @order_by = params[:order_by] - end - + @order_by = params[:order_by] + @sale_data = Sale.get_menu_item_query(@order_by) # get printer info diff --git a/app/views/reports/product_sale/index.html.erb b/app/views/reports/product_sale/index.html.erb index 7c0f3108..eb797122 100644 --- a/app/views/reports/product_sale/index.html.erb +++ b/app/views/reports/product_sale/index.html.erb @@ -1,102 +1,100 @@ -
- -
-
- + +
+
+ -
-
-
-
- - -
+
+
+
+
+ +
+
-
- <% if @print_settings.precision.to_i > 0 - precision = @print_settings.precision - else - precision = 0 - end - #check delimiter - if @print_settings.delimiter - delimiter = "," - else - delimiter = "" - end %> - - - - - - - - - - - - - - <% unless @sale_data.blank? %> - <% acc_arr = Array.new %> - <% cate_arr = Array.new %> +
+ <% if @print_settings.precision.to_i > 0 + precision = @print_settings.precision + else + precision = 0 + end + #check delimiter + if @print_settings.delimiter + delimiter = "," + else + delimiter = "" + end %> +
 <%= t("views.right_panel.header.menu_category") %><%= t("views.right_panel.detail.code") %><%= t("views.right_panel.detail.product") %><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %><%= t("views.right_panel.detail.unit_price") %><%= t("views.right_panel.detail.total") %>
+ + + + + + + + + + + + + <% unless @sale_data.blank? %> + <% acc_arr = Array.new %> + <% cate_arr = Array.new %> - <% grand_total = 0 %> - <% total_qty = 0 %> + <% grand_total = 0 %> + <% total_qty = 0 %> - <% @sale_data.each do |sale| %> - <% if sale.status_type != "Discount" && sale.status_type != "foc" - total_qty += sale.total_item - grand_total += sale.grand_total - end %> - <% if sale.status_type == "foc" && sale.price > 0 - total_qty += sale.total_item - grand_total += sale.grand_total - end %> + <% @sale_data.each do |sale| %> + <% if sale.status_type != "Discount" && sale.status_type != "foc" + total_qty += sale.total_item + grand_total += sale.grand_total + end %> + <% if sale.status_type == "foc" && sale.price > 0 + total_qty += sale.total_item + grand_total += sale.grand_total + end %> - - - <% if !cate_arr.include?(sale.menu_category_id) %> - - <% cate_arr.push(sale.menu_category_id) %> - <% else %> - - <% end %> - - - - - - - - - <% end %> - - - - - - - - - <% end %> - -
 <%= t("views.right_panel.header.menu_category") %><%= t("views.right_panel.detail.code") %><%= t("views.right_panel.detail.product") %><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %><%= t("views.right_panel.detail.unit_price") %><%= t("views.right_panel.detail.total") %>
 <%= sale.menu_category_name %> <%= sale.item_code rescue '-' %><%= sale.product_name rescue '-' %><%= sale.total_item rescue '-' %><%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%><%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %>
Total<%= total_qty %><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %>
-
+ +   + <% if !cate_arr.include?(sale.menu_category_id) %> + <%= sale.menu_category_name %> + <% cate_arr.push(sale.menu_category_id) %> + <% else %> +   + <% end %> + <%= sale.item_code rescue '-' %> + <%= sale.product_name rescue '-' %> + <%= sale.total_item rescue '-' %> + <%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%> + <%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %> + + + + <% end %> + + + Total + <%= total_qty %> + + <%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %> + + + <% end %> + +
@@ -110,13 +108,6 @@ $('#order_by').on('change', function(){ var order_by = $("#order_by").val(); - $('.div_product_sale').html(""); - $.ajax({ - type: 'GET', - url: '?order_by='+order_by, - success: function(data) { - $('.div_product_sale').html(data); - } - }); + window.location.href = "?order_by=" + order_by; }); \ No newline at end of file