class Panel::PersonalProject::BackEnd::ProjectCategorysController < OrbitBackendController
  include OrbitControllerLib::DivisionForDisable
	
  before_filter :force_order_for_visitor,:only=>[:index,:show]
  before_filter :force_order_for_user,:except => [:index,:show]
  before_filter :for_app_manager,:except => [:index]

  def index
	
    @project_categorys =  ProjectCategory.all
    @project_category = ProjectCategory.new(:display => 'List')
	
	@url = panel_personal_project_back_end_project_categorys_path
	
    respond_to do |format|
      format.html # index.html.erb
      format.js
    end
  end

  # GET /projects/1
  # GET /projects/1.xml
  def show
	
    @project_category = ProjectCategory.find(params[:id])

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

  # GET /projects/new
  # GET /projects/new.xml
  def new
	
    @project_category = ProjectCategory.new(:display => 'List')
	
	@verb = :post

    respond_to do |format|
      format.html # new.html.erb
      format.js
    end
  end
  
  # GET /projects/1/edit
  def edit
	
    @project_category = ProjectCategory.find(params[:id])
	
	@url = panel_personal_project_back_end_project_category_path(@project_category)
	
	@verb = :put

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

  # POST /projects
  # POST /projects.xml
  def create
	
    @project_category = ProjectCategory.new(params[:project_category])

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

  # PUT /projects/1
  # PUT /projects/1.xml
  def update
	
    @project_category = ProjectCategory.find(params[:id])
	# debugger
	@url = panel_personal_project_back_end_project_category_path(@project_category)

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

  # DELETE /projects/1
  # DELETE /projects/1.xml
  def destroy
	
    @project_category = ProjectCategory.find(params[:id])
    @project_category.disable = @project_category.disable ? false : true

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

  end
  
end
