pull from master
This commit is contained in:
@@ -196,7 +196,7 @@ $(document).on('turbolinks:load', function() {
|
||||
|
||||
$(document).on('click', '.access_modal', function(event){
|
||||
type = $(this).data("type");
|
||||
$(".ok").attr("data-action",type)
|
||||
$(".ok").attr("data-action",type);
|
||||
$('#AccessCodeModal').modal('show');
|
||||
});
|
||||
|
||||
|
||||
@@ -110,8 +110,8 @@ class HomeController < ApplicationController
|
||||
else
|
||||
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
end
|
||||
@top_products = Sale.top_products(today,current_user,@from,@to,@from_time,@to_time).sum('i.qty')
|
||||
@bottom_products = Sale.bottom_products(today,current_user,@from,@to,@from_time,@to_time).sum('i.qty')
|
||||
@top_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"top").sum('i.qty')
|
||||
@bottom_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"bottom").sum('i.qty')
|
||||
@hourly_sales = Sale.hourly_sales(today,current_user,@from,@to,@from_time,@to_time).sum(:grand_total)
|
||||
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
|
||||
# .sum(:grand_total)
|
||||
@@ -119,17 +119,15 @@ class HomeController < ApplicationController
|
||||
.sum('(CASE WHEN sp.payment_method="cash" THEN (sp.payment_amount - sales.amount_changed) ELSE sp.payment_amount END)')
|
||||
@inventories = StockJournal.inventory_balances(today,@from,@to,@from_time,@to_time).sum(:balance)
|
||||
|
||||
@total_sale = Sale.total_sale(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_count = Sale.total_count(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_card = Sale.total_card_sale(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_credit = Sale.credit_payment(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_trans = Sale.total_trans(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_payment_trans = Sale.total_payment_trans(today,current_user,@from,@to,@from_time,@to_time)
|
||||
|
||||
@sale_data = Array.new
|
||||
@total_payment_methods = Sale.total_payment_methods(today,current_user,@from,@to,@from_time,@to_time)
|
||||
|
||||
if !@total_payment_methods.nil?
|
||||
@total_payment_methods.each do |payment|
|
||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay" || payment.payment_method == "alipay" || payment.payment_method == "paymal" || payment.payment_method == "dinga" || payment.payment_method == "JunctionPay"
|
||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay" || payment.payment_method == "alipay"
|
||||
pay = Sale.payment_sale('card', today, current_user,@from,@to,@from_time,@to_time)
|
||||
@sale_data.push({'card' => pay.payment_amount})
|
||||
else
|
||||
@@ -139,11 +137,8 @@ class HomeController < ApplicationController
|
||||
end
|
||||
end
|
||||
@summ_sale = Sale.summary_sale_receipt(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_customer = Sale.total_customer(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_dinein = Sale.total_dinein(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_takeaway = Sale.total_takeaway(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_other_customer = Sale.total_other_customer(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_membership = Sale.total_membership(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(today,current_user,@from,@to,@from_time,@to_time)
|
||||
# @total_other_customer = Sale.total_other_customer(today,current_user)
|
||||
|
||||
@total_order = Sale.total_order(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_accounts = Sale.total_account(today,current_user,@from,@to,@from_time,@to_time)
|
||||
|
||||
@@ -3,8 +3,6 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
def index
|
||||
@shop = Shop.first
|
||||
|
||||
|
||||
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
# @orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
# @sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
@@ -18,16 +16,18 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
# .sum('(CASE WHEN sp.payment_method="cash" THEN (sp.payment_amount - sales.amount_changed) ELSE sp.payment_amount END)')
|
||||
# @inventories = StockJournal.inventory_balances(today).sum(:balance)
|
||||
|
||||
@total_sale = Sale.total_sale(today,current_user)
|
||||
@total_count = Sale.total_count(today,current_user)
|
||||
@total_card = Sale.total_card_sale(today,current_user)
|
||||
@total_credit = Sale.credit_payment(today,current_user)
|
||||
# @total_sale = Sale.total_sale(today,current_user)
|
||||
# @total_count = Sale.total_count(today,current_user)
|
||||
# @total_card = Sale.total_card_sale(today,current_user)
|
||||
# @total_credit = Sale.credit_payment(today,current_user)
|
||||
|
||||
@display_type = Lookup.find_by_lookup_type("display_type")
|
||||
|
||||
@sale_data = Array.new
|
||||
@total_payment_methods = Sale.total_payment_methods(today,current_user)
|
||||
if !@total_payment_methods.nil?
|
||||
@total_payment_methods.each do |payment|
|
||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb"
|
||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay" || payment.payment_method == "alipay"
|
||||
pay = Sale.payment_sale('card', today, current_user)
|
||||
@sale_data.push({'card' => pay.payment_amount})
|
||||
else
|
||||
@@ -39,11 +39,8 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
@sale_data = nil
|
||||
end
|
||||
@summ_sale = Sale.summary_sale_receipt(today,current_user)
|
||||
@total_customer = Sale.total_customer(today,current_user)
|
||||
@total_dinein = Sale.total_dinein(today,current_user)
|
||||
@total_takeaway = Sale.total_takeaway(today,current_user)
|
||||
@total_other_customer = Sale.total_other_customer(today,current_user)
|
||||
@total_membership = Sale.total_membership(today,current_user)
|
||||
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(today,current_user,@from,@to,@from_time,@to_time)
|
||||
# @total_other_customer = Sale.total_other_customer(today,current_user)
|
||||
|
||||
@total_order = Sale.total_order(today,current_user)
|
||||
@total_accounts = Sale.total_account(today,current_user)
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
class Origami::InDutiesController < BaseOrigamiController
|
||||
before_action :set_in_duty, only: %i[show edit update edit_in_duty update_for_in_duty destroy destroy_in_duty]
|
||||
# GET /in_duties
|
||||
# GET /in_duties.json
|
||||
def index
|
||||
@in_duties = InDuty.all
|
||||
end
|
||||
|
||||
def index_in_duty
|
||||
@duty_in = InDuty.where('dinning_id=?', params[:table_id])
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
@sale_id = params[:sale_id]
|
||||
booking = Booking.where("sale_id=?",@sale_id).first
|
||||
@booking_id = booking.booking_id
|
||||
@duty_in = InDuty.where('dinning_id=? and sale_id=?', booking.dining_facility_id, @sale_id)
|
||||
@table = DiningFacility.find(booking.dining_facility_id)
|
||||
@in_duty = InDuty.new
|
||||
@duties_in = Kaminari.paginate_array(@duty_in).page(params[:page]).per(10)
|
||||
end
|
||||
@@ -31,11 +29,14 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
|
||||
def edit_in_duty
|
||||
@in_duty = InDuty.find(params[:id])
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
@sale_id = params[:sale_id]
|
||||
booking = Booking.where("sale_id=?",@sale_id).first
|
||||
@booking_id = booking.booking_id
|
||||
@table = DiningFacility.find(booking.dining_facility_id)
|
||||
@commissioner = @in_duty.commissioner
|
||||
|
||||
# render json: {in_duty: @in_duty, commissioner: @commissioner}
|
||||
render partial: 'form'
|
||||
render json: {in_duty: @in_duty, commissioner: @commissioner}
|
||||
# render partial: 'form'
|
||||
end
|
||||
|
||||
def assign_in_duty
|
||||
@@ -45,20 +46,6 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
|
||||
# POST /in_duties
|
||||
# POST /in_duties.json
|
||||
def create
|
||||
@in_duty = InDuty.new(in_duty_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @in_duty.save
|
||||
format.html { redirect_to origami_in_duties_path, notice: 'In duty was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @in_duty }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @in_duty.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create_for_in_duty
|
||||
# this one use for create and update
|
||||
in_duty = in_duty_params
|
||||
@@ -66,8 +53,8 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
# in_time = in_time.change(offset: '+06:30')
|
||||
# out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i
|
||||
# out_time = out_time.change(offset: '+06:30')
|
||||
puts in_duty.to_json
|
||||
puts "sssssssssssssssssss"
|
||||
# puts in_duty.to_json
|
||||
# puts "sssssssssssssssssss"
|
||||
@in_duty = InDuty.new
|
||||
in_duty_id = in_duty[:id]
|
||||
unless in_duty_id.empty?
|
||||
@@ -75,6 +62,8 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
end
|
||||
|
||||
@in_duty.dinning_id = in_duty_params[:dinning_id]
|
||||
@in_duty.booking_id = in_duty_params[:booking_id]
|
||||
@in_duty.sale_id = in_duty_params[:sale_id]
|
||||
@in_duty.commissioner_ids = in_duty_params[:commissioner_ids]
|
||||
@in_duty.in_time = in_duty['in_time']
|
||||
@in_duty.out_time = in_duty['out_time']
|
||||
@@ -97,38 +86,18 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
|
||||
# PATCH/PUT /in_duties/1
|
||||
# PATCH/PUT /in_duties/1.json
|
||||
def update
|
||||
in_duty = in_duty_params
|
||||
in_time = DateTime.new in_duty['in_time(1i)'].to_i, in_duty['in_time(2i)'].to_i, in_duty['in_time(3i)'].to_i, in_duty['in_time(4i)'].to_i, in_duty['in_time(5i)'].to_i
|
||||
in_time = in_time.change(offset: '+06:30')
|
||||
out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i
|
||||
out_time = out_time.change(offset: '+06:30')
|
||||
@in_duty.commissioner_ids = in_duty_params[:commissioner_ids]
|
||||
@in_duty.in_time = in_time
|
||||
@in_duty.out_time = out_time
|
||||
respond_to do |format|
|
||||
if @in_duty.save
|
||||
format.html { redirect_to origami_index_in_duty_path(in_duty_params[:dinning_id]), notice: 'In duty was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @in_duty }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @in_duty.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update_for_in_duty
|
||||
in_duty = in_duty_params
|
||||
in_time = DateTime.new in_duty['in_time(1i)'].to_i, in_duty['in_time(2i)'].to_i, in_duty['in_time(3i)'].to_i, in_duty['in_time(4i)'].to_i, in_duty['in_time(5i)'].to_i
|
||||
in_time = in_time.change(offset: '+06:30')
|
||||
out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i
|
||||
out_time = out_time.change(offset: '+06:30')
|
||||
# in_time = DateTime.new in_duty['in_time(1i)'].to_i, in_duty['in_time(2i)'].to_i, in_duty['in_time(3i)'].to_i, in_duty['in_time(4i)'].to_i, in_duty['in_time(5i)'].to_i
|
||||
# in_time = in_time.change(offset: '+06:30')
|
||||
# out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i
|
||||
# out_time = out_time.change(offset: '+06:30')
|
||||
@in_duty.commissioner_ids = in_duty_params[:commissioner_ids]
|
||||
@in_duty.in_time = in_time
|
||||
@in_duty.out_time = out_time
|
||||
@in_duty.in_time = in_duty_params[:in_time]
|
||||
@in_duty.out_time = in_duty_params[:out_time]
|
||||
respond_to do |format|
|
||||
if @in_duty.save
|
||||
format.html { redirect_to origami_index_in_duty_path(in_duty_params[:dinning_id]), notice: 'In duty was successfully updated.' }
|
||||
format.html { redirect_to origami_index_in_duty_path(in_duty_params[:sale_id]), notice: 'In duty was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @in_duty }
|
||||
else
|
||||
format.html { render :edit }
|
||||
@@ -139,22 +108,15 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
|
||||
# DELETE /in_duties/1
|
||||
# DELETE /in_duties/1.json
|
||||
def destroy
|
||||
@in_duty.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to origami_in_duties_path, notice: 'In duty was successfully removed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
def destroy_in_duty
|
||||
@table_id = params[:table_id]
|
||||
@sale_id = params[:sale_id]
|
||||
booking = Booking.where("sale_id=?",@sale_id).first
|
||||
@booking_id = booking.booking_id
|
||||
@in_duty.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to origami_index_in_duty_path, notice: 'In duty was successfully removed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
flash[:notice] = 'In duty was successfully destroyed.'
|
||||
render :json => {:status=> "Success", :url => origami_index_in_duty_path }.to_json
|
||||
end
|
||||
|
||||
private
|
||||
@@ -166,7 +128,7 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def in_duty_params
|
||||
params.require(:in_duty).permit(:id, :dinning_id, :commissioner_ids, :in_time, :out_time)
|
||||
params.require(:in_duty).permit(:id, :dinning_id, :booking_id, :sale_id, :commissioner_ids, :in_time, :out_time)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
66
app/controllers/reports/induty_controller.rb
Normal file
66
app/controllers/reports/induty_controller.rb
Normal file
@@ -0,0 +1,66 @@
|
||||
class Reports::IndutyController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
@commissioners = Commissioner.all #.where("is_active='1'")
|
||||
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
@shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
else
|
||||
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
|
||||
@commissioner = params[:commissioner]
|
||||
@induty_data = InDuty.get_induty_by_shift(@shift_sale_range,@shift,from,to,@commissioner)
|
||||
|
||||
@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
|
||||
|
||||
@induty_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
@commissioner = params[:commissioner]
|
||||
|
||||
date_arr = Array.new
|
||||
@induty_data.each do |induty|
|
||||
local_opening_date = induty.opening_date.nil? ? '-' : induty.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
local_closing_date = induty.closing_date.nil? ? '-' : induty.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
opening_date = induty.opening_date.nil? ? '-' : induty.opening_date.utc
|
||||
closing_date = induty.closing_date.nil? ? '-' : induty.closing_date.utc
|
||||
shift_id = induty.id.nil? ? '-' : induty.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
|
||||
@@ -1,4 +1,34 @@
|
||||
class InDuty < ApplicationRecord
|
||||
belongs_to :dining_facility, foreign_key: 'dinning_id'
|
||||
belongs_to :commissioner, foreign_key: 'commissioner_ids'
|
||||
|
||||
def self.get_induty_by_shift(shift_sale_range,shift,from,to,commissioner)
|
||||
## => left join -> show all sales although no orders
|
||||
if commissioner.blank?
|
||||
commissioner = ''
|
||||
else
|
||||
if commissioner.present?
|
||||
commissioner = " and CAST(in_duties.commissioner_ids AS SIGNED INTEGER) = #{commissioner}"
|
||||
end
|
||||
end
|
||||
|
||||
query = InDuty.select("in_duties.*,sales.receipt_no, commissioners.name,dining_facilities.name as dining_name")
|
||||
.joins(" LEFT JOIN commissioners on commissioners.id = CAST(in_duties.commissioner_ids AS SIGNED INTEGER)")
|
||||
.joins(" LEFT JOIN dining_facilities on dining_facilities.id = in_duties.dinning_id")
|
||||
.joins(" JOIN sales on sales.sale_id = in_duties.sale_id")
|
||||
if shift.present?
|
||||
query = query.where("sales.shift_sale_id in (?) #{commissioner} and sales.sale_status= 'completed' and sale_payments.payment_amount != 0", shift.to_a)
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.group("sales.sale_id, in_duties.commissioner_ids")
|
||||
elsif shift_sale_range.present?
|
||||
query = query.where("sales.sale_status='completed' #{commissioner} and sale_payments.payment_amount != 0 and sales.shift_sale_id in (?)",shift_sale_range.to_a)
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.group("sales.sale_id, in_duties.commissioner_ids")
|
||||
else
|
||||
query = query.where("sales.sale_status='completed' and sales.receipt_date between ? and ? #{commissioner} and sale_payments.payment_amount != 0",from,to)
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.group("sales.sale_id, in_duties.commissioner_ids")
|
||||
end
|
||||
return query
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1256,7 +1256,7 @@ end
|
||||
return tax
|
||||
end
|
||||
|
||||
def self.top_products(today,current_user,from,to,from_time,to_time)
|
||||
def self.top_bottom_products(today,current_user,from,to,from_time,to_time,type)
|
||||
if !from.nil? && !to.nil?
|
||||
if current_user.nil?
|
||||
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
||||
@@ -1269,8 +1269,13 @@ end
|
||||
query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+
|
||||
" and sale_status= 'completed'")
|
||||
end
|
||||
if type == "top"
|
||||
query = query.group('mi.name')
|
||||
.order("SUM(i.qty) DESC").limit(20)
|
||||
elsif type == "bottom"
|
||||
query = query.group('mi.name')
|
||||
.order("SUM(i.qty) ASC").limit(20)
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
||||
@@ -1283,8 +1288,13 @@ end
|
||||
query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+
|
||||
" and sale_status= 'completed'")
|
||||
end
|
||||
if type == "top"
|
||||
query = query.group('mi.name')
|
||||
.order("SUM(i.qty) DESC").limit(20)
|
||||
elsif type == "bottom"
|
||||
query = query.group('mi.name')
|
||||
.order("SUM(i.qty) ASC").limit(20)
|
||||
end
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
@@ -1298,8 +1308,13 @@ end
|
||||
query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+
|
||||
" and sale_status= 'completed' and shift_sale_id='#{shift.id}'")
|
||||
end
|
||||
if type == "top"
|
||||
query = query.group('mi.name')
|
||||
.order("SUM(i.qty) DESC").limit(20)
|
||||
elsif type == "bottom"
|
||||
query = query.group('mi.name')
|
||||
.order("SUM(i.qty) ASC").limit(20)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1311,7 +1326,11 @@ end
|
||||
.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+
|
||||
" and sale_status= 'completed'")
|
||||
.group('mi.name')
|
||||
.order("SUM(i.qty) DESC").limit(20)
|
||||
if type == "top"
|
||||
query = query.order("SUM(i.qty) DESC").limit(20)
|
||||
elsif type == "bottom"
|
||||
query = query.order("SUM(i.qty) ASC").limit(20)
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
||||
@@ -1320,7 +1339,11 @@ end
|
||||
.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+
|
||||
" and sale_status= 'completed'")
|
||||
.group('mi.name')
|
||||
.order("SUM(i.qty) DESC").limit(20)
|
||||
if type == "top"
|
||||
query = query.order("SUM(i.qty) DESC").limit(20)
|
||||
elsif type == "bottom"
|
||||
query = query.order("SUM(i.qty) ASC").limit(20)
|
||||
end
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
@@ -1330,92 +1353,15 @@ end
|
||||
.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+
|
||||
" and sale_status= 'completed' and shift_sale_id='#{shift.id}'")
|
||||
.group('mi.name')
|
||||
.order("SUM(i.qty) DESC").limit(20)
|
||||
if type == "top"
|
||||
query = query.order("SUM(i.qty) DESC").limit(20)
|
||||
elsif type == "bottom"
|
||||
query = query.order("SUM(i.qty) ASC").limit(20)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.bottom_products(today,current_user,from,to,from_time,to_time)
|
||||
if !from.nil? && !to.nil?
|
||||
if current_user.nil?
|
||||
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
||||
" i.price as unit_price,mi.name as product_name")
|
||||
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+
|
||||
" and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}' and sale_status= 'completed'")
|
||||
else
|
||||
query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+
|
||||
" and sale_status= 'completed'")
|
||||
end
|
||||
query = query.group('mi.name')
|
||||
.order("SUM(i.qty) ASC").limit(20)
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
||||
" i.price as unit_price,mi.name as product_name")
|
||||
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+
|
||||
" and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}' and sale_status= 'completed'")
|
||||
else
|
||||
query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+
|
||||
" and sale_status= 'completed'")
|
||||
end
|
||||
query = query.group('mi.name')
|
||||
.order("SUM(i.qty) ASC").limit(20)
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
||||
" i.price as unit_price,mi.name as product_name")
|
||||
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+
|
||||
" and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}' and sale_status= 'completed' and shift_sale_id='#{shift.id}'")
|
||||
else
|
||||
query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30') between '#{from}' and '#{to}'"+
|
||||
" and sale_status= 'completed' and shift_sale_id='#{shift.id}'")
|
||||
end
|
||||
query = query.group('mi.name')
|
||||
.order("SUM(i.qty) ASC").limit(20)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if current_user.nil?
|
||||
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
||||
" i.price as unit_price,mi.name as product_name")
|
||||
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
|
||||
.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+
|
||||
"and sale_status= 'completed'")
|
||||
.group('mi.name')
|
||||
.order("SUM(i.qty) ASC").limit(20)
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
||||
" i.price as unit_price,mi.name as product_name")
|
||||
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
|
||||
.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+
|
||||
"and sale_status= 'completed'")
|
||||
.group('mi.name')
|
||||
.order("SUM(i.qty) ASC").limit(20)
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
||||
" i.price as unit_price,mi.name as product_name")
|
||||
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
|
||||
.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+
|
||||
" and sale_status= 'completed' and shift_sale_id=#{shift.id}")
|
||||
.group('mi.name')
|
||||
.order("SUM(i.qty) ASC").limit(20)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.hourly_sales(today,current_user,from,to,from_time,to_time)
|
||||
@@ -1544,207 +1490,102 @@ end
|
||||
end
|
||||
end
|
||||
|
||||
def self.total_sale(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
def self.total_trans(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
if !from.nil? && !to.nil?
|
||||
if current_user.nil?
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time).sum("grand_total")
|
||||
total = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count").where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time)
|
||||
else
|
||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to).sum("grand_total")
|
||||
total = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count").where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to)
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time).sum("grand_total")
|
||||
total = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count").where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time)
|
||||
else
|
||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to).sum("grand_total")
|
||||
total = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count").where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to)
|
||||
end
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and shift_sale_id=?',from,to,from_time,to_time,shift.id)
|
||||
.sum("grand_total")
|
||||
total = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count").where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and shift_sale_id=?',from,to,from_time,to_time,shift.id)
|
||||
else
|
||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id=?',from,to,shift.id)
|
||||
.sum("grand_total")
|
||||
total = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count").where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id=?',from,to,shift.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if current_user.nil?
|
||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today).sum("grand_total")
|
||||
total = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count").where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today)
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today).sum("grand_total")
|
||||
total = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count").where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today)
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id=?',today,today,shift.id)
|
||||
.sum("grand_total")
|
||||
total = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count").where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id=?',today,today,shift.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.total_count(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
def self.total_payment_trans(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
if !from.nil? && !to.nil?
|
||||
if current_user.nil?
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time).count
|
||||
query = Sale.select('(CASE WHEN (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") THEN SUM(sp.payment_amount) ELSE 0 END) as total_card, (CASE WHEN (sp.payment_method="creditnote") THEN SUM(sp.payment_amount) ELSE 0 END) as total_credit')
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time)
|
||||
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
else
|
||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ?',from,to).count
|
||||
query = Sale.select('(CASE WHEN (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") THEN SUM(sp.payment_amount) ELSE 0 END) as total_card, (CASE WHEN (sp.payment_method="creditnote") THEN SUM(sp.payment_amount) ELSE 0 END) as total_credit')
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to)
|
||||
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time).count
|
||||
query = Sale.select('(CASE WHEN (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") THEN SUM(sp.payment_amount) ELSE 0 END) as total_card, (CASE WHEN (sp.payment_method="creditnote") THEN SUM(sp.payment_amount) ELSE 0 END) as total_credit')
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time)
|
||||
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
else
|
||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ?',from,to).count
|
||||
query = Sale.select('(CASE WHEN (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") THEN SUM(sp.payment_amount) ELSE 0 END) as total_card, (CASE WHEN (sp.payment_method="creditnote") THEN SUM(sp.payment_amount) ELSE 0 END) as total_credit')
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to)
|
||||
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
end
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%H:%i") between ? and ? and shift_sale_id = ?',from,to,from_time,to_time,shift.id).count
|
||||
query = Sale.select('(CASE WHEN (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") THEN SUM(sp.payment_amount) ELSE 0 END) as total_card, (CASE WHEN (sp.payment_method="creditnote") THEN SUM(sp.payment_amount) ELSE 0 END) as total_credit')
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and shift_sale_id=?',from,to,from_time,to_time,shift.id)
|
||||
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
else
|
||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id = ?',from,to,shift.id).count
|
||||
query = Sale.select('(CASE WHEN (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") THEN SUM(sp.payment_amount) ELSE 0 END) as total_card, (CASE WHEN (sp.payment_method="creditnote") THEN SUM(sp.payment_amount) ELSE 0 END) as total_credit')
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id=?',from,to,shift.id)
|
||||
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if current_user.nil?
|
||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ?',today,today).count
|
||||
query = Sale.select('(CASE WHEN (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") THEN SUM(sp.payment_amount) ELSE 0 END) as total_card, (CASE WHEN (sp.payment_method="creditnote") THEN SUM(sp.payment_amount) ELSE 0 END) as total_credit')
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today)
|
||||
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ?',today,today).count
|
||||
query = Sale.select('(CASE WHEN (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") THEN SUM(sp.payment_amount) ELSE 0 END) as total_card, (CASE WHEN (sp.payment_method="creditnote") THEN SUM(sp.payment_amount) ELSE 0 END) as total_credit')
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today)
|
||||
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id = ?',today,today,shift.id).count
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.total_card_sale(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
if !from.nil? && !to.nil?
|
||||
if current_user.nil?
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher")',from,to,from_time,to_time)
|
||||
query = Sale.select('(CASE WHEN (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") THEN SUM(sp.payment_amount) ELSE 0 END) as total_card, (CASE WHEN (sp.payment_method="creditnote") THEN SUM(sp.payment_amount) ELSE 0 END) as total_credit')
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id=?',today,today,shift.id)
|
||||
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
.sum("sp.payment_amount")
|
||||
else
|
||||
query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher")',from,to)
|
||||
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
.sum("sp.payment_amount")
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher")',from,to,from_time,to_time)
|
||||
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
.sum("sp.payment_amount")
|
||||
else
|
||||
query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher")',from,to)
|
||||
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
.sum("sp.payment_amount")
|
||||
end
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") and shift_sale_id=?',from,to,from_time,to_time,shift.id)
|
||||
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
.sum("sp.payment_amount")
|
||||
else
|
||||
query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") and shift_sale_id=?',from,to,shift.id)
|
||||
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
.sum("sp.payment_amount")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if current_user.nil?
|
||||
query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher")',today,today)
|
||||
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
.sum("sp.payment_amount")
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher")',today,today)
|
||||
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
.sum("sp.payment_amount")
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay" or sp.payment_method = "giftvoucher") and shift_sale_id=?',today,today,shift.id)
|
||||
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
.sum("sp.payment_amount")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.credit_payment(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
if !from.nil? && !to.nil?
|
||||
if current_user.nil?
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time)
|
||||
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||
.sum("payment_amount")
|
||||
else
|
||||
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to)
|
||||
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||
.sum("payment_amount")
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time)
|
||||
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||
.sum("payment_amount")
|
||||
else
|
||||
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to)
|
||||
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||
.sum("payment_amount")
|
||||
end
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and s.shift_sale_id=?',from,to,from_time,to_time,shift.id)
|
||||
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||
.sum("payment_amount")
|
||||
else
|
||||
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and s.shift_sale_id=?',from,to,shift.id)
|
||||
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||
.sum("payment_amount")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if current_user.nil?
|
||||
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today)
|
||||
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||
.sum("payment_amount")
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today)
|
||||
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||
.sum("payment_amount")
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and s.shift_sale_id=?',today,today,shift.id)
|
||||
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||
.sum("payment_amount")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1972,57 +1813,62 @@ end
|
||||
end
|
||||
|
||||
def self.total_customer(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
dinein_cnt = self.total_dinein(today,current_user,from,to,from_time,to_time)
|
||||
takeaway_cnt = self.total_takeaway(today,current_user,from,to,from_time,to_time)
|
||||
total_dinein_takeaway = self.total_dinein_takeaway(today,current_user,from,to,from_time,to_time)
|
||||
dinein_cnt = 0
|
||||
takeaway_cnt = 0
|
||||
if !total_dinein_takeaway[0].nil?
|
||||
dinein_cnt = total_dinein_takeaway[0].total_dinein_cus
|
||||
takeaway_cnt = total_dinein_takeaway[0].total_take_cus
|
||||
end
|
||||
membership_cnt = self.total_membership(today,current_user,from,to,from_time,to_time)
|
||||
|
||||
total_cus = 0
|
||||
if !dinein_cnt.nil? || !takeaway_cnt.nil? || !membership_cnt.nil?
|
||||
total_cus = dinein_cnt.total_dinein_cus.to_int + takeaway_cnt.total_take_cus.to_int + membership_cnt.total_memb_cus.to_int
|
||||
total_cus = dinein_cnt.to_int + takeaway_cnt.to_int + membership_cnt.total_memb_cus.to_int
|
||||
end
|
||||
|
||||
return total_cus
|
||||
return total_cus, dinein_cnt, takeaway_cnt, membership_cnt.total_memb_cus
|
||||
end
|
||||
|
||||
def self.total_dinein(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
def self.total_dinein_takeaway(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
if !from.nil? && !to.nil?
|
||||
if current_user.nil?
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
|
||||
query = Sale.select("(CASE WHEN c.customer_type='Dinein' THEN count(sales.customer_id) ELSE 0 END) as total_dinein_cus, (CASE WHEN c.customer_type='Takeaway' THEN count(sales.customer_id) ELSE 0 END) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.customer_type = "Dinein" and c.membership_id is null',from,to,from_time,to_time)
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.membership_id is null',from,to,from_time,to_time)
|
||||
.first()
|
||||
else
|
||||
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
|
||||
query = Sale.select("(CASE WHEN c.customer_type='Dinein' THEN count(sales.customer_id) ELSE 0 END) as total_dinein_cus, (CASE WHEN c.customer_type='Takeaway' THEN count(sales.customer_id) ELSE 0 END) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and c.customer_type = "Dinein" and c.membership_id is null',from,to)
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and c.membership_id is null',from,to)
|
||||
.first()
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
|
||||
query = Sale.select("(CASE WHEN c.customer_type='Dinein' THEN count(sales.customer_id) ELSE 0 END) as total_dinein_cus, (CASE WHEN c.customer_type='Takeaway' THEN count(sales.customer_id) ELSE 0 END) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.customer_type = "Dinein" and c.membership_id is null',from,to,from_time,to_time)
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.membership_id is null',from,to,from_time,to_time)
|
||||
.first()
|
||||
else
|
||||
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
|
||||
query = Sale.select("(CASE WHEN c.customer_type='Dinein' THEN count(sales.customer_id) ELSE 0 END) as total_dinein_cus, (CASE WHEN c.customer_type='Takeaway' THEN count(sales.customer_id) ELSE 0 END) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and c.customer_type = "Dinein" and c.membership_id is null',from,to)
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and c.membership_id is null',from,to)
|
||||
.first()
|
||||
end
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
|
||||
query = Sale.select("(CASE WHEN c.customer_type='Dinein' THEN count(sales.customer_id) ELSE 0 END) as total_dinein_cus, (CASE WHEN c.customer_type='Takeaway' THEN count(sales.customer_id) ELSE 0 END) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.customer_type = "Dinein" and c.membership_id is null and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id)
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.membership_id is null and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id)
|
||||
.first()
|
||||
else
|
||||
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
|
||||
query = Sale.select("(CASE WHEN c.customer_type='Dinein' THEN count(sales.customer_id) ELSE 0 END) as total_dinein_cus, (CASE WHEN c.customer_type='Takeaway' THEN count(sales.customer_id) ELSE 0 END) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and c.customer_type = "Dinein" and c.membership_id is null and sales.shift_sale_id=?',from,to,shift.id)
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and c.membership_id is null and sales.shift_sale_id=?',from,to,shift.id)
|
||||
.first()
|
||||
end
|
||||
end
|
||||
@@ -2030,91 +1876,22 @@ end
|
||||
end
|
||||
else
|
||||
if current_user.nil?
|
||||
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
|
||||
query = Sale.select("(CASE WHEN c.customer_type='Dinein' THEN count(sales.customer_id) ELSE 0 END) as total_dinein_cus, (CASE WHEN c.customer_type='Takeaway' THEN count(sales.customer_id) ELSE 0 END) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today)
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.membership_id is null',today)
|
||||
.first()
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
|
||||
query = Sale.select("(CASE WHEN c.customer_type='Dinein' THEN count(sales.customer_id) ELSE 0 END) as total_dinein_cus, (CASE WHEN c.customer_type='Takeaway' THEN count(sales.customer_id) ELSE 0 END) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today)
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.membership_id is null',today)
|
||||
.first()
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
|
||||
query = Sale.select("(CASE WHEN c.customer_type='Dinein' THEN count(sales.customer_id) ELSE 0 END) as total_dinein_cus, (CASE WHEN c.customer_type='Takeaway' THEN count(sales.customer_id) ELSE 0 END) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null and sales.shift_sale_id=?',today,shift.id)
|
||||
.first()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.total_takeaway(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
if !from.nil? && !to.nil?
|
||||
if current_user.nil?
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = Sale.select("count(sales.customer_id) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZsales.receipt_date,"%H:%i") between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null',from,to,from_time,to_time)
|
||||
.first()
|
||||
else
|
||||
query = Sale.select("count(sales.customer_id) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null',from,to)
|
||||
.first()
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = Sale.select("count(sales.customer_id) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null',from,to,from_time,to_time)
|
||||
.first()
|
||||
else
|
||||
query = Sale.select("count(sales.customer_id) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null',from,to)
|
||||
.first()
|
||||
end
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = Sale.select("count(sales.customer_id) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id)
|
||||
.first()
|
||||
else
|
||||
query = Sale.select("count(sales.customer_id) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null and sales.shift_sale_id=?',from,to,shift.id)
|
||||
.first()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if current_user.nil?
|
||||
query = Sale.select("count(sales.customer_id) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today)
|
||||
.first()
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
query = Sale.select("count(sales.customer_id) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today)
|
||||
.first()
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
query = Sale.select("count(sales.customer_id) as total_take_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null and sales.shift_sale_id=?',today,shift.id)
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.membership_id is null and sales.shift_sale_id=?',today,shift.id)
|
||||
.first()
|
||||
end
|
||||
end
|
||||
@@ -2187,68 +1964,68 @@ end
|
||||
end
|
||||
end
|
||||
|
||||
def self.total_other_customer(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
if !from.nil? && !to.nil?
|
||||
if current_user.nil?
|
||||
query = Sale.select("count(sales.customer_id) as total_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.customer_type is null and c.membership_id is null',from,to,from_time,to_time)
|
||||
.first()
|
||||
else
|
||||
query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and c.customer_type is null and c.membership_id is null',from,to)
|
||||
.first()
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
query = Sale.select("count(sales.customer_id) as total_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.customer_type is null and c.membership_id is null',from,to,from_time,to_time)
|
||||
.first()
|
||||
else
|
||||
query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and c.customer_type is null and c.membership_id is null',from,to)
|
||||
.first()
|
||||
end
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
query = Sale.select("count(sales.customer_id) as total_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.customer_type is null and c.membership_id is null and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id)
|
||||
.first()
|
||||
else
|
||||
query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and c.customer_type is null and c.membership_id is null and sales.shift_sale_id=?',from,to,shift.id)
|
||||
.first()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if current_user.nil?
|
||||
query = Sale.select("count(sales.customer_id) as total_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today)
|
||||
.first()
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
query = Sale.select("count(sales.customer_id) as total_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today)
|
||||
.first()
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
query = Sale.select("count(sales.customer_id) as total_cus")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null and sales.shift_sale_id=?',today,shift.id)
|
||||
.first()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# def self.total_other_customer(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
# if !from.nil? && !to.nil?
|
||||
# if current_user.nil?
|
||||
# query = Sale.select("count(sales.customer_id) as total_cus")
|
||||
# .joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
# if !from_time.nil? && !to_time.nil?
|
||||
# query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.customer_type is null and c.membership_id is null',from,to,from_time,to_time)
|
||||
# .first()
|
||||
# else
|
||||
# query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and c.customer_type is null and c.membership_id is null',from,to)
|
||||
# .first()
|
||||
# end
|
||||
# else
|
||||
# if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
# query = Sale.select("count(sales.customer_id) as total_cus")
|
||||
# .joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
# if !from_time.nil? && !to_time.nil?
|
||||
# query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.customer_type is null and c.membership_id is null',from,to,from_time,to_time)
|
||||
# .first()
|
||||
# else
|
||||
# query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and c.customer_type is null and c.membership_id is null',from,to)
|
||||
# .first()
|
||||
# end
|
||||
# else
|
||||
# shift = ShiftSale.current_open_shift(current_user.id)
|
||||
# if !shift.nil?
|
||||
# query = Sale.select("count(sales.customer_id) as total_cus")
|
||||
# .joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
# if !from_time.nil? && !to_time.nil?
|
||||
# query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.customer_type is null and c.membership_id is null and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id)
|
||||
# .first()
|
||||
# else
|
||||
# query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and c.customer_type is null and c.membership_id is null and sales.shift_sale_id=?',from,to,shift.id)
|
||||
# .first()
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# else
|
||||
# if current_user.nil?
|
||||
# query = Sale.select("count(sales.customer_id) as total_cus")
|
||||
# .joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
# .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today)
|
||||
# .first()
|
||||
# else
|
||||
# if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
|
||||
# query = Sale.select("count(sales.customer_id) as total_cus")
|
||||
# .joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
# .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today)
|
||||
# .first()
|
||||
# else
|
||||
# shift = ShiftSale.current_open_shift(current_user.id)
|
||||
# if !shift.nil?
|
||||
# query = Sale.select("count(sales.customer_id) as total_cus")
|
||||
# .joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
# .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null and sales.shift_sale_id=?',today,shift.id)
|
||||
# .first()
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
def self.total_order(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
if !from.nil? && !to.nil?
|
||||
|
||||
@@ -24,7 +24,9 @@
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="text"><%= t :sale_count %></div>
|
||||
<div class="number count-to" data-from="0" data-to="<%= @total_count%>" data-speed="1000" data-fresh-interval="20"></div>
|
||||
<% if !@total_trans[0].nil? %>
|
||||
<div class="number count-to" data-from="0" data-to="<%= @total_trans[0].total_count%>" data-speed="1000" data-fresh-interval="20"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -35,7 +37,9 @@
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="text"><%= t :total_sale %></div>
|
||||
<div class="number count-to" data-from="0" data-to="<%= @total_sale%>" data-speed="15" data-fresh-interval="20"></div>
|
||||
<% if !@total_trans[0].nil? %>
|
||||
<div class="number count-to" data-from="0" data-to="<%= @total_trans[0].total_sale%>" data-speed="15" data-fresh-interval="20"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -47,7 +51,9 @@
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="text"><%= t :total_credit %></div>
|
||||
<div class="number count-to" data-from="0" data-to="<%= @total_credit%>" data-speed="1000" data-fresh-interval="20"></div>
|
||||
<% if !@total_payment_trans[0].nil? %>
|
||||
<div class="number count-to" data-from="0" data-to="<%= @total_payment_trans[0].total_credit%>" data-speed="1000" data-fresh-interval="20"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -58,7 +64,9 @@
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="text"><%= t :total_card %></div>
|
||||
<div class="number count-to" data-from="0" data-to="<%= @total_card%>" data-speed="1000" data-fresh-interval="20"></div>
|
||||
<% if !@total_payment_trans[0].nil? %>
|
||||
<div class="number count-to" data-from="0" data-to="<%= @total_payment_trans[0].total_card%>" data-speed="1000" data-fresh-interval="20"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -272,25 +280,25 @@
|
||||
<% if !@total_dinein.nil? %>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.dine_in") %> : </td>
|
||||
<td align="right"><%= @total_dinein.total_dinein_cus %></td>
|
||||
<td align="right"><%= @total_dinein %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if !@total_takeaway.nil? %>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.takeaway") %> : </td>
|
||||
<td align="right"><%= @total_takeaway.total_take_cus %></td>
|
||||
<td align="right"><%= @total_takeaway %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if !@total_other_customer.nil? %>
|
||||
<!-- <% if !@total_other_customer.nil? %>
|
||||
<tr>
|
||||
<td><%= t :customer %> : </td>
|
||||
<td align="right"><%= @total_other_customer.total_cus %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %> -->
|
||||
<% if !@total_membership.nil? %>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.membership") %> : </td>
|
||||
<td align="right"><%= @total_membership.total_memb_cus %></td>
|
||||
<td align="right"><%= @total_membership %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
@@ -161,6 +161,9 @@
|
||||
<li>
|
||||
<a href="<%= reports_commission_index_path %>">Commission</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<%= reports_induty_index_path %>">Induty</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<%= reports_stock_check_index_path %>">Stock Check</a>
|
||||
</li>
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
|
||||
var payment_method = "";
|
||||
$('.payment-type').on('click',function(){
|
||||
$('.payment-type').css("background-color","#7a62d3")
|
||||
$('.payment-type').css("background-color","#7a62d3");
|
||||
$(this).css("background-color","green");
|
||||
var type = $(this).attr('data-id')
|
||||
if(type == 'cash'){
|
||||
|
||||
@@ -137,25 +137,25 @@
|
||||
<% if !@total_dinein.nil? %>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.dine_in") %> : </td>
|
||||
<td align="right"><%= @total_dinein.total_dinein_cus %></td>
|
||||
<td align="right"><%= @total_dinein %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if !@total_takeaway.nil? %>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.takeaway") %> : </td>
|
||||
<td align="right"><%= @total_takeaway.total_take_cus %></td>
|
||||
<td align="right"><%= @total_takeaway %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if !@total_other_customer.nil? %>
|
||||
<!-- <% if !@total_other_customer.nil? %>
|
||||
<tr>
|
||||
<td><%= t :customer %> : </td>
|
||||
<td align="right"><%= @total_other_customer.total_cus %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %> -->
|
||||
<% if !@total_membership.nil? %>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.membership") %> : </td>
|
||||
<td align="right"><%= @total_membership.total_memb_cus %></td>
|
||||
<td align="right"><%= @total_membership %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
@@ -219,7 +219,13 @@ $(function() {
|
||||
});
|
||||
|
||||
$(".qs_view").on('click', function() {
|
||||
if ($('#server_mode').val() != "cloud") {
|
||||
var display_type = '<%= @display_type %>';
|
||||
if (display_type.length>0) {
|
||||
display_type = '<%= @display_type %>';
|
||||
}else{
|
||||
display_type = null;
|
||||
}
|
||||
if ($('#server_mode').val() != "cloud" && display_type == 2) {
|
||||
document.getElementById('second_view').click();
|
||||
}
|
||||
window.location.href = '/origami/quick_service';
|
||||
|
||||
@@ -991,8 +991,9 @@
|
||||
});
|
||||
|
||||
$('#in_duties').on('click', function () {
|
||||
var dining_id = "<%= @dining.id %>"
|
||||
window.location.href = '/origami/assign_in_duty/'+ dining_id;
|
||||
var dining_id = "<%= @dining.id %>";
|
||||
var sale_id = "<%= @obj_sale.sale_id rescue "" %>";
|
||||
window.location.href = '/origami/assign_in_duty/'+ sale_id;
|
||||
});
|
||||
|
||||
$('#void').on('click', function () {
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
<span class="patch_method"></span>
|
||||
<%= f.error_notification %>
|
||||
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
|
||||
<%= f.hidden_field :booking_id, :value => @booking_id %>
|
||||
<%= f.hidden_field :sale_id, :value => @sale_id %>
|
||||
<div class="form-inputs form-group">
|
||||
<%= f.hidden_field :dinning_id, :value => @table.id, :class => "form-control col-md-4 " %>
|
||||
<label>Commissioner Name:</label>
|
||||
@@ -21,9 +23,9 @@
|
||||
<i class="material-icons">date_range</i>
|
||||
</span>
|
||||
<% if !@in_duty.in_time.nil?%>
|
||||
<input type="text" name="in_duty[in_time]" value="<%= @in_duty.in_time.strftime('%A, %d-%m-%Y') %>" class="datepicker form-control col-md-12" placeholder="Start Date...">
|
||||
<input type="text" name="in_duty[in_time]" id="in_duty_in_time" value="<%= @in_duty.in_time.strftime('%A, %d-%m-%Y') %>" class="datepicker form-control col-md-12" placeholder="Start Date...">
|
||||
<% else %>
|
||||
<input type="text" name="in_duty[in_time]" class="datetimepicker form-control col-md-12" placeholder="In Time...">
|
||||
<input type="text" name="in_duty[in_time]" id="in_duty_in_time" class="datetimepicker form-control col-md-12" placeholder="In Time...">
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
@@ -34,19 +36,19 @@
|
||||
<i class="material-icons">date_range</i>
|
||||
</span>
|
||||
<% if !@in_duty.out_time.nil?%>
|
||||
<input type="text" name="in_duty[out_time]" value="<%= @in_duty.out_time.strftime('%A, %d-%m-%Y') %>" class="datepicker form-control col-md-12" placeholder="Start Date...">
|
||||
<input type="text" name="in_duty[out_time]" id="in_duty_out_time" value="<%= @in_duty.out_time.strftime('%A, %d-%m-%Y') %>" class="datepicker form-control col-md-12" placeholder="Start Date...">
|
||||
<% else %>
|
||||
<input type="text" name="in_duty[out_time]" class="datetimepicker form-control col-md-12" placeholder="Out Time...">
|
||||
<input type="text" name="in_duty[out_time]" id="in_duty_out_time" class="datetimepicker form-control col-md-12" placeholder="Out Time...">
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div><br>
|
||||
|
||||
<div class="form-group">
|
||||
<!-- <div class="form-group">
|
||||
<% f.button :submit, "Create", :class => 'btn bg-blue ', :id => 'create' %>
|
||||
<% f.button :submit, "Update", :class => 'btn bg-blue ', :disabled => '', :id => 'update' %>
|
||||
<% f.button :button, "Reset", :class => 'btn bg-danger ', :id => 'reset' %>
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="form-actions">
|
||||
<%= f.submit "Create In Duty", :class => 'btn bg-blue' %>
|
||||
</div>
|
||||
|
||||
@@ -53,11 +53,13 @@ $(function() {
|
||||
var commissioner_ids = $('#in_duty_commissioner_ids').val();
|
||||
var in_time = $('#in_duty_in_time').val();
|
||||
var out_time = $('#in_duty_out_time').val();
|
||||
var dining_id = '<%= @table.id %>'
|
||||
var dining_id = '<%= @table.id %>';
|
||||
var sale_id = '<%= @sale_id %>';
|
||||
var booking_id = '<%= @booking_id %>';
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'dining_id=' + dining_id + "&commissioner_ids=" + commissioner_ids +'&in_time=' + in_time + "&out_time=" + out_time,
|
||||
data: 'dining_id=' + dining_id + "sale_id=" + sale_id + "booking_id=" + booking_id + "&commissioner_ids=" + commissioner_ids +'&in_time=' + in_time + "&out_time=" + out_time,
|
||||
success: function (result) {
|
||||
window.location.href = '/origami/assign_in_duty/'+ dining_id;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<td><%= in_duty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
|
||||
<td><%= in_duty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
|
||||
<td>
|
||||
<button class="delete btn btn-danger btn-sm waves-effect" data-ref="../table/<%=in_duty.dining_facility.id%>/destroy_in_duty/<%=in_duty.id%>" data-method="delete">
|
||||
<button class="delete btn btn-danger btn-sm waves-effect" data-ref="../table/<%=in_duty.dining_facility.id%>/<%= @sale_id %>/destroy_in_duty/<%=in_duty.id%>" data-method="delete">
|
||||
Remove
|
||||
</button>
|
||||
|
||||
@@ -68,7 +68,8 @@
|
||||
|
||||
var in_duty_id = $(this).attr('data-ref');
|
||||
var table_id = "<%= @table.id %>";
|
||||
var url = "/origami/assign_in_duty/table/" + table_id + "/in_duty/" + in_duty_id + "/edit";
|
||||
var sale_id = "<%= @sale_id %>";
|
||||
var url = "/origami/assign_in_duty/table/" + sale_id + "/in_duty/" + in_duty_id + "/edit";
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
@@ -76,25 +77,30 @@
|
||||
data: {},
|
||||
|
||||
success: function (data) {
|
||||
debugger;
|
||||
$('.partial').empty().append(data);
|
||||
// $('#in_duty_id').val(data.in_duty.id);
|
||||
// $('#in_duty_commissioner_ids').val(data.commissioner.id);
|
||||
// $('#in_duty_in_time').val(data.in_duty.in_time);
|
||||
// $('#in_duty_out_time').val(data.in_duty.out_time);
|
||||
//
|
||||
// debugger;
|
||||
// $('.partial').empty().append(data);
|
||||
var inT = new Date(data.in_duty.in_time);
|
||||
var in_time = ((inT.getDate() >= 10 ? inT.getDate() : '0'+inT.getDate()) +"-"+ (inT.getMonth() >= 10 ? inT.getMonth() : '0'+inT.getMonth()) +"-"+ inT.getFullYear() +" - "+ (inT.getHours()>10? inT.getHours() : '0'+inT.getHours()) +":"+ (inT.getMinutes() >= 10? inT.getMinutes() : '0'+inT.getMinutes()));
|
||||
var outT = new Date(data.in_duty.out_time);
|
||||
var out_time = ((outT.getDate() >= 10? outT.getDate() : '0'+outT.getDate()) +"-"+ (outT.getMonth() >= 10 ? outT.getMonth() : '0'+outT.getMonth()) +"-"+ outT.getFullYear() +" - "+ (outT.getHours()>10? outT.getHours() : '0'+outT.getHours()) +":"+ (outT.getMinutes() >= 10? outT.getMinutes() : '0'+outT.getMinutes()));
|
||||
|
||||
$('#in_duty_id').val(data.in_duty.id);
|
||||
$('#in_duty_commissioner_ids').val(data.commissioner.id);
|
||||
$('#in_duty_in_time').val(in_time);
|
||||
$('#in_duty_out_time').val(out_time);
|
||||
|
||||
// $('#update').removeAttr('disabled').val('');
|
||||
// $('#update').attr('value', 'Update');
|
||||
// $('#create').attr('disabled', 'disabled');
|
||||
//
|
||||
// $("#new_in_duty").attr('class', 'simple_form edit_in_duty');
|
||||
// var id = "edit_in_duty_" + in_duty_id;
|
||||
// $("#new_in_duty").attr('id', id);
|
||||
//
|
||||
// $(".edit_in_duty").attr('id', id);
|
||||
// $(".edit_in_duty").attr('action', '/origami/edit_in_duty/' + $('#in_duty_id').val());
|
||||
// $(".edit_in_duty").attr('action', '/origami/edit_in_duty/' + $('#in_duty_id').val());
|
||||
// $(".patch_method").html('<input type="hidden" name="_method" value="patch">');
|
||||
|
||||
$("#new_in_duty").attr('class', 'simple_form edit_in_duty');
|
||||
var id = "edit_in_duty_" + data.in_duty.id;
|
||||
$("#new_in_duty").attr('id', data.in_duty.id);
|
||||
|
||||
$(".edit_in_duty").attr('id', data.in_duty.id);
|
||||
$(".edit_in_duty").attr('action', '/origami/edit_in_duty/' + $('#in_duty_id').val());
|
||||
$(".edit_in_duty").attr('action', '/origami/edit_in_duty/' + $('#in_duty_id').val());
|
||||
$(".patch_method").html('<input type="hidden" name="_method" value="patch">');
|
||||
|
||||
// setInterval(function () {
|
||||
// $('.partial').load('/controller_name/action_name');
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<% if table.get_checkout_booking.nil? %>
|
||||
<div class="card tables red text-white" data-id="<%= table.id %>" data-name="<%= table.name %>">
|
||||
<% else %>
|
||||
<div class="card tables orange text-white" data-id="<%= table.id %>">
|
||||
<div class="card tables orange text-white" data-id="<%= table.id %>" data-name=" <%= table.name %>">
|
||||
<% end %>
|
||||
<div class="card-block">
|
||||
<%= table.name %>
|
||||
@@ -35,9 +35,9 @@
|
||||
</div>
|
||||
<% else %>
|
||||
<% if table.get_checkout_booking.nil? %>
|
||||
<div class="card tables blue text-white" data-id="<%= table.id %>">
|
||||
<div class="card tables blue text-white" data-id="<%= table.id %>" data-name=" <%= table.name %>">
|
||||
<% else %>
|
||||
<div class="card tables orange text-white" data-id="<%= table.id %>">
|
||||
<div class="card tables orange text-white" data-id="<%= table.id %>" data-name=" <%= table.name %>">
|
||||
<% end %>
|
||||
<div class="card-block">
|
||||
<%= table.name %>
|
||||
@@ -350,7 +350,7 @@ end
|
||||
var dining_name = $(this).attr("data-name");
|
||||
var dining_id = $(this).attr("data-id");
|
||||
var change_from = "<%= @dining.id %>";
|
||||
if ((dining_id == change_from) || (dining_name==undefined)) {
|
||||
if ((dining_id == change_from)) {
|
||||
swal({
|
||||
title: "Alert!!",
|
||||
text: 'Please select another table !',
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<% if table.get_checkout_booking.nil? %>
|
||||
<div class="card tables red text-white" data-id="<%= table.id %>" data-name="<%= table.name %>">
|
||||
<% else %>
|
||||
<div class="card tables orange text-white" data-id="<%= table.id %>">
|
||||
<div class="card tables orange text-white" data-id="<%= table.id %>" data-name=" <%= table.name %>">
|
||||
<% end %>
|
||||
<div class="card-block">
|
||||
<%= table.name %>
|
||||
@@ -34,9 +34,9 @@
|
||||
</div>
|
||||
<% else %>
|
||||
<% if table.get_checkout_booking.nil? %>
|
||||
<div class="card tables blue text-white" data-id="<%= table.id %>">
|
||||
<div class="card tables blue text-white" data-id="<%= table.id %>" data-name=" <%= table.name %>">
|
||||
<% else %>
|
||||
<div class="card tables orange text-white" data-id="<%= table.id %>">
|
||||
<div class="card tables orange text-white" data-id="<%= table.id %>" data-name=" <%= table.name %>">
|
||||
<% end %>
|
||||
<div class="card-block">
|
||||
<%= table.name %>
|
||||
@@ -351,7 +351,7 @@ end
|
||||
var dining_name = $(this).attr("data-name");
|
||||
var dining_id = $(this).attr("data-id");
|
||||
var change_from = "<%= @dining.id %>";
|
||||
if ((dining_id == change_from) || (dining_name==undefined)) {
|
||||
if (dining_id == change_from) {
|
||||
swal({
|
||||
title: "Alert!!",
|
||||
text: 'Please select another table !',
|
||||
|
||||
@@ -324,15 +324,14 @@ $(document).ready(function(){
|
||||
swal("Opps","You are not authorized for void","warning")
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.access_modal', function(event){
|
||||
type = $(this).data("type");
|
||||
$(".ok").attr("data-action",type)
|
||||
$(".ok").attr("data-action",type);
|
||||
$('#AccessCodeModal').modal('show');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function check_emp_access_code(access_code,type) {
|
||||
var url = "/origami/check_emp_access_code/" + access_code ;
|
||||
$.ajax({
|
||||
|
||||
@@ -410,7 +410,7 @@ $('#back').on('click',function(){
|
||||
|
||||
$(document).on('click', '.access_modal', function(event){
|
||||
type = $(this).data("type");
|
||||
$(".ok").attr("data-action",type)
|
||||
$(".ok").attr("data-action",type);
|
||||
$('#AccessCodeModal').modal('show');
|
||||
});
|
||||
$('#void').on('click', function () {
|
||||
|
||||
127
app/views/reports/induty/_shift_sale_report_filter.html.erb
Executable file
127
app/views/reports/induty/_shift_sale_report_filter.html.erb
Executable file
@@ -0,0 +1,127 @@
|
||||
<div class="p-l-15">
|
||||
<%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
|
||||
<% if period_type != false %>
|
||||
<div class="row">
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<label class="font-14"><%= t("views.right_panel.detail.select_period") %></label>
|
||||
<select name="period" id="sel_period" class="form-control">
|
||||
<option value=""><%= t("views.right_panel.detail.select_period") %></option>
|
||||
<option value="0">Today</option>
|
||||
<option value="1">Yesterday</option>
|
||||
<option value="2">This week</option>
|
||||
<option value="3">Last week</option>
|
||||
<option value="4">Last 7 days</option>
|
||||
<option value="5">This month</option>
|
||||
<option value="6">Last month</option>
|
||||
<option value="7">Last 30 days</option>
|
||||
<option value="8">This year</option>
|
||||
<option value="9">Last year</option>
|
||||
</select>
|
||||
</div>
|
||||
<!-- <input type="hidden" name="report_type" value="sale_item" id="sel_sale_type"> -->
|
||||
<% if defined? commissioners %>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<label class="font-14">Select Commissioner</label>
|
||||
<select class="form-control" id="commissioner" name="commissioner">
|
||||
<option value="">--Select Commissioner--</option>
|
||||
<% if !@commissioners.nil? %>
|
||||
<% @commissioners.each do |comm| %>
|
||||
<% if params[:commissioner].to_i == comm.id.to_i %>
|
||||
<option value="<%= comm.id %>" selected><%= comm.name %></option>
|
||||
<% else %>
|
||||
<option value="<%= comm.id %>"><%= comm.name %></option>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<!-- <label class="">Select Shift Period</label> -->
|
||||
<label class="font-14"><%= t("views.right_panel.detail.from") %></label>
|
||||
<input data-behaviour='datepicker' class="form-control m-t-3 datepicker" name="from" id="from" type="text" placeholder="From date" style="height: 32px;">
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<label class="font-14"><%= t("views.right_panel.detail.to") %></label>
|
||||
<input data-behaviour='datepicker' class="form-control m-t-3 datepicker" name="to" id="to" type="text" placeholder="To date" style="height: 32px;">
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<label class="font-14">All Shift</label>
|
||||
<select class="form-control select" name="shift_name" id="shift_name" >
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2 margin-top-20">
|
||||
<br>
|
||||
<input type="submit" value="Generate Report" class='btn btn-primary'>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$('#custom_excel').hide();
|
||||
|
||||
$('#custom_excel').click(function(){
|
||||
var url = $('#custom_excel').attr('data-url');
|
||||
$('#frm_report').attr('action',url)
|
||||
$('#frm_report').submit();
|
||||
// window.location = url;
|
||||
});
|
||||
|
||||
var item = $('#item').val();
|
||||
|
||||
if(item == 'order'){
|
||||
$('#cashier').hide();
|
||||
$('#waiter').show();
|
||||
}
|
||||
else if(item == 'sale'){
|
||||
$('#waiter').hide();
|
||||
$('#cashier').show();
|
||||
}
|
||||
else{
|
||||
$('#waiter').hide();
|
||||
$('#cashier').show();
|
||||
$("#item").val('sale');
|
||||
}
|
||||
});
|
||||
|
||||
<% if params[:shift_name].to_i > 0%>
|
||||
shift_id = '<%= params[:shift_name] %>'
|
||||
local_date = '<%= @shift_from %> - <%= @shift_to %> '
|
||||
var shift = $('#shift_name');
|
||||
str = '<option value="'+ shift_id +'" '+ 'selected = "selected"' +'>' + local_date + '</option>';
|
||||
shift.append(str);
|
||||
<% end %>
|
||||
|
||||
$("#from").val("<%=params[:from] rescue '-'%>");
|
||||
$("#to").val("<%=params[:to] rescue '-'%>");
|
||||
$("#sel_period").val(<%=params[:period] rescue '-'%>);
|
||||
var sale_type = "<%=params[:sale_type]%>";
|
||||
$("#sel_sale_type").val(sale_type);
|
||||
|
||||
|
||||
<% if params[:period_type] == 1 || params[:period_type] == "1" %>
|
||||
$("#rd_period_type_1").attr("checked","checked");
|
||||
<% else %>
|
||||
$("#rd_period_type_0").attr("checked","checked");
|
||||
<% end %>
|
||||
$(".btn-group button").removeClass("active");
|
||||
<% report_type = params[:report_type].blank? ? "0" : params[:report_type] %>
|
||||
$("#btn_report_type_<%= report_type %>").addClass("active");
|
||||
|
||||
$('#item').change(function(){
|
||||
var item = $('#item').val();
|
||||
|
||||
if(item == 'sale'){
|
||||
$('#waiter').hide();
|
||||
$('#cashier').show();
|
||||
}
|
||||
else{
|
||||
$('#cashier').hide();
|
||||
$('#waiter').show();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
181
app/views/reports/induty/index.html.erb
Normal file
181
app/views/reports/induty/index.html.erb
Normal file
@@ -0,0 +1,181 @@
|
||||
<div class="page-header">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
|
||||
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.induty_report") %></li>
|
||||
<span class="float-right">
|
||||
<%= link_to 'Back', dashboard_path %>
|
||||
</span>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<%= render :partial=>'shift_sale_report_filter',
|
||||
:locals=>{ :period_type => true, :commissioners => true, :shift_name => true, :report_path =>reports_induty_index_path} %>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="text-right">
|
||||
<a href="javascript:export_to('<%=reports_induty_index_path%>.xls')" class = "btn btn-info wave-effects "><%= t("views.btn.exp_to_excel") %></a>
|
||||
</div>
|
||||
|
||||
<div class="margin-top-20">
|
||||
<div class="card">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped" id="items_table" border="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="7"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
|
||||
</tr>
|
||||
<% if @shift_from %>
|
||||
<tr>
|
||||
<% if @shift_data.employee %>
|
||||
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
|
||||
<% end %>
|
||||
<th colspan="7"> <%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th><%= t("views.right_panel.detail.receipt_no") %></th>
|
||||
<th><%= t :commissioners %></th>
|
||||
<th><%= t :table %></th>
|
||||
<th><%= t("views.right_panel.detail.in_time") %></th>
|
||||
<th><%= t("views.right_panel.detail.out_time") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if !@induty_data.nil? %>
|
||||
<% induty_arr = Array.new %>
|
||||
<% @induty_data.each do |induty| %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td><%= induty.receipt_no %></td>
|
||||
<td><%= induty.name %></td>
|
||||
<td><%= induty.dining_name %></td>
|
||||
<td><%= induty.in_time.utc.getlocal.strftime("%d-%m-%Y - %I:%M") %></td>
|
||||
<td><%= induty.out_time.utc.getlocal.strftime("%d-%m-%Y - %I:%M") %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function(){
|
||||
|
||||
|
||||
var check_arr = [];
|
||||
|
||||
var search = '<%= params[:period_type] %>';
|
||||
|
||||
if(search){
|
||||
|
||||
if(parseInt(search) == 0){
|
||||
search_by_period();
|
||||
}
|
||||
else{
|
||||
search_by_date();
|
||||
}
|
||||
}else{
|
||||
search_by_period();
|
||||
}
|
||||
|
||||
$('#sel_period').change(function(){
|
||||
search_by_period();
|
||||
});
|
||||
|
||||
function search_by_period(){
|
||||
var period = $('#sel_period').val();
|
||||
var period_type = 0;
|
||||
var from = "";
|
||||
var to = "";
|
||||
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
}
|
||||
|
||||
// OK button is clicked
|
||||
$('#from').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
|
||||
new_date = new Date(date) ;
|
||||
month = parseInt(new_date.getMonth()+1)
|
||||
from = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
|
||||
$('#from').val(from)
|
||||
search_by_date();
|
||||
});
|
||||
$('#to').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
|
||||
new_date = new Date(date) ;
|
||||
month = parseInt(new_date.getMonth()+1)
|
||||
to = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
|
||||
$('#to').val(to)
|
||||
search_by_date();
|
||||
});
|
||||
|
||||
function search_by_date(){
|
||||
from = $("#from").val();
|
||||
to = $("#to").val();
|
||||
var period = 0;
|
||||
var period_type = 1;
|
||||
|
||||
if(to != '' && from != ''){
|
||||
shift_name = from + ',' + to;
|
||||
|
||||
check_arr.push(to);
|
||||
|
||||
if(check_arr.length == 1){
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
}
|
||||
if(check_arr.length == 3){
|
||||
check_arr = [];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function show_shift_name(period,period_type,from,to,shift_item){
|
||||
var shift = $('#shift_name');
|
||||
if (from == '' && to == '') {
|
||||
from = $("#from").val();
|
||||
to = $("#to").val();
|
||||
}
|
||||
shift.empty();
|
||||
var selected = '';
|
||||
var str = '';
|
||||
var param_shift = '<%= params[:shift_name]%>';
|
||||
|
||||
url = '<%= reports_get_shift_by_induty_path %>';
|
||||
$.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){
|
||||
|
||||
str = '<option value="0">--- All Shift ---</option>';
|
||||
$(data.message).each(function(index){
|
||||
|
||||
var local_date = data.message[index].local_opening_date + ' - ' + data.message[index].local_closing_date;
|
||||
var sh_date = data.message[index].opening_date + ' - ' + data.message[index].closing_date;
|
||||
var shift_id = data.message[index].shift_id ;
|
||||
|
||||
if(param_shift != ''){
|
||||
if(shift_id == param_shift){
|
||||
selected = 'selected = "selected"';
|
||||
}
|
||||
else{
|
||||
selected = '';
|
||||
}
|
||||
}
|
||||
else{
|
||||
selected = '';
|
||||
}
|
||||
|
||||
|
||||
str += '<option value="'+ shift_id +'" '+ selected +'>' + local_date + '</option>';
|
||||
|
||||
// console.log(sh_date)
|
||||
})
|
||||
shift.append(str);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
55
app/views/reports/induty/index.xls.erb
Executable file
55
app/views/reports/induty/index.xls.erb
Executable file
@@ -0,0 +1,55 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-type" content="application/vnd.ms-excel; charset=UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="margin-top-20">
|
||||
<div class="card">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped" id="items_table" border="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="7"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
|
||||
</tr>
|
||||
<% if @shift_from %>
|
||||
<tr>
|
||||
<% if @shift_data.employee %>
|
||||
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
|
||||
<% end %>
|
||||
<th colspan="7"> <%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.receipt_no") %></th>
|
||||
<th><%= t :commissioners %></th>
|
||||
<th><%= t :table %></th>
|
||||
<th><%= t("views.right_panel.detail.in_time") %></th>
|
||||
<th><%= t("views.right_panel.detail.out_time") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if !@induty_data.nil? %>
|
||||
<% induty_arr = Array.new %>
|
||||
<% @induty_data.each do |induty| %>
|
||||
<tr>
|
||||
<td><%= induty.receipt_no %></td>
|
||||
<td><%= induty.name %></td>
|
||||
<td><%= induty.dining_name %></td>
|
||||
<td><%= induty.in_time.utc.getlocal.strftime("%d-%m-%Y - %I:%M") %></td>
|
||||
<td><%= induty.out_time.utc.getlocal.strftime("%d-%m-%Y - %I:%M") %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9">
|
||||
<%= simple_form_for([:settings,@category, @settings_menu_item]) do |f| %>
|
||||
<%= simple_form_for([:settings,@category, @settings_menu_item],:html => {:onsubmit=>"return validateForm()"}) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
<div class="card">
|
||||
<div class="row">
|
||||
@@ -92,4 +92,22 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
function validateForm() {
|
||||
var x = $(".item_attributes").val();
|
||||
if (x == null) {
|
||||
swal({
|
||||
title: "Opps!",
|
||||
text: "Item attributes must be filled out",
|
||||
type: 'error',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
location.reload();
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9">
|
||||
<%= simple_form_for([:settings,@category, @settings_menu_item]) do |f| %>
|
||||
<%= simple_form_for([:settings,@category, @settings_menu_item],:html => {:onsubmit=>"return validateForm()"}) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
<div class="card">
|
||||
<div class="row">
|
||||
@@ -88,4 +88,23 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function validateForm() {
|
||||
var x = $(".item_attributes").val();
|
||||
if (x == null) {
|
||||
swal({
|
||||
title: "Opps!",
|
||||
text: "Item attributes must be filled out",
|
||||
type: 'error',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
location.reload();
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -487,6 +487,9 @@ en:
|
||||
order_reservation: "Order Reservation"
|
||||
cooking_time: "Cooking Time"
|
||||
township: "Township"
|
||||
induty_report: "Induty Report"
|
||||
in_time: "In Time"
|
||||
out_time: "Out Time"
|
||||
|
||||
code_txt: "code "
|
||||
charge_txt: "charge"
|
||||
|
||||
@@ -481,6 +481,9 @@ mm:
|
||||
order_reservation: "Order Reservation"
|
||||
cooking_time: "Cooking Time"
|
||||
township: "Township"
|
||||
induty_report: "Induty Report"
|
||||
in_time: "In Time"
|
||||
out_time: "Out Time"
|
||||
|
||||
code_txt: "ကုတ်ဒ် "
|
||||
charge_txt: "ကောက်ခံသည်"
|
||||
|
||||
@@ -131,13 +131,13 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
post 'cancel_all_void' => 'sale_edit#cancel_all_void'
|
||||
post 'apply_void' => 'sale_edit#apply_void'
|
||||
# in_duties
|
||||
get '/table/:table_id/assign_in_duty' => 'in_duties#assign_in_duty', as: 'assign_in_duty'
|
||||
get 'assign_in_duty/:table_id' => 'in_duties#index_in_duty', as: 'index_in_duty'
|
||||
post 'assign_in_duty/:table_id' => 'in_duties#create_for_in_duty'
|
||||
get '/table/:sale_id/assign_in_duty' => 'in_duties#assign_in_duty', as: 'assign_in_duty'
|
||||
get 'assign_in_duty/:sale_id' => 'in_duties#index_in_duty', as: 'index_in_duty'
|
||||
post 'assign_in_duty/:sale_id' => 'in_duties#create_for_in_duty'
|
||||
|
||||
get 'assign_in_duty/table/:table_id/in_duty/:id/edit' => 'in_duties#edit_in_duty' ,as: 'edit_in_duty'
|
||||
get 'assign_in_duty/table/:sale_id/in_duty/:id/edit' => 'in_duties#edit_in_duty' ,as: 'edit_in_duty'
|
||||
patch 'edit_in_duty/:id' => 'in_duties#update_for_in_duty', as: 'update_for_in_duty'
|
||||
delete 'table/:table_id/destroy_in_duty/:id' => 'in_duties#destroy_in_duty', as: 'destroy_in_duty'
|
||||
delete 'table/:table_id/:sale_id/destroy_in_duty/:id' => 'in_duties#destroy_in_duty', as: 'destroy_in_duty'
|
||||
|
||||
get 'table/:dining_id/movetable' => "movetable#move_dining"
|
||||
get 'table/:dining_id/moveroom' => "moveroom#move_dining"
|
||||
@@ -454,9 +454,12 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
resources :payment_method
|
||||
resources :product_sale, :only => [:index, :show]
|
||||
resources :order_reservation, :only => [:index, :show]
|
||||
resources :induty, :only => [:index, :show]
|
||||
|
||||
get "saleitem/get_shift_by_date", to: "saleitem#show", as: "get_shift_by_sale_item"
|
||||
get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date"
|
||||
get "order_reservation/get_shift_by_date", to: "order_reservation#show", as: "get_shift_by_order_reservation"
|
||||
get "induty/get_shift_by_date", to: "induty#show", as: "get_shift_by_induty"
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user