}
}
+//returns an overview over all orders
+function getOrderListXml()
+{
+ global $db;
+ $xml=new DomDocument;
+ $doc=$xml->createElement("OrderList");
+ $res=$db->select("order","orderid,customerid,status,amountpaid","");
+ foreach($res as $ord){
+ //collect tickets
+ $tres=$db->select("ticket","price,status","orderid=".$db->escapeInt($ord["orderid"]));
+ $price=0;
+ foreach($tres as $tc)
+ if(($tc["status"]&TICKET_MPAY)!=0)
+ $price+=$tc["price"];
+ //generate XML
+ $ox=$xml->createElement("Order");
+ $ox->setAttribute("id",$ord["orderid"]);
+ $ox->setAttribute("customer",$ord["customerid"]);
+ $ox->setAttribute("totalprice",$price);
+ $ox->setAttribute("paid",$ord["amountpaid"]);
+ switch($ord["status"]){
+ case ORDER_PLACED:
+ $ox->setAttribute("status","placed");
+ break;
+ case ORDER_SENT:
+ $ox->setAttribute("status","sent");
+ break;
+ case ORDER_CANCELLED:
+ $ox->setAttribute("status","cancelled");
+ break;
+ case ORDER_CLOSED:
+ $ox->setAttribute("status","closed");
+ break;
+ default:
+ $ox->setAttribute("status","error");
+ break;
+ }
+ //add to XML
+ $doc->appendChild($ox);
+ }
+ $xml->appendChild($doc);
+ //output
+ print($xml->saveXml());
+}
+
?>
\ No newline at end of file
/**mask: ticket is blocked (can be used or is used)*/
define("TICKET_MBLOCK",0x100);
/**mask: ticket must be paid or is paid*/
-define("TICKET_MBLOCK",0x200);
+define("TICKET_MPAY",0x200);
/**ticket has been reserved by a seller*/
tr("geteventlist"),tr("geteventdata"),tr("seteventdata"),tr("eventsummary"), //event infos
tr("getroomdata"),tr("setroomdata"),//room infos
tr("getcustomerlist"),tr("getcustomer"),tr("setcustomer"), //customer info
- tr("checkorder"),tr("createorder"),tr("createsale"), //sell/order stuff
+ tr("checkorder"),tr("createorder"),tr("createsale"),tr("getorderlist"), //sell/order stuff
tr("gettemplatelist"),tr("gettemplate"),tr("settemplate") //templates
);
/**contains the low-level request name from the client*/
exit();
}
-
+//check that the order can be executed
if($SMOKEREQUEST=="checkorder"){
createOrderXml($REQUESTDATA,"check");
exit();
}
+//create order as normal order
if($SMOKEREQUEST=="createorder"){
createOrderXml($REQUESTDATA,"order");
exit();
}
+//create order recors as a sale (already paid and delivered)
if($SMOKEREQUEST=="createsale"){
createOrderXml($REQUESTDATA,"sell");
exit();
}
+//get list of all orders
+if($SMOKEREQUEST=="getorderlist"){
+ getOrderListXml();
+ exit();
+}
//EOF