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

class Admin::MOdrFileRoulagesController < ApplicationController
  layout "admin"
  before_action :auth_admin

  before_action :admin_space
  
  def admin_space
    @admin_space = "default"
  end
  
  def index
    @m_odr_file_roulages = MOdrFileRoulage.order(:name).all

    @m_odr_file_roulages = sort_by_sorting(@m_odr_file_roulages, "id DESC")
    respond_to do |format|
      format.html{
      
        params[:search][:per_page] = params[:search][:per_page] || 100
        per_page = params[:search][:per_page]
        page = (params[:page] and params[:page] != "") ? params[:page] : 1 
        @m_odr_file_roulages = @m_odr_file_roulages.page(page).per(per_page)
      
      }
    end
  end

  def show
    @m_odr_file_roulage = MOdrFileRoulage.find(params[:id])

  end

  def new
    @m_odr_file_roulage = MOdrFileRoulage.new
  
  end

  def edit
    @m_odr_file_roulage = MOdrFileRoulage.find(params[:id])
    
  end

  def create
    @m_odr_file_roulage = MOdrFileRoulage.new(params.require(:m_odr_file_roulage).permit!)

    if @m_odr_file_roulage.save
      
    else
      render action: "new"
 
    end

  end


  def update
    @m_odr_file_roulage = MOdrFileRoulage.find(params[:id])


    if @m_odr_file_roulage.update_attributes(params.require(:m_odr_file_roulage).permit!)
      
    else
     render action: "edit" 
      
    end
      
  end


  def destroy
    @m_odr_file_roulage = MOdrFileRoulage.find(params[:id])
    @m_odr_file_roulage.destroy
    
  end
end
