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));
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
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()<<tr("Status")<<tr("Total")<<tr("Paid")<<tr("Customer"));
+ QList<MOrder> orders=req->getAllOrders();
+ if(orders.size()==0)return;
+ QList<MCustomer> cust=req->getAllCustomers();
+ int cl=0;
+ for(int i=0;i<orders.size();i++){
+ //filter
+ if(orders[i].customerID()!=custid)continue;
+ //put into table
+ ordermodel->insertRow(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()