# encoding: utf-8
class Klienti < ActiveRecord::Base
  set_primary_key :ID_Klient
  set_table_name :klienti
  
  has_and_belongs_to_many :podujatia, :join_table => 'podujatie_klienti', :foreign_key => 'ID_Klient', :association_foreign_key => 'ID_Podujatie'
  has_many :evidencia_zmluv, :foreign_key => 'ID_Klient'
  has_many :videa, :foreign_key => 'ID_Klient', :dependent => :destroy
  has_many :zvukove_subory, :foreign_key => 'ID_Klient', :dependent => :destroy
  has_many :galeria_fotky, :foreign_key => 'ID_Klient', :dependent => :destroy
  
  validates :Meno, :Priezvisko, :Ulica, :Mesto, :Telefon, :presence => true
  
  validates_length_of :Meno, :Cislo_Bank_Uctu, :maximum => 15
  validates_length_of :Priezvisko, :maximum => 25
  validates_length_of :Titul, :maximum => 20
  validates_length_of :Nazov_Zdruzenie, :maximum => 60
  validates_length_of :Ulica, :Email, :maximum => 50
  validates_length_of :Mesto, :maximum => 30
  validates_length_of :PSC, :maximum => 5
  validates_length_of :Telefon, :in => 13..14, :too_short => 'Prosím vložte aj s predvoľbou +421/+420/...'
  
end
