stock_check report template
This commit is contained in:
50
app/controllers/reports/stock_check_controller.rb
Normal file
50
app/controllers/reports/stock_check_controller.rb
Normal file
@@ -0,0 +1,50 @@
|
||||
class Reports::StockCheckController < BaseReportController
|
||||
# authorize_resource :class => false
|
||||
|
||||
def index
|
||||
from_date = DateTime.now.beginning_of_day.utc.getlocal
|
||||
to_date = DateTime.now.end_of_day.utc.getlocal
|
||||
unless params[:daterange].blank?
|
||||
from_date = Date.parse(params[:daterange].split(' - ')[0]).beginning_of_day.utc.getlocal
|
||||
to_date = Date.parse(params[:daterange].split(' - ')[1]).end_of_day.utc.getlocal
|
||||
@daterange = params[:daterange]
|
||||
end
|
||||
commissioner = params[:commissioner].to_i
|
||||
@com_id = commissioner
|
||||
@commissioner = Commissioner.active.all
|
||||
@inventory_definitions = InventoryDefinition.active.all
|
||||
|
||||
@transaction = ProductCommission.get_transaction(from_date, to_date, commissioner)
|
||||
@from = from_date
|
||||
@to = to_date
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
|
||||
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
|
||||
shift_id = sale.id.nil? ? '-' : sale.id
|
||||
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
|
||||
date_arr.push(str)
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user