コード例 #1
0
ファイル: json.php プロジェクト: rrsc/beansbooks
 public function action_monthlyexpenses()
 {
     $date = $this->request->post('date');
     if (!$date) {
         if (Session::instance()->get('dash_expense_date')) {
             $date = Session::instance()->get('dash_expense_date');
         } else {
             $date = date("Y-m-d");
         }
     }
     Session::instance()->set('dash_expense_date', $date);
     $report_budget = new Beans_Report_Budget($this->_beans_data_auth((object) array('date_start' => date("Y-m", strtotime($date)) . "-01", 'date_end' => date("Y-m-t", strtotime($date)))));
     $report_budget_result = $report_budget->execute();
     if (!$report_budget_result->success) {
         return $this->_return_error($this->_beans_result_get_error($report_budget_result));
     }
     $this->_return_object->data->expense_data = array();
     $other_total = 0.0;
     $other_cutoff = round($report_budget_result->data->account_types['expense_total']->date_ranges[0] / 20, 0, PHP_ROUND_HALF_UP);
     foreach ($report_budget_result->data->account_types['expense'] as $account) {
         if ($account->date_ranges[0] and $other_cutoff > $account->date_ranges[0]) {
             $other_total = round($other_total + $account->date_ranges[0]);
         } else {
             if ($account->date_ranges[0]) {
                 $this->_return_object->data->expense_data[] = (object) array('name' => $account->name, 'amount' => $account->date_ranges[0]);
             }
         }
     }
     if ($other_total) {
         $this->_return_object->data->expense_data[] = (object) array('name' => "Other", 'amount' => $other_total);
     }
 }
コード例 #2
0
ファイル: dash.php プロジェクト: rrsc/beansbooks
 public function action_budget()
 {
     $date_start = date("Y") . "-01-01";
     $months = 12;
     if ($this->request->post('date_start')) {
         $date_start = date("Y-m", strtotime($this->request->post('date_start'))) . "-01";
     }
     if ($this->request->post('months') and $this->request->post('months') <= 12 and $this->request->post('months') >= 1) {
         $months = $this->request->post('months');
     }
     // Last day in month = t
     $date_end = date("Y-m-t", strtotime($date_start . " +" . ($months - 1) . " Months"));
     $report_budget = new Beans_Report_Budget($this->_beans_data_auth((object) array('date_start' => $date_start, 'date_end' => $date_end)));
     $report_budget_result = $report_budget->execute();
     if ($this->_beans_result_check($report_budget_result)) {
         $this->_view->report_budget_result = $report_budget_result;
     }
     $this->_view->months = $months;
     if ($this->request->post('report-budget-zero-toggle')) {
         $this->_view->show_zero = TRUE;
     }
     $this->_action_tab_name = "Budget Detail";
     $this->_action_tab_uri = '/' . $this->request->uri();
 }