ui updating for report
This commit is contained in:
@@ -1,8 +1,77 @@
|
||||
class BaseReportController < ActionController::Base
|
||||
include LoginVerification
|
||||
include LoginVerification
|
||||
layout "application"
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
PERIOD = {
|
||||
"today" => 0,
|
||||
"yesterday" => 1,
|
||||
"this_week" => 2,
|
||||
"last_week" => 3,
|
||||
"last_7" => 4,
|
||||
"this_month" => 5,
|
||||
"last_month" => 6,
|
||||
"last_30" => 7,
|
||||
"this_year" => 8,
|
||||
"last_year" => 9
|
||||
}
|
||||
|
||||
def get_date_range_from_params
|
||||
period_type = params[:period_type]
|
||||
period = params[:period]
|
||||
from = params[:from]
|
||||
to = params[:to]
|
||||
day_ref = Time.now
|
||||
if period_type.to_i == 1
|
||||
if params[:from] && params[:to]
|
||||
if params[:from] != "" && params[:to] !=""
|
||||
from = DateTime.strptime(params[:from], "%m/%d/%Y")
|
||||
to = DateTime.strptime(params[:to], "%m/%d/%Y")
|
||||
else
|
||||
from = day_ref.beginning_of_day.utc
|
||||
to = day_ref.end_of_day.utc
|
||||
end
|
||||
end
|
||||
else
|
||||
case period.to_i
|
||||
when PERIOD["today"]
|
||||
|
||||
from = day_ref.beginning_of_day.utc
|
||||
to = day_ref.end_of_day.utc
|
||||
|
||||
when PERIOD["yesterday"]
|
||||
from = (day_ref - 1.day).beginning_of_day.utc
|
||||
to = (day_ref - 1.day).end_of_day.utc
|
||||
|
||||
when PERIOD["this_week"]
|
||||
from = Time.now.beginning_of_week.utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["last_week"]
|
||||
from = (day_ref - 7.day).beginning_of_week.utc
|
||||
to = (day_ref - 7.day).end_of_week.utc
|
||||
when PERIOD["last_7"]
|
||||
from = (day_ref - 7.day).utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["this_month"]
|
||||
from = Time.now.beginning_of_month.utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["last_month"]
|
||||
from = (day_ref - 1.month).beginning_of_month.utc
|
||||
to = (day_ref - 1.month).end_of_month.utc
|
||||
when PERIOD["last_30"]
|
||||
from = (day_ref - 30.day).utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["this_year"]
|
||||
from = Time.now.beginning_of_year.utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["last_year"]
|
||||
from = (day_ref - 1.year).beginning_of_year.utc
|
||||
to = (day_ref - 1.year).end_of_year.utc
|
||||
end
|
||||
end
|
||||
return from, to
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
21
app/controllers/reports/daily_sale_controller.rb
Normal file
21
app/controllers/reports/daily_sale_controller.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
class Reports::DailySaleController < BaseReportController
|
||||
PERIOD = {
|
||||
"today" => 0,
|
||||
"yesterday" => 1,
|
||||
"this_week" => 2,
|
||||
"last_week" => 3,
|
||||
"last_7" => 4,
|
||||
"this_month" => 5,
|
||||
"last_month" => 6,
|
||||
"last_30" => 7,
|
||||
"this_year" => 8,
|
||||
"last_year" => 9
|
||||
}
|
||||
|
||||
def index
|
||||
from, to = get_date_range_from_params
|
||||
@sale_data = Sale.get_receipt_no_list(from,to)
|
||||
@sale_data = Kaminari.paginate_array(@sale_data).page(params[:page]).per(50)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,17 +1,4 @@
|
||||
class Reports::ReceiptNoController < ApplicationController
|
||||
PERIOD = {
|
||||
"today" => 0,
|
||||
"yesterday" => 1,
|
||||
"this_week" => 2,
|
||||
"last_week" => 3,
|
||||
"last_7" => 4,
|
||||
"this_month" => 5,
|
||||
"last_month" => 6,
|
||||
"last_30" => 7,
|
||||
"this_year" => 8,
|
||||
"last_year" => 9
|
||||
}
|
||||
|
||||
class Reports::ReceiptNoController < BaseReportController
|
||||
def index
|
||||
from, to = get_date_range_from_params
|
||||
puts "from..."
|
||||
@@ -25,61 +12,4 @@ class Reports::ReceiptNoController < ApplicationController
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
def get_date_range_from_params
|
||||
period_type = params[:period_type]
|
||||
period = params[:period]
|
||||
from = params[:from]
|
||||
to = params[:to]
|
||||
day_ref = Time.now
|
||||
if period_type.to_i == 1
|
||||
if params[:from] && params[:to]
|
||||
if params[:from] != "" && params[:to] !=""
|
||||
from = DateTime.strptime(params[:from], "%m/%d/%Y")
|
||||
to = DateTime.strptime(params[:to], "%m/%d/%Y")
|
||||
else
|
||||
from = day_ref.beginning_of_day.utc
|
||||
to = day_ref.end_of_day.utc
|
||||
end
|
||||
end
|
||||
else
|
||||
case period.to_i
|
||||
when PERIOD["today"]
|
||||
|
||||
from = day_ref.beginning_of_day.utc
|
||||
to = day_ref.end_of_day.utc
|
||||
|
||||
when PERIOD["yesterday"]
|
||||
from = (day_ref - 1.day).beginning_of_day.utc
|
||||
to = (day_ref - 1.day).end_of_day.utc
|
||||
|
||||
when PERIOD["this_week"]
|
||||
from = Time.now.beginning_of_week.utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["last_week"]
|
||||
from = (day_ref - 7.day).beginning_of_week.utc
|
||||
to = (day_ref - 7.day).end_of_week.utc
|
||||
when PERIOD["last_7"]
|
||||
from = (day_ref - 7.day).utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["this_month"]
|
||||
from = Time.now.beginning_of_month.utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["last_month"]
|
||||
from = (day_ref - 1.month).beginning_of_month.utc
|
||||
to = (day_ref - 1.month).end_of_month.utc
|
||||
when PERIOD["last_30"]
|
||||
from = (day_ref - 30.day).utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["this_year"]
|
||||
from = Time.now.beginning_of_year.utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["last_year"]
|
||||
from = (day_ref - 1.year).beginning_of_year.utc
|
||||
to = (day_ref - 1.year).end_of_year.utc
|
||||
end
|
||||
end
|
||||
return from, to
|
||||
end
|
||||
end
|
||||
@@ -316,7 +316,7 @@
|
||||
sub_total = 0
|
||||
if @selected_item_type == "Sale"
|
||||
@selected_item.sale_items.each do |sale_item|
|
||||
sub_total += sale_item.qty*sale_item.unit_price
|
||||
sub_total += (sale_item.qty*sale_item.unit_price)
|
||||
%>
|
||||
<tr>
|
||||
<td class='item-name'><%= sale_item.product_name %></td>
|
||||
@@ -351,7 +351,7 @@
|
||||
<table class="table" id="order-charges-table" border="0">
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Sub Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-sub-total"><%=sub_total%></strong></td>
|
||||
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
|
||||
</tr>
|
||||
<!-- <tr>
|
||||
<td class="charges-name"><strong>Food:</strong></td>
|
||||
|
||||
0
app/views/reports/daily_sale_report.html.erb
Normal file
0
app/views/reports/daily_sale_report.html.erb
Normal file
@@ -1,5 +1,6 @@
|
||||
<%= form_tag report_path, :method => :get, :id=>"frm_report" do %>
|
||||
<div class="row">
|
||||
<div class="col-md-12"></div>
|
||||
<div class="span3">
|
||||
<% if defined? product_account %>
|
||||
<%= select_tag "account", options_from_collection_for_select(@accounts,"id","title", :selected => params[:account])%>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
</span>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
|
||||
Reference in New Issue
Block a user