add Old Town req:
This commit is contained in:
@@ -62,57 +62,59 @@ class HomeController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dashboard
|
def dashboard
|
||||||
|
@from, @to = get_date_range_from_params
|
||||||
|
|
||||||
@shop = Shop.first
|
@shop = Shop.first
|
||||||
|
|
||||||
today = DateTime.now.strftime('%Y-%m-%d')
|
today = DateTime.now.strftime('%Y-%m-%d')
|
||||||
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||||
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||||
|
|
||||||
@top_products = Sale.top_products(today).sum('i.qty')
|
@top_products = Sale.top_products(today,@from,@to).sum('i.qty')
|
||||||
@bottom_products = Sale.bottom_products(today).sum('i.qty')
|
@bottom_products = Sale.bottom_products(today,@from,@to).sum('i.qty')
|
||||||
@hourly_sales = Sale.hourly_sales(today).sum(:grand_total)
|
@hourly_sales = Sale.hourly_sales(today,@from,@to).sum(:grand_total)
|
||||||
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
|
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
|
||||||
# .sum(:grand_total)
|
# .sum(:grand_total)
|
||||||
@employee_sales = Sale.employee_sales(today)
|
@employee_sales = Sale.employee_sales(today,@from,@to)
|
||||||
.sum('(CASE WHEN sp.payment_method="cash" THEN (sp.payment_amount - sales.amount_changed) ELSE sp.payment_amount END)')
|
.sum('(CASE WHEN sp.payment_method="cash" THEN (sp.payment_amount - sales.amount_changed) ELSE sp.payment_amount END)')
|
||||||
@inventories = StockJournal.inventory_balances(today).sum(:balance)
|
@inventories = StockJournal.inventory_balances(today,@from,@to).sum(:balance)
|
||||||
|
|
||||||
@total_sale = Sale.total_sale(today)
|
@total_sale = Sale.total_sale(today,current_user,@from,@to)
|
||||||
@total_count = Sale.total_count(today)
|
@total_count = Sale.total_count(today,current_user,@from,@to)
|
||||||
@total_card = Sale.total_card_sale(today)
|
@total_card = Sale.total_card_sale(today,current_user,@from,@to)
|
||||||
@total_credit = Sale.credit_payment(today)
|
@total_credit = Sale.credit_payment(today,current_user,@from,@to)
|
||||||
|
|
||||||
@sale_data = Array.new
|
@sale_data = Array.new
|
||||||
@total_payment_methods = Sale.total_payment_methods(today)
|
@total_payment_methods = Sale.total_payment_methods(today,current_user,@from,@to)
|
||||||
|
|
||||||
@total_payment_methods.each do |payment|
|
@total_payment_methods.each do |payment|
|
||||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb"
|
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb"
|
||||||
pay = Sale.payment_sale('card', today)
|
pay = Sale.payment_sale('card', today, current_user,@from,@to)
|
||||||
@sale_data.push({'card' => pay.payment_amount})
|
@sale_data.push({'card' => pay.payment_amount})
|
||||||
else
|
else
|
||||||
pay = Sale.payment_sale(payment.payment_method, today)
|
pay = Sale.payment_sale(payment.payment_method, today, current_user,@from,@to)
|
||||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@summ_sale = Sale.summary_sale_receipt(today)
|
@summ_sale = Sale.summary_sale_receipt(today,current_user,@from,@to)
|
||||||
@total_customer = Sale.total_customer(today)
|
@total_customer = Sale.total_customer(today,current_user,@from,@to)
|
||||||
@total_dinein = Sale.total_dinein(today)
|
@total_dinein = Sale.total_dinein(today,current_user,@from,@to)
|
||||||
@total_takeaway = Sale.total_takeaway(today)
|
@total_takeaway = Sale.total_takeaway(today,current_user,@from,@to)
|
||||||
@total_other_customer = Sale.total_other_customer(today)
|
@total_other_customer = Sale.total_other_customer(today,current_user,@from,@to)
|
||||||
@total_membership = Sale.total_membership(today)
|
@total_membership = Sale.total_membership(today,current_user,@from,@to)
|
||||||
|
|
||||||
@total_order = Sale.total_order(today)
|
@total_order = Sale.total_order(today,current_user,@from,@to)
|
||||||
@total_accounts = Sale.total_account(today)
|
@total_accounts = Sale.total_account(today,current_user,@from,@to)
|
||||||
@account_data = Array.new
|
@account_data = Array.new
|
||||||
@total_accounts.each do |account|
|
@total_accounts.each do |account|
|
||||||
acc = Sale.account_data(account.account_id, today)
|
acc = Sale.account_data(account.account_id, today,current_user,@from,@to)
|
||||||
if !acc.nil?
|
if !acc.nil?
|
||||||
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@top_items = Sale.top_items(today)
|
@top_items = Sale.top_items(today,current_user,@from,@to)
|
||||||
@total_foc_items = Sale.total_foc_items(today)
|
@total_foc_items = Sale.total_foc_items(today,current_user,@from,@to)
|
||||||
|
|
||||||
# get printer info
|
# get printer info
|
||||||
@print_settings = PrintSetting.get_precision_delimiter()
|
@print_settings = PrintSetting.get_precision_delimiter()
|
||||||
@@ -162,4 +164,20 @@ class HomeController < ApplicationController
|
|||||||
redirect_to reports_dailysale_index_path
|
redirect_to reports_dailysale_index_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_date_range_from_params
|
||||||
|
from = params[:from]
|
||||||
|
to = params[:to]
|
||||||
|
|
||||||
|
if from.present? && to.present?
|
||||||
|
f_date = DateTime.parse(from)
|
||||||
|
t_date = DateTime.parse(to)
|
||||||
|
f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
|
||||||
|
t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
|
||||||
|
from = f_time.beginning_of_day.utc.getlocal
|
||||||
|
to = t_time.end_of_day.utc.getlocal
|
||||||
|
end
|
||||||
|
|
||||||
|
return from, to
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
18
app/controllers/reports/product_sale_controller.rb
Executable file
18
app/controllers/reports/product_sale_controller.rb
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
class Reports::ProductSaleController < BaseReportController
|
||||||
|
authorize_resource :class => false
|
||||||
|
|
||||||
|
def index
|
||||||
|
@order_by = params[:order_by]
|
||||||
|
|
||||||
|
@sale_data = Sale.get_menu_item_query(@order_by)
|
||||||
|
|
||||||
|
# get printer info
|
||||||
|
@print_settings = PrintSetting.get_precision_delimiter()
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.json
|
||||||
|
format.xls
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
|||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="block-header">
|
<div class="block-header">
|
||||||
<h2><%= t :dashboard %></h2>
|
<!-- <h2><%= t :dashboard %></h2> -->
|
||||||
|
<h2><%= t :date_time %> : <%= Time.zone.now.utc.getlocal.strftime("%Y-%m-%d %I:%M %p") %></h2>
|
||||||
</div>
|
</div>
|
||||||
<% if @print_settings.precision.to_i > 0
|
<% if @print_settings.precision.to_i > 0
|
||||||
precision = @print_settings.precision
|
precision = @print_settings.precision
|
||||||
@@ -65,8 +66,28 @@
|
|||||||
<!-- #END# Widgets -->
|
<!-- #END# Widgets -->
|
||||||
<!-- CPU Usage -->
|
<!-- CPU Usage -->
|
||||||
|
|
||||||
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
|
<!-- Date range for dashboard -->
|
||||||
|
<div class="row clearfix">
|
||||||
|
<div class="col-lg-4 col-md-4 col-sm-4">
|
||||||
|
<label class="font-14"><%= t("views.right_panel.detail.from") %></label>
|
||||||
|
<input data-behaviour='datepicker' class="form-control datepicker" name="from" id="from" type="text" value="<%= Time.now.utc.strftime('%d-%m-%Y') %>" placeholder="From date" style="height: 35px;">
|
||||||
|
<span id="fromErr" style="color:red;"></span>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4 col-md-4 col-sm-4">
|
||||||
|
<label class="font-14"><%= t("views.right_panel.detail.to") %></label>
|
||||||
|
<input data-behaviour='datepicker' class="form-control datepicker" name="to" id="to" type="text" value="<%= Time.now.utc.strftime('%d-%m-%Y') %>" placeholder="To date" style="height: 35px;">
|
||||||
|
<span id="toErr" style="color:red;"></span>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||||
|
<label></label><br>
|
||||||
|
<input type="button" value="Generate" class='btn btn-primary btn_generate'>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<!-- Date range for dashboard -->
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
|
||||||
<div class="col-xs-8 col-sm-8 col-md-8 col-lg-8">
|
<div class="col-xs-8 col-sm-8 col-md-8 col-lg-8">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
|
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
|
||||||
@@ -122,10 +143,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
<% end %>
|
||||||
|
<% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'cashier' %>
|
||||||
<% if !@summ_sale.nil? %>
|
<% if !@summ_sale.nil? %>
|
||||||
|
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
|
||||||
|
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||||
|
<% else %>
|
||||||
|
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
||||||
|
<% end %>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<h6><%= t :sale %></h6>
|
<h6><%= t :sale %></h6>
|
||||||
@@ -136,19 +165,19 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= t("views.right_panel.detail.total") %> <%= t :sale %> : </td>
|
<td><%= t("views.right_panel.detail.total") %> <%= t :sale %> : </td>
|
||||||
<td align="right"><%= number_with_precision( @summ_sale.total_amount, precision: precision.to_i ,delimiter: delimiter) %></td>
|
<td align="right"><%= number_with_precision( @summ_sale.total_amount, precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.discount") %> : </td>
|
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.discount") %> : </td>
|
||||||
<td align="right"><%= number_with_precision( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) %></td>
|
<td align="right"><%= number_with_precision( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %> : </td>
|
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %> : </td>
|
||||||
<td align="right"><%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter)%></td>
|
<td align="right"><%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= t("views.right_panel.detail.grand_total") %> : </td>
|
<td><%= t("views.right_panel.detail.grand_total") %> : </td>
|
||||||
<td align="right"><%= number_with_precision( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%></td>
|
<td align="right"><%= number_with_precision( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
@@ -161,7 +190,7 @@
|
|||||||
<td align="right">
|
<td align="right">
|
||||||
<% @sale_data.each do |data| %>
|
<% @sale_data.each do |data| %>
|
||||||
<% pay_mth = payment.payment_method %>
|
<% pay_mth = payment.payment_method %>
|
||||||
<%= data[""+pay_mth+""] %>
|
<%= number_with_precision(data[""+pay_mth+""], precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -174,7 +203,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><%= t("views.right_panel.detail.card_sale") %> : </td>
|
<td><%= t("views.right_panel.detail.card_sale") %> : </td>
|
||||||
<td align="right">
|
<td align="right">
|
||||||
<%= total_card["card"].to_f %>
|
<%= number_with_precision(total_card["card"], precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -184,11 +213,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||||
|
<% else %>
|
||||||
|
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
||||||
|
<% end %>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<h6><%= t :customer %></h6>
|
<h6><%= t :customer %></h6>
|
||||||
@@ -227,10 +262,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||||
|
<% else %>
|
||||||
|
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
||||||
|
<% end %>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<h6><%= t("views.right_panel.detail.order") %></h6>
|
<h6><%= t("views.right_panel.detail.order") %></h6>
|
||||||
@@ -274,6 +315,41 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
</div>
|
||||||
</div>
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function(){
|
||||||
|
var from = '<%= @from.strftime('%d-%m-%Y') rescue '' %>';
|
||||||
|
var to = '<%= @to.strftime('%d-%m-%Y') rescue '' %>';
|
||||||
|
|
||||||
|
if((from!=undefined) && (from != null) && (from != '')){
|
||||||
|
$('#from').val(from);
|
||||||
|
}
|
||||||
|
if((to!=undefined) && (to != null) && (to != '')){
|
||||||
|
$('#to').val(to);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.btn_generate').on('click',function(){
|
||||||
|
var from = $("#from").val();
|
||||||
|
var to = $("#to").val();
|
||||||
|
if((from=='') && (to=='')){
|
||||||
|
$('#fromErr').html("can't be blank");
|
||||||
|
$('#toErr').html("can't be blank");
|
||||||
|
}else if((from!='') && (to=='')){
|
||||||
|
$('#fromErr').html("");
|
||||||
|
$('#toErr').html("can't be blank");
|
||||||
|
}else if((from=='') && (to!='')){
|
||||||
|
$('#fromErr').html("can't be blank");
|
||||||
|
$('#toErr').html("");
|
||||||
|
}else{
|
||||||
|
$('#fromErr').html("");
|
||||||
|
$('#toErr').html("");
|
||||||
|
}
|
||||||
|
if((from!='') && (to!='')){
|
||||||
|
window.location.href = '/dashboard?from='+from+'&to='+to;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
113
app/views/reports/product_sale/index.html.erb
Executable file
113
app/views/reports/product_sale/index.html.erb
Executable file
@@ -0,0 +1,113 @@
|
|||||||
|
<div class="page-header">
|
||||||
|
<ol class="breadcrumb">
|
||||||
|
<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>
|
||||||
|
<span class="float-right">
|
||||||
|
<%= link_to 'Back', dashboard_path %>
|
||||||
|
</span>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="margin-top-20">
|
||||||
|
<div class="card">
|
||||||
|
<div class="p-l-20 p-t-20 p-b-20">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="font-16" for="order_by">Order by Qty</label>
|
||||||
|
<select name="order_by" id="order_by" class="form-control" style="width:10%">
|
||||||
|
<option value="asc">ASC</option>
|
||||||
|
<option value="desc">DESC</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
<% 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 %>
|
||||||
|
<table class="table table-striped" id="items_table" border="0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th> </th>
|
||||||
|
<th><%= t("views.right_panel.header.menu_category") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.code") %></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.unit_price") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.total") %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="tbd_data">
|
||||||
|
<% unless @sale_data.blank? %>
|
||||||
|
<% acc_arr = Array.new %>
|
||||||
|
<% cate_arr = Array.new %>
|
||||||
|
|
||||||
|
<% 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 %>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<% if !cate_arr.include?(sale.menu_category_id) %>
|
||||||
|
<td><%= sale.menu_category_name %></td>
|
||||||
|
<% cate_arr.push(sale.menu_category_id) %>
|
||||||
|
<% else %>
|
||||||
|
<td> </td>
|
||||||
|
<% end %>
|
||||||
|
<td><%= sale.item_code rescue '-' %></td>
|
||||||
|
<td><%= sale.product_name 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.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
|
||||||
|
</tr>
|
||||||
|
<!-- sub total -->
|
||||||
|
<!-- end sub total -->
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3"></td>
|
||||||
|
<td><strong>Total</strong></td>
|
||||||
|
<td><strong><%= total_qty %></strong></td>
|
||||||
|
<td></td>
|
||||||
|
<td><strong><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></strong></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function(){
|
||||||
|
$('#order_by').val('<%= @order_by %>');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#order_by').on('change', function(){
|
||||||
|
var order_by = $("#order_by").val();
|
||||||
|
window.location.href = "?order_by=" + order_by;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
64
app/views/reports/product_sale/index.xls.erb
Executable file
64
app/views/reports/product_sale/index.xls.erb
Executable file
@@ -0,0 +1,64 @@
|
|||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="margin-top-20">
|
||||||
|
<div class="card">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped" id="items_table" border="0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th> </th>
|
||||||
|
<th><%= t("views.right_panel.header.menu_category") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.code") %></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.unit_price") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.total") %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% unless @sale_data.blank? %>
|
||||||
|
<% acc_arr = Array.new %>
|
||||||
|
<% cate_arr = Array.new %>
|
||||||
|
<% 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 %>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<% if !cate_arr.include?(sale.menu_category_id) %>
|
||||||
|
<td><%= sale.menu_category_name %></td>
|
||||||
|
<% cate_arr.push(sale.menu_category_id) %>
|
||||||
|
<% else %>
|
||||||
|
<td> </td>
|
||||||
|
<% end %>
|
||||||
|
<td><%= sale.item_code rescue '-' %></td>
|
||||||
|
<td><%= sale.product_name rescue '-' %></td>
|
||||||
|
<td><%= sale.total_item rescue '-' %></td>
|
||||||
|
<td><%= sale.unit_price rescue '-' %></td>
|
||||||
|
<td><%= sale.grand_total rescue '-' %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3"></td>
|
||||||
|
<td><strong>Total</strong></td>
|
||||||
|
<td><strong><%= total_qty %></strong></td>
|
||||||
|
<td></td>
|
||||||
|
<td><strong><%= grand_total rescue '-' %></strong></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -373,6 +373,7 @@ scope "(:locale)", locale: /en|mm/ do
|
|||||||
resources :commission, :only => [:index, :show]
|
resources :commission, :only => [:index, :show]
|
||||||
resources :stock_check, :only => [:index, :show]
|
resources :stock_check, :only => [:index, :show]
|
||||||
resources :payment_method
|
resources :payment_method
|
||||||
|
resources :product_sale, :only => [:index, :show]
|
||||||
|
|
||||||
get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date"
|
get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user