Class: Refinery::Bookings::Admin::BookingsController
- Inherits:
-
AdminController
- Object
- AdminController
- Refinery::Bookings::Admin::BookingsController
- Defined in:
- app/controllers/refinery/bookings/admin/bookings_controller.rb
Instance Method Summary collapse
Instance Method Details
#book ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/refinery/bookings/admin/bookings_controller.rb', line 17 def book puts "FROM: #{params[:from]} TO: #{params[:to]}" from = Date.parse(params[:from]) to = Date.parse(params[:to]) @bookings = [] from.upto(to).each do |date| @bookings << Booking.find_or_create_by_date(:status => true, :date => date) end respond_to do |format| format.html { redirect_to refinery.bookings_admin_bookings_path } format.js { render :json => { :dates => Booking.select(:date).map{|b| b.date.strftime('%Y,%m,%d')}, :start_date => @bookings.map{|b| b.date.strftime('%d-%m-%Y')} }} end end |
#index ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/refinery/bookings/admin/bookings_controller.rb', line 6 def index @bookings = Booking.all respond_to do |format| format.html format.js { render :json => { :dates => Booking.select(:date).map{|b| b.date.to_date.strftime('%Y,%m,%d')}, :start_date => Date.today.strftime('%d-%m-%Y') } } end end |
#release ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/refinery/bookings/admin/bookings_controller.rb', line 36 def release from = Date.parse(params[:from]) to = Date.parse(params[:to]) @bookings = Booking.in_date(from, to) start_date = @bookings.first.date.strftime('%d-%m-%Y') @bookings.destroy_all respond_to do |format| format.html { redirect_to refinery.bookings_admin_bookings_path } format.js { render :json => { :dates => Booking.select(:date).map{|b| b.date.strftime('%Y,%m,%d')}, :start_date => start_date }} end end |