From 4f513b95defe3bc799789489b037a069ddea2f6f Mon Sep 17 00:00:00 2001 From: konrad Date: Sun, 31 Aug 2008 11:23:09 +0000 Subject: [PATCH] * getAllEvents transaction is ordered by date now * added ordersByEvents transaction git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@169 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- www/config.php.template | 5 +++-- www/inc/classes/event.php | 2 +- www/inc/classes/order.php | 43 +++++++++++++++++++++++++++++++++++++++++-- www/inc/classes/ticket.php | 16 ++++++++-------- www/inc/db/db.php | 4 ++-- www/inc/db/db_mysql.php | 3 ++- www/machine.php | 6 +++++- 7 files changed, 62 insertions(+), 17 deletions(-) diff --git a/www/config.php.template b/www/config.php.template index 4142f64..97d3662 100644 --- a/www/config.php.template +++ b/www/config.php.template @@ -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 +?> diff --git a/www/inc/classes/event.php b/www/inc/classes/event.php index 463b94d..6c98e5a 100644 --- a/www/inc/classes/event.php +++ b/www/inc/classes/event.php @@ -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*/ diff --git a/www/inc/classes/order.php b/www/inc/classes/order.php index 2b36516..231e7da 100644 --- a/www/inc/classes/order.php +++ b/www/inc/classes/order.php @@ -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 " "; + return; + } + //find orders + $res=$db->select("ticket","orderid","eventid IN (".$eids.")"); + $oar=array(); + $olst=""; + for($i=0;$i "; + }else{ + getOrderListXml("orderid IN (".$olst.")"); + } +} ?> \ No newline at end of file diff --git a/www/inc/classes/ticket.php b/www/inc/classes/ticket.php index 95c112f..a6b9979 100644 --- a/www/inc/classes/ticket.php +++ b/www/inc/classes/ticket.php @@ -13,21 +13,21 @@ //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)); } }; diff --git a/www/inc/db/db.php b/www/inc/db/db.php index 67f51fd..932d09b 100644 --- a/www/inc/db/db.php +++ b/www/inc/db/db.php @@ -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); diff --git a/www/inc/db/db_mysql.php b/www/inc/db/db_mysql.php index edbfd82..5e09031 100644 --- a/www/inc/db/db_mysql.php +++ b/www/inc/db/db_mysql.php @@ -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); diff --git a/www/machine.php b/www/machine.php index be9bf78..a85bcdd 100644 --- a/www/machine.php +++ b/www/machine.php @@ -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"){ -- 1.7.2.5