class InstitutionConsultant < ActiveRecord::Base

  # Accessible attributes
  attr_accessible :description, :email, :functions, :institution_id, :job, :name, :phone, :active,
                  :technical_information, :experience, :assigned_unit, :net_salary

  # Associations
  belongs_to :institution

  # Validations
  validates :name, :institution_id, presence: true
  validates :description, :email, :functions, :job, :phone,
    :technical_information, :experience, :assigned_unit, :net_salary, presence: true
  validates :net_salary, numericality: { greater_than_or_equal_to: 0 }

  # scopes
  scope :active, where(active: true)

  # Paper trail, track changes
  has_paper_trail

  # Will paginate uses this method
  # to know how many rows to show
  #
  def self.per_page
    50
  end

  def data_for_csv
    [
      name,
      description,
      job,
      assigned_unit,
      net_salary,
      phone,
      email,
      technical_information,
      experience,
      functions
    ]
  end

  def self.header_for_csv
    [:name, :description, :job, :assigned_unit, :net_salary, :phone, :email, :technical_information, :experience, :functions]
  end

  def self.attributes_for_grid
    [
      :institution_id,
      :name,
      :description,
      :job,
      :net_salary,
      :assigned_unit,
      :phone,
      :email,
      :active,
      :technical_information,
      :experience,
      :functions
    ]
  end
end
