more functionality in index
authorRichard Whitehouse <github@richardwhiuk.com>
Thu, 3 Feb 2011 16:31:23 +0000 (16:31 +0000)
committerRichard Whitehouse <github@richardwhiuk.com>
Thu, 3 Feb 2011 16:31:23 +0000 (16:31 +0000)
index.php
pages/index.php
templates/index.php

index 1bc10e5bd5d4d22b13dc723f25c1eb1ea1d19b82..3061d50110b58513b2f3b34fa7b4be01a40a8289 100644 (file)
--- a/index.php
+++ b/index.php
@@ -20,6 +20,19 @@ class Template {
 
        }
 
+       public function title(){
+               return 'Review Orders';
+       }
+
+}
+
+class Theme {
+
+       public function display($template){
+               
+
+       }
+
 }
 
 class Config {
@@ -87,6 +100,40 @@ class Database extends mysqli {
 
 }
 
+class Type {
+
+       private $id;
+       private $name;
+       private $price;
+
+       public function __construct($id, $name, $price){
+               $this->id = $id;
+               $this->name = $name;
+               $this->price = $price;
+       }
+
+       public function id(){
+               if(!isset($this->id)){
+                       throw new Exception('Invalid Operation');
+               }
+               return $this->id;
+       }
+
+       public static function Get_All(){
+               $query = 'SELECT `id`,`name`,`price` FROM `type`';
+               $stmt = Ticketing::Get()->database()->prepare($query);
+               $stmt->execute();
+               $stmt->bind_result($id, $name, $price);
+               $types = array();
+               while($stmt->fetch()){
+                       $types[$id] = new Type($id, $name, $price);
+               }
+               $stmt->close();
+               return $types;
+       }
+
+}
+
 class Order {
 
        private $id;
@@ -232,17 +279,32 @@ class Ticketing {
                return $this->template;
        }
 
+       private $theme;
+
+       public function theme(){
+               if(!isset($this->theme)){
+                       require_once('theme.php');
+                       $this->theme = new Theme_Impl();
+               }
+               return $this->theme;
+       }
+
        public function run(){
                try {
 
                        $this->page()->logic($this->template());
-                       $this->template()->display();
+                       $this->theme()->display($this->template());
 
                } catch(Exception $e){
                        header('Content-type: text/plain'); print_r($e); exit;
                }
        }
 
+       public function url(){
+               $args = func_get_args();
+               return $this->config()->get('base') . implode('/', $args);
+       }
+
 }
 
 Ticketing::Get()->run();
index 4e0a8865a8bc11d729b631c293c5cfa4110604d9..e20981d8dc27aa6c4061bcedc963cb4c60a7fb3e 100644 (file)
@@ -50,6 +50,21 @@ class Page_Index extends Page {
 
                        }
 
+                       // Do we have any tickets left?
+
+                       $types = Type::Get_All();
+
+                       $template->types = array();
+
+                       foreach($types as $type){
+                               $template->types[$type->id()] == array(
+                                       'name' => $type->name(),
+                                       'tickets_left' => $type->left()
+                               );
+                       }
+
+                       $templates->add = $system->url('add');
+
 
                        $system->database()->commit();
 
index 036a8498adb90abbb10c3d9fba26a11b0b17cd4f..801e7bb124da33be653328d705fe4c2b18195fd8 100644 (file)
@@ -2,5 +2,21 @@
 
 class Template_Index extends Template {
 
+       public function display(){
+?>
+<div id="index">
+<?php if(count($this->previous) > 0){ ?>
+<div id="previous">
+       <h1>Previous Orders</h1>
+
+</div>
+<?php } ?>
+<div id="current">
+       <h1>Current Order</h1>
+
+</div>
+</div>
+<?php
+       }
 
 }