# -*- coding: utf-8 -*-
# Смены менеджеров
class ManagerShift < Shift
  has_many :reports, :class_name => "Report", :finder_sql => 'SELECT reports.* FROM reports WHERE DATE(date) = DATE("#{self.shift_date}") AND department = "#{self.department}" AND (status = 2 OR department = "ams")'

  before_save :check_ident


  private

  def check_ident
    if ManagerShift.for_department(self.department).for_date(self.shift_date).with_employee(self.employee_id).size != 0
      return false
    end
  end


end
