This commit is contained in:
BoHung Chiu 2021-09-09 10:14:57 +08:00
parent ceb60e3afc
commit b88915c6e7
1 changed files with 8 additions and 6 deletions

View File

@ -290,10 +290,10 @@ class PropertyHiresController < ApplicationController
check_setting = property.set_unavailibility && (property.property_day_settings.where(:enable=>false).count != 0) check_setting = property.set_unavailibility && (property.property_day_settings.where(:enable=>false).count != 0)
@check_start_time = property.start_time.blank? ? "00:00" : property.start_time @check_start_time = property.start_time.blank? ? "00:00" : property.start_time
@check_end_time = property.end_time.blank? ? "24:00" : property.end_time @check_end_time = property.end_time.blank? ? "24:00" : property.end_time
@check_start_date = property.start_date @check_start_date = property.start_date.to_date rescue nil
@check_end_date = property.end_date @check_end_date = property.end_date.to_date rescue nil
if check_setting if check_setting
if (@check_start_date > edt rescue false) || (@check_end_date > sdt rescue false) if (@check_start_date > edt rescue false) || (@check_end_date < sdt rescue false)
check_setting = false check_setting = false
end end
end end
@ -319,11 +319,13 @@ class PropertyHiresController < ApplicationController
end end
def reserve_calendar_event(date,title,allow_times) def reserve_calendar_event(date,title,allow_times)
available = true available = true
if @check_setting && !allow_times[5] if @check_setting && allow_times.select{|a| !a[5]}.count != 0
available = date > @check_end_date || date < @check_start_date available = (date > @check_end_date rescue false) || (date < @check_start_date rescue false)
unless available unless available
allow_times = allow_times.select do |allow_time| allow_times = allow_times.select do |allow_time|
if allow_time[0] > @check_end_time || allow_time[1] < @check_start_time if allow_time[5]
true
elsif (allow_time[0] > @check_end_time || allow_time[1] < @check_start_time)
true true
else else
false false