getFromDB(m_orderid);
}
+void MOrder::pruneInvalid()
+{
+ //tickets
+ QList<MTicket>ntc;
+ for(int i=0;i<m_tickets.size();i++)
+ switch(m_tickets[i].status()){
+ case MTicket::CheckFailTooLate:
+ case MTicket::CheckFailExhausted:
+ case MTicket::CheckFailCancelled:
+ case MTicket::CheckFailEventInvalid:
+ case MTicket::Invalid:
+ //ignore
+ break;
+ default:
+ //keep all others
+ ntc.append(m_tickets[i]);
+ }
+ m_tickets=ntc;
+ //TODO: vouchers
+ //TODO: shipping info?
+}
+
/**************
* below this line we need to make sure the order is completed before we return results
*/
->setEnabled(req->hasRole("createorder")&&o.canOrder());
m->addAction(tr("&Sell..."),this,SLOT(createSale()))
->setEnabled(req->hasRole("createsale")&&o.canSell());
+ m->addAction(tr("&Prune and recheck..."),this,SLOT(recheckOrder()));
m->addSeparator();
m->addAction(tr("C&ancel Order..."),this,SLOT(cancelOrder()))
->setEnabled(req->hasRole("cancelorder")&&o.isStored());
close();
}
-
void MOrderWindow::createSale()
{
createOrder(true);
}
+void MOrderWindow::recheckOrder()
+{
+ //prune
+ m_order.pruneInvalid();
+ //now check
+ MOrder ord;
+ ord=m_order.createOrder("checkorder");
+ if(!ord.isValid())return;
+ //display final order
+ MOrderWindow *ow=new MOrderWindow(parentWidget(),req,ord);
+ ow->show();
+ //undisplay self
+ close();
+}
+
void MOrderWindow::shipOrder()
{
if(QMessageBox::question(this,tr("Mark as shipped?"),tr("Mark this order as shipped now?"),QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes)==QMessageBox::Yes){
continue;
}
$stime=$evt->getStartTime();
+ $etime=$evt->getEndTime();
$estat="ok";
//check whether we can still order
if(($stime-$orderstop)<=$curtime){
}
}
//check whether we can still sell
- if(($stime-$salestop)<=$curtime){
+ if(($etime-$salestop)<=$curtime){
if($estat=="ok")$estat="orderonly";
else $estat="toolate";
//if this is a sale: can't do it
return false;
}
}
- //create matching error XML for order/sale failure
+ //set order state
if($estat!="ok"){
+ if($ostat=="ok")$ostat=$estat;
+ else if($ostat!=$estat)$ostat="fail";
+ }
+ //create matching error XML for total order+sale failure
+ if($estat=="toolate"){
//create only one ticket and make it sound negative
$ev=$xml->createElement("Ticket");
$ev->setAttribute("event",$evid);
if($estat!="toolate")
$ev->setAttribute("price",$evt->getDefaultPrice());
$ord->appendChild($ev);
- if($ostat=="ok")$ostat=$estat;
- else if($ostat!=$estat)$ostat="fail";
continue;
}
//check whether event is cancelled
$avail=$evt->availableTicketAmount();
if($avail<$amount){
if($dumpxml===false)return false;
- //create a few good ones
+ //create a few (semi-)good ones
for($i=0;$i<$avail;$i++){
$ev=$xml->createElement("Ticket");
$ev->setAttribute("event",$evid);
- $ev->setAttribute("status","ok");
+ $ev->setAttribute("status",$estat);
$ev->setAttribute("price",$evt->getDefaultPrice());
$ev->setAttribute("id",$ftid++);
$ord->appendChild($ev);
$ev->setAttribute("status","exhausted");
$ev->setAttribute("id",$ftid++);
$ord->appendChild($ev);
+ $ostat="fail";
$ret=false;
continue;
}
- //survived all tests: finally create good tickets
+ //survived all tests: finally create (semi-)good tickets
for($i=0;$i<$amount;$i++){
$ev=$xml->createElement("Ticket");
$ev->setAttribute("event",$evid);
- $ev->setAttribute("status","ok");
+ $ev->setAttribute("status",$estat);
$ev->setAttribute("price",$evt->getDefaultPrice());
$ev->setAttribute("id",$ftid++);
$ord->appendChild($ev);
//TODO: check vouchers
+ //TODO: check shipping
+
//add other data and dump XML
if($dumpxml){
$ord->appendChild($xml->createElement("DeliveryAddress",$this->deliveryaddress));