function getProjectedAbsencePolicyBalance($absence_policy_id, $user_id, $epoch, $amount, $previous_amount = 0)
 {
     if ($absence_policy_id == '') {
         return $this->returnHandler(FALSE);
     }
     if ($user_id == '') {
         return $this->returnHandler(FALSE);
     }
     $epoch = TTDate::parseDateTime($epoch);
     $aplf = TTnew('AbsencePolicyListFactory');
     $aplf->getByIdAndCompanyId($absence_policy_id, $this->getCurrentCompanyObject()->getId());
     if ($aplf->getRecordCount() > 0) {
         $ap_obj = $aplf->getCurrent();
         if ($ap_obj->getAccrualPolicyID() != '') {
             $acplf = new AccrualPolicyListFactory();
             $acplf->getById($ap_obj->getAccrualPolicyID());
             if ($acplf->getRecordCount() > 0) {
                 $acp_obj = $acplf->getCurrent();
                 $ulf = TTnew('UserListFactory');
                 $ulf->getByIDAndCompanyID($user_id, $this->getCurrentCompanyObject()->getId());
                 if ($ulf->getRecordCount() == 1) {
                     $u_obj = $ulf->getCurrent();
                     return $this->returnHandler($acp_obj->getAccrualBalanceWithProjection($u_obj, $epoch, $amount, $previous_amount));
                 }
             }
         }
     }
     return $this->returnHandler(FALSE);
 }
        AccrualBalanceFactory::calcBalance($user_id, $accrual_policy_id);
        $alf->CommitTransaction();
        Redirect::Page(URLBuilder::getURL(NULL, 'ViewUserAccrualList.php'));
        break;
    default:
        $alf = new AccrualListFactory();
        $alf->getByCompanyIdAndUserIdAndAccrualPolicyID($current_company->getId(), $user_id, $accrual_policy_id, $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array);
        $pager = new Pager($alf);
        $type_options = $alf->getOptions('type');
        foreach ($alf as $a_obj) {
            $date_stamp = $a_obj->getColumn('date_stamp');
            if ($date_stamp != '') {
                $date_stamp = TTDate::strtotime($date_stamp);
            }
            $accruals[] = array('id' => $a_obj->getId(), 'user_id' => $a_obj->getUser(), 'accrual_policy_id' => $a_obj->getAccrualPolicyId(), 'type_id' => $a_obj->getType(), 'type' => $type_options[$a_obj->getType()], 'user_date_total_id' => $a_obj->getUserDateTotalId(), 'user_date_total_date_stamp' => $date_stamp, 'time_stamp' => $a_obj->getTimeStamp(), 'amount' => $a_obj->getAmount(), 'deleted' => $a_obj->getDeleted());
        }
        $smarty->assign_by_ref('accruals', $accruals);
        $ulf = new UserListFactory();
        $user_obj = $ulf->getById($user_id)->getCurrent();
        $aplf = new AccrualPolicyListFactory();
        $accrual_policy_obj = $aplf->getById($accrual_policy_id)->getCurrent();
        $smarty->assign_by_ref('user_id', $user_id);
        $smarty->assign_by_ref('user_full_name', $user_obj->getFullName());
        $smarty->assign_by_ref('accrual_policy_id', $accrual_policy_id);
        $smarty->assign_by_ref('accrual_policy', $accrual_policy_obj->getName());
        $smarty->assign_by_ref('sort_column', $sort_column);
        $smarty->assign_by_ref('sort_order', $sort_order);
        $smarty->assign_by_ref('paging_data', $pager->getPageVariables());
        break;
}
$smarty->display('accrual/ViewUserAccrualList.tpl');
 function getAccrualPolicyObject()
 {
     if (is_object($this->accrual_policy_obj)) {
         return $this->accrual_policy_obj;
     } else {
         $aplf = new AccrualPolicyListFactory();
         $aplf->getById($this->getAccrualPolicyID());
         if ($aplf->getRecordCount() > 0) {
             $this->accrual_policy_obj = $aplf->getCurrent();
             return $this->accrual_policy_obj;
         }
         return FALSE;
     }
 }