diff --git a/app/controllers/reports/bksaleitem_controller.rb b/app/controllers/reports/bksaleitem_controller.rb
new file mode 100644
index 00000000..0f91681d
--- /dev/null
+++ b/app/controllers/reports/bksaleitem_controller.rb
@@ -0,0 +1,19 @@
+class Reports::SaleitemController < BaseReportController
+ authorize_resource :class => false
+ def index
+
+ from, to, report_type = get_date_range_from_params
+
+ @sale_data = Sale.get_by_range_by_saleitems(from,to,Sale::SALE_STATUS_COMPLETED,report_type)
+
+ respond_to do |format|
+ format.html
+ format.xls
+ end
+ end
+
+ def show
+
+ end
+
+end
diff --git a/app/controllers/reports/dailysale_controller.rb b/app/controllers/reports/dailysale_controller.rb
index 14013a1b..280f497c 100644
--- a/app/controllers/reports/dailysale_controller.rb
+++ b/app/controllers/reports/dailysale_controller.rb
@@ -5,9 +5,7 @@ class Reports::DailysaleController < BaseReportController
from, to ,report_type = get_date_range_from_params
@sale_data = Sale.daily_sales_list(from,to)
@tax = SaleTax.get_tax(from,to)
- puts from
- puts to
- puts "sssssssss"
+
respond_to do |format|
format.html
format.xls
diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb
index fd203791..e71df43e 100644
--- a/app/controllers/reports/receipt_no_controller.rb
+++ b/app/controllers/reports/receipt_no_controller.rb
@@ -2,16 +2,6 @@ class Reports::ReceiptNoController < BaseReportController
authorize_resource :class => false
def index
from, to, report_type = get_date_range_from_params
- # if to.blank?
- # @shift = ShiftSale.where('shift_started_at <= ? and shift_closed_at is NULL',from).take
- # else
- # @shift = ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to).take
- # end
- # puts "2017-07-07T10:46:09.000Z - 2017-07-07T11:12:51.000Z"
- # puts "2017-06-25 17:30:00 UTC 2017-07-02 17:29:59 UTC"
-# puts params[:shift_name]
-# puts from.utc
-# puts to.utc
if params[:shift_name].to_i != 0
@shift = ShiftSale.where('shift_started_at >= ? and shift_closed_at <= ?',from,to).take
@@ -40,29 +30,23 @@ authorize_resource :class => false
def show
from, to, report_type = get_date_range_from_params
- @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
-puts "hhhhhhhhhhhhhhhhhhhhh"
-puts @sale_data.to_json
-puts from
-puts to
-puts report_type
-puts params[:shift_name]
+ @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
- str = { :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
+ 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
+ str = { :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
+ out = {:status => 'ok', :message => date_arr}
+
+ respond_to do |format|
+ format.json { render json: out }
+ end
end
diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb
index 0f91681d..80bd8b93 100644
--- a/app/controllers/reports/saleitem_controller.rb
+++ b/app/controllers/reports/saleitem_controller.rb
@@ -2,9 +2,38 @@ class Reports::SaleitemController < BaseReportController
authorize_resource :class => false
def index
- from, to, report_type = get_date_range_from_params
+ from, to, report_type = get_date_range_from_params
+ shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
- @sale_data = Sale.get_by_range_by_saleitems(from,to,Sale::SALE_STATUS_COMPLETED,report_type)
+ shift = ''
+ if to.blank?
+ shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',from)
+ else
+ shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',from, to)
+ end
+
+ @sale_data, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED, report_type)
+
+ @account_cate_count = Hash.new {|hash, key| hash[key] = 0}
+
+
+ @sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
+
+ @menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
+ @sale_data.each {|cate| @menu_cate_count[cate.menu_category_id] += 1}
+
+
+ @totalByAccount = Hash.new {|hash, key| hash[key] = 0}
+ @sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
+
+
+ if !shift.nil?
+ 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
@@ -13,7 +42,246 @@ class Reports::SaleitemController < BaseReportController
end
def show
-
+ from, to, report_type = 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
+ str = { :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
+
+ 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
diff --git a/app/models/sale.rb b/app/models/sale.rb
index 2ffa5afd..f0f068cc 100644
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -534,25 +534,25 @@ end
# .joins("join shift_sales sh on sh.id = sales.shift_sale_id")
# .where('sales.sale_status = "void" and sales.total_amount != 0 and sales.shift_sale_id = ?', shift.id)
# .sum(:grand_total)
-# cash = all_total.select('sr.payment_type')
-# .where('sr.payment_type = "cash"')
+# cash = all_total.select('sr.payment_method')
+# .where('sr.payment_method = "cash"')
# .sum(:amount)
-# credit = all_total.where('sr.payment_type = "creditnote"')
+# credit = all_total.where('sr.payment_method = "creditnote"')
# .sum(:amount)
# accept_credit = all_total.select('ci.amout')
# .joins("INNER JOIN credit_items ci ON ci.sale_id = sales.id")
-# .where('sr.payment_type = "creditnote"')
+# .where('sr.payment_method = "creditnote"')
# .sum(:amout)
-# foc = all_total.where('sales.payment_type = "foc" and sales.sale_status = "completed"')
+# foc = all_total.where('sales.payment_method = "foc" and sales.sale_status = "completed"')
# .sum(:grand_total)
-# card = all_total.select('payment_type')
-# .where('sr.payment_type = "card"')
+# card = all_total.select('payment_method')
+# .where('sr.payment_method = "card"')
# .sum(:amount).to_f
# rounding_adj = all_total.sum(:rounding_adjustment)
@@ -586,10 +586,96 @@ def self.get_by_shift_sale(from,to,status)
return query = query.where("shift_sales.shift_started_at >= ?" + " AND shift_sales.shift_closed_at <= ?", from,to)
end
-def self.get_separate_tax(from,to,payment_type=nil)
+def self.get_item_query()
+ query = Sale.select("acc.title as account_name,mi.account_id, mi.item_code as item_code, " +
+ "(SUM(i.qty * i.unit_price)) as grand_total,SUM(i.qty) as total_item," +
+ " i.unit_price as unit_price,mi.name as product_name, mc.name as" +
+ " menu_category_name,mc.id as menu_category_id ")
+
+ query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code" +
+ " JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
+ # "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ")
+
+ query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id")
+ query = query.group('i.product_code ').order("mi.account_id, mi.menu_category_id")
+ end
+
+
+ def self.get_by_shift_items(shift_sale_range, shift, from, to, status, report_type)
+
+ # date_type_selection = get_sql_function_for_report_type(report_type)
+
+ query = self.get_item_query()
+ discount_query = 0
+ total_card_amount = 0
+ total_cash_amount = 0
+ total_credit_amount = 0
+ total_foc_amount = 0
+ total_grand_total = 0
+
+ if shift == '[]'
+ ### => get all sales range in shift_sales
+ query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
+ discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
+ sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_ - sales.amount_changed) else 0 end) as card_amount,
+ SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
+ SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
+ SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
+ .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
+ .where("sales.shift_sale_id in (?) and sale_status = 'completed' ", shift_sale_range.to_a)
+ sale_cash.each do |s_c|
+ total_cash_amount += s_c.cash_amount.to_f
+ total_card_amount += s_c.card_amount.to_f
+ total_credit_amount += s_c.credit_amount.to_f
+ total_foc_amount += s_c.foc_amount.to_f
+ end
+ total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
+
+ elsif shift_sale_range == '[]'
+ query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
+ discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
+ sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
+ SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
+ SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
+ SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
+ .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
+ .where("sales.shift_sale_id in (?) and sale_status = 'completed' ", shift.to_a)
+ sale_cash.each do |s_c|
+ total_cash_amount += s_c.cash_amount.to_f
+ total_card_amount += s_c.card_amount.to_f
+ total_credit_amount += s_c.credit_amount.to_f
+ total_foc_amount += s_c.foc_amount.to_f
+ end
+ total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
+
+ else
+ query = query.where("receipt_date between ? and ? and sale_status=?",from,to,'completed')
+ sale_cash = Sale.select("sales.total_discount as total_discount,
+ SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
+ SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
+ SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
+ SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
+ .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
+ .where("sales.shift_sale_id in (?) and sale_status = 'completed' ", shift.to_a)
+
+ sale_cash.each do |s_c|
+ total_cash_amount += s_c.cash_amount.to_f
+ total_card_amount += s_c.card_amount.to_f
+ total_credit_amount += s_c.credit_amount.to_f
+ total_foc_amount += s_c.foc_amount.to_f
+ discount_query = s_c.total_discount.to_f
+ end
+ total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
+
+ end
+
+ return query, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total
+ end
+
+def self.get_separate_tax(from,to,payment_method=nil)
query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
- .joins("INNER JOIN sales ON sales.id = sale_taxes.sale_id")
+ .joins("INNER JOIN sales ON sales.sale_id = sale_taxes.sale_id")
.group("sale_taxes.tax_name")
return query = query.where("sale_status=? and receipt_date between ? and ?","completed",from,to)
diff --git a/app/views/reports/saleitem (copy)/_shift_sale_report_filter.html.erb b/app/views/reports/saleitem (copy)/_shift_sale_report_filter.html.erb
new file mode 100644
index 00000000..c57c8be9
--- /dev/null
+++ b/app/views/reports/saleitem (copy)/_shift_sale_report_filter.html.erb
@@ -0,0 +1,194 @@
+
+
+ <%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
+ <% if period_type != false %>
+
+
+ Select Period
+
+ Today
+ Yesterday
+ This week
+ Last week
+ Last 7 days
+ This month
+ Last month
+ Last 30 days
+ This year
+ Last year
+
+
+
+
+
+
+ From
+
+
+
+ To
+
+
+
+
+
+
+ <% end %>
+
+
+
+
+
+ <% if defined? promotions %>
+ <%= select_tag "promotion", options_for_select(@promotions, :selected => params[:promotion_type]), :class => "form-control" %>
+ <% end %>
+
+ <% if defined? menu_types %>
+ <%= select_tag "menu_type", options_for_select(@menu_types, :selected => params[:menu_type]), :class => "form-control" %>
+ <% end %>
+
+ <% if defined? payments %>
+ <%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %>
+ <% end %>
+
+ <% if defined? shift_name %>
+
+ <% end %>
+
+ <% if defined? cashiers %>
+ <%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations", :class => "form-control" %>
+ <% end %>
+
+ <% if defined? singer %>
+ <%= select_tag "singer", options_from_collection_for_select(singer,"id","name"),:prompt => "All Vocal List", :class => "form-control" %>
+ <% end %>
+
+ <% if defined? bsm %>
+ <%= select_tag "singer", options_from_collection_for_select(bsm,"id","name"),:prompt => "All BSM List", :class => "form-control" %>
+ <% end %>
+
+ <% if defined? guest_role %>
+ <%= select_tag "guest_role", options_from_collection_for_select(@guest_role,"id","name"),:prompt => "Vocal/BSM List", :class => "form-control" %>
+ <% end %>
+
+ <% if defined? list_by_payment_type %>
+ <%= select_tag "payment_type_list", options_for_select(@payment_list, :selected => params[:payment_type_list]), :class => "form-control" %>
+ <% end %>
+
+ <% if defined? products %>
+ <%= select_tag "product", options_from_collection_for_select(@products,"id","name"),:prompt => "All Products", :class => "form-control" %>
+ <% end %>
+
+ <% if defined? items %>
+ <%= select_tag "item", options_for_select(@items, :selected => params[:item_type]), :class => "form-control" %>
+ <% end %>
+
+
+
+
+
+ <% end %>
+
+
+
\ No newline at end of file
diff --git a/app/views/reports/saleitem (copy)/index.html.erb b/app/views/reports/saleitem (copy)/index.html.erb
new file mode 100644
index 00000000..b6482271
--- /dev/null
+++ b/app/views/reports/saleitem (copy)/index.html.erb
@@ -0,0 +1,141 @@
+
+
+
+ <%= render :partial=>'shift_sale_report_filter',
+ :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_saleitem_index_path} %>
+
+
+
+
+
+
+
+
+
+
+
+ Date
+
+
+
+ Menu Category
+ Code
+ Product
+ Total Item
+ Unit Price
+ Revenue
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/reports/saleitem (copy)/index.xls.erb b/app/views/reports/saleitem (copy)/index.xls.erb
new file mode 100644
index 00000000..3773619b
--- /dev/null
+++ b/app/views/reports/saleitem (copy)/index.xls.erb
@@ -0,0 +1,104 @@
+
+
+
+
+
+
+
+
+<% unless @sale_data.blank? %>
+
+
+
+
+ <% if !params[:from].blank?%>
+
+ From Date : <%= params[:from] %> , To Date : <%= params[:to] %>
+
+ <% end %>
+ <% if @shift_from %>
+
+ <% if @shift_data.employee %>
+ <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
+ <% end %>
+ Shift Name = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )
+
+ <% end %>
+
+
+ Menu Category
+ Code
+ Product
+ Total Item
+ Unit Price
+ Revenue
+
+
+
+
+ <% acc_arr = Array.new %>
+ <% cate_arr = Array.new %>
+
+ <% sub_total = 0.0 %>
+ <% count = 0%>
+ <% total_price = 0.0 %>
+ <% cate_count = 0 %>
+ <% acc_count = 0%>
+ <% grand_total = 0%>
+ <% total_discount = 0.0 %>
+
+ <% @sale_data.order("total_item desc").each do |sale| %>
+
+
+
+ <% if !cate_arr.include?(sale.menu_category_id) %>
+ <%= sale.menu_category_name %>
+ <% cate_arr.push(sale.menu_category_id) %>
+ <% else %>
+
+ <% end %>
+ <%= sale.code rescue '-' %>
+ <% if @item_table == 'sale' %>
+ <% if sale.item_remark == 'FOC' %>
+ <%= '[PROMO] '.to_s + sale.product_name.to_s rescue '-' %>
+ <% elsif sale.item_remark == 'FOC ITEM' %>
+ <%= '[DIS:QTY] '.to_s + sale.product_name.to_s rescue '-' %>
+ <% elsif sale.item_remark == 'DISCOUNT' %>
+ <%= '[DIS:TP] '.to_s + sale.product_name.to_s rescue '-' %>
+ <% else %>
+ <%= sale.product_name.to_s rescue '-' %>
+ <% end %>
+ <% if sale.item_remark == 'DISCOUNT' %>
+ -
+ -
+ <%= sale.total_price.abs rescue '-' %>
+ <% total_price += sale.total_price %>
+ <% else %>
+ <%= sale.total_item.abs rescue '-' %>
+ <%= sale.unit_price rescue '-' %>
+ <%= sale.grand_total.abs rescue '-' %>
+ <% end %>
+ <% else %>
+ <%= sale.product_name.to_s rescue '-' %>
+ <%= sale.total_item.abs rescue '-' %>
+ <%= sale.unit_price rescue '-' %>
+ <%= sale.grand_total.abs rescue '-' %>
+ <% end %>
+
+
+
+
+
+ <% grand_total += sale.grand_total%>
+ <% end %>
+
+
+ Grand Total
+ <%= grand_total + total_discount %>
+
+
+
+<% end %>
+
+
+
\ No newline at end of file
diff --git a/app/views/reports/saleitem/_shift_sale_report_filter.html.erb b/app/views/reports/saleitem/_shift_sale_report_filter.html.erb
index c57c8be9..5c8c47b1 100644
--- a/app/views/reports/saleitem/_shift_sale_report_filter.html.erb
+++ b/app/views/reports/saleitem/_shift_sale_report_filter.html.erb
@@ -18,7 +18,7 @@
Last year
-
+
+ <% @menu_cate_count.each do |key,value| %>
+ <% if sale.menu_category_id == key %>
+
+ <% count = count + 1 %>
+ <% sub_total += sale.grand_total %>
+ <% if count == value %>
+
+
+ Sub Total
+ <%= sub_total %>
+
+
+ <% sub_total = 0.0%>
+ <% count = 0%>
+ <% end %>
+ <% end %>
+ <% end %>
+
+
+
+ <% end %>
+
+
+
+ Total Item
+ <%= total_qty%>
+ Total Amount
+ <%= grand_total%>
+
+ <% end %>
+
+
+
+
+
+
+
-
\ No newline at end of file