* Visit http://www.badger-finance.org 
*
**/
define("BADGER_ROOT", "../..");
require_once BADGER_ROOT . "/includes/fileHeaderFrontEnd.inc.php";
require_once BADGER_ROOT . "/core/widgets/DataGrid.class.php";
require_once BADGER_ROOT . '/modules/account/AccountManager.class.php';
require_once BADGER_ROOT . '/modules/account/accountCommon.php';
if (isset($_GET['accountID'])) {
    $accountID = $_GET['accountID'];
} else {
    throw new badgerException('accountOverviewPlanned', 'noAccountID', '');
}
$am = new AccountManager($badgerDb);
$account = $am->getAccountById($accountID);
transferFormerFinishedTransactions($account);
$pageTitle = getBadgerTranslation2('accountOverviewPlanned', 'pageTitle');
$widgets = new WidgetEngine($tpl);
$tpl->addJavaScript("js/behaviour.js");
$tpl->addJavaScript("js/prototype.js");
$dataGrid = new DataGrid($tpl);
$pageTitle .= ": " . $account->getTitle();
$dataGrid->sourceXML = BADGER_ROOT . "/core/XML/getDataGridXML.php?q=Account&qp={$accountID};planned";
$dataGrid->headerName = array(getBadgerTranslation2('accountOverview', 'colTitle'), getBadgerTranslation2('accountOverviewPlanned', 'colBeginDate'), getBadgerTranslation2('accountOverviewPlanned', 'colEndDate'), getBadgerTranslation2('accountOverviewPlanned', 'colUnit'), getBadgerTranslation2('accountOverviewPlanned', 'colFrequency'), getBadgerTranslation2('accountOverview', 'colAmount'), getBadgerTranslation2('accountOverview', 'colCategoryTitle'));
$dataGrid->columnOrder = array("title", "beginDate", "endDate", "repeatUnit", "repeatFrequency", "amount", "categoryTitle");
$dataGrid->initialSort = "beginDate";
$dataGrid->initialSortDirection = "asc";
$dataGrid->height = "350px";
$dataGrid->headerSize = array(210, 85, 85, 70, 70, 120, 200);
$dataGrid->cellAlign = array("left", "right", "right", "left", "right", "right", "left");
$dataGrid->deleteAction = "Transaction.php?action=delete&backTo=planned&accountID={$accountID}&ID=";
function handleOldFinishedTransactions($accountManager)
{
    $accountManager->resetAccounts();
    while ($account = $accountManager->getNextAccount()) {
        transferFormerFinishedTransactions($account);
    }
}