# encoding: utf-8
class Cinnosti < ActiveRecord::Base
  set_primary_key :ID_Cinnost
  set_table_name :cinnosti
  
  has_and_belongs_to_many :firmy, :join_table => 'cinnosti_firmy', :foreign_key => 'ID_Cinnost', :association_foreign_key => 'ID_Firma'
  has_and_belongs_to_many :zamestnanci, :join_table => 'cinnosti_zam', :foreign_key => 'ID_Cinnost', :association_foreign_key => 'ID_Zam'
  belongs_to :podujatia, :foreign_key => 'ID_Podujatie', :class_name => Podujatium
  belongs_to :c_stav_cinnosti, :foreign_key => 'ID_Stav_Cinnosti', :class_name => CStavCinnosti
  belongs_to :c_typ_cinnosti, :foreign_key => 'ID_Typ_Cinnosti', :class_name => CTypCinnosti
  
  validates :Popis, :Datum_Od, :Datum_Do, :ID_Typ_Cinnosti, :ID_Stav_Cinnosti, :ID_Podujatie, :presence => true
  
  default_scope :order => 'Datum_Do'
end
