コード例 #1
0
         $category = Factory::getView(new CategoryKey($categoryId));
         $budget->setUser($user);
         $budget->setActive(TRUE);
         $budget->setAmount($budgetedAmount);
         $budget->setCategory($category);
         $transaction->commit();
     } elseif ($action === "remove") {
         $key = htmlentities($_POST['key']);
         $transaction = new Transaction(new MySqlDB());
         $transaction->start();
         $budgetItem = Factory::getView(new BudgetKey($key));
         $budgetItem->setActive(0);
         $transaction->commit();
     }
 }
 $budgets = Budget::getOptions(array("USER_ID" => $user->getId(), "ACTIVE" => 1));
 $spent = array();
 $budgetLeft = array();
 foreach ($budgets as $key => $item) {
     $activities = Activity::getOptions(array("USER_ID" => $user->getId(), "CATEGORY_ID" => $item['category_id'], "TRANSACTION_DATE_START" => Date::firstOfMonth()));
     $value = 0;
     foreach ($activities as $activityKey => $activityItem) {
         $value += $activityItem['amount'];
     }
     $spent[$key] = 0 - $value;
     $budgetLeft[$key] = $item['amount'] + $value;
 }
 $smarty->assign('spent', $spent);
 $smarty->assign('budgets', $budgets);
 $smarty->assign('budgetLeft', $budgetLeft);
 if ($fullPage) {