Пример #1
0
 }
 $page_title = 'Budget';
 if (!(isset($_REQUEST['year']) && isset($_REQUEST['month']))) {
     $meta = "<meta http-equiv='refresh' content='0;url=index.php?year=" . date("Y") . "&month=" . date("m") . "' />";
 }
 $alt_menu = getAddButton() . ButtonView::render(new ButtonModel(IconView::render(new IconModel('arrows-ccw', 'Recurring')), 'recurring.php', 'recurring'));
 $addModel = new AddModel('Add', 'add_budget_item', 'receipt.php');
 $addModel->addRow('store', 'Store');
 $addModel->addRadioOption('dateOption-current', 'CURRENT_TIMESTAMP', 'dateOption', 'checked="checked"');
 $addModel->addRadioOption('dateOption-selectTime', 'Date/Time', 'dateOption');
 $addModel->addRow('selectTime-date', 'Date', '', 'YYYY-MM-DD');
 $addModel->addRow('selectTime-time', 'Time', '', 'HH:MM:SS');
 // build recurring table model
 $recurringModel = new TableModel('Recurring items', 'recurring');
 $recurringModel->addRow(array(TableView2::createCell('amount', 'Amount', 'th'), TableView2::createCell('category', 'Category', 'th'), TableView2::createCell('store', 'Store', 'th'), TableView2::createCell('items', 'Items', 'th')));
 $recurring_items_data = BudgetManager::getAllRecurringByMonth($year, $month);
 while (($recurring_items_row = mysql_fetch_array($recurring_items_data)) != null) {
     $amount = $recurring_items_row['amount'];
     $category = $recurring_items_row['category'];
     $recurringModel->addRow(array(TableView2::createCell('amount', format_currency($amount)), TableView2::createCell('category', $category), TableView2::createCell('store', $recurring_items_row['store']), TableView2::createCell('items', $recurring_items_row['items'])));
     $total_spent += $amount;
     $category_normalized = strtolower($category);
     $totals[$category_normalized] = isset($totals[$category_normalized]) ? $totals[$category_normalized] + $amount : $amount;
 }
 // build budget table model
 $budgetModel = new TableModel('Reciepts', 'budget');
 $budgetModel->addRow(array(TableView2::createCell('amount', 'Amount', 'th'), TableView2::createCell('store', 'Store', 'th'), TableView2::createCell('date', 'Date', 'th'), TableView2::createCell(), TableView2::createCell()));
 while (($spending_history_row = mysql_fetch_array($spending_history_data)) != null) {
     $this_id = $spending_history_row['BUDGET_ID'];
     $store = $spending_history_row['store'];
     $date = $spending_history_row['date'];