fix error
This commit is contained in:
parent
ec3e4463ca
commit
304dffbe9f
|
@ -92,25 +92,38 @@ class Property
|
|||
end
|
||||
if available
|
||||
bookings = self.p_hires.where(:recurring_end_date.gte => stime, :recurring => true)
|
||||
bookings.each do |booking|
|
||||
interval = booking.recurring_interval
|
||||
if interval == 'month'
|
||||
sdata = stime.day*10000 + stime.hour*100 + stime.minute
|
||||
edata = etime.day*10000 + etime.hour*100 + etime.minute
|
||||
elsif interval == 'week'
|
||||
sdata = stime.wday*10000 + stime.hour*100 + stime.minute
|
||||
edata = etime.wday*10000 + etime.hour*100 + etime.minute
|
||||
case interval
|
||||
when 'week'
|
||||
d_step = 1.week
|
||||
when 'day'
|
||||
d_step = 1.day
|
||||
else
|
||||
d_step = 0
|
||||
end
|
||||
if interval == 'month'
|
||||
bookings.each do |booking|
|
||||
b_interval = booking.recurring_interval
|
||||
if b_interval == 'month'
|
||||
b_sdata = booking.start_time.day*10000 + booking.start_time.hour*100 + booking.start_time.minute
|
||||
b_edata = booking.end_time.day*10000 + booking.end_time.hour*100 + booking.end_time.minute
|
||||
elsif interval == 'week'
|
||||
elsif b_interval == 'week'
|
||||
b_sdata = booking.start_time.wday*10000 + booking.start_time.hour*100 + booking.start_time.minute
|
||||
b_edata = booking.end_time.wday*10000 + booking.end_time.hour*100 + booking.end_time.minute
|
||||
end
|
||||
while True:
|
||||
if b_interval == 'month'
|
||||
sdata = stime.day*10000 + stime.hour*100 + stime.minute
|
||||
edata = etime.day*10000 + etime.hour*100 + etime.minute
|
||||
elsif b_interval == 'week'
|
||||
sdata = stime.wday*10000 + stime.hour*100 + stime.minute
|
||||
edata = etime.wday*10000 + etime.hour*100 + etime.minute
|
||||
end
|
||||
if (b_sdata <= sdata && b_edata >= sdata) || (b_sdata >= sdata && b_edata <= edata) || (b_sdata <= edata && b_edata >= edata)
|
||||
available = false
|
||||
end
|
||||
stime = stime + d_step
|
||||
etime = etime + d_step
|
||||
break if recurring_end_date.nil? || recurring_end_date < stime
|
||||
end
|
||||
break if available == false
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue