function printFrontend()
{
    global $tpl;
    global $cm;
    global $order;
    global $redirectPageAfterSave;
    if (isset($_GET['ID'])) {
        //edit: load values for this ID
        $ID = getGPC($_GET, 'ID', 'integer');
        $pageTitle = getBadgerTranslation2('accountCategory', 'pageTitleEdit');
        $category = $cm->getCategoryById($ID);
        $titleValue = $category->getTitle();
        $descriptionValue = $category->getDescription();
        if ($category->getOutsideCapital() == "1") {
            $outsideCapitalValue = "checked";
        } else {
            $outsideCapitalValue = "";
        }
        $keywordsValue = $category->getKeywords();
        if ($category->getParent()) {
            $parentValue = $category->getParent()->getTitle();
            $parentId = $category->getParent()->getId();
        } else {
            $parentValue = "";
            $parentId = "";
        }
        $expenseValue = $category->getExpense();
    } else {
        //new: empty values
        $pageTitle = getBadgerTranslation2('accountCategory', 'pageTitleNew');
        $ID = "new";
        $titleValue = "";
        $descriptionValue = "";
        $outsideCapitalValue = "";
        $keywordsValue = "";
        $parentValue = "";
        $parentId = "";
        $expenseValue = null;
    }
    $widgets = new WidgetEngine($tpl);
    $widgets->addToolTipJS();
    $widgets->addJSValMessages();
    $tpl->addJavaScript("js/prototype.js");
    $tpl->addOnLoadEvent("Form.focusFirstElement('mainform')");
    $widgets->addNavigationHead();
    echo $tpl->getHeader($pageTitle);
    echo $widgets->addToolTipLayer();
    //set vars with values
    $FormAction = $_SERVER['PHP_SELF'];
    $legend = getBadgerTranslation2('accountCategory', 'legend');
    $hiddenID = $widgets->createField("hiddenID", 20, $ID, "", false, "hidden");
    $pageHeading = $pageTitle;
    //Fields & Labels
    $titleLabel = $widgets->createLabel("title", getBadgerTranslation2('accountCategory', 'title'), true);
    $titleField = $widgets->createField("title", 30, $titleValue, "", true, "text", "style='width: 30ex;'");
    $descriptionLabel = $widgets->createLabel("description", getBadgerTranslation2('accountCategory', 'description'), false);
    $descriptionField = $widgets->createTextarea("description", $descriptionValue, "", false, "style='width: 30ex; height: 5em;'");
    $parentLabel = $widgets->createLabel("parent", getBadgerTranslation2('accountCategory', 'parent'), false);
    $parentCats = array("" => getBadgerTranslation2('CategoryManager', 'no_parent'));
    while ($cat = $cm->getNextCategory()) {
        $cat->getParent();
    }
    $cm->resetCategories();
    while ($cat = $cm->getNextCategory()) {
        if (is_null($cat->getParent())) {
            $parentCats[$cat->getId()] = $cat->getTitle();
        }
    }
    $parentField = $widgets->createSelectField("parent", $parentCats, $parentId, '', false, "style='width: 31ex;'");
    $outsideCapitalLabel = $widgets->createLabel("outsideCapital", getBadgerTranslation2('accountCategory', 'outsideCapital'), false);
    $outsideCapitalField = $widgets->createField("outsideCapital", 30, "on", "", false, "checkbox", $outsideCapitalValue);
    $keywordsLabel = $widgets->createLabel('keywords', getBadgerTranslation2('accountCategory', 'keywordsLabel'), false);
    $keywordsField = $widgets->createTextarea('keywords', $keywordsValue, getBadgerTranslation2('accountCategory', 'keywordsDescription'), false, "style='width: 30ex; height: 5em;'");
    $expenseRowLabel = getBadgerTranslation2('accountCategory', 'expenseRowLabel');
    $incomeField = $widgets->createField('expense', 0, 'income', '', false, 'radio', $expenseValue === false ? 'checked="checked"' : '');
    $incomeLabel = $widgets->createLabel('expense', getBadgerTranslation2('accountCategory', 'expenseIncome'), false);
    $expenseField = $widgets->createField('expense', 0, 'expense', '', false, 'radio', $expenseValue === true ? 'checked="checked"' : '');
    $expenseLabel = $widgets->createLabel('expense', getBadgerTranslation2('accountCategory', 'expenseExpense'), false);
    //Buttons
    $submitBtn = $widgets->createButton("submitBtn", getBadgerTranslation2('dataGrid', 'save'), "submit", "Widgets/accept.gif", "accesskey='s'");
    $backBtn = $widgets->createButton("backBtn", getBadgerTranslation2('dataGrid', 'back'), "location.href='{$redirectPageAfterSave}';return false;", "Widgets/back.gif");
    //add vars to template, print site
    eval("echo \"" . $tpl->getTemplate("Account/Category") . "\";");
}
function printFrontend()
{
    global $pageTitle;
    global $tpl;
    global $am;
    global $redirectPageAfterSave;
    $widgets = new WidgetEngine($tpl);
    $widgets->addToolTipJS();
    $widgets->addJSValMessages();
    $tpl->addJavaScript("js/prototype.js");
    $tpl->addOnLoadEvent("Form.focusFirstElement('mainform')");
    $tpl->addJavaScript("js/account.js");
    $widgets->addNavigationHead();
    if (isset($_GET['ID'])) {
        $pageTitle = getBadgerTranslation2('accountAccount', 'pageTitleProp');
    } else {
        $pageTitle = getBadgerTranslation2('accountAccount', 'pageTitlePropNew');
    }
    echo $tpl->getHeader($pageTitle);
    echo $widgets->addToolTipLayer();
    if (isset($_GET['ID'])) {
        //edit: load values for this ID
        $ID = getGPC($_GET, 'ID', 'integer');
        $account = $am->getAccountById($ID);
        $titleValue = $account->getTitle();
        $descriptionValue = $account->getDescription();
        $lowerLimitValue = is_null($tmp = $account->getLowerLimit()) ? '' : $tmp->getFormatted();
        $upperLimitValue = is_null($tmp = $account->getUpperLimit()) ? '' : $tmp->getFormatted();
        $balanceValue = is_null($tmp = $account->getBalance()) ? '' : $tmp->getFormatted();
        $currencyValue = $account->getCurrency()->getId();
        $deleteOldPlannedTransactionsValue = $account->getDeleteOldPlannedTransactions() == false ? 'checked="checked"' : '';
        $csvParserValue = $account->getCsvParser();
    } else {
        //new: empty values
        $ID = "new";
        $account = "";
        $titleValue = "";
        $descriptionValue = "";
        $lowerLimitValue = "";
        $upperLimitValue = "";
        $balanceValue = "";
        $currencyValue = "";
        $deleteOldPlannedTransactionsValue = 'checked="checked"';
        $csvParserValue = '';
    }
    //set vars with values
    $FormAction = $_SERVER['PHP_SELF'];
    $legend = getBadgerTranslation2('accountAccount', 'legend');
    $hiddenID = $widgets->createField("hiddenID", 20, $ID, "", false, "hidden");
    $pageHeading = $pageTitle;
    //Fields & Labels
    $titleLabel = $widgets->createLabel("title", getBadgerTranslation2('accountAccount', 'title'), true);
    $titleField = $widgets->createField("title", 30, $titleValue, "", true, "text", "style='width: 30ex;'");
    $descriptionLabel = $widgets->createLabel("description", getBadgerTranslation2('accountAccount', 'description'), false);
    $descriptionField = $widgets->createTextarea("description", $descriptionValue, "", false, "style='width: 30ex; height: 5em;'");
    $lowerLimitLabel = $widgets->createLabel("lowerLimit", getBadgerTranslation2('accountAccount', 'lowerLimit'), false);
    $lowerLimitField = $widgets->createField("lowerLimit", 30, $lowerLimitValue, "", false, "text", "style='width: 30ex;' regexp='BADGER_NUMBER'");
    $upperLimitLabel = $widgets->createLabel("upperLimit", getBadgerTranslation2('accountAccount', 'upperLimit'), false);
    $upperLimitField = $widgets->createField("upperLimit", 30, $upperLimitValue, "", true, "text", "style='width: 30ex;' regexp='BADGER_NUMBER'");
    $currencyLabel = $widgets->createLabel("currency", getBadgerTranslation2('accountAccount', 'currency'), true);
    $currencies = getCurrencyArray('symbol');
    $currencyField = $widgets->createSelectField("currency", $currencies, $default = $currencyValue, "", false, "style='width: 31ex;'");
    $deleteOldPlannedTransactionsLabel = $widgets->createLabel('deleteOldPlannedTransactions', getBadgerTranslation2('accountAccount', 'deleteOldPlannedTransactions'), false);
    $deleteOldPlannedTransactionsField = $widgets->createField('deleteOldPlannedTransactions', 30, 'on', getBadgerTranslation2('accountAccount', 'deleteOldPlannedTransactionsDescription'), false, 'checkbox', $deleteOldPlannedTransactionsValue);
    $csvParserLabel = $widgets->createLabel('csvParser', getBadgerTranslation2('accountAccount', 'csvParser'), false);
    $csvParsers = getParsers();
    $csvParsers = array_merge(array('NULL' => getBadgerTranslation2('accountAccount', 'csvNoParser')), $csvParsers);
    $csvParserField = $widgets->createSelectField('csvParser', $csvParsers, $csvParserValue, '', false, "style='width: 31ex;'");
    //Buttons
    $submitBtn = $widgets->createButton("submitBtn", getBadgerTranslation2('dataGrid', 'save'), "submit", "Widgets/accept.gif", "accesskey='s'");
    $backBtn = $widgets->createButton("backBtn", getBadgerTranslation2('dataGrid', 'back'), "location.href='{$redirectPageAfterSave}';return false;", "Widgets/back.gif");
    //add vars to template, print site
    eval("echo \"" . $tpl->getTemplate("Account/Account") . "\";");
    eval("echo \"" . $tpl->getTemplate("badgerFooter") . "\";");
}
function printFrontendPlanned($AccountID, $plannedTransactionId, $finishedTransactionId = null)
{
    global $pageTitle;
    global $tpl;
    global $am;
    global $redirectPage;
    $widgets = new WidgetEngine($tpl);
    $widgets->addToolTipJS();
    $widgets->addCalendarJS();
    $widgets->addJSValMessages();
    $tpl->addJavaScript("js/prototype.js");
    $tpl->addJavaScript('js/Transaction.js');
    $tpl->addOnLoadEvent("Form.focusFirstElement('mainform')");
    $now = new Date();
    $categoryExpenseJS = getCategoryExpense();
    $categoryExpenseWarning = getBadgerTranslation2('accountTransaction', 'categoryExpenseWarning');
    $transactionType = "planned";
    if ($plannedTransactionId != "new") {
        $acc = $am->getAccountById($AccountID);
        $transaction = $acc->getPlannedTransactionById($plannedTransactionId);
        $backToIdField = $widgets->createField('backToId', 0, $AccountID, '', false, 'hidden');
        if (is_null($transaction->getTransferalTransaction())) {
            $transferalAmountValue = new Amount($transaction->getAmount());
            $transferalAmountValue->mul(-1);
            $transferalAmountValue = $transferalAmountValue->getFormatted();
        } else {
            if ($transaction->getTransferalSource()) {
                $transferalAmountValue = $transaction->getTransferalTransaction()->getAmount()->getFormatted();
            } else {
                $transferalAmountValue = $transaction->getAmount()->getFormatted();
                $AccountID = $transaction->getTransferalTransaction()->getAccount()->getId();
                $plannedTransactionId = $transaction->getTransferalTransaction()->getId();
                $ID = $transaction->getTransferalTransaction()->getId();
                $transaction = $transaction->getTransferalTransaction();
            }
        }
        $titleValue = $transaction->getTitle();
        $descriptionValue = $transaction->getDescription();
        $beginDateValue = is_null($tmp = $transaction->getBeginDate()) ? '' : $tmp->getFormatted();
        $endDateValue = is_null($tmp = $transaction->getEndDate()) ? '' : $tmp->getFormatted();
        $amountValue = is_null($tmp = $transaction->getAmount()) ? '' : $tmp->getFormatted();
        $negativeAmountValue = new Amount($tmp);
        $negativeAmountValue->mul(-1);
        $negativeAmountValue = $negativeAmountValue->getFormatted();
        $outsideCapitalValue = is_null($tmp = $transaction->getOutsideCapital()) ? '' : $tmp;
        $transactionPartnerValue = $transaction->getTransactionPartner();
        $categoryValue = is_null($tmp = $transaction->getCategory()) ? '' : $tmp->getId();
        $repeatUnitValue = $transaction->getRepeatUnit();
        $repeatFrequencyValue = $transaction->getRepeatFrequency();
    } else {
        //new: empty values
        $titleValue = "";
        $descriptionValue = "";
        $beginDateValue = $now->getFormatted();
        $endDateValue = "";
        $amountValue = "";
        $negativeAmountValue = '';
        $outsideCapitalValue = "";
        $transactionPartnerValue = "";
        $categoryValue = "";
        $repeatUnitValue = "";
        $repeatFrequencyValue = "1";
        $transferalAmountValue = '';
        $backToIdField = '';
    }
    $tpl->addHeaderTag("<script type='text/javascript'>var previousAmount = '{$negativeAmountValue}';</script>");
    $widgets->addNavigationHead();
    echo $tpl->getHeader($pageTitle);
    echo $widgets->addToolTipLayer();
    if ($plannedTransactionId == 'new' || is_null($transaction->getTransferalTransaction())) {
        $transferalLabel = $widgets->createLabel('transferalEnabled', getBadgerTranslation2('accountTransaction', 'transferalEnabled'), false);
        $transferalField = $widgets->createField('transferalEnabled', 30, 'on', '', false, 'checkbox', "onclick='toggleTransferal();'");
        $transferalFieldStyle = 'display: none;';
        $transferalDataStyle = 'style="display: none;"';
        $transferalAccountField = $widgets->createSelectField('transferalAccountId', getAccountsSelectArray($AccountID), '', '', false, "style='width: 213px;'");
    } else {
        $transferalLabel = '';
        $transferalField = '';
        $transferalFieldStyle = '';
        $transferalDataStyle = '';
        $transferalAccountField = $transaction->getTransferalTransaction()->getAccount()->getTitle();
    }
    $transferalAccountLabel = $widgets->createLabel('transferalAccountId', getBadgerTranslation2('accountTransaction', 'transferalAccount'), false);
    $transferalAmountLabel = $widgets->createLabel('transferalAmount', getBadgerTranslation2('accountTransaction', 'transferalAmount'), false);
    $transferalAmountField = $widgets->createField('transferalAmount', 30, $transferalAmountValue, '', true, 'text', " onkeyup='adjustInputNumberClass(this);' onkeydown='adjustInputNumberClass(this);' onkeypress='adjustInputNumberClass(this);' style='width: 30ex;{$transferalFieldStyle}'");
    //set vars with values
    $FormAction = $_SERVER['PHP_SELF'];
    $backTo = $widgets->createField('backTo', 0, isset($_GET['backTo']) ? getGPC($_GET, 'backTo') : '', null, false, 'hidden');
    if ($AccountID == "choose") {
        $AccountLabel = $widgets->createLabel("hiddenAccID", getBadgerTranslation2('accountTransaction', 'Account'), true);
        $hiddenAccID = $widgets->createSelectField("hiddenAccID", getAccountsSelectArray(), $AccountID, "", false, "style='width: 31ex;'");
    } else {
        $AccountLabel = "";
        $hiddenAccID = $widgets->createField("hiddenAccID", 20, $AccountID, "", false, "hidden");
    }
    $hiddenID = $widgets->createField("hiddenID", 20, $plannedTransactionId, "", false, "hidden");
    $hiddenType = $widgets->createField("hiddenType", 20, $transactionType, "", false, "hidden");
    //Fields & Labels
    $titleLabel = $widgets->createLabel("title", getBadgerTranslation2('accountTransaction', 'title'), true);
    $titleField = $widgets->createField("title", 30, $titleValue, "", true, "text", "style='width: 30ex;'");
    $descriptionLabel = $widgets->createLabel("description", getBadgerTranslation2('accountTransaction', 'description'), false);
    $descriptionField = $widgets->createTextarea("description", $descriptionValue, "", false, "style='width: 30ex; height: 4em;'");
    $beginDateLabel = $widgets->createLabel("beginDate", getBadgerTranslation2('accountTransaction', 'beginDate'), true);
    $beginDateField = $widgets->addDateField("beginDate", $beginDateValue);
    $endDateLabel = $widgets->createLabel("endDate", getBadgerTranslation2('accountTransaction', 'endDate'), true);
    $endDateField = $widgets->addDateField("endDate", $endDateValue);
    $amountLabel = $widgets->createLabel("amount", getBadgerTranslation2('accountTransaction', 'amount'), true);
    $amountField = $widgets->createField("amount", 30, $amountValue, "", true, "text", "onchange='updateTransferalAmount();' onkeyup='adjustInputNumberClass(this);' onkeydown='adjustInputNumberClass(this);' onkeypress='adjustInputNumberClass(this);' style='width: 30ex;'");
    $transactionPartnerLabel = $widgets->createLabel("transactionPartner", getBadgerTranslation2('accountTransaction', 'transactionPartner'), false);
    $transactionPartnerField = $widgets->createField("transactionPartner", 30, $transactionPartnerValue, "", false, "text", "style='width: 30ex;'");
    $outsideCapitalLabel = $widgets->createLabel("outsideCapital", getBadgerTranslation2('accountTransaction', 'outsideCapital'), false);
    $outsideCapitalField = $widgets->createField("outsideCapital", 30, "on", "", false, "checkbox", $outsideCapitalValue);
    $outsideToolTip = $widgets->addToolTip(getBadgerTranslation2("importCsv", "outsideCapitalToolTip"));
    $categoryLabel = $widgets->createLabel("category", getBadgerTranslation2('accountTransaction', 'category'), false);
    $categoryField = $widgets->createSelectField("category", getCategorySelectArray(), $categoryValue, "", false, "style='width: 31ex;' onchange='updateExpenseWarning();'");
    $repeatUnitLabel = $widgets->createLabel("repeatUnit", getBadgerTranslation2('accountTransaction', 'repeatFrequency'), true);
    $repeatUnitField = $widgets->createSelectField("repeatUnit", getIntervalUnitsArray(), $repeatUnitValue, "", true, "style='width: 104px;'");
    $everyLabel = getBadgerTranslation2('intervalUnits', 'every');
    $repeatFrequencyField = $widgets->createField("repeatFrequency", 1, $repeatFrequencyValue, "", true, "text", "");
    if (!is_null($finishedTransactionId) && $finishedTransactionId != 'X') {
        $hiddenFinishedTransactionID = $widgets->createField('hiddenFinishedTransactionID', 20, $finishedTransactionId, '', false, 'hidden');
        $rangeLabel = getBadgerTranslation2('accountTransaction', 'range');
        $rangeUnit = getBadgerTranslation2('accountTransaction', 'rangeUnit');
        $rangeAllField = $widgets->createField('range', null, 'all', '', false, 'radio', 'checked="checked" onclick="checkBeginEndDate();"');
        $rangeAllLabel = $widgets->createLabel('range', getBadgerTranslation2('accountTransaction', 'rangeAll'));
        $rangeThisField = $widgets->createField('range', null, 'this', '', false, 'radio', 'onclick="checkBeginEndDate();"');
        $rangeThisLabel = $widgets->createLabel('range', getBadgerTranslation2('accountTransaction', 'rangeThis'));
        $rangePreviousField = $widgets->createField('range', null, 'previous', '', false, 'radio', 'onclick="checkBeginEndDate();"');
        $rangePreviousLabel = $widgets->createLabel('range', getBadgerTranslation2('accountTransaction', 'rangePrevious'));
        $rangeFollowingField = $widgets->createField('range', null, 'following', '', false, 'radio', 'onclick="checkBeginEndDate();"');
        $rangeFollowingLabel = $widgets->createLabel('range', getBadgerTranslation2('accountTransaction', 'rangeFollowing'));
        //$deleteBtn = $widgets->createButton('deleteBtn', getBadgerTranslation2('dataGrid', 'delete'), 'submit', 'Widgets/cancel.gif', "accesskey='d'");
        $deleteBtn = '';
    } else {
        $hiddenFinishedTransactionID = '';
        $rangeLabel = '';
        $rangeUnit = '';
        $rangeAllField = $widgets->createField('range', 20, 'all', '', false, 'hidden');
        $rangeAllLabel = '';
        $rangeThisField = '';
        $rangeThisLabel = '';
        $rangePreviousField = '';
        $rangePreviousLabel = '';
        $rangeFollowingField = '';
        $rangeFollowingLabel = '';
        $deleteBtn = '';
    }
    //Buttons
    $submitBtn = $widgets->createButton("submitBtn", getBadgerTranslation2('dataGrid', 'save'), "submit", "Widgets/accept.gif", "accesskey='s'");
    if ($redirectPage) {
        $backBtn = $widgets->createButton("backBtn", getBadgerTranslation2('dataGrid', 'back'), "location.href='{$redirectPage}';return false;", "Widgets/back.gif");
    } else {
        $backBtn = '';
    }
    //add vars to template, print site
    $pageHeading = getBadgerTranslation2('accountTransaction', 'headingTransactionPlanned');
    eval("echo \"" . $tpl->getTemplate("Account/PlannedTransaction") . "\";");
}