check route in product sale
This commit is contained in:
@@ -2,11 +2,8 @@ class Reports::ProductSaleController < BaseReportController
|
|||||||
authorize_resource :class => false
|
authorize_resource :class => false
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@order_by = 'desc'
|
@order_by = params[:order_by]
|
||||||
if !params[:order_by].nil?
|
|
||||||
@order_by = params[:order_by]
|
|
||||||
end
|
|
||||||
|
|
||||||
@sale_data = Sale.get_menu_item_query(@order_by)
|
@sale_data = Sale.get_menu_item_query(@order_by)
|
||||||
|
|
||||||
# get printer info
|
# get printer info
|
||||||
|
|||||||
@@ -1,102 +1,100 @@
|
|||||||
<div class="div_product_sale">
|
<div class="page-header">
|
||||||
<div class="page-header">
|
<ol class="breadcrumb">
|
||||||
<ol class="breadcrumb">
|
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
|
||||||
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
|
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.sale_item_report") %></li>
|
||||||
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.sale_item_report") %></li>
|
<span class="float-right">
|
||||||
<span class="float-right">
|
<%= link_to 'Back', dashboard_path %>
|
||||||
<%= link_to 'Back', dashboard_path %>
|
</span>
|
||||||
</span>
|
</ol>
|
||||||
</ol>
|
</div>
|
||||||
</div>
|
<div class="row">
|
||||||
<div class="row">
|
<div class="col-md-12">
|
||||||
<div class="col-md-12">
|
<div class="text-right">
|
||||||
<div class="text-right">
|
<a href="javascript:export_to('<%=reports_product_sale_index_path%>.xls')" class = "btn btn-info wave-effects "><%= t("views.btn.exp_to_excel") %></a>
|
||||||
<a href="javascript:export_to('<%=reports_product_sale_index_path%>.xls')" class = "btn btn-info wave-effects "><%= t("views.btn.exp_to_excel") %></a>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="margin-top-20">
|
<div class="margin-top-20">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="p-l-20 p-t-20 p-b-20">
|
<div class="p-l-20 p-t-20 p-b-20">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<label class="font-16" for="order_by">Order by Qty</label>
|
<label class="font-16" for="order_by">Order by Qty</label>
|
||||||
<select name="order_by" id="order_by" class="form-control" style="width:10%">
|
<select name="order_by" id="order_by" class="form-control" style="width:10%">
|
||||||
<option value="asc">ASC</option>
|
<option value="asc">ASC</option>
|
||||||
<option value="desc">DESC</option>
|
<option value="desc">DESC</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<% if @print_settings.precision.to_i > 0
|
<% if @print_settings.precision.to_i > 0
|
||||||
precision = @print_settings.precision
|
precision = @print_settings.precision
|
||||||
else
|
else
|
||||||
precision = 0
|
precision = 0
|
||||||
end
|
end
|
||||||
#check delimiter
|
#check delimiter
|
||||||
if @print_settings.delimiter
|
if @print_settings.delimiter
|
||||||
delimiter = ","
|
delimiter = ","
|
||||||
else
|
else
|
||||||
delimiter = ""
|
delimiter = ""
|
||||||
end %>
|
end %>
|
||||||
<table class="table table-striped" id="items_table" border="0">
|
<table class="table table-striped" id="items_table" border="0">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
<th><%= t("views.right_panel.header.menu_category") %></th>
|
<th><%= t("views.right_panel.header.menu_category") %></th>
|
||||||
<th><%= t("views.right_panel.detail.code") %></th>
|
<th><%= t("views.right_panel.detail.code") %></th>
|
||||||
<th><%= t("views.right_panel.detail.product") %></th>
|
<th><%= t("views.right_panel.detail.product") %></th>
|
||||||
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></th>
|
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></th>
|
||||||
<th><%= t("views.right_panel.detail.unit_price") %></th>
|
<th><%= t("views.right_panel.detail.unit_price") %></th>
|
||||||
<th><%= t("views.right_panel.detail.total") %></th>
|
<th><%= t("views.right_panel.detail.total") %></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="tbd_data">
|
<tbody id="tbd_data">
|
||||||
<% unless @sale_data.blank? %>
|
<% unless @sale_data.blank? %>
|
||||||
<% acc_arr = Array.new %>
|
<% acc_arr = Array.new %>
|
||||||
<% cate_arr = Array.new %>
|
<% cate_arr = Array.new %>
|
||||||
|
|
||||||
<% grand_total = 0 %>
|
<% grand_total = 0 %>
|
||||||
<% total_qty = 0 %>
|
<% total_qty = 0 %>
|
||||||
|
|
||||||
<% @sale_data.each do |sale| %>
|
<% @sale_data.each do |sale| %>
|
||||||
<% if sale.status_type != "Discount" && sale.status_type != "foc"
|
<% if sale.status_type != "Discount" && sale.status_type != "foc"
|
||||||
total_qty += sale.total_item
|
total_qty += sale.total_item
|
||||||
grand_total += sale.grand_total
|
grand_total += sale.grand_total
|
||||||
end %>
|
end %>
|
||||||
<% if sale.status_type == "foc" && sale.price > 0
|
<% if sale.status_type == "foc" && sale.price > 0
|
||||||
total_qty += sale.total_item
|
total_qty += sale.total_item
|
||||||
grand_total += sale.grand_total
|
grand_total += sale.grand_total
|
||||||
end %>
|
end %>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
<% if !cate_arr.include?(sale.menu_category_id) %>
|
<% if !cate_arr.include?(sale.menu_category_id) %>
|
||||||
<td><%= sale.menu_category_name %></td>
|
<td><%= sale.menu_category_name %></td>
|
||||||
<% cate_arr.push(sale.menu_category_id) %>
|
<% cate_arr.push(sale.menu_category_id) %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<td><%= sale.item_code rescue '-' %></td>
|
<td><%= sale.item_code rescue '-' %></td>
|
||||||
<td><%= sale.product_name rescue '-' %></td>
|
<td><%= sale.product_name rescue '-' %></td>
|
||||||
<td><%= sale.total_item rescue '-' %></td>
|
<td><%= sale.total_item rescue '-' %></td>
|
||||||
<td><%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
<td><%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td><%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
|
<td><%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- sub total -->
|
<!-- sub total -->
|
||||||
<!-- end sub total -->
|
<!-- end sub total -->
|
||||||
<% end %>
|
<% end %>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3"></td>
|
<td colspan="3"></td>
|
||||||
<td><strong>Total</strong></td>
|
<td><strong>Total</strong></td>
|
||||||
<td><strong><%= total_qty %></strong></td>
|
<td><strong><%= total_qty %></strong></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td><strong><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></strong></td>
|
<td><strong><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -110,13 +108,6 @@
|
|||||||
|
|
||||||
$('#order_by').on('change', function(){
|
$('#order_by').on('change', function(){
|
||||||
var order_by = $("#order_by").val();
|
var order_by = $("#order_by").val();
|
||||||
$('.div_product_sale').html("");
|
window.location.href = "?order_by=" + order_by;
|
||||||
$.ajax({
|
|
||||||
type: 'GET',
|
|
||||||
url: '?order_by='+order_by,
|
|
||||||
success: function(data) {
|
|
||||||
$('.div_product_sale').html(data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
Reference in New Issue
Block a user