# -*- encoding : utf-8 -*- class Admin::ReservationsController < ApplicationController before_filter :auth_admin layout "admin" def index if params[:year] and params[:month] @date = Date.parse("#{params[:year]}/#{params[:month]}").beginning_of_month else @date = Date.today.beginning_of_month end @prev_month = @date.prev_month @next_month = @date.next_month @start_date = @date @end_date = @start_date + 1.month @start_month_date = @start_date.beginning_of_month @end_month_date = @start_month_date.end_of_month @start_week_date = @start_month_date.beginning_of_week end def new @reservation = Admin.new respond_to do |format| format.js end end def create @reservation = Reservation.new(params.require(:reservation).permit!) @date = Date.parse("#{params[:year]}/#{params[:month]}").beginning_of_month @prev_month = @date.prev_month @next_month = @date.next_month @start_date = @date @end_date = @start_date + 1.month @start_month_date = @start_date.beginning_of_month @end_month_date = @start_month_date.end_of_month @start_week_date = @start_month_date.beginning_of_week @reservation.save end def destroy @reservation = Reservation.find(params[:id]) @date = Date.parse("#{params[:year]}/#{params[:month]}").beginning_of_month @prev_month = @date.prev_month @next_month = @date.next_month @start_date = @date @end_date = @start_date + 1.month @start_month_date = @start_date.beginning_of_month @end_month_date = @start_month_date.end_of_month @start_week_date = @start_month_date.beginning_of_week @reservation.destroy end end