From 9310baa81abbc3be0405f2a1c67ef37c2a394040 Mon Sep 17 00:00:00 2001 From: phyusin Date: Fri, 8 Dec 2017 16:42:53 +0630 Subject: [PATCH] add checkin checkout time in origami --- app/models/dining_facility.rb | 8 ++++---- app/views/origami/home/show.html.erb | 6 +++++- app/views/origami/rooms/show.html.erb | 12 ++++++++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index 1b245b24..9948ec48 100755 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -78,13 +78,13 @@ class DiningFacility < ApplicationRecord def get_checkout_booking booking = self.get_current_checkout_booking if booking - now = Time.now.utc + now = Time.now.utc.getlocal hr = (now.strftime("%H").to_i).to_int min = (now.strftime("%M").to_i).to_int if !booking.checkout_at.nil? - checkout_at = booking.checkout_at.utc - checkout_at_hr = (checkout_at.utc.strftime("%H").to_i).to_int - checkout_at_min = (checkout_at.utc.strftime("%M").to_i).to_int + checkout_at = booking.checkout_at.utc.getlocal + checkout_at_hr = (checkout_at.strftime("%H").to_i).to_int + checkout_at_min = (checkout_at.strftime("%M").to_i).to_int checkout_at_min -= min if (checkout_at_hr <= hr) && (checkout_at_min <= 15) return booking diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 780ace0b..6d83f852 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -132,7 +132,11 @@
<% end %> ORDER DETAILS | Table <%= @dining.name rescue "" %> - Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> + <% if @booking.checkout_by.nil? && !@booking.reserved_by.nil? && %> + <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> - <%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") %> + <% else %> + Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> + <% end %>
<% elsif @status_sale == 'sale' %>
INVOICE DETAILS | Table <%= @dining.name rescue "" %> diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 0b65eae4..aee41b77 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -132,12 +132,20 @@
<% if @status_order == 'order' %>
ORDER DETAILS | Table <%= @room.name rescue "" %> - Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> + <% if @booking.checkout_by.nil? && !@booking.reserved_by.nil? && %> + <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> - <%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") %> + <% else %> + Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> + <% end %>
<% elsif @status_sale == 'sale' %>
INVOICE DETAILS | Table <%= @room.name rescue "" %> - Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> + <% if @booking.checkout_by.nil? && !@booking.reserved_by.nil? && %> + <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> - <%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") %> + <% else %> + Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> + <% end %>
<% end %>