From 074afd7590fcec4c92056dfa2a2eac60d6cba3e8 Mon Sep 17 00:00:00 2001 From: konrad Date: Sun, 3 Jan 2010 19:25:52 +0000 Subject: [PATCH] event summary works again git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@398 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- src/dialogs/eventsummary.cpp | 150 +++++++++++++++++++++--------------------- src/dialogs/eventsummary.h | 6 +- src/mwin/eventstab.cpp | 2 +- wob/event.wolf | 12 ++++ www/inc/wext/event.php | 22 ++++++ 5 files changed, 114 insertions(+), 78 deletions(-) diff --git a/src/dialogs/eventsummary.cpp b/src/dialogs/eventsummary.cpp index f600648..756d680 100644 --- a/src/dialogs/eventsummary.cpp +++ b/src/dialogs/eventsummary.cpp @@ -28,7 +28,7 @@ #include MEventSummary::MEventSummary(QWidget*par,qint64 eid) - :QDialog(par)/*,event(eid) TODO: get event somehow*/ + :QDialog(par),eventid(eid) { nreserved=ncancelled=ntotaltickets=ntotalmoney=0; //get event data @@ -49,7 +49,7 @@ MEventSummary::MEventSummary(QWidget*par,qint64 eid) gl->addWidget(new QLabel(tr("Artist:")),++rc,0); gl->addWidget(new QLabel(event.artist().value().name()),rc,1); gl->addWidget(new QLabel(tr("Start:")),++rc,0); -// gl->addWidget(new QLabel(event.startTimeString()),rc,1); + gl->addWidget(new QLabel(event.startTimeString()),rc,1); gl->addWidget(new QLabel(tr("Capacity:")),++rc,0); gl->addWidget(new QLabel(QString::number(event.capacity())),rc,1); gl->addWidget(new QLabel(tr("Tickets currently reserved:")),++rc,0); @@ -108,65 +108,67 @@ MEventSummary::MEventSummary(QWidget*par,qint64 eid) MEventSummary::~MEventSummary(){} -void MEventSummary::getOrderData() +void MEventSummary::getSummaryData() { - if(orderids.size()==orders.size())return; - for(int i=0;iqueryGetEventSummary(eventid); + if(ges.hasError()){ + QMessageBox::warning(this,tr("Warning"),tr("Error while retrieving data: %1").arg(ges.errorString())); + return; } -} + event=ges.getevent(); + QListord=ges.getorders(); + + nreserved=ncancelled=ntotaltickets=ntotalmoney=0; + QMapmaptickets; -void MEventSummary::getSummaryData() -{/*TODO: - if(!req->request("eventsummary",QString::number(event.eventId()).toAscii()))return; - if(req->responseStatus()!=MWebRequest::Ok)return; - QDomDocument doc; - if(!doc.setContent(req->responseBody()))return; - QDomElement sum=doc.documentElement(); - nreserved=sum.attribute("reserved","0").toInt(); - ncancelled=sum.attribute("cancelled","0").toInt(); - ntotaltickets=sum.attribute("totaltickets","0").toInt(); - ntotalmoney=sum.attribute("totalmoney","0").toInt(); - QDomNodeList nl=sum.elementsByTagName("Tickets"); - for(int i=0;iticks=ord[i].tickets(); + for(int j=0;jgetTemplate("eventsummary"); +{ + MTemplate tf=req->templateStore()->getTemplate("eventsummary"); if(!tf.isValid()){ QMessageBox::warning(this,tr("Warning"),tr("Unable to get template file (eventsummary). Giving up.")); return; @@ -175,12 +177,12 @@ void MEventSummary::print() connect(&rend,SIGNAL(getVariable(QString,MOdtRenderer::VarType&,QVariant&)),this,SLOT(getVariable(QString,MOdtRenderer::VarType&,QVariant&))); connect(&rend,SIGNAL(getLoopIterations(QString,int&)),this,SLOT(getLoopIterations(QString,int&))); connect(&rend,SIGNAL(getLoopVariable(QString,int,QString,MOdtRenderer::VarType&,QVariant&)),this,SLOT(getLoopVariable(QString,int,QString,MOdtRenderer::VarType&,QVariant&))); - rend.renderToPrinter();*/ + rend.renderToPrinter(); } void MEventSummary::saveas() -{/*TODO: - MTemplate tf=req->getTemplate("eventsummary"); +{ + MTemplate tf=req->templateStore()->getTemplate("eventsummary"); if(!tf.isValid()){ QMessageBox::warning(this,tr("Warning"),tr("Unable to get template file (eventsummary). Giving up.")); return; @@ -201,7 +203,7 @@ void MEventSummary::saveas() connect(&rend,SIGNAL(getVariable(QString,MOdtRenderer::VarType&,QVariant&)),this,SLOT(getVariable(QString,MOdtRenderer::VarType&,QVariant&))); connect(&rend,SIGNAL(getLoopIterations(QString,int&)),this,SLOT(getLoopIterations(QString,int&))); connect(&rend,SIGNAL(getLoopVariable(QString,int,QString,MOdtRenderer::VarType&,QVariant&)),this,SLOT(getLoopVariable(QString,int,QString,MOdtRenderer::VarType&,QVariant&))); - rend.renderToFile(fname);*/ + rend.renderToFile(fname); } void MEventSummary::getVariable(QString varname,MOdtRenderer::VarType&av,QVariant&value) @@ -310,8 +312,6 @@ void MEventSummary::getLoopVariable(QString loopname,int iteration,QString varna }else if(loopname=="ORDERS"){ if(iteration<0 || iteration>=orderids.size())return; - //make sure data is here - getOrderData(); //get order id int oid=orderids[iteration]; @@ -328,38 +328,40 @@ void MEventSummary::getLoopVariable(QString loopname,int iteration,QString varna if(varname=="FULLPRICE"){ value=orders[oid].totalprice().value(); av=MOdtRenderer::MoneyVar; - }/*TODO: else - if(varname=="SHIPPING")value=orders[oid].shipping().description();else + }else + if(varname=="SHIPPING")value=orders[oid].shippingtype().value().description().value();else if(varname=="SHIPPINGCOST"){ - value=orders[oid].shipping().price(); + value=orders[oid].shippingcosts().value(); av=MOdtRenderer::MoneyVar; }else{ - QListticks=orders[oid].tickets(); - QListeticks; + QListticks=orders[oid].tickets(); + QListeticks; int first,last; - first=last=event.startTime(); - int eid=event.eventId(); + first=last=event.start(); + int eid=event.eventid(); for(int i=0;itickets; @@ -60,11 +61,10 @@ class MEventSummary:public QDialog QListcomments; QListorderids; QMaporders; + QMapcustomers; //get summary void getSummaryData(); - //helper: get order details - void getOrderData(); }; #endif diff --git a/src/mwin/eventstab.cpp b/src/mwin/eventstab.cpp index 01f868b..b222119 100644 --- a/src/mwin/eventstab.cpp +++ b/src/mwin/eventstab.cpp @@ -64,7 +64,7 @@ MEventsTab::MEventsTab(QString pk) vl->addSpacing(15); vl->addWidget(p=new QPushButton(tr("Event Summary...")),0); connect(p,SIGNAL(clicked()),this,SLOT(eventSummary())); - p->setEnabled(req->hasRole("eventsummary")); + p->setEnabled(req->hasRight(req->RGetEventSummary)); vl->addSpacing(15); vl->addWidget(p=new QPushButton(tr("Cancel Event...")),0); p->setEnabled(req->hasRight(req->RCancelEvent)); diff --git a/wob/event.wolf b/wob/event.wolf index ecc405a..28fb4c2 100644 --- a/wob/event.wolf +++ b/wob/event.wolf @@ -305,4 +305,16 @@ + + + Returns the event plus all orders concerning it + + + + + + + + + \ No newline at end of file diff --git a/www/inc/wext/event.php b/www/inc/wext/event.php index 6714c04..afb9747 100644 --- a/www/inc/wext/event.php +++ b/www/inc/wext/event.php @@ -177,6 +177,28 @@ class WOEvent extends WOEventAbstract } } } + + /**called by the GetEventSummary transaction: returns the full event summary*/ + public static function getSummary($trans) + { + $evt=WOEvent::fromTableevent(WTevent::getFromDB($trans->geteventid())); + if(!is_a($evt,"WOEvent")){ + $trans->abortWithError(tr("The event ID is not valid.")); + return; + } + //return event + $trans->setevent($evt); + //find orders + //get list of valid orderids + global $db; + $res=$db->select("ticket","orderid","eventid=".$db->escapeInt($trans->geteventid()),"GROUP BY orderid ORDER BY orderid"); + $oidl=array(); + foreach($res as $r) + if(!in_array($r["orderid"],$oidl))$oidl[]=$r["orderid"]; + //get orders + $olst=WOOrder::fromTableArrayorder(WTorder::selectFromDB("orderid in ".$db->escapeIntList($oidl),"ORDER BY orderid")); + $trans->setorders($olst); + } }; ?> \ No newline at end of file -- 1.7.2.5