$action = Misc::findSubmitButton();
switch ($action) {
    case 'add':
        Redirect::Page(URLBuilder::getURL(NULL, 'EditAccrualPolicy.php', FALSE));
        break;
    case 'delete':
    case 'undelete':
        if (strtolower($action) == 'delete') {
            $delete = TRUE;
        } else {
            $delete = FALSE;
        }
        $aplf = new AccrualPolicyListFactory();
        foreach ($ids as $id) {
            $aplf->getByIdAndCompanyId($id, $current_company->getId());
            $aplf->StartTransaction();
            foreach ($aplf as $ap_obj) {
                $ap_obj->setDeleted($delete);
                if ($ap_obj->isValid()) {
                    $ap_obj->Save();
                }
            }
            $aplf->CommitTransaction();
        }
        Redirect::Page(URLBuilder::getURL(NULL, 'AccrualPolicyList.php'));
        break;
    default:
        $aplf = new AccrualPolicyListFactory();
        $aplf->getByCompanyId($current_company->getId());
        $pager = new Pager($aplf);
        $type_options = $aplf->getOptions('type');