From 9c335f0a5f923cd7a4946e5ee5c0383fe091869e Mon Sep 17 00:00:00 2001 From: sk821 Date: Mon, 3 Sep 2018 17:51:56 +0800 Subject: [PATCH] fix view_calendar recurring & added show recurring_end_date --- app/controllers/property_hires_controller.rb | 2 +- app/models/p_hire.rb | 4 ++-- .../admin/property_hires/show_booking_details.html.erb | 10 ++++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/controllers/property_hires_controller.rb b/app/controllers/property_hires_controller.rb index 38bc037..9ff91bd 100644 --- a/app/controllers/property_hires_controller.rb +++ b/app/controllers/property_hires_controller.rb @@ -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 diff --git a/app/models/p_hire.rb b/app/models/p_hire.rb index 745dd42..30f8ba1 100644 --- a/app/models/p_hire.rb +++ b/app/models/p_hire.rb @@ -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 diff --git a/app/views/admin/property_hires/show_booking_details.html.erb b/app/views/admin/property_hires/show_booking_details.html.erb index 55a4a69..4aecfd4 100644 --- a/app/views/admin/property_hires/show_booking_details.html.erb +++ b/app/views/admin/property_hires/show_booking_details.html.erb @@ -18,6 +18,16 @@ <%= t("property_hire.period") %> <%= @booking.period %> + <% if @booking.recurring %> + + <%= t("property_hire.recurring_interval") %> + <%= @booking.recurring_interval %> + + + <%= t("property_hire.recurring_end_date") %> + <%= @booking.recurring_end_date.strftime("%y-%m-%d %H:%M") %> + + <% end %> <%= t("property_hire.reason_for_hire") %> <%= @booking.reason_for_hire %>