$page_title = 'Receipt | Budget'; $alt_menu = getAddButton() . getBackButton(); // add Item form $addModel = new AddModel('Add', 'add_receipt_item'); $addModel->addRow('item_name', 'Item'); $addModel->addRow('amount', 'Amount'); $addModel->addRow('qty', 'Qty', 1); $addModel->addRow('category', 'Category'); $addModel->addRow('brand', 'Brand'); $addModel->addRow('size', 'Size'); $addModel->addRow('size_unit', 'Units'); $addModel->addRow('sale', 'Sale'); $addModel->addOptionBox('tax', 'Tax', ['13%', '0%']); $addModel->addRow('budget_id', 'budget_id', $id); // build items table model $itemsModel = new TableModel('Items', 'budget'); $itemsModel->addRow(array(TableView2::createCell('total', 'total', 'th'), TableView2::createCell('qty', 'qty', 'th'), TableView2::createCell('tax', 'tax', 'th'), TableView2::createCell('amount', 'Amount', 'th'), TableView2::createCell('item_name', 'Item', 'th'), TableView2::createCell('category', 'Category', 'th'), TableView2::createCell('brand', 'Brand', 'th'), TableView2::createCell('size', 'Size', 'th'), TableView2::createCell('units', 'units', 'th'), TableView2::createCell('sale', 'sale', 'th'), TableView2::createCell())); while (($items_row = mysql_fetch_array($items)) != null) { $item_total = $items_row['amount'] * $items_row['qty'] * (1 + $items_row['tax']); $itemsModel->addRow(array(TableView2::createCell('total', format_currency($item_total)), TableView2::createCell('qty', $items_row['qty']), TableView2::createCell('tax', format_percent($items_row['tax'])), TableView2::createCell('amount', format_currency($items_row['amount'])), TableView2::createCell('item_name', $items_row['item_name']), TableView2::createCell('category', $items_row['category']), TableView2::createCell('brand', $items_row['brand']), TableView2::createCell('size', $items_row['size']), TableView2::createCell('units', $items_row['size_unit']), TableView2::createCell('sale', $items_row['sale']), TableView2::createEdit($items_row['BUDGET_ITEM_ID'], 'editItem.php'))); $receipt_total += $item_total; } // build budget table model $budgetModel = new TableModel('', 'budget'); $budgetModel->addRow(array(TableView2::createCell('total', 'Total', 'th'), TableView2::createCell('store', 'Store', 'th'), TableView2::createCell('date', 'Date', 'th'))); $budgetModel->addRow(array(TableView2::createCell('amount', format_currency($receipt_total)), TableView2::createCell('store', $spending_history_data['store']), TableView2::createCell('date', $spending_history_data['date']))); $views_to_load[] = ' ' . AddView2::render($addModel); $views_to_load[] = ' ' . TableView2::render($budgetModel); $views_to_load[] = ' ' . TableView2::render($itemsModel); include $relative_base_path . 'views/_generic.php'; }
break; case 'delete_by_id': $db_delete_success = BudgetManager::deleteRecurringRecord($id); break; } $page_title = 'Recurring | Budget'; $alt_menu = getAddButton() . getBackButton(); $addModel = new AddModel('Add', 'add_budget_item'); $addModel->addRow('amount', 'Amount'); $addModel->addRow('category', 'Category'); $addModel->addRow('store', 'Store'); $addModel->addRow('items', 'Items'); $addModel->addRow('startdate', 'Start Date', 'CURRENT_TIMESTAMP'); $addModel->addRow('enddate', 'End Date', '2037-12-31 23:59:59'); // 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'), TableView2::createCell())); $recurring_items_data = BudgetManager::getAllRecurring(); 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']), TableView2::createEdit($recurring_items_row['RECURRING_ID'], 'editRecurring.php'))); $total_spent += $amount; $category_normalized = strtolower($category); $totals[$category_normalized] = isset($totals[$category_normalized]) ? $totals[$category_normalized] + $amount : $amount; } $views_to_load = array(); $views_to_load[] = ' ' . AddView2::render($addModel); $views_to_load[] = ' ' . TableView2::render($recurringModel); include $relative_base_path . 'views/_generic.php'; }
break; case 'add_bookmark': $db_update_success = BookmarkManager::addRecord($title, $url); break; case 'delete_by_id': $db_delete_success = BookmarkManager::deleteRecord($id); break; } $page_title = 'Bookmarks'; $search_target = 'bookmarks'; $bookmark_data = BookmarkManager::getAllRecords(); $alt_menu = getAddButton() . getSearchButton(); $searchModel = new SearchModel($search_target); $addModel = new AddModel('Add', 'add_bookmark'); $addModel->addRow('title', 'Title'); $addModel->addRow('url', 'URL'); $bookmarkModel = new TableModel('', $search_target); /*$bookmarkModel->addRow ( array ( TableView2::createCell ('site', 'Site', 'th'), TableView2::createCell () ));*/ while (($bookmark_row = mysql_fetch_array($bookmark_data)) != null) { $target = $sbookmark ? ' target="_blank"' : ''; $bookmarkModel->addRow(array(TableView2::createCell('bookmark', '<a href="' . $bookmark_row['url'] . '" ' . $target . '>' . $bookmark_row['title'] . '</a>'), TableView2::createEdit($bookmark_row['BOOKMARK_ID']))); } $views_to_load = array(); $views_to_load[] = ' ' . AddView2::render($addModel); $views_to_load[] = ' ' . SearchView::render($searchModel); $views_to_load[] = ' ' . TableView2::render($bookmarkModel); include $relative_base_path . 'views/_generic.php'; }
$date = $spending_history_row['date']; $total = BudgetManager::getRecieptTotalById($this_id); $reciept_items_data = BudgetManager::getItems($this_id); while (($reciept_items_row = mysql_fetch_array($reciept_items_data)) != null) { $amount = $reciept_items_row['amount'] * $reciept_items_row['qty'] * (1 + $reciept_items_row['tax']); $total_spent += $amount; $category_normalized = strtolower($reciept_items_row['category']); $totals[$category_normalized] = isset($totals[$category_normalized]) ? $totals[$category_normalized] + $amount : $amount; } $budgetModel->addRow(array(TableView2::createCell('amount', format_currency($total)), TableView2::createCell('store', $spending_history_row['store']), TableView2::createCell('date', $spending_history_row['date']), TableView2::createCell('view', "<a href='receipt.php?id={$this_id}'>View</a>"), TableView2::createEdit($this_id))); } $categoryModel = new TableModel('Category totals', 'categoryTotals'); foreach ($totals as $this_category => $this_amount) { $categoryModel->addRow(array(TableView2::createCell('category', $this_category, 'th'), TableView2::createCell('amount', format_currency($this_amount)))); } $categoryModel->addRow(array(TableView2::createCell('', 'Total', 'th'), TableView2::createCell('total', format_currency($total_spent)))); $categoryModel->setTitleWeight('h3'); $recurringModel->setTitleWeight('h3'); $budgetModel->setTitleWeight('h3'); $views_to_load = array(); if ($hasTitle) { $views_to_load[] = " <h2>{$todayDateFormated}</h2>"; } $views_to_load[] = ' ' . AddView2::render($addModel); $views_to_load[] = '_paging.php'; $views_to_load[] = ' ' . TableView2::render($categoryModel); $views_to_load[] = ' ' . TableView2::render($recurringModel); $views_to_load[] = ' ' . TableView2::render($budgetModel); $views_to_load[] = '_paging.php'; include $relative_base_path . 'views/_generic.php'; }