} } 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()); } } } elseif ($action == 'add_milestone') { Debug::Text('Adding Blank Week', __FILE__, __LINE__, __METHOD__, 10); if (!isset($data['milestone_rows'])) { $data['milestone_rows'] = array();
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; }