*|  _ < / /\ \ | |  | | | |_ |  __| |  _  / 
*| |_) / ____ \| |__| | |__| | |____| | \ \ 
*|____/_/    \_\_____/ \_____|______|_|  \_\
* Open Source Financial Management
* Visit http://www.badger-finance.org 
*
**/
define('BADGER_ROOT', '../..');
require_once BADGER_ROOT . '/includes/fileHeaderFrontEnd.inc.php';
require_once BADGER_ROOT . '/modules/account/AccountManager.class.php';
require_once BADGER_ROOT . '/modules/account/CurrencyManager.class.php';
header('Content-Type: text/plain');
define('endl', "\n");
$am = new AccountManager($badgerDb);
while ($acc = $am->getNextAccount()) {
    echo 'Account Title: ' . $acc->getTitle() . endl;
}
$acc1 = $am->getAccountById(1);
echo 'Account Id: ' . $acc1->getId() . endl;
$cm = new CurrencyManager($badgerDb);
$curr = $cm->getCurrencyById(1);
$lowerLimit = new Amount(rand(-100, 100));
$upperLimit = new Amount(rand(1000, 3000));
$acc2 = $am->addAccount('Neues Konto ' . rand(0, 100), $curr, 'Bähschraipunk', $lowerLimit, $upperLimit);
echo 'New Account Title: ' . $acc2->getTitle() . endl;
$acc3 = $am->addAccount('Temporäres Konto', $curr);
$tmpId = $acc3->getId();
echo 'Temporary Account Id: ' . $tmpId . endl;
$am->deleteAccount($tmpId);
$acc4 = $am->getAccountById($tmpId);
echo 'Temporary Account Title (never shown): ' . $acc4->getTitle() . endl;
if (isset($_GET['action'])) {
    switch (getGPC($_GET, 'action')) {
        case 'delete':
            //background delete
            //called by dataGrid
            if (isset($_GET['ID'])) {
                $IDs = getGPC($_GET, 'ID', 'integerList');
                //check if we can delete this item
                foreach ($IDs as $ID) {
                    $am = new AccountManager($badgerDb);
                    //workaround, because of twice calling 'getAccountById'
                    $acc = $am->getAccountById($ID);
                    //delete all transactions in this account
                    $acc->deleteAllTransactions();
                    //delete account
                    $am->deleteAccount($ID);
                    //delete entry in navigation
                    deleteFromNavi($us->getProperty("accountNaviId_{$ID}"));
                }
            } else {
                echo "no ID was transmitted!";
            }
            break;
        case 'save':
            //add record, update record
            if (isset($_POST['hiddenID'])) {
                updateRecord();
            } else {
                header("Location: {$redirectPageAfterSave}");
            }
            break;
<?php

require 'account.php';
require "appmanager.php";
if (AppManager::checkAppCode($_REQUEST['appcode'])) {
    switch ($_REQUEST['type']) {
        case 'CREATE':
            echo AccountManager::createNewAccount($_REQUEST['id'], $_REQUEST['number']);
            break;
        case 'DELETE_ONE':
            echo AccountManager::deleteAccount($_REQUEST['id'], $_REQUEST['number']);
            break;
        case 'DELETE_ALL':
            echo AccountManager::deleteAllAccountOfId($_REQUEST['id']);
            break;
        case 'CHECK_EXIST_ACCOUNT':
            echo AccountManager::checkExistAccount($_REQUEST['id'], $_REQUEST['number']);
            break;
        case 'CHECK_EXIST_NUMBER':
            echo AccountManager::checkExistNumber($_REQUEST['number']);
            break;
        case 'GET_USER_BY_NUMBER':
            echo json_encode(AccountManager::getUserByNumber($_REQUEST['number']));
            break;
        case 'GET_NUMBER_BY_ID':
            echo json_encode(AccountManager::getNumbersById($_REQUEST['id']));
            break;
        default:
            echo "Unknown type";
            break;
    }