public function service()
 {
     $categoryManager = new CategoryManager($this->config, $this->args);
     $categoryHierarchyManager = new CategoryHierarchyManager($this->config, $this->args);
     $categoryTitle = $this->secure($_REQUEST["category_title"]);
     $parentCategoryId = $this->secure($_REQUEST["parent_category_id"]);
     $adminManager = new AdminManager($this->config, $this->args);
     $adminId = $this->sessionManager->getUser()->getId();
     $adminDto = $adminManager->selectByPK($adminId);
     if ($adminDto) {
         $sortIndex = count($categoryHierarchyManager->getCategoryChildrenIdsArray($parentCategoryId)) + 1;
         $categoryId = $categoryManager->addCategory($categoryTitle, '0', '0', '1');
         $categoryHierarchyManager->addSubCategoryToCategory($parentCategoryId, $categoryId, $sortIndex);
         $jsonArr = array('status' => "ok", "message" => "ok");
         echo json_encode($jsonArr);
         return true;
     } else {
         $jsonArr = array('status' => "err", "errText" => "System Error: You are not Admin!");
         echo json_encode($jsonArr);
         return false;
     }
 }
/*
* ____          _____   _____ ______ _____  
*|  _ \   /\   |  __ \ / ____|  ____|  __ \ 
*| |_) | /  \  | |  | | |  __| |__  | |__) |
*|  _ < / /\ \ | |  | | | |_ |  __| |  _  / 
*| |_) / ____ \| |__| | |__| | |____| | \ \ 
*|____/_/    \_\_____/ \_____|______|_|  \_\
* 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';
header('Content-Type: text/plain');
define('endl', "\n");
$cm = new CategoryManager($badgerDb);
while ($cat = $cm->getNextCategory()) {
    echo 'Category Title: ' . $cat->getTitle() . endl;
}
$cat1 = $cm->getCategoryById(1);
echo 'Category Id: ' . $cat1->getId() . endl;
$cat2 = $cm->addCategory('Neue Kategorie ' . rand(0, 100), 'Bähschraipunk');
echo 'New Category Title: ' . $cat2->getTitle() . endl;
$cat3 = $cm->addCategory('Temporäre Kategorie');
$tmpId = $cat3->getId();
echo 'Temporary Category Id: ' . $tmpId . endl;
$cm->deleteCategory($tmpId);
$cat4 = $cm->getCategoryById($tmpId);
echo 'Temporary Category Title (never shown): ' . $cat4->getTitle() . endl;