*added tables for shopping cart
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sun, 30 Sep 2007 09:18:28 +0000 (09:18 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sun, 30 Sep 2007 09:18:28 +0000 (09:18 +0000)
*added getallevents transaction

git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@40 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

www/config.php.template
www/inc/db_mysql.php
www/inc/db_scheme.php
www/inc/event.php [new file with mode: 0644]
www/loader_nonadmin.php
www/machine.php

index c1727bb..ac5e0e3 100644 (file)
@@ -48,4 +48,11 @@ $ClientAuthTimeout=300;
 //Authenticated session timeout - how long an authenticated session lasts
 // this should usually be a few hours (3600s per hour)
 $ClientSessionTimeout=2*3600;
+
+
+///////////
+//Web-Client Configuration
+
+//how long the stuff in a shopping cart is stored
+$CartTimeout=3600;
 ?>
\ No newline at end of file
index b07619d..56e3141 100644 (file)
@@ -71,7 +71,9 @@ class MysqlEngine extends DbEngine
        
        public function select($table,$cols,$where)
        {
-               $res=mysql_query("SELECT $cols FROM ".$this->tableName($table)." WHERE ".$where);
+               $query="SELECT $cols FROM ".$this->tableName($table);
+               if($where!="")$query.=" WHERE ".$where;
+               $res=mysql_query($query);
                if($res===false)return false;
                $nr=mysql_num_rows($res);
                $ret=array();
index ea5b3fa..3b4e3f4 100644 (file)
@@ -95,7 +95,10 @@ class DbScheme {
                        "ordertime" => array("int32","notnull"),
                        "senttime" => array("int32"),
                        //comments made on web form (eg. "urgently needed for dads birthday")
-                       "comments" => array("text")
+                       "comments" => array("text"),
+                       //how much has been paid already (including used vouchers)
+                       //this is for comparison with the price fields in ticket and voucher tables
+                       "amountpaid" => array("int32")
                );
                //tickets
                $this->scheme["ticket"]=array(
@@ -123,6 +126,28 @@ class DbScheme {
                        //remaining value in cents
                        "value" => array("int32","notnull")
                );
+               
+               //shopping cart
+               $this->scheme["cart"]=array(
+                       //the cookie for this cart
+                       "cartid" => array("string:32","primarykey"),
+                       //when the cart expires
+                       "timeout" => array("int32","notnull")
+               );
+               //buying tickets
+               $this->scheme["cart_ticket"]=array(
+                       "ctid" => array("int64","primarykey"),
+                       //tickets in the cart
+                       "eventid" => array("int32","foreignkey:event:eventid"),
+                       "amount" => array("int32","notnull"),
+               );
+               //buying vouchers
+               $this->scheme["cart_voucher"]=array(
+                       "cvid" => array("int64","primarykey"),
+                       //voucher value
+                       "value" => array("int32","notnull")
+               );
+                       
        }
        
        /**return the tables to be created in order*/
diff --git a/www/inc/event.php b/www/inc/event.php
new file mode 100644 (file)
index 0000000..3348f02
--- /dev/null
@@ -0,0 +1,46 @@
+<?
+//
+// PHP Implementation: event
+//
+// Description: 
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+
+/**Get an overview of all events:
+returns an array of array("eventid"=>int, "title"=>string,"starttime"=>int)*/
+function getAllEvents()
+{
+       global $db;
+       return $db->select("event","eventid,title,starttime","");
+}
+
+/**Machine-wrapper for getAllEvents() */
+function getAllEventsXml()
+{
+       $all=getAllEvents();
+       if($all===false){
+               header("X-MagicSmoke-Status: Error");
+               echo "Database Error.";
+               return;
+       }
+       header("X-MagicSmoke-Status: Ok");
+       $xml=new DOMDocument;
+       $root=$xml->createElement("EventList");
+       if(count($all)>0)
+       foreach($all as $k => $ev){
+               $nod=$xml->createElement("Event",$ev["title"]);
+               $nod->setAttribute("id",$ev["eventid"]);
+               $nod->setAttribute("start",$ev["starttime"]);
+               $root->appendChild($nod);
+       }
+       $xml->appendChild($root);
+       echo $xml->saveXml();
+}
+
+?>
\ No newline at end of file
index a22f454..2b2af5f 100644 (file)
@@ -2,4 +2,6 @@
 //check database
 if(!$db->canUseDb())
        die("Database is not correctly configured. Giving up.");
+//load class-files
+include('inc/event.php');
 ?>
\ No newline at end of file
index 433a03c..0934ce6 100644 (file)
@@ -100,6 +100,12 @@ if(!$session->canExecute($SMOKEREQUEST)){
        die("You do not have the right to execute this transaction.");
 }
 
+//get a list of events
+if($SMOKEREQUEST=="geteventlist"){
+       getAllEventsXml();
+       exit();
+}
+
 //EOF
 header("X-MagicSmoke-Status: Error");
 die("Internal Error: unknown command, hiccup in code structure.");