Пример #1
0
         $db_update_success = BudgetManager::updateItemRecord($item_id, $item_name, $amount, $qty, $category, $brand, $size, $size_unit, $tax, $sale);
         break;
     case 'add_receipt_item':
         $id = $budget_id;
         $db_add_success = BudgetManager::addItemRecord($budget_id, $item_name, $amount, $qty, $category, $brand, $size, $size_unit, $tax, $sale);
         break;
     case 'delete_item_by_id':
         $id = BudgetManager::getBudgetIdFromItemId($item_id);
         $db_delete_success = BudgetManager::deleteItemRecord($item_id);
         break;
     case 'add_budget_item':
         $id = BudgetManager::addRecord($store, $date);
         break;
 }
 $spending_history_data = BudgetManager::getRecord($id);
 $items = BudgetManager::getItems($id);
 $receipt_total = 0;
 $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);
Пример #2
0
     $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'];
     $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');