コード例 #1
0
ファイル: statement.php プロジェクト: psagi/cloudbank
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;
}
コード例 #2
0
ファイル: event.php プロジェクト: psagi/cloudbank
function processActions(&$p_variables, &$p_form)
{
    /* + create new event (ID is empty)
    	 + just render empty form (set defaults)
    	 + form submitted (call server create, if OK redirect to events view)
    	 + if error, render the form w/ data entered
          + create new event from statement data (ID is empty)
    	 + render the form w/ data got in paramters (adjust is_income, amount)
    	 + form submitted (call server create, if OK redirect to events view)
    	 + if error, render the form w/ data entered
          + modify event (ID is filled)
    	 + render the form w/ data got in paramters (adjust is_income, amount,
    	    populate old_ variables)
    	 + form submitted (call server modify, if OK redirect to events view)
    	 + if error, render the form w/ data entered
       */
    $v_event_id = $p_variables->get('event_id');
    $v_isEdit = !empty($v_event_id);
    if ($p_form->validate($p_variables)) {
        // submitted -> process
        $v_account_id = $p_variables->get('account_id');
        try {
            if ($v_isEdit) {
                Book::Singleton()->modifyEvent($p_variables);
            } else {
                //print "submitted/before createEvent(): " . $p_variables->get('amount');
                Book::Singleton()->createEvent($p_variables);
            }
            header('Location: ' . Horde::url('events.php', true)->add(array('ledger_account_id' => $v_account_id, 'ledger_account_type' => CloudBankConsts::LedgerAccountType_Account), NULL, false));
            exit;
        } catch (Exception $v_exception) {
            Cloudbank::PushError(Book::XtractMessage($v_exception));
        }
        //print "submitted/after create/modifyEvent(): " . $p_variables->get('amount');
    } else {
        $v_isEmpty = !$p_variables->get('date');
        //print "not submitted/before PopulateEventForm():" . $p_variables->get('amount');
        if ($v_isEmpty) {
            setDefaultValues($p_variables);
        } else {
            Book::Singleton()->PopulateEventForm($p_variables);
        }
        //print "not submitted/after PopulateEventForm():" . $p_variables->get('amount');
    }
    return $v_isEdit;
}
コード例 #3
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;
}
コード例 #4
0
ファイル: delete_event.php プロジェクト: psagi/cloudbank
<?php

/**
 * $Id: delete_event.php,v 1.1 2010/10/24 17:24:39 pety Exp pety $
 *
 * Copyright 2007-2009 The Horde Project (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
 *
 * @author Peter Sagi <*****@*****.**>
 */
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('cloudbank');
require_once CLOUDBANK_BASE . '/lib/Cloudbank.php';
require_once CLOUDBANK_BASE . '/lib/Book.php';
/* main() */
$g_variables =& Horde_Variables::getDefaultVariables();
$g_account_id = $g_variables->get('account_id');
$g_event_id = $g_variables->get('event_id');
try {
    Book::Singleton()->deleteEvent($g_event_id);
    header('Location: ' . Horde::url('events.php', true)->add(array('ledger_account_id' => $g_account_id, 'ledger_account_type' => CloudBankConsts::LedgerAccountType_Account), NULL, false));
} catch (Exception $v_exception) {
    Cloudbank::PushError(Book::XtractMessage($v_exception));
    $page_output->header();
    $notification->notify(array('listeners' => 'status'));
    $page_output->footer();
}
コード例 #5
0
$g_form->addHidden('', 'account_type', 'text', false);
$g_form->addHidden('', 'old_name', 'text', false);
if ($g_form->validate($g_variables)) {
    // submitted -> process
    try {
        if ($g_isEdit) {
            if ($g_account_type == CloudBankConsts::LedgerAccountType_Account) {
                Book::Singleton()->modifyAccount($g_variables);
            } else {
                Book::Singleton()->modifyCategory($g_variables);
            }
        } else {
            if ($g_account_type == CloudBankConsts::LedgerAccountType_Account) {
                Book::Singleton()->createAccount($g_variables);
            } else {
                Book::Singleton()->createCategory($g_variables);
            }
        }
        header('Location: ' . Horde::url($g_account_type == CloudBankConsts::LedgerAccountType_Account ? 'accounts.php' : 'categories.php'), true);
        exit;
    } catch (Exception $v_exception) {
        Cloudbank::PushError(Book::XtractMessage($v_exception));
        $g_isRetry = TRUE;
    }
}
// render
if ($g_isEdit && !$g_isRetry) {
    Book::PopulateAccountForm($g_variables);
}
$title = ($g_isEdit ? 'Edit' : 'Add') . ' ' . $g_objectName;
$page_output->header();
コード例 #6
0
ファイル: delete_account.php プロジェクト: psagi/cloudbank
<?php

/**
 * $Id: delete_account.php,v 1.2 2010/11/02 21:51:59 pety Exp pety $
 *
 * Copyright 2007-2009 The Horde Project (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
 *
 * @author Peter Sagi <*****@*****.**>
 */
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('cloudbank');
require_once CLOUDBANK_BASE . '/lib/Cloudbank.php';
require_once CLOUDBANK_BASE . '/lib/Book.php';
/* main() */
$g_variables =& Horde_Variables::getDefaultVariables();
$g_account_id = $g_variables->get('account_id');
$g_account_type = $g_variables->get('account_type');
try {
    Book::Singleton()->deleteAccount($g_account_id);
    header('Location: ' . Horde::url($g_account_type == CloudBankConsts::LedgerAccountType_Account ? 'accounts.php' : 'categories.php', true));
} catch (Exception $v_exception) {
    Cloudbank::PushError(Book::XtractMessage($v_exception));
    $page_output->header();
    $notification->notify(array('listeners' => 'status'));
    $page_output->footer();
}
コード例 #7
0
<?php

/**
 * $Id: delete_event.php,v 1.1 2010/10/24 17:24:39 pety Exp pety $
 *
 * Copyright 2007-2009 The Horde Project (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
 *
 * @author Peter Sagi <*****@*****.**>
 */
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('cloudbank');
require_once CLOUDBANK_BASE . '/lib/Cloudbank.php';
require_once CLOUDBANK_BASE . '/lib/Book.php';
/* main() */
$g_variables =& Horde_Variables::getDefaultVariables();
$g_account_id = $g_variables->get('account_id');
try {
    Book::Singleton()->matchStatementItems($g_account_id);
    header('Location: ' . Horde::url('events.php', true)->add(array('ledger_account_id' => $g_account_id, 'ledger_account_type' => CloudBankConsts::LedgerAccountType_Account), NULL, false));
} catch (Exception $v_exception) {
    Cloudbank::PushError(Book::XtractMessage($v_exception));
    $page_output->header();
    $notification->notify(array('listeners' => 'status'));
    $page_output->footer();
}
コード例 #8
0
<?php

/**
 * $Id: delete_event.php,v 1.1 2010/10/24 17:24:39 pety Exp pety $
 *
 * Copyright 2007-2009 The Horde Project (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
 *
 * @author Peter Sagi <*****@*****.**>
 */
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('cloudbank');
require_once CLOUDBANK_BASE . '/lib/Cloudbank.php';
require_once CLOUDBANK_BASE . '/lib/Book.php';
/* main() */
$g_variables =& Horde_Variables::getDefaultVariables();
$g_account_id = $g_variables->get('account_id');
try {
    Book::Singleton()->clearAllMatchedEvents($g_account_id);
    header('Location: ' . Horde::url('events.php', true)->add(array('ledger_account_id' => $g_account_id, 'ledger_account_type' => CloudBankConsts::LedgerAccountType_Account), NULL, false));
} catch (Exception $v_exception) {
    Cloudbank::PushError(Book::XtractMessage($v_exception));
    $page_output->header();
    $notification->notify(array('listeners' => 'status'));
    $page_output->footer();
}
コード例 #9
0
@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);
    echo $g_template->fetch(CLOUDBANK_TEMPLATES . '/accounts.html');
}