small fix for current property hiring check
This commit is contained in:
parent
77764690af
commit
610f824628
|
@ -1,6 +1,6 @@
|
|||
module Admin::PropertyHiresHelper
|
||||
|
||||
def check_for_availability(stime, etime, pid, interval, recurring_end_date)
|
||||
def check_for_availability(stime, etime, pid, interval=nil, recurring_end_date=nil)
|
||||
property = Property.find(pid)
|
||||
return {"success" => false, "msg" => "Values are not ok."} if property.nil? || stime.blank? || etime.blank?
|
||||
stime = DateTime.parse(stime + Time.zone.to_s) rescue nil
|
||||
|
|
|
@ -97,12 +97,15 @@ class Property
|
|||
stepu = 1.week
|
||||
when "month"
|
||||
stepu = 1.month
|
||||
else
|
||||
stepu = 0
|
||||
end
|
||||
bookings = self.p_hires.where(:recurring_end_date.gte => stime, :recurring => true)
|
||||
bookings.each do |booking|
|
||||
booking.time_iterate do |st,et|
|
||||
tst = stime
|
||||
tet = etime
|
||||
if stepu != 0
|
||||
begin
|
||||
common_time = (tst..tet) & (st..et)
|
||||
available = false if !common_time.nil?
|
||||
|
@ -110,6 +113,11 @@ class Property
|
|||
break if !available
|
||||
break if tst > st
|
||||
end while (tst += stepu) <= recurring_end_date
|
||||
else
|
||||
common_time = (tst..tet) & (st..et)
|
||||
available = false if !common_time.nil?
|
||||
break if !available
|
||||
end
|
||||
break if !available
|
||||
end
|
||||
break if !available
|
||||
|
|
Loading…
Reference in New Issue