class Panel::SurveyB::BackEnd::PeriodsController < OrbitBackendController

  # include AdminHelper
  # include OrbitControllerLib::DivisionForDisable

  # before_filter :for_app_manager
  
  open_for_manager
  
  # def initialize
  #   super
  #   @app_title = 'survey_b'
  # end


  # before_filter :force_order_for_user,:only => :index
  # before_filter :for_app_sub_manager,:except => :index


  def index
    @periods = SurveyBPeriod.page params[:page]
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @periods }
      format.js
    end
  end

  def new
    @period = SurveyBPeriod.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @period }
    end
  end

  def create
    @period = SurveyBPeriod.new params[:survey_b_period]

    respond_to do |format|
      if @period.save
        format.html { redirect_to(panel_survey_b_back_end_periods_url) }
        format.xml  { render :xml => @period, :status => :created, :location => @period  }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @period.errors, :status => :unprocessable_entity }
      end
    end
  end

  def edit
    @period = SurveyBPeriod.find(params[:id])
  end

  def update
    @period = SurveyBPeriod.find(params[:id])

    respond_to do |format|
      if @period.update_attributes(params[:survey_b_period])
        format.html { redirect_to(panel_survey_b_back_end_periods_url(:page => params[:page])) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @period.errors, :status => :unprocessable_entity }
      end
    end
  end

  def destroy
    @period = SurveyBPeriod.find(params[:id])

    respond_to do |format|
      if @period.destroy
        format.html { redirect_to(panel_survey_b_back_end_periods_url(:page => params[:page])) }
        format.xml  { head :ok }
      end
    end
  end

end