class Panel::PersonalExperience::BackEnd::ExperienceCategorysController < OrbitBackendController
  include OrbitControllerLib::DivisionForDisable
	
  open_for_manager :except => [:index]

  def index
  
    @experience_categorys =  get_categories_for_index("ExperienceCategory")
    @experience_category = ExperienceCategory.new(:display => 'List')
	
	@url = panel_personal_experience_back_end_experience_categorys_path
	
    respond_to do |format|
      format.html # index.html.erb
      format.js
    end
  end

  # GET /experiences/1
  # GET /experiences/1.xml
  def show
	
    @experience_category = ExperienceCategory.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.js
    end
  end

  # GET /experiences/new
  # GET /experiences/new.xml
  def new
	
    @experience_category = ExperienceCategory.new(:display => 'List')
	
	@verb = :post

    respond_to do |format|
      format.html # new.html.erb
      format.js
    end
  end
  
  # GET /experiences/1/edit
  def edit
	
    @experience_category = ExperienceCategory.find(params[:id])
	
	# @url = panel_personal_experience_back_end_experience_category_path(@experience_category)
	# @url = eval("panel_personal_experience_back_end_#{@app_type}_path(@experience_category)")
	@url = polymorphic_path([:panel, :personal_experience, :back_end, @experience_category])
	
	@verb = :put

    respond_to do |format|
      format.html
      format.js
    end
  end

  # POST /experiences
  # POST /experiences.xml
  def create
	
    @experience_category = ExperienceCategory.new(params[:experience_category])

    respond_to do |format|
      if @experience_category.save
        format.html { redirect_to(panel_personal_experience_back_end_experience_categorys_url, :notice => t('experience_category.create_experience_category_success')) }
        format.js
      else
        format.html { render :action => "new" }
        format.js { render action: "new" }
      end
    end
  end

  # PUT /experiences/1
  # PUT /experiences/1.xml
  def update
	
    @experience_category = ExperienceCategory.find(params[:id])
	# debugger
	# @url = panel_personal_experience_back_end_experience_category_path(@experience_category)
	# @url = eval("panel_personal_experience_back_end_#{@app_type}_path(#{@experience_category})")
	@url = polymorphic_path([:panel, :personal_experience, :back_end, @experience_category])

    respond_to do |format|
      if @experience_category.update_attributes(params[:experience_category])
        format.html { redirect_to(panel_personal_experience_back_end_experience_categorys_url, :notice => t('experience_category.update_experience_category_success')) }
        # format.xml  { head :ok }
        format.js
      else
        format.html { render :action => "edit" }
        format.js { render :action => "edit" }
      end
    end
  end

  # DELETE /experiences/1
  # DELETE /experiences/1.xml
  def destroy
	
    @experience_category = ExperienceCategory.find(params[:id])
    @experience_category.disable = @experience_category.disable ? false : true

    if @experience_category.save!
      respond_to do |format|
        format.html { redirect_to(panel_personal_experience_back_end_experience_categorys_url) }
        # format.xml  { head :ok }
        format.js
      end      
    else
      flash[:error] = t("experience_category.update_failed")
      format.html { render :action => "index" }
    end

  end
  
end
