change future checkin time flow
This commit is contained in:
@@ -11,6 +11,10 @@ class Api::BillController < Api::ApiController
|
||||
table = 0
|
||||
if (params[:booking_id])
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if booking.checkin_at.utc.strftime("%Y-%m-%d %H:%M") > Time.now.utc.strftime("%Y-%m-%d %H:%M") && booking.checkout_at.nil?
|
||||
@status = false
|
||||
@error_message = "Operation failed, Could not request bill!"
|
||||
else
|
||||
# for Multiple Cashier by Zone
|
||||
table = DiningFacility.find(booking.dining_facility_id)
|
||||
|
||||
@@ -46,6 +50,7 @@ class Api::BillController < Api::ApiController
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
elsif (params[:order_id])
|
||||
order = Order.find(params[:order_id])
|
||||
@sale = Sale.new
|
||||
@@ -59,7 +64,7 @@ class Api::BillController < Api::ApiController
|
||||
# Bind shift sale id to sale
|
||||
# @sale_data.shift_sale_id = shift_by_terminal.id
|
||||
# @sale_data.save
|
||||
|
||||
if @status
|
||||
#check checkInOut pdf print
|
||||
check_booking = Booking.find_by_sale_id(@sale_id)
|
||||
checkout_time = Lookup.collection_of('checkout_time')
|
||||
@@ -88,6 +93,7 @@ class Api::BillController < Api::ApiController
|
||||
from = ""
|
||||
end
|
||||
ActionCable.server.broadcast "bill_channel",table: table, from: from
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@error_message = "No Current Open Shift"
|
||||
|
||||
@@ -62,7 +62,7 @@ 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"
|
||||
if dining_facility.is_active && dining_facility.status == "available"
|
||||
if params[:checkin_time]
|
||||
checkin_at = nil
|
||||
if !params[:checkin_time].empty?
|
||||
|
||||
@@ -16,6 +16,10 @@ class Origami::RequestBillsController < ApplicationController
|
||||
bk_order = BookingOrder.find_by_order_id(order_id)
|
||||
order = Order.find(order_id)
|
||||
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
||||
if check_booking.checkin_at.utc.strftime("%Y-%m-%d %H:%M") > Time.now.utc.strftime("%Y-%m-%d %H:%M") && check_booking.checkout_at.nil?
|
||||
@status = false
|
||||
@error_message = "Operation failed, Could not request bill!"
|
||||
else
|
||||
if check_booking.dining_facility_id.to_i > 0
|
||||
table = DiningFacility.find(check_booking.dining_facility_id)
|
||||
else
|
||||
@@ -89,6 +93,7 @@ class Origami::RequestBillsController < ApplicationController
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@error_message = "No Current Open Shift for This Employee"
|
||||
|
||||
@@ -32,7 +32,8 @@ class DiningFacility < ApplicationRecord
|
||||
end
|
||||
|
||||
def get_current_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}' and checkout_by is null").limit(1) #and checkout_at is null
|
||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and (CASE WHEN checkin_at > '#{DateTime.now.utc}' THEN checkin_at >= '#{DateTime.now.utc}' ELSE checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' END) and checkout_by is null").limit(1) #and checkout_at is null
|
||||
# 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 checkout_by is null").limit(1) #and checkout_at is null
|
||||
if booking.count > 0 then
|
||||
return booking[0]
|
||||
else
|
||||
|
||||
@@ -1078,7 +1078,19 @@
|
||||
// data: 'order_id='+ order_id,
|
||||
success: function (result) {
|
||||
if (!result.status) {
|
||||
swal("Information!", result.error_message);
|
||||
swal({
|
||||
title: 'Oops',
|
||||
text: result.error_message,
|
||||
type: 'error',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function (isConfirm) {
|
||||
if(isConfirm){
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
location.reload();
|
||||
|
||||
@@ -1146,7 +1146,19 @@ $('#request_bills').click(function() {
|
||||
// data: 'order_id='+ order_id,
|
||||
success: function (result) {
|
||||
if (!result.status) {
|
||||
swal("Information!", result.error_message);
|
||||
swal({
|
||||
title: 'Oops',
|
||||
text: result.error_message,
|
||||
type: 'error',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function (isConfirm) {
|
||||
if(isConfirm){
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
location.reload();
|
||||
|
||||
Reference in New Issue
Block a user