function getActiveMilestoneObject($u_obj, $epoch = NULL) { if (!is_object($u_obj)) { return FALSE; } if ($epoch == '') { $epoch = TTDate::getTime(); } $milestone_obj = FALSE; $apmlf = new AccrualPolicyMilestoneListFactory(); $apmlf->getByAccrualPolicyId($this->getId(), NULL, array('length_of_service_days' => 'desc')); Debug::Text(' Total Accrual Policy MileStones: ' . (int) $apmlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); if ($apmlf->getRecordCount() > 0) { $worked_time = NULL; $length_of_service_days = NULL; foreach ($apmlf as $apm_obj) { if ($apm_obj->getLengthOfServiceUnit() == 50) { Debug::Text(' MileStone is in Hours...', __FILE__, __LINE__, __METHOD__, 10); //Hour based if ($worked_time == NULL) { //Get users worked time. $worked_time = TTDate::getHours($this->getWorkedTimeByUserIdAndEndDate($u_obj->getId(), $epoch)); Debug::Text(' Worked Time: ' . $worked_time . 'hrs', __FILE__, __LINE__, __METHOD__, 10); } if ($worked_time >= $apm_obj->getLengthOfService()) { Debug::Text(' bLength Of Service: ' . $apm_obj->getLengthOfService() . 'hrs', __FILE__, __LINE__, __METHOD__, 10); $milestone_obj = $apmlf->getCurrent(); break; } else { Debug::Text(' Skipping Milestone...', __FILE__, __LINE__, __METHOD__, 10); } } else { Debug::Text(' MileStone is in Days...', __FILE__, __LINE__, __METHOD__, 10); //Calendar based if ($length_of_service_days == NULL) { $length_of_service_days = TTDate::getDays($epoch - $this->getMilestoneRolloverDate($u_obj->getHireDate())); if ($length_of_service_days < 0) { $length_of_service_days = 0; } Debug::Text(' Length of Service Days: ' . $length_of_service_days, __FILE__, __LINE__, __METHOD__, 10); } if ($length_of_service_days >= $apm_obj->getLengthOfServiceDays()) { $milestone_obj = $apmlf->getCurrent(); break; } else { Debug::Text(' Skipping Milestone...', __FILE__, __LINE__, __METHOD__, 10); } } } } unset($apmlf, $apm_obj); return $milestone_obj; }