Example #1
0
 /**
  * Command: Report
  */
 public function run()
 {
     //
     // Setup the categories
     //
     $categories = Category::readAll();
     $report = array();
     foreach ($categories as $category) {
         $report[$category->getName()] = array();
     }
     $report['Ignored'] = array();
     $transactions = array();
     Transaction::getTransactions($transactions, $this->startDate, $this->stopDate);
     foreach ($transactions as &$transaction) {
         if ($transaction->getStatus() == Transaction::StatusIgnore) {
             $report['Ignored'][] = $transaction;
         } else {
             $report[$transaction->getCategory()->getName()][] = $transaction;
         }
     }
     $total = 0;
     foreach ($report as $categoryName => $transactions) {
         if (count($transactions) == 0) {
             continue;
         }
         $categoryTotal = 0;
         echo $categoryName . "\n";
         foreach ($transactions as $transaction) {
             printf("\t%s %-30.30s %10.2f\n", $transaction->getDate(), $transaction->getDescription(), $transaction->getAmount());
             $categoryTotal += $transaction->getAmount();
         }
         printf("\tTotal: %.2f", $categoryTotal);
         printf("\n\n\n");
         if ($categoryName == 'Ignored') {
             continue;
         }
         $total += $categoryTotal;
     }
     printf("Total: %.2f\n", $total);
 }
Example #2
0
<?php

require_once dirname(__FILE__) . '/../vendor/autoload.php';
//autoload packages
$db = new Database();
$item = new Item($db->conn);
$vendor = new Vendor($db->conn);
$category = new Category($db->conn);
$vendors = $vendor->readAll();
$categories = $category->readAll();
//dump($vendors);
if ($_POST) {
    //dump($_FILES);
    $item->name = $_POST['name'];
    $item->article = $_POST['article'];
    $item->vendor_id = $_POST['vendor_id'];
    $item->category_id = $_POST['category_id'];
    $item->images = json_encode($_FILES['images']['name']);
    $item->status = isset($_POST['status']) ? 1 : 0;
    $num = 0;
    foreach ($_FILES['images']['name'] as $file) {
        upload('images', $num, 'items');
        $num++;
    }
    //exit;
    $state = false;
    if ($item->add()) {
        $state = true;
        unset($_POST);
    }
}
Example #3
0
include_once "../config/core.php";
// check if logged in as admin
include_once "login_checker.php";
// include classes
include_once "../config/database.php";
include_once "../objects/category.php";
// get database connection
$database = new Database();
$db = $database->getConnection();
// prepare category object
$category = new Category($db);
// set page title
$page_title = "Categories";
// include page header HTML
include_once "layout_head.php";
// for pagination purposes
$page = isset($_GET['page']) ? $_GET['page'] : 1;
// page is the current page, if there's nothing set, default is page 1
$records_per_page = 5;
// set records or rows of data per page
$from_record_num = $records_per_page * $page - $records_per_page;
// calculate for the query LIMIT clause
// read all categories from the database
$stmt = $category->readAll($from_record_num, $records_per_page);
$num = $stmt->rowCount();
// to identify page for paging
$page_url = "read_categories.php?";
// include categories HTML table template
include_once "read_categories_template.php";
// include page footer HTML
include_once "layout_foot.php";