예제 #1
0
파일: events.php 프로젝트: psagi/cloudbank
function populateStatementItemsTemplateIf($p_account_id, $p_accountName)
{
    if (!Book::Singleton()->isThereStatementForAccount($p_account_id)) {
        return NULL;
    }
    $v_statementItems = Book::Singleton()->getUnmatchedStatementItems($p_account_id, $p_accountName);
    CloudBank::AddLinks($v_statementItems, 'event.php', array('date' => 'date', 'description' => 'description_short', 'amount' => 'amount', 'statement_item_id' => 'id', 'account_id' => 'account_id', 'account_type' => 'account_type', 'account_name' => 'account_name'), 'description', 'description_link');
    Book::SortResultSet($v_statementItems, 'date', TRUE);
    $v_clearedOrMatchedBalance = Book::Singleton()->getClearedOrMatchedBalance($p_account_id);
    $v_closingStatementItem = Book::Singleton()->getClosingBalance($p_account_id);
    $v_template = new Horde_Template();
    $v_template->set('match_link', Horde::link(Horde::url('statement_item_match.php')->add(array('account_id' => $p_account_id)), 'Update matching Events with Statement Item ID reference') . 'Match</a>');
    $v_template->set('clear_all_matched_link', Horde::link(Horde::url('clear_all_matched_events.php')->add(array('account_id' => $p_account_id)), 'Clear all matched Events and PURGE corresponding STATEMENT ITEMS') . 'Clear all matched</a>');
    $v_template->set('statement_items', $v_statementItems);
    $v_template->set('cleared_or_matched_balance', Book::FormatAmount($v_clearedOrMatchedBalance));
    $v_template->set('statement_closing', $v_closingStatementItem);
    $v_template->set('amount_left', Book::FormatAmount($v_clearedOrMatchedBalance - $v_closingStatementItem['amount']));
    //var_dump($v_template);
    return $v_template;
}
예제 #2
0
function prepareView($p_variables, &$p_form)
{
    $v_accounts = NULL;
    try {
        $v_accounts = Book::Singleton()->getAccountsForStatement();
    } catch (Exception $v_exception) {
        Cloudbank::PushError(Book::XtractMessage($v_exception));
    }
    $v_template = NULL;
    $p_form = NULL;
    switch (is_null($v_accounts) || count($v_accounts) == 0 ? 'import' : 'accounts') {
        case 'accounts':
            $v_template = new Horde_Template();
            array_walk($v_accounts, function (&$p_record, $p_key) {
                $p_record['type'] = CloudBankConsts::LedgerAccountType_Account;
            });
            CloudBank::AddLinks($v_accounts, 'events.php', array('ledger_account_id' => 'id', 'ledger_account_type' => 'type'), 'name', 'account_link');
            $v_template->set('accounts', $v_accounts);
            $p_form = preparePurgeForm($p_variables);
            break;
        case 'import':
            $p_form = prepareImportForm($p_variables, $v_dummy);
            break;
    }
    return $v_template;
}
예제 #3
0
 * @author Peter Sagi <*****@*****.**>
 */
@define('CLOUDBANK_BASE', dirname(__FILE__));
require_once CLOUDBANK_BASE . '/lib/Cloudbank.php';
require_once CLOUDBANK_BASE . '/lib/Book.php';
/* main() */
$g_isError = FALSE;
try {
    $g_accountsOrCategories = Book::Singleton()->getAccountsOrCategoriesWBalance($g_account_type);
    CloudBank::AddLinks($g_accountsOrCategories, 'events.php', array('ledger_account_id' => 'id', 'ledger_account_type' => 'type'), 'name', 'account_link');
    if ($g_account_type == CloudBankConsts::LedgerAccountType_Account) {
        CloudBank::AddLinks($g_accountsOrCategories, 'account_or_category.php', array('account_id' => 'id', 'name' => 'name', 'account_type' => 'type', 'beginning_balance' => 'beginning_balance'), 'edit_icon', 'edit_icon_link', NULL, 'Edit');
    } else {
        CloudBank::AddLinks($g_accountsOrCategories, 'account_or_category.php', array('account_id' => 'id', 'name' => 'name', 'account_type' => 'type'), 'edit_icon', 'edit_icon_link', NULL, 'Edit');
    }
    CloudBank::AddLinks($g_accountsOrCategories, 'delete_account.php', array('account_id' => 'id', 'account_type' => 'type'), 'delete_icon', 'delete_icon_link', NULL, 'Delete');
    Book::SortResultSet($g_accountsOrCategories, 'name');
    $g_total = $g_account_type == CloudBankConsts::LedgerAccountType_Account ? Book::Singleton()->getAccountsTotal() : Book::Singleton()->getCategoriesTotal();
    $g_template = new Horde_Template();
    $g_template->set('new_account_link', Horde::link(Horde::url('account_or_category.php')->add(array('account_type' => $g_account_type))) . 'New</a>');
    $g_template->set('accounts', $g_accountsOrCategories);
    $g_template->set('total', $g_total);
    $title = _($g_account_type == CloudBankConsts::LedgerAccountType_Account ? "Accounts" : "Categories");
} catch (Exception $v_exception) {
    Cloudbank::PushError(Book::XtractMessage($v_exception));
    $g_isError = TRUE;
}
$page_output->header();
$notification->notify(array('listeners' => 'status'));
if (!$g_isError) {
    //$g_template->setOption('debug', true);