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; }
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; }
<?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(); }