dashboard ui and checkin checkout process
This commit is contained in:
78
app/controllers/api/check_in_process_controller.rb
Normal file
78
app/controllers/api/check_in_process_controller.rb
Normal file
@@ -0,0 +1,78 @@
|
||||
class Api::CheckInProcessController < Api::ApiController
|
||||
|
||||
def check_in_process
|
||||
if params[:dining_id]
|
||||
dining_facility = DiningFacility.find(params[:dining_id])
|
||||
if dining_facility.status == "available"
|
||||
dining_charge = DiningCharge.select('charge_type','charge_block')
|
||||
.where('dining_facility_id = ?',params[:dining_id])
|
||||
.first()
|
||||
|
||||
checkout_at = Time.now.utc
|
||||
|
||||
if !dining_charge.nil?
|
||||
hr = (dining_charge.charge_block.utc.strftime("%H").to_i).to_int
|
||||
min = (dining_charge.charge_block.utc.strftime("%M").to_i).to_int
|
||||
# if dining_charge.charge_type == 'hr'
|
||||
checkout_at = checkout_at + hr.hour + min.minutes
|
||||
# else
|
||||
|
||||
# end
|
||||
end
|
||||
|
||||
dining_facility.status = "occupied"
|
||||
dining_facility.save!
|
||||
|
||||
if dining_facility.type == "Table"
|
||||
type = "TableBooking"
|
||||
else
|
||||
type = "RoomBooking"
|
||||
end
|
||||
|
||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
||||
:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign" })
|
||||
booking.save!
|
||||
|
||||
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.strftime("%Y-%m-%d %H:%M") }
|
||||
else
|
||||
error_message = "#{dining_facility.type} is not available!"
|
||||
render :json => { :status => false, :error_message => error_message }
|
||||
end
|
||||
else
|
||||
error_message = "dining_id is required!"
|
||||
render :json => { :status => false, :error_message => error_message }
|
||||
end
|
||||
end
|
||||
|
||||
def request_time
|
||||
if !params[:booking_id].nil? && !params[:time].nil?
|
||||
time = Time.parse(params[:time])
|
||||
booking = Booking.find(params[:booking_id])
|
||||
|
||||
checkout_at = booking.checkout_at.utc
|
||||
|
||||
hr = (time.strftime("%H").to_i).to_int
|
||||
min = (time.strftime("%M").to_i).to_int
|
||||
checkout_at = checkout_at + hr.hour + min.minutes
|
||||
|
||||
booking.checkout_at = checkout_at
|
||||
booking.save!
|
||||
|
||||
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.strftime("%Y-%m-%d %H:%M") }
|
||||
elsif !params[:booking_id].nil? && params[:time].nil?
|
||||
error_message = "time is required!"
|
||||
render :json => { :status => false, :error_message => error_message }
|
||||
elsif params[:booking_id].nil? && !params[:time].nil?
|
||||
error_message = "booking_id is required!"
|
||||
render :json => { :status => false, :error_message => error_message }
|
||||
else
|
||||
error_message = "booking_id and time are required!"
|
||||
render :json => { :status => false, :error_message => error_message }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def check_in_process_params
|
||||
params.permit(:dining_id,:booking_id,:time)
|
||||
end
|
||||
end
|
||||
@@ -74,18 +74,42 @@ class HomeController < ApplicationController
|
||||
@employee_sales = Sale.employee_sales(today).sum(:grand_total)
|
||||
@inventories = StockJournal.inventory_balances(today).sum(:balance)
|
||||
|
||||
#@employee_sales = Hash.new
|
||||
#employee_sales.each do |key, value|
|
||||
# if(@employee_sales.has_key? key[1])
|
||||
# @employee_sales[key[1]].push({key[0] => value})
|
||||
# else
|
||||
# @employee_sales[key[1]] = [key[0] => value]
|
||||
# end
|
||||
#end
|
||||
@total_sale = Sale.total_sale(today)
|
||||
@total_count = Sale.total_count(today)
|
||||
@total_card = Sale.total_card_sale(today)
|
||||
@total_credit = Sale.credit_payment(today)
|
||||
@total_credit = Sale.credit_payment(today)
|
||||
|
||||
@sale_data = Array.new
|
||||
@total_payment_methods = Sale.total_payment_methods(today)
|
||||
@total_payment_methods.each do |payment|
|
||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb"
|
||||
pay = Sale.payment_sale('card', today)
|
||||
@sale_data.push({'card' => pay})
|
||||
else
|
||||
pay = Sale.payment_sale(payment.payment_method, today)
|
||||
@sale_data.push({payment.payment_method => pay})
|
||||
end
|
||||
end
|
||||
@summ_sale = Sale.summary_sale_receipt(today)
|
||||
|
||||
@total_customer = Sale.total_customer(today)
|
||||
@total_dinein = Sale.total_dinein(today)
|
||||
@total_takeaway = Sale.total_takeaway(today)
|
||||
@total_other_customer = Sale.total_other_customer(today)
|
||||
@total_membership = Sale.total_membership(today)
|
||||
|
||||
@total_order = Sale.total_order(today)
|
||||
@total_accounts = Sale.total_account(today)
|
||||
@account_data = Array.new
|
||||
@total_accounts.each do |account|
|
||||
acc = Sale.account_data(account.account_id, today)
|
||||
if !acc.nil?
|
||||
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
||||
end
|
||||
end
|
||||
|
||||
@top_items = Sale.top_items(today)
|
||||
@total_foc_items = Sale.total_foc_items(today)
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
||||
38
app/controllers/origami/check_in_process_controller.rb
Normal file
38
app/controllers/origami/check_in_process_controller.rb
Normal file
@@ -0,0 +1,38 @@
|
||||
class Origami::CheckInProcessController < BaseOrigamiController
|
||||
|
||||
def check_in_process
|
||||
dining_charge = DiningCharge.select('charge_type','charge_block')
|
||||
.where('dining_facility_id = ?',params[:dining_id])
|
||||
.first()
|
||||
|
||||
checkout_at = Time.now.utc
|
||||
|
||||
if !dining_charge.nil?
|
||||
hr = (dining_charge.charge_block.utc.strftime("%H").to_i).to_int
|
||||
min = (dining_charge.charge_block.utc.strftime("%M").to_i).to_int
|
||||
# if dining_charge.charge_type == 'hr'
|
||||
checkout_at = checkout_at + hr.hour + min.minutes
|
||||
# else
|
||||
|
||||
# end
|
||||
end
|
||||
@dining_facility = DiningFacility.find(params[:dining_id])
|
||||
@dining_facility.status = "occupied"
|
||||
@dining_facility.save!
|
||||
|
||||
if @dining_facility.type == "Table"
|
||||
type = "TableBooking"
|
||||
else
|
||||
type = "RoomBooking"
|
||||
end
|
||||
|
||||
@booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
||||
:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign" })
|
||||
@booking.save!
|
||||
|
||||
respond = {:status => 'ok'}
|
||||
respond_to do |format|
|
||||
format.json { render json: respond }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -7,7 +7,7 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
||||
@orders = Order.all.order('date desc')
|
||||
@shop = Shop.find_by_id(1)
|
||||
|
||||
|
||||
# @shift = ShiftSale.current_open_shift(current_user.id)
|
||||
end
|
||||
|
||||
@@ -23,10 +23,12 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@sale_array = Array.new
|
||||
|
||||
@dining.bookings.active.each do |booking|
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
|
||||
@order_items = Array.new
|
||||
booking.booking_orders.each do |booking_order|
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
@order_items = Array.new
|
||||
if booking.booking_orders.empty?
|
||||
@booking = booking
|
||||
else
|
||||
booking.booking_orders.each do |booking_order|
|
||||
order = Order.find(booking_order.order_id)
|
||||
if (order.status == "new")
|
||||
@obj_order = order
|
||||
@@ -43,29 +45,30 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@account_arr.push(account)
|
||||
end
|
||||
end
|
||||
end
|
||||
@status_order = 'order'
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
if sale.sale_status != "completed" && sale.sale_status != 'void'
|
||||
|
||||
@sale_array.push(sale)
|
||||
if @status_order == 'order'
|
||||
@status_order = 'sale'
|
||||
end
|
||||
@booking= booking
|
||||
@date = sale.created_at
|
||||
@status_sale = 'sale'
|
||||
@obj_sale = sale
|
||||
@customer = sale.customer
|
||||
accounts = @customer.tax_profiles
|
||||
@account_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find(acc)
|
||||
@account_arr.push(account)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@status_order = 'order'
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
if sale.sale_status != "completed" && sale.sale_status != 'void'
|
||||
|
||||
@sale_array.push(sale)
|
||||
if @status_order == 'order'
|
||||
@status_order = 'sale'
|
||||
end
|
||||
@booking= booking
|
||||
@date = sale.created_at
|
||||
@status_sale = 'sale'
|
||||
@obj_sale = sale
|
||||
@customer = sale.customer
|
||||
accounts = @customer.tax_profiles
|
||||
@account_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find(acc)
|
||||
@account_arr.push(account)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user