function updateRecord() { global $redirectPageAfterSave; global $am; //Account Manager global $curMan; //Currency Manager global $us; if (isset($_POST['hiddenID'])) { switch (getGPC($_POST, 'hiddenID')) { case 'new': //add new record $ID = $am->addAccount(getGPC($_POST, 'title'), $curMan->getCurrencyById(getGPC($_POST, 'currency', 'integer')), getGPC($_POST, 'description'), getGPC($_POST, 'lowerLimit', 'AmountFormatted'), getGPC($_POST, 'upperLimit', 'AmountFormatted'), getGPC($_POST, 'csvParser'), !getGPC($_POST, 'deleteOldPlannedTransactions', 'checkbox')); $naviId = addToNavi($us->getProperty('accountNaviParent'), $us->getProperty('accountNaviNextPosition'), 'item', 'Account' . $ID->getId(), 'account.gif', '{BADGER_ROOT}/modules/account/AccountOverview.php?accountID=' . $ID->getId()); $us->setProperty('accountNaviId_' . $ID->getId(), $naviId); $us->setProperty('accountNaviNextPosition', $us->getProperty('accountNaviNextPosition') + 1); addTranslation('Navigation', 'Account' . $ID->getId(), getGPC($_POST, 'title'), getGPC($_POST, 'title')); $account = $ID; break; default: //update record $account = $am->getAccountById(getGPC($_POST, 'hiddenID', 'integer')); $account->setTitle(getGPC($_POST, 'title')); $account->setDescription(getGPC($_POST, 'description')); $account->setCurrency($curMan->getCurrencyById(getGPC($_POST, 'currency', 'integer'))); $account->setLowerLimit(getGPC($_POST, 'lowerLimit', 'AmountFormatted')); $account->setUpperLimit(getGPC($_POST, 'upperLimit', 'AmountFormatted')); $account->setDeleteOldPlannedTransactions(!getGPC($_POST, 'deleteOldPlannedTransactions', 'checkbox')); $account->setCsvParser(getGPC($_POST, 'csvParser')); modifyTranslation('Navigation', 'Account' . $account->getId(), getGPC($_POST, 'title'), getGPC($_POST, 'title')); } $account->expandPlannedTransactions(new Date('1000-01-01')); //REDIRECT header("Location: {$redirectPageAfterSave}"); } }
function updateRecord() { global $redirectPageAfterSave; global $am; //Account Manager global $curMan; //Currency Manager global $us; if (isset($_POST['hiddenID'])) { switch ($_POST['hiddenID']) { case 'new': //add new record $ID = $am->addAccount($_POST['title'], $curMan->getCurrencyById($_POST['currency']), $_POST['description'], new Amount($_POST['lowerLimit'], true), new Amount($_POST['upperLimit'], true)); $naviId = addToNavi($us->getProperty('accountNaviParent'), $us->getProperty('accountNaviNextPosition'), 'item', 'Account' . $ID->getId(), 'account.gif', '{BADGER_ROOT}/modules/account/AccountOverview.php?accountID=' . $ID->getId()); $us->setProperty('accountNaviId_' . $ID->getId(), $naviId); $us->setProperty('accountNaviNextPosition', $us->getProperty('accountNaviNextPosition') + 1); addTranslation('Navigation', 'Account' . $ID->getId(), $_POST['title'], $_POST['title']); break; default: //update record $account = $am->getAccountById($_POST['hiddenID']); $account->setTitle($_POST['title']); $account->setDescription($_POST['description']); //print("<br/>".$curMan->getCurrencyById($_POST['currency'])->getLongName()."<br/>"); $account->setCurrency($curMan->getCurrencyById($_POST['currency'])); $account->setLowerLimit(new Amount($_POST['lowerLimit'], true)); $account->setUpperLimit(new Amount($_POST['upperLimit'], true)); modifyTranslation('Navigation', 'Account' . $account->getId(), $_POST['title'], $_POST['title']); } //REDIRECT header("Location: {$redirectPageAfterSave}"); } }