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

  def index
  
    @writing_patent_categorys =  get_categories_for_index("WritingPatentCategory")
    @writing_patent_category = WritingPatentCategory.new(:display => 'List')
	
	@url = panel_personal_patent_back_end_writing_patent_categorys_path
	
    respond_to do |format|
      format.html # index.html.erb
      format.js
    end
  end

  # GET /writing_patents/1
  # GET /writing_patents/1.xml
  def show
	
    @writing_patent_category = WritingPatentCategory.find(params[:id])

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

  # GET /writing_patents/new
  # GET /writing_patents/new.xml
  def new
	
    @writing_patent_category = WritingPatentCategory.new(:display => 'List')
	
	@verb = :post

    respond_to do |format|
      format.html # new.html.erb
      format.js
    end
  end
  
  # GET /writing_patents/1/edit
  def edit
	
    @writing_patent_category = WritingPatentCategory.find(params[:id])
	
	# @url = panel_personal_patent_back_end_writing_patent_category_path(@writing_patent_category)
	# @url = eval("panel_personal_patent_back_end_#{@app_type}_path(@writing_patent_category)")
	@url = polymorphic_path([:panel, :personal_patent, :back_end, @writing_patent_category])
	
	@verb = :put

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

  # POST /writing_patents
  # POST /writing_patents.xml
  def create
	
    @writing_patent_category = WritingPatentCategory.new(params[:writing_patent_category])

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

  # PUT /writing_patents/1
  # PUT /writing_patents/1.xml
  def update
	
    @writing_patent_category = WritingPatentCategory.find(params[:id])
	# debugger
	# @url = panel_personal_patent_back_end_writing_patent_category_path(@writing_patent_category)
	# @url = eval("panel_personal_patent_back_end_#{@app_type}_path(#{@writing_patent_category})")
	@url = polymorphic_path([:panel, :personal_patent, :back_end, @writing_patent_category])

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

  # DELETE /writing_patents/1
  # DELETE /writing_patents/1.xml
  def destroy
	
    @writing_patent_category = WritingPatentCategory.find(params[:id])
    @writing_patent_category.disable = @writing_patent_category.disable ? false : true

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

  end
  
end
