# -*- encoding : utf-8 -*-

class Admin::PPaymentTypesController < ApplicationController
  layout "admin"
  before_filter :auth_admin

  before_filter :admin_space
  
  def admin_space
    @admin_space = "payments"
  end
  
  def index
    @p_payment_types = PPaymentType.order(:name).all

   
  end

  def show
    @p_payment_type = PPaymentType.find(params[:id])

  end

  def new
    
    
		@p_payment_type = PPaymentType.new(:enabled => true)
    

  end

 

  def edit
  
    
    @p_payment_type = PPaymentType.find(params[:id])
  end

  def create
    @p_payment_type = PPaymentType.new(params.require(:p_payment_type).permit!)


    if @p_payment_type.save
     @p_payment_types = PPaymentType.order(:name).all
      
    else
      render action: "new"
 
    end

  end


  def update
    @p_payment_type = PPaymentType.find(params[:id])


    if @p_payment_type.update_attributes(params.require(:p_payment_type).permit!)
      
       @p_payment_types = PPaymentType.order(:name).all
    else
     render action: "edit" 
      
    end
      
  end


  def destroy
    @p_payment_type = PPaymentType.find(params[:id])
    @p_payment_type.destroy
    
    
  end
end
