*| |_) / ____ \| |__| | |__| | |____| | \ \ *|____/_/ \_\_____/ \_____|______|_| \_\ * 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/CategoryManager.class.php'; require_once BADGER_ROOT . '/modules/account/AccountManager.class.php'; $redirectPageAfterSave = "CategoryManagerOverview.php"; $pageTitle = getBadgerTranslation2('accountCategory', 'pageTitle'); $cm = new CategoryManager($badgerDb); $am = new AccountManager($badgerDb); $order = array(array('key' => 'title', 'dir' => 'asc')); $cm->setOrder($order); if (isset($_GET['action'])) { switch ($_GET['action']) { case 'delete': //background delete //called by dataGrid if (isset($_GET['ID'])) { $IDs = explode(",", $_GET['ID']); //for all categories which should be deleted foreach ($IDs as $ID) { //for all accounts: $am = new AccountManager($badgerDb); while ($account = $am->getNextAccount()) { //set filter: get all transaction with this category $filter = array(array('key' => 'categoryId', 'op' => 'eq', 'val' => $ID)); $account->setFilter($filter);
function getCategorySelectArray() { global $badgerDb; $cm = new CategoryManager($badgerDb); $order = array(array('key' => 'parentTitle', 'dir' => 'asc'), array('key' => 'title', 'dir' => 'asc')); $cm->setOrder($order); $parentCats = array(); $parentCats['NULL'] = ""; while ($cat = $cm->getNextCategory()) { $cat->getParent(); } $cm->resetCategories(); while ($cat = $cm->getNextCategory()) { if (is_null($cat->getParent())) { $parentCats[$cat->getId()] = $cat->getTitle(); $children = $cat->getChildren(); //echo "<pre>"; print_r($children); echo "</pre>"; if ($children) { foreach ($children as $key => $value) { $parentCats[$value->getId()] = " - " . $value->getTitle(); } } } } return $parentCats; }