#include <QPushButton>
#include <QStandardItemModel>
#include <QTableView>
+#include <QTextBrowser>
+
+inline QString htmlize(QString str)
+{
+ QString out;
+ for(int i=0;i<str.size();i++){
+ QChar c=str[i];
+ ushort ci=c.unicode();
+ if(c=='<')out+="<";else
+ if(c=='>')out+=">";else
+ if(c=='&')out+="&";else
+ if(c=='\n')out+="<br/>\n";else
+ if(c.isSpace()||(c.unicode()>=32&&c.unicode()<=0x7f))out+=c;
+ else out+="&#"+QString::number(ci)+";";
+ }
+ return out;
+}
+
MEventSummary::MEventSummary(QWidget*par,MWebRequest*rq,int eid)
:QDialog(par)
//get event data
getEventData();
getSummaryData();
- //layout
+ //layout/tabs
setWindowTitle(tr("Summary for Event %1").arg(title));
QVBoxLayout*vl;
setLayout(vl=new QVBoxLayout);
+ QTabWidget*tab;
+ vl->addWidget(tab=new QTabWidget);
+ QWidget*w;
+ tab->addTab(w=new QWidget,tr("Summary"));
QGridLayout*gl;
- vl->addLayout(gl=new QGridLayout,0);
+ w->setLayout(gl=new QGridLayout);
int rc=0;
gl->addWidget(new QLabel(tr("Title:")),rc,0);
gl->addWidget(new QLabel(title),rc,1);
QTableView*table;
QStandardItemModel*model;
- vl->addWidget(table=new QTableView,10);
+ tab->addTab(table=new QTableView,tr("Tickets"));
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
table->setModel(model=new QStandardItemModel(this));
model->insertColumns(0,4);
}
table->resizeColumnsToContents();
+ QTextBrowser *tb;
+ tab->addTab(tb=new QTextBrowser,tr("Comments"));
+ QString cmt;
+ for(int i=0;i<comments.size();i++){
+ Comment c=comments[i];
+ if(cmt=="")cmt="<html><body>";
+ else cmt+="<hr/>";
+ cmt+="<b>"+tr("Order: ");
+ cmt+=QString::number(c.orderid);
+ cmt+="</b><br/><b>"+tr("Customer: ")+htmlize(c.custname);
+ cmt+="</b><p/>"+htmlize(c.comment);
+ }
+ tb->setHtml(cmt);
+
QHBoxLayout*hl;
vl->addSpacing(15);
vl->addLayout(hl=new QHBoxLayout,0);
tc.unused=el.attribute("unused","0").toInt();
tickets.append(tc);
}
+ nl=sum.elementsByTagName("Comment");
+ for(int i=0;i<nl.size();i++){
+ QDomElement el=nl.at(i).toElement();
+ if(el.isNull())continue;
+ Comment c;
+ c.custid=el.attribute("customerid","-1").toInt();
+ c.custname=el.attribute("customer");
+ c.orderid=el.attribute("orderid","-1").toInt();
+ c.comment=el.text();
+ comments.append(c);
+ }
}
void MEventSummary::print()
connect(p,SIGNAL(clicked()),this,SLOT(eventOrderTicket()));
p->setEnabled(req->hasRole("createorder"));
vl->addSpacing(15);
- vl->addWidget(p=new QPushButton(tr("Ticket Summary...")),0);
+ vl->addWidget(p=new QPushButton(tr("Event Summary...")),0);
connect(p,SIGNAL(clicked()),this,SLOT(eventSummary()));
p->setEnabled(req->hasRole("eventsummary"));
vl->addSpacing(15);
{
global $db;
//collect statistics
- $res=$db->select("ticket","price,status","eventid=".$db->escapeInt($evid));
+ $res=$db->select("ticket","price,status,orderid","eventid=".$db->escapeInt($evid));
$tcreserve=0;
$tccancel=0;
$totalmoney=0;
$tcbought=array();
$tcused=array();
$tcall=array();
+ $oids=array();
foreach($res as $tc){
switch($tc["status"]){
case TICKET_RESERVED:$tcreserve++;break;
$total++;
break;
}
+ if($tc["orderid"]!==false && !in_array($tc["orderid"],$oids))
+ $oids[]=$tc["orderid"];
+ }
+ //get comments
+ sort($oids);
+ $comments=array();
+ foreach($oids as $oid){
+ $res=$db->select("order","comments,customerid","orderid=".$db->escapeInt($oid));
+ if($res===false || count($res)==0)continue;
+ if($res[0]["comments"]===false || trim($res[0]["comments"])=="")continue;
+ $res2=$db->select("customer","name","customerid=".$db->escapeInt($res[0]["customerid"]));
+ if($res2===false || count($res2)==0)continue;
+ $comments[]=array("cid"=>$res[0]["customerid"],"cs"=>$res2[0]["name"],"cm"=>$res[0]["comments"],"oid"=>$oid);
}
//create XML
$xml=new DomDocument;
$p->setAttribute("used",0);
$doc->appendChild($p);
}
+ foreach($comments as $comment){
+ $p=$xml->createElement("Comment");
+ $p->setAttribute("customerid",$comment["cid"]);
+ $p->setAttribute("customer",$comment["cs"]);
+ $p->setAttribute("orderid",$comment["oid"]);
+ $p->appendChild($xml->createTextNode($comment["cm"]));
+ $doc->appendChild($p);
+ }
$xml->appendChild($doc);
header("X-MagicSmoke-Status: Ok");
print($xml->saveXml());