change future checkin time flow
This commit is contained in:
@@ -11,6 +11,10 @@ class Api::BillController < Api::ApiController
|
|||||||
table = 0
|
table = 0
|
||||||
if (params[:booking_id])
|
if (params[:booking_id])
|
||||||
booking = Booking.find(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
|
# for Multiple Cashier by Zone
|
||||||
table = DiningFacility.find(booking.dining_facility_id)
|
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)
|
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
elsif (params[:order_id])
|
elsif (params[:order_id])
|
||||||
order = Order.find(params[:order_id])
|
order = Order.find(params[:order_id])
|
||||||
@sale = Sale.new
|
@sale = Sale.new
|
||||||
@@ -59,7 +64,7 @@ class Api::BillController < Api::ApiController
|
|||||||
# Bind shift sale id to sale
|
# Bind shift sale id to sale
|
||||||
# @sale_data.shift_sale_id = shift_by_terminal.id
|
# @sale_data.shift_sale_id = shift_by_terminal.id
|
||||||
# @sale_data.save
|
# @sale_data.save
|
||||||
|
if @status
|
||||||
#check checkInOut pdf print
|
#check checkInOut pdf print
|
||||||
check_booking = Booking.find_by_sale_id(@sale_id)
|
check_booking = Booking.find_by_sale_id(@sale_id)
|
||||||
checkout_time = Lookup.collection_of('checkout_time')
|
checkout_time = Lookup.collection_of('checkout_time')
|
||||||
@@ -88,6 +93,7 @@ class Api::BillController < Api::ApiController
|
|||||||
from = ""
|
from = ""
|
||||||
end
|
end
|
||||||
ActionCable.server.broadcast "bill_channel",table: table, from: from
|
ActionCable.server.broadcast "bill_channel",table: table, from: from
|
||||||
|
end
|
||||||
else
|
else
|
||||||
@status = false
|
@status = false
|
||||||
@error_message = "No Current Open Shift"
|
@error_message = "No Current Open Shift"
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class Api::CheckInProcessController < Api::ApiController
|
|||||||
def check_in_process
|
def check_in_process
|
||||||
if params[:dining_id]
|
if params[:dining_id]
|
||||||
dining_facility = DiningFacility.find(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]
|
if params[:checkin_time]
|
||||||
checkin_at = nil
|
checkin_at = nil
|
||||||
if !params[:checkin_time].empty?
|
if !params[:checkin_time].empty?
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ class Origami::RequestBillsController < ApplicationController
|
|||||||
bk_order = BookingOrder.find_by_order_id(order_id)
|
bk_order = BookingOrder.find_by_order_id(order_id)
|
||||||
order = Order.find(order_id)
|
order = Order.find(order_id)
|
||||||
check_booking = Booking.find_by_booking_id(bk_order.booking_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
|
if check_booking.dining_facility_id.to_i > 0
|
||||||
table = DiningFacility.find(check_booking.dining_facility_id)
|
table = DiningFacility.find(check_booking.dining_facility_id)
|
||||||
else
|
else
|
||||||
@@ -89,6 +93,7 @@ class Origami::RequestBillsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
@status = false
|
@status = false
|
||||||
@error_message = "No Current Open Shift for This Employee"
|
@error_message = "No Current Open Shift for This Employee"
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ class DiningFacility < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_current_booking
|
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
|
if booking.count > 0 then
|
||||||
return booking[0]
|
return booking[0]
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1078,7 +1078,19 @@
|
|||||||
// data: 'order_id='+ order_id,
|
// data: 'order_id='+ order_id,
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
if (!result.status) {
|
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 {
|
else {
|
||||||
location.reload();
|
location.reload();
|
||||||
|
|||||||
@@ -1146,7 +1146,19 @@ $('#request_bills').click(function() {
|
|||||||
// data: 'order_id='+ order_id,
|
// data: 'order_id='+ order_id,
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
if (!result.status) {
|
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 {
|
else {
|
||||||
location.reload();
|
location.reload();
|
||||||
|
|||||||
Reference in New Issue
Block a user