add fun: for checkin and checkout
This commit is contained in:
@@ -3,7 +3,7 @@ class Api::CheckInProcessController < Api::ApiController
|
|||||||
def check_in_time
|
def check_in_time
|
||||||
if params[:dining_id]
|
if params[:dining_id]
|
||||||
dining_facility = DiningFacility.find(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?
|
if !booking.nil?
|
||||||
check_in_time = booking.checkin_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
|
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")
|
check_out_time = booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
|
||||||
@@ -51,10 +51,10 @@ class Api::CheckInProcessController < Api::ApiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
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!
|
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
|
else
|
||||||
error_message = "#{dining_facility.type} is not available!"
|
error_message = "#{dining_facility.type} is not available!"
|
||||||
render :json => { :status => false, :error_message => error_message }
|
render :json => { :status => false, :error_message => error_message }
|
||||||
@@ -79,7 +79,7 @@ class Api::CheckInProcessController < Api::ApiController
|
|||||||
booking.checkout_at = checkout_at
|
booking.checkout_at = checkout_at
|
||||||
booking.save!
|
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?
|
elsif !params[:booking_id].nil? && params[:time].nil?
|
||||||
error_message = "time is required!"
|
error_message = "time is required!"
|
||||||
render :json => { :status => false, :error_message => error_message }
|
render :json => { :status => false, :error_message => error_message }
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class Origami::CheckInProcessController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
@booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
@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!
|
@booking.save!
|
||||||
|
|
||||||
respond = {:status => 'ok'}
|
respond = {:status => 'ok'}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class DiningFacility < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_current_checkout_booking
|
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
|
if booking.count > 0 then
|
||||||
return booking[0]
|
return booking[0]
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -41,14 +41,22 @@
|
|||||||
<% @tables.each do |table| %>
|
<% @tables.each do |table| %>
|
||||||
<% if table.status == 'occupied' %>
|
<% if table.status == 'occupied' %>
|
||||||
<% if table.get_booking.nil? %>
|
<% if table.get_booking.nil? %>
|
||||||
|
<% if table.get_current_checkout_booking.nil? %>
|
||||||
<div class="card tables red text-white" data-id="<%= table.id %>">
|
<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">
|
<div class="card-block">
|
||||||
Zone <%= table.zone_id %> <br>
|
Zone <%= table.zone_id %> <br>
|
||||||
Table <%= table.name %> ( <%= table.seater %> Seat )
|
Table <%= table.name %> ( <%= table.seater %> Seat )
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
<% if table.get_current_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 %>">
|
||||||
|
<% else %>
|
||||||
|
<div class="card tables orange text-white" data-id="<%= table.id %>">
|
||||||
|
<% end %>
|
||||||
<div class="card-block">
|
<div class="card-block">
|
||||||
Zone <%= table.zone_id %> <br>
|
Zone <%= table.zone_id %> <br>
|
||||||
Table <%= table.name %> ( <%= table.seater %> Seat )
|
Table <%= table.name %> ( <%= table.seater %> Seat )
|
||||||
|
|||||||
@@ -40,7 +40,11 @@
|
|||||||
<% @tables.each do |table| %>
|
<% @tables.each do |table| %>
|
||||||
<% if table.status == 'occupied' %>
|
<% if table.status == 'occupied' %>
|
||||||
<% if table.get_booking.nil? %>
|
<% 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 %>">
|
<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">
|
<div class="card-block">
|
||||||
<%= table.name %>
|
<%= table.name %>
|
||||||
<span class="float-right font-12 new_text_<%= table.id %>"> billed</span>
|
<span class="float-right font-12 new_text_<%= table.id %>"> billed</span>
|
||||||
@@ -48,7 +52,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
<% if table.get_current_checkout_booking.nil? %>
|
||||||
<div class="card tables blue text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
<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">
|
<div class="card-block">
|
||||||
<%= table.name %>
|
<%= table.name %>
|
||||||
<span class="float-right font-12 new_text_<%= table.id %>"> new</span>
|
<span class="float-right font-12 new_text_<%= table.id %>"> new</span>
|
||||||
|
|||||||
@@ -40,14 +40,22 @@
|
|||||||
<% @tables.each do |table| %>
|
<% @tables.each do |table| %>
|
||||||
<% if table.status == 'occupied' %>
|
<% if table.status == 'occupied' %>
|
||||||
<% if table.get_booking.nil? %>
|
<% 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 %>">
|
<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">
|
<div class="card-block">
|
||||||
<%= table.name %>
|
<%= table.name %>
|
||||||
<span class="pull-right font-12 new_text_<%= table.id %>"> billed</span>
|
<span class="pull-right font-12 new_text_<%= table.id %>"> billed</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
<% if table.get_current_checkout_booking.nil? %>
|
||||||
<div class="card tables blue text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
<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">
|
<div class="card-block">
|
||||||
<%= table.name %>
|
<%= table.name %>
|
||||||
<span class="pull-right font-12 new_text_<%= table.id %>"> new</span>
|
<span class="pull-right font-12 new_text_<%= table.id %>"> new</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user