function getByCompanyId($company_id, $where = NULL, $order = NULL)
    {
        if ($company_id == '') {
            return FALSE;
        }
        $udf = new UserDefaultFactory();
        $ph = array('company_id' => $company_id);
        $query = '
					select 	a.*
					from	' . $this->getTable() . ' as a
					LEFT JOIN ' . $udf->getTable() . ' as udf ON a.user_default_id = udf.id
					where	udf.company_id = ?
						AND ( udf.deleted = 0 )';
        $query .= $this->getWhereSQL($where);
        $query .= $this->getSortSQL($order);
        $this->ExecuteSQL($query, $ph);
        return $this;
    }
 function postSave()
 {
     if ($this->getDeleted() == TRUE) {
         Debug::Text('UnAssign title from employees: ' . $this->getId(), __FILE__, __LINE__, __METHOD__, 10);
         //Unassign hours from this job.
         $uf = new UserFactory();
         $udf = new UserDefaultFactory();
         $query = 'update ' . $uf->getTable() . ' set title_id = 0 where company_id = ' . $this->getCompany() . ' AND title_id = ' . $this->getId();
         $this->db->Execute($query);
         $query = 'update ' . $udf->getTable() . ' set title_id = 0 where company_id = ' . $this->getCompany() . ' AND title_id = ' . $this->getId();
         $this->db->Execute($query);
     }
 }
 function postSave()
 {
     if ($this->getDeleted() == TRUE) {
         Debug::Text('UnAssign Policy Group from User Defaults...' . $this->getId(), __FILE__, __LINE__, __METHOD__, 10);
         $udf = new UserDefaultFactory();
         $query = 'update ' . $udf->getTable() . ' set policy_group_id = 0 where company_id = ' . $this->getCompany() . ' AND policy_group_id = ' . $this->getId();
         $this->db->Execute($query);
     }
     return TRUE;
 }
 function postSave()
 {
     $this->removeCache($this->getId());
     if ($this->getDeleted() == TRUE) {
         Debug::Text('UnAssign Hours from Branch: ' . $this->getId(), __FILE__, __LINE__, __METHOD__, 10);
         //Unassign hours from this branch.
         $pcf = new PunchControlFactory();
         $udtf = new UserDateTotalFactory();
         $uf = new UserFactory();
         $sf = new StationFactory();
         $sf_b = new ScheduleFactory();
         $udf = new UserDefaultFactory();
         $rstf = new RecurringScheduleTemplateFactory();
         $query = 'update ' . $pcf->getTable() . ' set branch_id = 0 where branch_id = ' . $this->getId();
         $this->db->Execute($query);
         $query = 'update ' . $udtf->getTable() . ' set branch_id = 0 where branch_id = ' . $this->getId();
         $this->db->Execute($query);
         $query = 'update ' . $sf_b->getTable() . ' set branch_id = 0 where branch_id = ' . $this->getId();
         $this->db->Execute($query);
         $query = 'update ' . $uf->getTable() . ' set default_branch_id = 0 where company_id = ' . $this->getCompany() . ' AND default_branch_id = ' . $this->getId();
         $this->db->Execute($query);
         $query = 'update ' . $udf->getTable() . ' set default_branch_id = 0 where company_id = ' . $this->getCompany() . ' AND default_branch_id = ' . $this->getId();
         $this->db->Execute($query);
         $query = 'update ' . $sf->getTable() . ' set branch_id = 0 where company_id = ' . $this->getCompany() . ' AND branch_id = ' . $this->getId();
         $this->db->Execute($query);
         $query = 'update ' . $rstf->getTable() . ' set branch_id = 0 where branch_id = ' . $this->getId();
         $this->db->Execute($query);
     }
     return TRUE;
 }