// 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
//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
+?>
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*/
}
//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"]));
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
//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
{
}
$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));
}
};
/**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);
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);
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
);
orderByTicketXml(trim($REQUESTDATA));
exit();
}
+if($SMOKEREQUEST=="getordersbyevents"){
+ orderByEventXml(trim($REQUESTDATA));
+ exit();
+}
//get a ticket
if($SMOKEREQUEST=="getticket"){