fix error

This commit is contained in:
chiu 2020-05-26 22:15:45 +08:00
parent d159171993
commit 386cb0c5e0
1 changed files with 21 additions and 15 deletions

View File

@ -108,27 +108,33 @@ class Property
if (b_interval == 'month' || b_interval == 'week') && booking.recurring_end_date.nil?
b_interval = nil
end
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 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
else
if b_interval != 'month' && b_interval != 'week'
b_sdata = booking.start_time
b_edata = booking.end_time
end
while true
if b_interval == 'month'
sdata = stime_tp.day*10000 + stime_tp.hour*100 + stime_tp.minute
edata = etime_tp.day*10000 + etime_tp.hour*100 + etime_tp.minute
elsif b_interval == 'week'
sdata = stime_tp.wday*10000 + stime_tp.hour*100 + stime_tp.minute
edata = etime_tp.wday*10000 + etime_tp.hour*100 + etime_tp.minute
else
diff_month = booking.end_time.month - booking.start_time.month
diff_month = diff_month + 12 if diff_month < 0
e_month = stime_tp.month + diff_month
e_year = stime_tp.year + (booking.end_time.year-booking.start_time.year)
e_month = e_month - 12
b_sdata = "#{stime_tp.year}/#{stime_tp.month}/#{booking.start_time.day} #{booking.start_time.hour}:#{booking.start_time.minute}".to_datetime
b_edata = "#{e_year}/#{e_month}/#{booking.end_time.day} #{booking.end_time.hour}:#{booking.end_time.minute}".to_datetime
elsif b_interval = 'week'
diff_day = booking.end_time -booking.start_time
if (booking.end_time.wday <= booking.start_time.wday && diff_day>1) || diff_day > 7
over_one_week = true
end
b_sdata = stime_tp - stime_tp.wday + booking.start_time.wday
if over_one_week && etime_tp.wday<=booking.start_time.wday
b_sdata = b_sdata - 7.day
end
b_edata_tp = b_sdata + (booking.end_time-booking.start_time).to_i.day
b_edata = "#{b_edata_tp.year}/#{b_edata_tp.month}/#{b_edata_tp.day} #{booking.end_time.hour}:#{booking.end_time.minute}".to_datetime
end
sdata = stime_tp
edata = etime_tp
end
if etime_tp > booking.start_time
if (sdata <= b_sdata && edata >= b_sdata) || (sdata >= b_sdata && edata <= b_edata) || (sdata <= b_edata && edata >= b_edata)
available = false