* getAllEvents transaction is ordered by date now
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sun, 31 Aug 2008 11:23:09 +0000 (11:23 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sun, 31 Aug 2008 11:23:09 +0000 (11:23 +0000)
* added ordersByEvents transaction

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

www/config.php.template
www/inc/classes/event.php
www/inc/classes/order.php
www/inc/classes/ticket.php
www/inc/db/db.php
www/inc/db/db_mysql.php
www/machine.php

index 4142f64..97d3662 100644 (file)
@@ -17,7 +17,8 @@ $template="./template/";
 // create engine: server, user, password
 $db = new MysqlEngine("localhost","smoke","");
 // set database name
-$db->setDbName("smoke");
+//$db->setDbName("smoke");
+$db->setDbName("DB396352");
 // set table-prefix (optional)
 $db->setPrefix("smoke_");
 //set this to one of the supported MySQL storage engines for DB creation
@@ -60,4 +61,4 @@ $CartTimeout=3600;
 //Authenticated web session timeout - how long an authenticated web session lasts
 // this should usually be a few hours (3600s per hour)
 $WebSessionTimeout=1800;
-?>
\ No newline at end of file
+?>
index 463b94d..6c98e5a 100644 (file)
@@ -17,7 +17,7 @@ returns an array of array("eventid"=>int, "title"=>string,"starttime"=>int)*/
 function getAllEvents()
 {
        global $db;
-       return $db->select("event","eventid,title,starttime","");
+       return $db->select("event","eventid,title,starttime","","ORDER BY starttime");
 }
 
 /**Get an overview of events: returns an array of array("eventid"=>int); used by createEventList; returns only events in the future  and ordered*/
index 2b36516..231e7da 100644 (file)
@@ -535,12 +535,12 @@ function createOrderXml($xmldata,$action)
 }
 
 //returns an overview over all orders
-function getOrderListXml()
+function getOrderListXml($where="")
 {
        global $db;
        $xml=new DomDocument;
        $doc=$xml->createElement("OrderList");
-       $res=$db->select("order","orderid,customerid,status,amountpaid","");
+       $res=$db->select("order","orderid,customerid,status,amountpaid",$where);
        foreach($res as $ord){
                //collect tickets
                $tres=$db->select("ticket","price,status","orderid=".$db->escapeInt($ord["orderid"]));
@@ -705,4 +705,43 @@ function orderByTicketXml($ticket)
        echo $res[0]["orderid"];
 }
 
+//find an order
+function orderByEventXml($events)
+{
+       global $db;
+       //collate eventids
+       $eids="";
+       foreach(explode(" ",$events) as $eid){
+               $eid=trim($eid);
+               if($eid=="")continue;
+               if($eids!="")$eids.=",";
+               $eids.=$db->escapeInt($eid);
+       }
+       if($eids==""){
+               header("X-MagicSmoke-Status: Ok");
+               echo "<OrderList/> <!-- no events requested -->";
+               return;
+       }
+       //find orders
+       $res=$db->select("ticket","orderid","eventid IN (".$eids.")");
+       $oar=array();
+       $olst="";
+       for($i=0;$i<count($res);$i++){
+               $oid=$res[$i]["orderid"];
+               if($oid===NULL || $oid<0)
+                       continue;
+               if(!in_array($oid,$oar)){
+                       $oar[]=$oid;
+                       if($olst!="")$olst.=",";
+                       $olst.=$oid;
+               }
+       }
+       //print them
+       if($olst==""){
+               header("X-MagicSmoke-Status: Ok");
+               echo "<OrderList/> <!-- no orders found -->";
+       }else{
+               getOrderListXml("orderid IN (".$olst.")");
+       }
+}
 ?>
\ No newline at end of file
index 95c112f..a6b9979 100644 (file)
 
 //masks
 /**mask: ticket is blocked (can be used or is used)*/
-define("TICKET_MBLOCK",0x100);
+define("TICKET_MBLOCK",0x100); //dec: 256
 /**mask: ticket must be paid or is paid*/
-define("TICKET_MPAY",0x200);
+define("TICKET_MPAY",0x200); //dec: 512
 
 
 /**ticket has been reserved by a seller*/
-define("TICKET_RESERVED",0x101);
+define("TICKET_RESERVED",0x101); //dec: 257
 /**ticket is part of an order or has been sold independently*/
-define("TICKET_BOUGHT",0x302);
+define("TICKET_BOUGHT",0x302); //dec: 770
 /**ticket has been used*/
-define("TICKET_USED",0x303);
+define("TICKET_USED",0x303); //dec: 771
 /**ticket has been cancelled by some entity*/
-define("TICKET_CANCELLED",0x4);
+define("TICKET_CANCELLED",0x4); //dec: 4
 /**ticket has been refunded*/
-define("TICKET_REFUND",0x4);
+define("TICKET_REFUND",0x4); //dec: 4
 
 class Ticket
 {
@@ -217,7 +217,7 @@ class Ticket
                }
                $this->status=TICKET_USED;
                global $db;
-               $db->update("ticket",array("status"=>TICKET_USED),"ticketid=".$db->escapeInt($this->ticketid));
+               $db->update("ticket",array("status"=>TICKET_USED),"ticketid=".$db->escapeString($this->ticketid));
        }
 };
 
index 67f51fd..932d09b 100644 (file)
@@ -50,8 +50,8 @@ abstract class DbEngine
        /**ends a transaction with a rollback; must be implemented by driver; returns true on success*/
        public abstract function rollbackTransaction();
        
-       /**gets some data from the database; $table is the name of the table, $cols is the list of columns to return or "*" for all, $where is the where clause of the SQL-statement; returns array of rows, which are in *_fetch_array format; returns false on error*/
-       public abstract function select($table,$cols,$where);
+       /**gets some data from the database; $table is the name of the table, $cols is the list of columns to return or "*" for all, $where is the where clause of the SQL-statement, $orderby may contain additional ORDER BY or GROUP BY clauses; returns array of rows, which are in *_fetch_array format; returns false on error*/
+       public abstract function select($table,$cols,$where,$orderby="");
        
        /**insert values into a table; returns false on failure, the new primary key if a sequence was set, true otherwise*/
        public abstract function insert($table,array $values);
index edbfd82..5e09031 100644 (file)
@@ -83,10 +83,11 @@ class MysqlEngine extends DbEngine
                return mysqli_query($this->dbhdl,"ROLLBACK");
        }
        
-       public function select($table,$cols,$where)
+       public function select($table,$cols,$where,$orderby="")
        {
                $query="SELECT $cols FROM ".$this->tableName($table);
                if($where!="")$query.=" WHERE ".$where;
+               if($orderby!="")$query.=" ".$orderby;
                $res=mysqli_query($this->dbhdl,$query);
                if($res===false)return false;
                $nr=mysqli_num_rows($res);
index be9bf78..a85bcdd 100644 (file)
@@ -23,7 +23,7 @@ $ALLOWEDREQUESTS=array(
        tr("geteventlist"),tr("geteventdata"),tr("seteventdata"),tr("eventsummary"),tr("cancelevent"),//event infos
        tr("getroomdata"),tr("setroomdata"),//room infos
        tr("getcustomerlist"),tr("getcustomer"),tr("setcustomer"), //customer info
-       tr("checkorder"),tr("createorder"),tr("createsale"),tr("getorderlist"),tr("getorder"),tr("orderpay"),tr("orderrefund"),tr("ordershipped"),tr("cancelorder"),tr("orderbyticket"), //sell/order stuff
+       tr("checkorder"),tr("createorder"),tr("createsale"),tr("getorderlist"),tr("getorder"),tr("orderpay"),tr("orderrefund"),tr("ordershipped"),tr("cancelorder"),tr("orderbyticket"),tr("getordersbyevents"), //sell/order stuff
        tr("getticket"),tr("useticket"),tr("changeticketprice"),tr("ticketreturn"),//ticket management
        tr("gettemplatelist"),tr("gettemplate"),tr("settemplate") //templates
 );
@@ -317,6 +317,10 @@ if($SMOKEREQUEST=="orderbyticket"){
        orderByTicketXml(trim($REQUESTDATA));
        exit();
 }
+if($SMOKEREQUEST=="getordersbyevents"){
+       orderByEventXml(trim($REQUESTDATA));
+       exit();
+}
 
 //get a ticket
 if($SMOKEREQUEST=="getticket"){