add fun: for checkin and checkout
This commit is contained in:
@@ -3,7 +3,7 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
def check_in_time
|
||||
if params[:dining_id]
|
||||
dining_facility = DiningFacility.find(params[:dining_id])
|
||||
booking = dining_facility.get_current_booking
|
||||
booking = dining_facility.get_current_checkout_booking
|
||||
if !booking.nil?
|
||||
check_in_time = booking.checkin_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
|
||||
check_out_time = booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
|
||||
@@ -51,10 +51,10 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
end
|
||||
|
||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
||||
:checkin_by=>get_cashier[0].name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign" })
|
||||
:checkin_by=>get_cashier[0].name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => get_cashier[0].name })
|
||||
booking.save!
|
||||
|
||||
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.strftime("%Y-%m-%d %H:%M") }
|
||||
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") }
|
||||
else
|
||||
error_message = "#{dining_facility.type} is not available!"
|
||||
render :json => { :status => false, :error_message => error_message }
|
||||
@@ -79,7 +79,7 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
booking.checkout_at = checkout_at
|
||||
booking.save!
|
||||
|
||||
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.strftime("%Y-%m-%d %H:%M") }
|
||||
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.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 }
|
||||
|
||||
@@ -27,7 +27,7 @@ class Origami::CheckInProcessController < BaseOrigamiController
|
||||
end
|
||||
|
||||
@booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
||||
:checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign" })
|
||||
:checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
|
||||
@booking.save!
|
||||
|
||||
respond = {:status => 'ok'}
|
||||
|
||||
@@ -67,7 +67,7 @@ class DiningFacility < ApplicationRecord
|
||||
end
|
||||
|
||||
def get_current_checkout_booking
|
||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}'").limit(1)
|
||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and reserved_by is not null").limit(1)
|
||||
if booking.count > 0 then
|
||||
return booking[0]
|
||||
else
|
||||
|
||||
@@ -41,14 +41,22 @@
|
||||
<% @tables.each do |table| %>
|
||||
<% if table.status == 'occupied' %>
|
||||
<% if table.get_booking.nil? %>
|
||||
<% if table.get_current_checkout_booking.nil? %>
|
||||
<div class="card tables red text-white" data-id="<%= table.id %>">
|
||||
<% else %>
|
||||
<div class="card tables orange text-white" data-id="<%= table.id %>">
|
||||
<% end %>
|
||||
<div class="card-block">
|
||||
Zone <%= table.zone_id %> <br>
|
||||
Table <%= table.name %> ( <%= table.seater %> Seat )
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="card tables blue text-white" data-id="<%= table.id %>">
|
||||
<% else %>
|
||||
<% if table.get_current_checkout_booking.nil? %>
|
||||
<div class="card tables blue text-white" data-id="<%= table.id %>">
|
||||
<% else %>
|
||||
<div class="card tables orange text-white" data-id="<%= table.id %>">
|
||||
<% end %>
|
||||
<div class="card-block">
|
||||
Zone <%= table.zone_id %> <br>
|
||||
Table <%= table.name %> ( <%= table.seater %> Seat )
|
||||
|
||||
@@ -40,15 +40,23 @@
|
||||
<% @tables.each do |table| %>
|
||||
<% if table.status == 'occupied' %>
|
||||
<% if table.get_booking.nil? %>
|
||||
<div class="card tables red text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% if table.get_current_checkout_booking.nil? %>
|
||||
<div class="card tables red text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% else %>
|
||||
<div class="card tables orange text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% end %>
|
||||
<div class="card-block">
|
||||
<%= table.name %>
|
||||
<span class="float-right font-12 new_text_<%= table.id %>"> billed</span>
|
||||
<div style="font-size:12px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="card tables blue text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% else %>
|
||||
<% if table.get_current_checkout_booking.nil? %>
|
||||
<div class="card tables blue text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% else %>
|
||||
<div class="card tables orange text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% end %>
|
||||
<div class="card-block">
|
||||
<%= table.name %>
|
||||
<span class="float-right font-12 new_text_<%= table.id %>"> new</span>
|
||||
|
||||
@@ -39,15 +39,23 @@
|
||||
<div class="card-columns">
|
||||
<% @tables.each do |table| %>
|
||||
<% if table.status == 'occupied' %>
|
||||
<% if table.get_booking.nil? %>
|
||||
<div class="card tables red text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% if table.get_booking.nil? %>
|
||||
<% if table.get_current_checkout_booking.nil? %>
|
||||
<div class="card tables red text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% else %>
|
||||
<div class="card tables orange text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% end %>
|
||||
<div class="card-block">
|
||||
<%= table.name %>
|
||||
<span class="pull-right font-12 new_text_<%= table.id %>"> billed</span>
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="card tables blue text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% if table.get_current_checkout_booking.nil? %>
|
||||
<div class="card tables blue text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% else %>
|
||||
<div class="card tables orange text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% end %>
|
||||
<div class="card-block">
|
||||
<%= table.name %>
|
||||
<span class="pull-right font-12 new_text_<%= table.id %>"> new</span>
|
||||
|
||||
Reference in New Issue
Block a user