guiAssign('zoneUrl', $this->getZoneUrl()); } function pageDefault($params) { $month = $params[2]; $year = $params[1]; $categories = Category::getBudgetList($month, $year); $this->guiAssign('categories', $categories); $this->guiAssign('month', $month); $this->guiAssign('prevmonth', $month - 1); $this->guiAssign('nextmonth', $month + 1); $this->guiAssign('year', $year); $this->guiAssign('prevyear', $year - 1); $this->guiAssign('nextyear', $year + 1); $this->guiDisplay('default.tpl'); } function postDefault($params) { $month = $params[2]; $year = $params[1]; $action = getPostText('actionField'); switch($action) { case 'editCat': $catId = getPostInt('catId'); $this->zoneRedirect("editCat/$catId/$year/$month"); case 'addCat': $this->zoneRedirect("editCat/new/$year/$month"); case 'viewExpenses': BaseRedirect("/expenses/list/$year/$month"); default: echo_r($action); break; } } function pageEditCat($params) { global $strings; $catId = $params[1]; $year = $params[2]; $month = $params[3]; if($catId == 'new') { $categoryInfo = Category::getBlankInfo(); } else { $category = &new Category($catId); $categoryInfo = $category->getInfo($month, $year); } $name = &getGuiControl('text', 'name'); $name->setParam('validate', array('required' => true)); $name->setValue($categoryInfo['name']); $this->guiAssign('name', $name); $amount = &getGuiControl('text', 'amount'); $amount->setParam('validate', array('type' => 'numeric')); $amount->setValue($categoryInfo['amount']); $this->guiAssign('amount', $amount); $unused = Category::getUnusedColors(); foreach($strings['colors'] as $color => $value) { if(isset($unused[$color])) $colors[$color] = $color . ' (unused)'; else $colors[$color] = $color; } $color = &getGuiControl('select', 'color'); $color->setParam('index', $colors); $color->setValue($categoryInfo['color']); $this->guiAssign('color', $color); $description = &getGuiControl('text', 'description'); $description->setValue($categoryInfo['description']); $this->guiAssign('description', $description); $comments = &getGuiControl('text', 'comments'); $comments->setValue($categoryInfo['comments']); $this->guiAssign('comments', $comments); $this->guiAssign('month', $month); $this->guiAssign('year', $year); $this->guiDisplay('editCat.tpl'); } function postEditCat($params) { $catId = $params[1]; $year = $params[2]; $month = $params[3]; $info['name'] = getPostText('name'); $info['amount'] = getPostText('amount'); $info['color'] = getPostText('color'); $info['description'] = getPostText('description'); $info['comments'] = getPostText('comments'); if($catId == 'new') { $category = &Category::insert($info, $month, $year); } else { $category = &new Category($catId); $category->setInfo($info, $month, $year); } BaseRedirect("/expenses/list/$year/$month"); //phasing out the budget pages... $this->zoneRedirect("$year/$month"); } function pageDeleteCat($params) { $catId = $params[1]; $year = $params[2]; $month = $params[3]; Category::delete($catId, $month, $year); BaseRedirect("/expenses/list/$year/$month"); //$this->zoneRedirect("$year/$month"); } function pagePrintPie($params) { global $strings; $year = $params[1]; $month= $params[2]; $budgetList = Category::getBudgetList($month, $year); $pdf = &new SmartPdf(1,'wide'); $pdf->addDivParser(new ChartParser()); $pdf->addParser(new ChartObjectParser()); $pdf->assign('year', $year); $pdf->assign('month', $month); $pdf->assign('categories', $budgetList); $pdf->assign('strings', $strings); $pdf->display('budget/pie.tpl'); } function pagePrintBarChart($params) { global $strings; $year = $params[1]; $month= $params[2]; $budgetList = Category::getBudgetList($month, $year); $pdf = &new SmartPdf(1, 'wide'); $pdf->addDivParser(new ChartParser()); $pdf->addParser(new ChartObjectParser()); $pdf->assign('year', $year); $pdf->assign('month', $month); $pdf->assign('categories', $budgetList); $pdf->assign('strings', $strings); $pdf->display('budget/bar.tpl'); } }