The <tt>getordersbyevents</tt> transaction can be used to return all orders that contain tickets for a specific event. The request is a space separated list of event IDs, the response has the format of the <tt>getorderlist</tt> response.
+<h3>Changing the Comment of an Order</h3>
+
+The <tt>setordercomment</tt> transaction is used to change the orders comment. The request is a simple XML document:<p>
+
+<pre>
+<OrderComment orderid="id">comment text...</OrderComment>
+</pre>
+
+The response body is empty or optionally contains an error message.
+
<!-- ************************************************************************************
************************************************************************************
************************************************************************************ -->
return r;
}
+bool MOrder::sendComment(QString nc)
+{
+ //make sure we are in a sane state
+ makeComplete();
+ if(!req || m_orderid<0)return false;
+ //create XML
+ QDomDocument doc;
+ QDomElement root=doc.createElement("OrderComment");
+ root.setAttribute("orderid",m_orderid);
+ root.appendChild(doc.createTextNode(nc));
+ doc.appendChild(root);
+ //request
+ if(!req->request("setordercomment",doc.toByteArray()))return false;
+ if(req->responseStatus()==MWebRequest::Ok){
+ m_comment=nc;
+ return true;
+ }else
+ return false;
+}
+
/******************************************************************************
* Ticket
/**mark the order as shipped; queries DB; returns true on success*/
bool shipOrder();
+
+ /**set a new comment and immediately send it to the server (will not set the comment if the server rejects it); returns whether setting was successful*/
+ bool sendComment(QString);
private:
MWebRequest*req;
#include <QPushButton>
#include <QStandardItemModel>
#include <QTableView>
+#include <QTextEdit>
#include <math.h>
->setEnabled(req->hasRole("changeticketprice"));
m->addAction(tr("&Return Ticket..."),this,SLOT(ticketReturn()))
->setEnabled(req->hasRole("ticketreturn"));
+ m->addAction(tr("Change Commen&t..."),this,SLOT(changeComment()))
+ ->setEnabled(req->hasRole("setordercomment"));
m->addSeparator();
m->addAction(tr("&Close"),this,SLOT(close()));
m=mb->addMenu(tr("&Payment"));
gl->addWidget(new QLabel(tr("Order State:")),++rw,0);
gl->addWidget(m_state=new QLabel(m_order.orderStatusString()),rw,1);
gl->addWidget(new QLabel(tr("Order Comment:")),++rw,0);
- gl->addWidget(lab=new QLabel(m_order.comment()),rw,1);
+ gl->addWidget(m_comment=lab=new QLabel(m_order.comment()),rw,1);
lab->setWordWrap(true);
gl->setColumnStretch(0,0);
gl->setColumnStretch(1,10);
}
}
+void MOrderWindow::changeComment()
+{
+ //create editor dialog
+ QString cmt=m_order.comment();
+ QDialog d;
+ d.setWindowTitle(tr("Set comment: order %1").arg(m_order.orderID()));
+ QVBoxLayout*vl;
+ d.setLayout(vl=new QVBoxLayout);
+ QTextEdit*te;
+ vl->addWidget(te=new QTextEdit,1);
+ te->setPlainText(cmt);
+ vl->addSpacing(15);
+ QHBoxLayout*hl;
+ vl->addLayout(hl=new QHBoxLayout,0);
+ hl->addStretch(10);
+ QPushButton*p;
+ hl->addWidget(p=new QPushButton(tr("&Save")));
+ connect(p,SIGNAL(clicked()),&d,SLOT(accept()));
+ hl->addWidget(p=new QPushButton(tr("&Cancel")));
+ connect(p,SIGNAL(clicked()),&d,SLOT(reject()));
+ //get status
+ if(d.exec()!=QDialog::Accepted)return;
+ //send to server
+ m_order.sendComment(cmt=te->toPlainText());
+ //reset display
+ m_comment->setText(cmt);
+}
+
/*************************************************************************************/
MTicketView::MTicketView(QWidget*w,QList<MTicket>t)
/**return a ticket*/
void ticketReturn();
+ /**change the comment on the order*/
+ void changeComment();
+
/**cancel the order*/
void cancelOrder();
/**mark as shipped*/
MWebRequest*req;
MOrder m_order;
bool m_changed;
- QLabel *m_orderid,*m_orderdate,*m_sentdate,*m_state,*m_paid,*m_total;
+ QLabel *m_orderid,*m_orderdate,*m_sentdate,*m_state,*m_paid,*m_total,*m_comment;
QTableView *m_tickettable;
QStandardItemModel *m_ticketmodel;
};
getOrderListXml("orderid IN (".$olst.")");
}
}
+
+//change the comment on an order
+function setOrderCommentXml($txt)
+{
+ //parse XML data
+ $xml=new DomDocument;
+ $xml->loadXml($txt);
+ $doc=$xml->documentElement;
+ $oid=$doc->getAttribute("orderid")+0;
+ $comment="";
+ foreach($doc->childNodes as $cn)
+ if($cn->nodeType==XML_TEXT_NODE)
+ $comment=$cn->wholeText;
+ //set comment
+ global $db;
+ $db->beginTransaction();
+ $upcnt=$db->update("order",array("comments"=>$comment),"orderid=".$db->escapeInt($oid));
+ $db->commitTransaction();
+ if($upcnt!==false)
+ header("X-MagicSmoke-Status: Ok");
+ else{
+ header("X-MagicSmoke-Status: Error");
+ echo "Unable to update order comment.";
+ }
+}
?>
\ No newline at end of file
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"),tr("getordersbyevents"), //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"),tr("setordercomment"), //sell/order stuff
tr("getticket"),tr("useticket"),tr("changeticketprice"),tr("ticketreturn"),//ticket management
tr("gettemplatelist"),tr("gettemplate"),tr("settemplate") //templates
);
orderByEventXml(trim($REQUESTDATA));
exit();
}
+if($SMOKEREQUEST=="setordercomment"){
+ setOrderCommentXml(trim($REQUESTDATA));
+ exit();
+}
//get a ticket
if($SMOKEREQUEST=="getticket"){