if (isset($ap_id) and isset($data['recalculate']) and $data['recalculate'] == 1) {
                 Debug::Text('Recalculating Accruals...', __FILE__, __LINE__, __METHOD__, 10);
                 if (isset($data['recalculate_start_date']) and isset($data['recalculate_end_date']) and $data['recalculate_start_date'] < $data['recalculate_end_date']) {
                     Redirect::Page(URLBuilder::getURL(array('action' => 'recalculate_accrual_policy', 'data' => array('accrual_policy_id' => $ap_id, 'start_date' => $data['recalculate_start_date'], 'end_date' => $data['recalculate_end_date']), 'next_page' => urlencode(URLBuilder::getURL(NULL, '../policy/AccrualPolicyList.php'))), '../progress_bar/ProgressBarControl.php'), FALSE);
                 }
             }
             Redirect::Page(URLBuilder::getURL(NULL, 'AccrualPolicyList.php'));
             break;
         }
     }
     $apf->FailTransaction();
 default:
     if (isset($id)) {
         BreadCrumb::setCrumb($title);
         $aplf = new AccrualPolicyListFactory();
         $apmlf = new AccrualPolicyMilestoneListFactory();
         $aplf->getByIdAndCompanyID($id, $current_company->getID());
         if ($aplf->getRecordCount() > 0) {
             $apmlf->getByAccrualPolicyId($id);
             if ($apmlf->getRecordCount() > 0) {
                 foreach ($apmlf as $apm_obj) {
                     $milestone_rows[$apm_obj->getId()] = array('id' => $apm_obj->getId(), 'length_of_service' => $apm_obj->getLengthOfService(), 'length_of_service_unit_id' => $apm_obj->getLengthOfServiceUnit(), 'accrual_rate' => $apm_obj->getAccrualRate(), 'maximum_time' => $apm_obj->getMaximumTime());
                 }
             } else {
                 $milestone_rows[-1] = array('id' => -1, 'length_of_service' => 0, 'accrual_rate' => 0, 'minimum_time' => 0, 'maximum_time' => 0);
             }
             foreach ($aplf as $ap_obj) {
                 //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10);
                 $data = array('id' => $ap_obj->getId(), 'name' => $ap_obj->getName(), 'type_id' => $ap_obj->getType(), 'enable_pay_stub_balance_display' => $ap_obj->getEnablePayStubBalanceDisplay(), 'apply_frequency_id' => $ap_obj->getApplyFrequency(), 'apply_frequency_month' => $ap_obj->getApplyFrequencyMonth(), 'apply_frequency_day_of_month' => $ap_obj->getApplyFrequencyDayOfMonth(), 'apply_frequency_day_of_week' => $ap_obj->getApplyFrequencyDayOfWeek(), 'milestone_rollover_hire_date' => $ap_obj->getMilestoneRolloverHireDate(), 'milestone_rollover_month' => $ap_obj->getMilestoneRolloverMonth(), 'milestone_rollover_day_of_month' => $ap_obj->getMilestoneRolloverDayOfMonth(), 'minimum_employed_days' => $ap_obj->getMinimumEmployedDays(), 'recalculate_start_date' => TTDate::getBeginMonthEpoch(time()), 'recalculate_end_date' => TTDate::getEndMonthEpoch(time()), 'milestone_rows' => $milestone_rows, 'created_date' => $ap_obj->getCreatedDate(), 'created_by' => $ap_obj->getCreatedBy(), 'updated_date' => $ap_obj->getUpdatedDate(), 'updated_by' => $ap_obj->getUpdatedBy(), 'deleted_date' => $ap_obj->getDeletedDate(), 'deleted_by' => $ap_obj->getDeletedBy());
             }
         }
 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('&nbsp;&nbsp;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('&nbsp;&nbsp;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('&nbsp;&nbsp;Worked Time: ' . $worked_time . 'hrs', __FILE__, __LINE__, __METHOD__, 10);
                 }
                 if ($worked_time >= $apm_obj->getLengthOfService()) {
                     Debug::Text('&nbsp;&nbsp;bLength Of Service: ' . $apm_obj->getLengthOfService() . 'hrs', __FILE__, __LINE__, __METHOD__, 10);
                     $milestone_obj = $apmlf->getCurrent();
                     break;
                 } else {
                     Debug::Text('&nbsp;&nbsp;Skipping Milestone...', __FILE__, __LINE__, __METHOD__, 10);
                 }
             } else {
                 Debug::Text('&nbsp;&nbsp;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('&nbsp;&nbsp;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('&nbsp;&nbsp;Skipping Milestone...', __FILE__, __LINE__, __METHOD__, 10);
                 }
             }
         }
     }
     unset($apmlf, $apm_obj);
     return $milestone_obj;
 }