setLayout(vl=new QVBoxLayout);
vl->addLayout(gl=new QGridLayout);
- gl->addWidget(lab=new QLabel(tr("Title:")),lctr,0);
+ gl->addWidget(lab=new QLabel(tr("ID:")),lctr,0);
+ lab->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+ gl->addWidget(eventid=new QLabel,lctr,1);
+ eventid->setText(QString::number(event.eventId()));
+
+ gl->addWidget(lab=new QLabel(tr("Title:")),++lctr,0);
lab->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
gl->addWidget(title=new QLineEdit,lctr,1);
title->setText(event.title());
m=mb->addMenu(tr("&Misc"));
m->addAction(tr("&Return ticket..."),this,SLOT(ticketReturn()));
+ m=mb->addMenu(tr("&Admin"));
+ m->setEnabled(req->hasRole("_admin"));
+ m->addAction(tr("&Schedule Backup..."));
+ m->addAction(tr("&Backup now..."));
+ m->addAction(tr("&Restore..."));
+
//tabs
setCentralWidget(tab=new QTabWidget);
connect(tab,SIGNAL(currentChanged(int)),this,SLOT(tabChanged()));
vl->addWidget(p=new QPushButton(tr("Find by Ticket...")),0);
connect(p,SIGNAL(clicked()),this,SLOT(orderByTicket()));
p->setEnabled(req->hasRole("orderbyticket"));
+ vl->addWidget(p=new QPushButton(tr("Find by Event...")),0);
+ connect(p,SIGNAL(clicked()),this,SLOT(orderByEvent()));
+ p->setEnabled(req->hasRole("getordersbyevents"));
vl->addStretch(10);
//Entrance Control Tab
om->show();
}
+void MOverview::orderByEvent()
+{
+ //display selection dialog
+ QDialog d(this);
+ d.setWindowTitle(tr("Select Event"));
+ QVBoxLayout*vl;
+ QHBoxLayout*hl;
+ d.setLayout(vl=new QVBoxLayout);
+ QTableView*tv;
+ vl->addWidget(tv=new QTableView,10);
+ tv->setEditTriggers(QAbstractItemView::NoEditTriggers);
+ tv->setModel(eventmodel);
+ tv->resizeColumnsToContents();
+ vl->addLayout(hl=new QHBoxLayout,0);
+ hl->addStretch(10);
+ QPushButton*p;
+ hl->addWidget(p=new QPushButton(tr("Ok")),0);
+ connect(p,SIGNAL(clicked()),&d,SLOT(accept()));
+ hl->addWidget(p=new QPushButton(tr("Cancel")),0);
+ connect(p,SIGNAL(clicked()),&d,SLOT(reject()));
+ //wait for user
+ if(d.exec()!=QDialog::Accepted)
+ return;
+ //get selection
+ QModelIndexList ilst=tv->selectionModel()->selectedIndexes();
+ if(ilst.size()<1){
+ qDebug("nothing selected");
+ return;
+ }
+ //get events
+ QList<int>eventids;
+ for(int i=0;i<ilst.size();i++){
+ int eid=eventmodel->data(eventmodel->index(ilst[i].row(),0),Qt::UserRole).toInt();
+ if(!eventids.contains(eid))eventids.append(eid);
+ }
+ //request data and display
+ //TODO: unify this part with updateOrders
+ ordermodel->clear();
+ ordermodel->setHorizontalHeaderLabels(QStringList()<<tr("Status")<<tr("Total")<<tr("Paid")<<tr("Customer"));
+ QList<MOrder> orders=req->getOrdersByEvents(eventids);
+ if(orders.size()==0)return;
+ QList<MCustomer> cust=req->getAllCustomers();
+ for(int cl=0;cl<orders.size();cl++){
+ ordermodel->insertRow(cl);
+ ordermodel->setHeaderData(cl,Qt::Vertical,orders[cl].orderID());
+ ordermodel->setData(ordermodel->index(cl,0),orders[cl].orderStatusString());
+ ordermodel->setData(ordermodel->index(cl,0),orders[cl].orderID(),Qt::UserRole);
+ ordermodel->setData(ordermodel->index(cl,1),orders[cl].totalPriceString());
+ ordermodel->setData(ordermodel->index(cl,2),orders[cl].amountPaidString());
+ int cid=orders[cl].customerID();
+ //TODO: make this more effective:
+ for(int j=0;j<cust.size();j++)
+ if(cust[j].customerID()==cid)
+ ordermodel->setData(ordermodel->index(cl,3),cust[j].name());
+ }
+}
+
void MOverview::uploadTemplate()
{
//get file
return ret;
}
+QList<MOrder> MWebRequest::getOrdersByEvents(QList<int>evids)
+{
+ errstr="";
+ QString evs;
+ for(int i=0;i<evids.size();i++)
+ evs+=QString::number(evids[i])+" ";
+ if(!request("getordersbyevents",evs.trimmed().toUtf8()))return QList<MOrder>();
+ if(responseStatus()!=Ok)return QList<MOrder>();
+ //parse return document
+ QDomDocument doc;
+ QString msg;int ln,cl;
+ if(!doc.setContent(rspdata,&msg,&ln,&cl)){
+ errstr=tr("Error parsing OrderList XML data (line %1 column %2): %3").arg(ln).arg(cl).arg(msg);
+ return QList<MOrder>();
+ }
+ QDomElement root=doc.documentElement();
+ QDomNodeList nl=root.elementsByTagName("Order");
+ QList<MOrder>ret;
+ for(int i=0;i<nl.size();i++){
+ QDomElement el=nl.at(i).toElement();
+ if(el.isNull())continue;
+ MOrder mo(this,el);
+ if(mo.isValid())ret.append(mo);
+ }
+ return ret;
+}
+
QByteArray MWebRequest::responseBody()
{
return rspdata;