diff --git a/app/controllers/property_hires_controller.rb b/app/controllers/property_hires_controller.rb index c513bac..985ad57 100644 --- a/app/controllers/property_hires_controller.rb +++ b/app/controllers/property_hires_controller.rb @@ -290,10 +290,10 @@ class PropertyHiresController < ApplicationController 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_end_time = property.end_time.blank? ? "24:00" : property.end_time - @check_start_date = property.start_date - @check_end_date = property.end_date + @check_start_date = property.start_date.to_date rescue nil + @check_end_date = property.end_date.to_date rescue nil 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 end end @@ -319,11 +319,13 @@ class PropertyHiresController < ApplicationController end def reserve_calendar_event(date,title,allow_times) available = true - if @check_setting && !allow_times[5] - available = date > @check_end_date || date < @check_start_date + if @check_setting && allow_times.select{|a| !a[5]}.count != 0 + available = (date > @check_end_date rescue false) || (date < @check_start_date rescue false) unless available 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 else false