From 899be539537d4b40046beb23ab1b3532518ebed1 Mon Sep 17 00:00:00 2001 From: konrad Date: Fri, 1 Jan 2010 14:52:52 +0000 Subject: [PATCH] basic template retrieval ticket/voucher printing minor fixups in config dialog git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@386 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- src/dialogs/configdialog.cpp | 3 ++ src/templates/templates.cpp | 56 +++++++++++++---------------------- src/templates/ticketrender.cpp | 8 ++-- src/wbase/WTransaction.cpp | 2 +- src/wext/MOTicket.cpp | 29 ++++++++++++++++++ src/wext/MOTicket.h | 7 ++++ src/wext/wext.pri | 1 + wob/basics.wolf | 9 ----- wob/event.wolf | 2 +- wob/magicsmoke.wolf | 1 + wob/template.wolf | 64 ++++++++++++++++++++++++++++++++++++++++ woc/qtout.cpp | 4 +- www/inc/wext/autoload.php | 1 + www/inc/wext/template.php | 31 +++++++++++++++++++ 14 files changed, 166 insertions(+), 52 deletions(-) create mode 100644 src/wext/MOTicket.cpp create mode 100644 wob/template.wolf create mode 100644 www/inc/wext/template.php diff --git a/src/dialogs/configdialog.cpp b/src/dialogs/configdialog.cpp index 3b827b0..431f2dd 100644 --- a/src/dialogs/configdialog.cpp +++ b/src/dialogs/configdialog.cpp @@ -114,6 +114,7 @@ MConfigDialog::MConfigDialog() proxypass->setEchoMode(QLineEdit::Password); connect(useproxy,SIGNAL(toggled(bool)),proxyuser,SLOT(setEnabled(bool))); connect(useproxy,SIGNAL(toggled(bool)),proxypass,SLOT(setEnabled(bool))); + gl->setRowStretch(++lctr,10); tab->addTab(w=new QWidget,tr("Authentication")); w->setLayout(gl=new QGridLayout); @@ -145,6 +146,8 @@ MConfigDialog::MConfigDialog() hl->addWidget(pb=new QPushButton(tr("Probe Server"))); connect(pb,SIGNAL(clicked()),this,SLOT(serverProbe())); + setSizeGripEnabled(true); + initProfiles(); loadProfile(); } diff --git a/src/templates/templates.cpp b/src/templates/templates.cpp index e4b0646..489b868 100644 --- a/src/templates/templates.cpp +++ b/src/templates/templates.cpp @@ -75,14 +75,8 @@ MTemplate MTemplateStore::getTemplate(QString f) else return MTemplate(); } -struct STemp{ - STemp(QString f,QString c,QString d){fname=f;checksum=c;descr=d;} - STemp(){} - QString fname,checksum,descr; -}; - void MTemplateStore::updateTemplates(bool force) -{/*TODO +{ //basics QString dname=req->dataDir()+"/templates/"; QSettings set; @@ -95,9 +89,11 @@ void MTemplateStore::updateTemplates(bool force) //get local info QStringList files=set.childGroups(); - QMap fmap; + QMap fmap; for(int i=0;irequest("gettemplatelist",""))return; - if(req->responseStatus()!=MWebRequest::Ok)return; + MTGetTemplateList gtl=req->queryGetTemplateList(); + if(gtl.hasError())return; //remember update time set.setValue("lastupdate",QDateTime::currentDateTime().toTime_t()); - //parse info - QDomDocument doc; - if(!doc.setContent(req->responseBody()))return; //scan and create new list - QDomNodeList nl=doc.elementsByTagName("Template"); - QMapnfmap; - for(int i=0;inf=gtl.gettemplates(); + QMapnfmap; + for(int i=0;irequest("gettemplate",fn.toUtf8()))return false; - if(req->responseStatus()!=MWebRequest::Ok)return false; + MTGetTemplate gt=req->queryGetTemplate(fn); + if(gt.hasError())return false; //store QFile f(dname+"/"+fn); if(!f.open(QIODevice::WriteOnly|QIODevice::Truncate))return false; - f.write(req->responseBody()); + f.write(gt.gettemplatefile().value().content()); return true; - */return false; } bool MTemplateStore::setTemplate(QString n,QString f) diff --git a/src/templates/ticketrender.cpp b/src/templates/ticketrender.cpp index 7de714b..fd4d4f0 100644 --- a/src/templates/ticketrender.cpp +++ b/src/templates/ticketrender.cpp @@ -525,11 +525,11 @@ class MTicketLabel:public MLabel QString MTicketLabel::getVariable(QString var)const { if(var=="TICKETID"||var=="BARCODE")return tick.ticketid(); - /*if(var=="PRICE")return tick.priceString(); + if(var=="PRICE")return tick.priceString(); if(var=="DATETIME")return tick.event().startTimeString(); if(var=="ROOM")return tick.event().room(); if(var=="TITLE")return tick.event().title(); - if(var=="ARTIST")return tick.event().artist().value().name();*/ + if(var=="ARTIST")return tick.event().artist().value().name(); return ""; } @@ -551,8 +551,8 @@ class MVoucherLabel:public MLabel QString MVoucherLabel::getVariable(QString var)const { if(var=="VOUCHERID"||var=="BARCODE")return vouc.voucherid(); - /*if(var=="PRICE")return vouc.priceString(); - if(var=="VALUE")return vouc.valueString();*/ + if(var=="PRICE")return vouc.priceString(); + if(var=="VALUE")return vouc.valueString(); return ""; } diff --git a/src/wbase/WTransaction.cpp b/src/wbase/WTransaction.cpp index 22d5fc6..8005179 100644 --- a/src/wbase/WTransaction.cpp +++ b/src/wbase/WTransaction.cpp @@ -179,8 +179,8 @@ void WTransaction::webTimeout() void WTransaction::webReady(int i,bool e) { - qDebug("finished req %i",i); if(i!=m_httpid)return; + qDebug("finished req %i",i); if(e){ m_stage=Error; m_errtype="_web"; diff --git a/src/wext/MOTicket.cpp b/src/wext/MOTicket.cpp new file mode 100644 index 0000000..990d322 --- /dev/null +++ b/src/wext/MOTicket.cpp @@ -0,0 +1,29 @@ +// +// C++ Implementation: MOTicket +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2010 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#include "MOTicket.h" +#include "msinterface.h" + +MOEvent MOTicket::event()const +{ + //if I am valid... + if(!ticketid().isNull() && !eventid().isNull()) + //...and the event is not... + if(m_event.eventid().isNull()){ + //...then retrieve the event + MTGetEvent ge=req->queryGetEvent(eventid()); + if(!ge.hasError()) + m_event=ge.getevent(); + } + //return whatever we have by now + return m_event; +} diff --git a/src/wext/MOTicket.h b/src/wext/MOTicket.h index 175ad2d..0332fab 100644 --- a/src/wext/MOTicket.h +++ b/src/wext/MOTicket.h @@ -15,6 +15,7 @@ #include "MOTicketAbstract.h" #include "misc.h" +#include "MOEvent.h" class MOTicket:public MOTicketAbstract { @@ -28,6 +29,12 @@ class MOTicket:public MOTicketAbstract /**returns the ticket status as localized string*/ QString statusString()const{return TicketState2locstr(status());} + + /**returns the event that this ticket belongs to - does a roundtrip to the database the first time this is called!*/ + MOEvent event()const; + private: + //this must be mutable, since event() is semantically and technically const + mutable MOEvent m_event; }; #endif diff --git a/src/wext/wext.pri b/src/wext/wext.pri index 6ab44cb..b47c22b 100644 --- a/src/wext/wext.pri +++ b/src/wext/wext.pri @@ -12,5 +12,6 @@ HEADERS += \ SOURCES += \ wext/MOCustomerInfo.cpp \ wext/MOOrder.cpp \ + wext/MOTicket.cpp \ wext/MOAddress.cpp \ wext/MOEvent.cpp \ No newline at end of file diff --git a/wob/basics.wolf b/wob/basics.wolf index 90a3e41..30a7715 100644 --- a/wob/basics.wolf +++ b/wob/basics.wolf @@ -22,15 +22,6 @@ - - - - - - - -
- This transaction allows to make a complete database backup. The backup file is replayed into the database via the admin.php interface. diff --git a/wob/event.wolf b/wob/event.wolf index 26d513e..0c474d7 100644 --- a/wob/event.wolf +++ b/wob/event.wolf @@ -145,7 +145,7 @@ - + diff --git a/wob/magicsmoke.wolf b/wob/magicsmoke.wolf index 232f398..d1304fc 100644 --- a/wob/magicsmoke.wolf +++ b/wob/magicsmoke.wolf @@ -44,5 +44,6 @@ + \ No newline at end of file diff --git a/wob/template.wolf b/wob/template.wolf new file mode 100644 index 0000000..59e4eab --- /dev/null +++ b/wob/template.wolf @@ -0,0 +1,64 @@ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/woc/qtout.cpp b/woc/qtout.cpp index 1d9bbf1..3be218d 100644 --- a/woc/qtout.cpp +++ b/woc/qtout.cpp @@ -456,12 +456,12 @@ void WocQtClientOut::classSerializers(const WocClass&cls,MFile&hdr,MFile&src,QSt }else if(cls.propertyIsString(prop)){ scd+="\t\tQDomElement el=doc.createElement(\""+prop+"\");\n"; - scd+="\t\tel.appendChild(doc.createTextNode(mp_"+prop+"));\n"; + scd+="\t\tel.appendChild(doc.createTextNode(mp_"+prop+".value()));\n"; scd+="\t\tr.appendChild(el);\n"; }else if(cls.propertyIsBlob(prop)){ scd+="\t\tQDomElement el=doc.createElement(\""+prop+"\");\n"; - scd+="\t\tel.appendChild(doc.createTextNode(mp_"+prop+".toBase64()));\n"; + scd+="\t\tel.appendChild(doc.createTextNode(mp_"+prop+".value().toBase64()));\n"; scd+="\t\tr.appendChild(el);\n"; }else{ qDebug("Error: cannot generate serializer for class %s property %s.",cls.name().toAscii().data(),prop.toAscii().data()); diff --git a/www/inc/wext/autoload.php b/www/inc/wext/autoload.php index ae21d53..22a289d 100644 --- a/www/inc/wext/autoload.php +++ b/www/inc/wext/autoload.php @@ -15,4 +15,5 @@ $AUTOCLASS["WORole"]="inc/wext/role.php"; $AUTOCLASS["WOOrderInfo"]="inc/wext/order.php"; $AUTOCLASS["WOOrder"]="inc/wext/order.php"; $AUTOCLASS["WOTicket"]="inc/wext/ticket.php"; +$AUTOCLASS["WOTemplate"]="inc/wext/template.php"; ?> \ No newline at end of file diff --git a/www/inc/wext/template.php b/www/inc/wext/template.php new file mode 100644 index 0000000..5044ad2 --- /dev/null +++ b/www/inc/wext/template.php @@ -0,0 +1,31 @@ +, (C) 2010 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +class WOTemplate extends WOTemplateAbstract +{ + /**called by the TemplateList transaction*/ + static public function getList($trans) + { + //TODO: filter by flags + $trans->settemplates(WOTemplateInfo::fromTableArraytemplate(WTtemplate::selectFromDB())); + } + + /**called by the GetTemplate transaction*/ + static public function getFile($trans) + { + //TODO: filter by flags + $trans->settemplatefile(WOTemplate::fromTabletemplate(WTtemplate::getFromDB($trans->getfilename()))); + } +}; + +?> \ No newline at end of file -- 1.7.2.5