73 lines
3.1 KiB
Ruby
73 lines
3.1 KiB
Ruby
class Reports::OrderReservationController < BaseReportController
|
|
# authorize_resource :class => false
|
|
def index
|
|
@providers = [["All",''], ["Direct Delivery","direct_delivery"],["Pick-Up","pick_up"],["TURBO","turbo"],["food2u","food2u"], ["ygndoor2door","ygndoor2door"]]
|
|
@payment_types = [["All",''], ["COD","cash_on_delivery"],["DINGA","dinga"]]
|
|
|
|
from, to = get_date_range_from_params
|
|
|
|
@shift_sale_range = ''
|
|
|
|
@shift = ''
|
|
if params[:shift_name].to_i != 0
|
|
|
|
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
|
|
|
shift_sale = ShiftSale.find(params[:shift_name])
|
|
if to.blank?
|
|
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
|
|
else
|
|
if shift_sale.shift_closed_at.blank?
|
|
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
|
|
else
|
|
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
|
end
|
|
end
|
|
end
|
|
|
|
provider = params[:provider]
|
|
payment_type = params[:payment_type]
|
|
@order_reservation_data = OrderReservation.get_order_reservation_by_shift(@shift_sale_range,@shift,from,to,provider,payment_type).where("sales.shop_code='#{@shop.shop_code}'")
|
|
@from = from
|
|
@to = to
|
|
# get printer info
|
|
@print_settings = PrintSetting.get_precision_delimiter()
|
|
if @shift.present?
|
|
@shift.each do |sh|
|
|
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
|
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
|
@shift_data = sh
|
|
end
|
|
end
|
|
|
|
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_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
|
|
|
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
|