update reports

This commit is contained in:
Aung Myo
2017-07-17 12:11:21 +06:30
parent 25ef380b4f
commit bd0b8681c9
3 changed files with 144 additions and 318 deletions

View File

@@ -66,226 +66,5 @@ class Reports::SaleitemController < BaseReportController
format.json { render json: out }
end
end
# def get_date_range_from_params
# period_type = params[:period_type]
# period = params[:period]
# from = params[:from]
# to = params[:to]
# branch = params[:branch]
# report_type = params[:report_type]
# shift_name = params[:shift_name]
# unless shift_name.nil?
# shift_arr = shift_name.split(' - ')
# shift_from = shift_arr[0]
# shift_to = shift_arr[1]
# end
# day_ref = Time.now
# if period_type.to_i == 1
# ### =>search by from and to
# unless shift_name.nil?
# if shift_name.to_s == '0'
# ### => all shift
# #f_date = DateTime.parse(from)
# #t_date = DateTime.parse(to)
# if params[:from] && params[:to]
# if params[:from] != "" && params[:to] !=""
# f_date = DateTime.strptime(from, "%m/%d/%Y")
# t_date = DateTime.strptime(to, "%m/%d/%Y")
# 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
# to = t_time.end_of_day.utc
# end
# else
# from = day_ref.beginning_of_day.utc
# to = day_ref.end_of_day.utc
# end
# else
# unless shift_from == '-'
# f_date = DateTime.parse(shift_from)
# from = f_date
# else
# from = ''
# end
# unless shift_to == '-'
# t_date = DateTime.parse(shift_to)
# to = t_date
# else
# to = ''
# end
# end
# else
# # f_date = DateTime.parse(from)
# # t_date = DateTime.parse(to)
# if params[:from] && params[:to]
# if params[:from] != "" && params[:to] !=""
# f_date = DateTime.strptime(from, "%m/%d/%Y")
# t_date = DateTime.strptime(to, "%m/%d/%Y")
# 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
# to = t_time.end_of_day.utc
# end
# else
# from = day_ref.beginning_of_day.utc
# to = day_ref.end_of_day.utc
# end
# end
# else
# ### => search by Today or yesterday
# unless shift_name.nil?
# if shift_name.to_s == '0'
# ### => all shift
# 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
# else
# unless shift_from == '-'
# f_date = DateTime.parse(shift_from)
# # f_date = DateTime.strptime(shift_from, "%m/%d/%Y")
# #f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
# from = f_date
# else
# from = ''
# end
# unless shift_to == '-'
# t_date = DateTime.parse(shift_to)
# # t_date = DateTime.strptime(shift_to, "%m/%d/%Y")
# #t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
# to = t_date
# else
# to = ''
# end
# end
# else
# if params[:report_type].to_i != 0
# r_type = params[:report_type].to_s
# if r_type == 'shift_item'
# 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
# else
# ### => report not shift
# 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
# end
# end
# return from, to,report_type
# end
end