From 76387915e8649ed5d0fbe03483337810c78793e6 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 17 Jan 2018 15:53:58 +0800 Subject: [PATCH] added delete option ofr property hire --- app/controllers/admin/property_hires_controller.rb | 7 +++++++ app/models/p_hire.rb | 2 +- app/views/admin/property_hires/show.html.erb | 2 ++ .../admin/property_hires/show_booking_details.html.erb | 2 ++ config/routes.rb | 1 + 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/property_hires_controller.rb b/app/controllers/admin/property_hires_controller.rb index 17e99f0..a33e0cc 100644 --- a/app/controllers/admin/property_hires_controller.rb +++ b/app/controllers/admin/property_hires_controller.rb @@ -64,6 +64,13 @@ class Admin::PropertyHiresController < OrbitAdminController @booking = PHire.find(params[:id]) rescue nil end + def delete_booking_details + booking = PHire.find(params[:id]) + property = booking.property + booking.destroy + redirect_to admin_property_hire_path(property) + end + def pass_booking phire = PHire.find(params[:id]) rescue nil case params[:status] diff --git a/app/models/p_hire.rb b/app/models/p_hire.rb index a8840d8..9f6cdd0 100644 --- a/app/models/p_hire.rb +++ b/app/models/p_hire.rb @@ -39,7 +39,7 @@ class PHire end def self.monthly_event(start_date,end_date,property_id) - self.where(:property_id => property_id, :passed => true).any_of(:start_time.gte => start_date, :end_time.gte => start_date).and(:start_time.lte => end_date).asc(:start_time) + self.where(:property_id => property_id).any_of(:start_time.gte => start_date, :end_time.gte => start_date).and(:start_time.lte => end_date).asc(:start_time) end end \ No newline at end of file diff --git a/app/views/admin/property_hires/show.html.erb b/app/views/admin/property_hires/show.html.erb index 8ed0f35..e7f579f 100644 --- a/app/views/admin/property_hires/show.html.erb +++ b/app/views/admin/property_hires/show.html.erb @@ -1,3 +1,4 @@ +<%= csrf_meta_tag %> @@ -35,6 +36,7 @@ <% else %> "index") %>" class="btn btn-success">Accept <% end %> + Delete <% end %> 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 3fd60b9..b63127d 100644 --- a/app/views/admin/property_hires/show_booking_details.html.erb +++ b/app/views/admin/property_hires/show_booking_details.html.erb @@ -1,3 +1,4 @@ +<%= csrf_meta_tag %>

<%= @booking.property.title %>

@@ -43,6 +44,7 @@ <% else %> " class="btn btn-success">Accept <% end %> +Delete diff --git a/config/routes.rb b/config/routes.rb index 9fbdbdd..2f5dead 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,6 +13,7 @@ Rails.application.routes.draw do delete "destroy_location" get "show_booking_details" get "pass_booking" + delete "delete_booking_details" end collection do get "manage_locations"