added delete option ofr property hire

This commit is contained in:
Harry Bomrah 2018-01-17 15:53:58 +08:00
parent 12f4591a49
commit 76387915e8
5 changed files with 13 additions and 1 deletions

View File

@ -64,6 +64,13 @@ class Admin::PropertyHiresController < OrbitAdminController
@booking = PHire.find(params[:id]) rescue nil @booking = PHire.find(params[:id]) rescue nil
end 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 def pass_booking
phire = PHire.find(params[:id]) rescue nil phire = PHire.find(params[:id]) rescue nil
case params[:status] case params[:status]

View File

@ -39,7 +39,7 @@ class PHire
end end
def self.monthly_event(start_date,end_date,property_id) 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
end end

View File

@ -1,3 +1,4 @@
<%= csrf_meta_tag %>
<table class="table main-list"> <table class="table main-list">
<thead> <thead>
<tr class="sort-header"> <tr class="sort-header">
@ -35,6 +36,7 @@
<% else %> <% else %>
<a href="<%= pass_booking_admin_property_hire_path(p_hire, :page => params[:page], :status => "accept", :ref => "index") %>" class="btn btn-success">Accept</a> <a href="<%= pass_booking_admin_property_hire_path(p_hire, :page => params[:page], :status => "accept", :ref => "index") %>" class="btn btn-success">Accept</a>
<% end %> <% end %>
<a href="<%= delete_booking_details_admin_property_hire_path(p_hire, :page => params[:page]) %>" class="btn btn-danger" data-method="delete" data-confirm="Are you sure?">Delete</a>
</td> </td>
</tr> </tr>
<% end %> <% end %>

View File

@ -1,3 +1,4 @@
<%= csrf_meta_tag %>
<h3><%= @booking.property.title %></h3> <h3><%= @booking.property.title %></h3>
<table class="table main-list"> <table class="table main-list">
<tbody> <tbody>
@ -43,6 +44,7 @@
<% else %> <% else %>
<a href="<%= pass_booking_admin_property_hire_path(@booking, :status => "accept") %>" class="btn btn-success">Accept</a> <a href="<%= pass_booking_admin_property_hire_path(@booking, :status => "accept") %>" class="btn btn-success">Accept</a>
<% end %> <% end %>
<a href="<%= delete_booking_details_admin_property_hire_path(@booking, :page => params[:page]) %>" class="btn btn-danger" data-method="delete" data-confirm="Are you sure?">Delete</a>

View File

@ -13,6 +13,7 @@ Rails.application.routes.draw do
delete "destroy_location" delete "destroy_location"
get "show_booking_details" get "show_booking_details"
get "pass_booking" get "pass_booking"
delete "delete_booking_details"
end end
collection do collection do
get "manage_locations" get "manage_locations"