From: konrad Date: Sat, 6 Sep 2008 14:24:48 +0000 (+0000) Subject: make orders selectable by customer# X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=2005eca33427c0c420f27bfbe25ee08ac01153c1;p=web%2Fkonrad%2Fsmoke.git make orders selectable by customer# git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@174 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/src/overview.cpp b/src/overview.cpp index 2375204..cc47cb1 100644 --- a/src/overview.cpp +++ b/src/overview.cpp @@ -178,6 +178,8 @@ MOverview::MOverview(MWebRequest*mw,QString pk) ordermode->addItem(tr("Outstanding Payments"),ORDERPAY); ordermode->addItem(tr("Outstanding Refunds"),ORDERREFUND); ordermode->addItem(tr("Undelivered Orders"),ORDERUNSENT); + //make sure this entry is the last one, since we use count()-1 to select it + ordermode->addItem(tr("-search result-"),ORDERNONE); connect(ordermode,SIGNAL(currentIndexChanged(int)),this,SLOT(updateOrders())); vl->addWidget(ordertable=new QTableView); ordertable->setModel(ordermodel=new QStandardItemModel(this)); @@ -198,6 +200,9 @@ MOverview::MOverview(MWebRequest*mw,QString pk) vl->addWidget(p=new QPushButton(tr("Find by Event...")),0); connect(p,SIGNAL(clicked()),this,SLOT(orderByEvent())); p->setEnabled(req->hasRole("getordersbyevents")); + vl->addWidget(p=new QPushButton(tr("Find by Customer...")),0); + connect(p,SIGNAL(clicked()),this,SLOT(orderByCustomer())); + p->setEnabled(req->hasRole("getorderlist")); vl->addStretch(10); //Entrance Control Tab @@ -1045,6 +1050,46 @@ void MOverview::orderByEvent() if(cust[j].customerID()==cid) ordermodel->setData(ordermodel->index(cl,3),cust[j].name()); } + ordermode->setCurrentIndex(ordermode->count()-1); +} + +void MOverview::orderByCustomer() +{ + //display selection dialog + MCustomerListDialog mcl(req,this,true); + //wait for user + if(mcl.exec()!=QDialog::Accepted) + return; + //get selection + MCustomer cst=mcl.getCustomer(); + if(!cst.isValid()){ + qDebug("nothing selected"); + return; + } + qint64 custid=cst.customerID(); + //request data and display + //TODO: unify this part with updateOrders + ordermodel->clear(); + ordermodel->setHorizontalHeaderLabels(QStringList()< orders=req->getAllOrders(); + if(orders.size()==0)return; + QList cust=req->getAllCustomers(); + int cl=0; + for(int i=0;iinsertRow(cl); + ordermodel->setHeaderData(cl,Qt::Vertical,orders[i].orderID()); + ordermodel->setData(ordermodel->index(cl,0),orders[i].orderStatusString()); + ordermodel->setData(ordermodel->index(cl,0),orders[i].orderID(),Qt::UserRole); + ordermodel->setData(ordermodel->index(cl,1),orders[i].totalPriceString()); + ordermodel->setData(ordermodel->index(cl,2),orders[i].amountPaidString()); + ordermodel->setData(ordermodel->index(cl,3),cst.name()); + //count up + cl++; + } + ordermode->setCurrentIndex(ordermode->count()-1); } void MOverview::uploadTemplate() diff --git a/src/overview.h b/src/overview.h index cb6ee5e..2a747a6 100644 --- a/src/overview.h +++ b/src/overview.h @@ -126,6 +126,8 @@ class MOverview:public QMainWindow void orderByTicket(); /**find/select orders by event*/ void orderByEvent(); + /**find/select orders by customer*/ + void orderByCustomer(); private: //my session object