From 098ed084a6979b64058a155bfa78535703b9ae26 Mon Sep 17 00:00:00 2001 From: konrad Date: Wed, 12 Nov 2008 15:36:58 +0000 Subject: [PATCH] show comments in event summary git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@178 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- src/eventsummary.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++-- src/eventsummary.h | 5 ++++ src/overview.cpp | 2 +- www/inc/classes/event.php | 24 +++++++++++++++++++- 4 files changed, 79 insertions(+), 5 deletions(-) diff --git a/src/eventsummary.cpp b/src/eventsummary.cpp index cf45cd4..de1baf9 100644 --- a/src/eventsummary.cpp +++ b/src/eventsummary.cpp @@ -24,6 +24,24 @@ #include #include #include +#include + +inline QString htmlize(QString str) +{ + QString out; + for(int i=0;i')out+=">";else + if(c=='&')out+="&";else + if(c=='\n')out+="
\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) @@ -34,12 +52,16 @@ MEventSummary::MEventSummary(QWidget*par,MWebRequest*rq,int eid) //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); @@ -62,7 +84,7 @@ MEventSummary::MEventSummary(QWidget*par,MWebRequest*rq,int eid) 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); @@ -78,6 +100,20 @@ MEventSummary::MEventSummary(QWidget*par,MWebRequest*rq,int eid) } table->resizeColumnsToContents(); + QTextBrowser *tb; + tab->addTab(tb=new QTextBrowser,tr("Comments")); + QString cmt; + for(int i=0;i"; + else cmt+="
"; + cmt+=""+tr("Order: "); + cmt+=QString::number(c.orderid); + cmt+="
"+tr("Customer: ")+htmlize(c.custname); + cmt+="

"+htmlize(c.comment); + } + tb->setHtml(cmt); + QHBoxLayout*hl; vl->addSpacing(15); vl->addLayout(hl=new QHBoxLayout,0); @@ -136,6 +172,17 @@ void MEventSummary::getSummaryData() tc.unused=el.attribute("unused","0").toInt(); tickets.append(tc); } + nl=sum.elementsByTagName("Comment"); + for(int i=0;itickets; + struct Comment{ + int custid,orderid; + QString custname,comment; + }; + QListcomments; //get basic data about event void getEventData(); diff --git a/src/overview.cpp b/src/overview.cpp index cc47cb1..278a732 100644 --- a/src/overview.cpp +++ b/src/overview.cpp @@ -112,7 +112,7 @@ MOverview::MOverview(MWebRequest*mw,QString pk) 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); diff --git a/www/inc/classes/event.php b/www/inc/classes/event.php index 6c98e5a..6eb2f35 100644 --- a/www/inc/classes/event.php +++ b/www/inc/classes/event.php @@ -299,7 +299,7 @@ function getEventSummaryXml($evid) { 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; @@ -307,6 +307,7 @@ function getEventSummaryXml($evid) $tcbought=array(); $tcused=array(); $tcall=array(); + $oids=array(); foreach($res as $tc){ switch($tc["status"]){ case TICKET_RESERVED:$tcreserve++;break; @@ -336,6 +337,19 @@ function getEventSummaryXml($evid) $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; @@ -361,6 +375,14 @@ function getEventSummaryXml($evid) $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()); -- 1.7.2.5