fix view_calendar recurring & added show recurring_end_date

This commit is contained in:
sk821 2018-09-03 17:51:56 +08:00
parent 849cf2e680
commit 9c335f0a5f
3 changed files with 13 additions and 3 deletions

View File

@ -189,7 +189,7 @@ class PropertyHiresController < ApplicationController
sdt = Time.at(params[:start].to_i)
edt = Time.at(params[:end].to_i)
events = PHire.monthly_event(sdt,edt,params[:property_id])
re = PHire.recurring_event(sdt,edt)
re = PHire.recurring_event(sdt,edt,params[:property_id])
allevents = events.inject(re, :<<)
end
end

View File

@ -47,8 +47,8 @@ class PHire
self.where(:property_id => property_id, :recurring => false).any_of(:start_time.gte => start_date, :end_time.gte => start_date).and(:start_time.lte => end_date).asc(:start_time)
end
def self.recurring_event(start_date,end_date)
@recurring_events = self.where(:recurring => true, :recurring_end_date.gte => start_date)
def self.recurring_event(start_date,end_date,property_id)
@recurring_events = self.where(:property_id => property_id, :recurring => true, :recurring_end_date.gte => start_date)
@recurring = []
@recurring_events.each do |re|
case re.recurring_interval

View File

@ -18,6 +18,16 @@
<td><%= t("property_hire.period") %></td>
<td><%= @booking.period %></td>
</tr>
<% if @booking.recurring %>
<tr>
<td><%= t("property_hire.recurring_interval") %></td>
<td><%= @booking.recurring_interval %></td>
</tr>
<tr>
<td><%= t("property_hire.recurring_end_date") %></td>
<td><%= @booking.recurring_end_date.strftime("%y-%m-%d %H:%M") %></td>
</tr>
<% end %>
<tr>
<td><%= t("property_hire.reason_for_hire") %></td>
<td><%= @booking.reason_for_hire %></td>