m->addAction(tr("Print &Current Item..."),this,SLOT(printCurrentItem()));
m->addAction(tr("&View Items..."),this,SLOT(itemView()));
+ m=mb->addMenu(tr("&Audit"));
+ m->addAction(tr("Voucher History..."),this,SLOT(voucherAudit()))
+ ->setEnabled(req->hasRight(req->RGetVoucherAudit));
+ m->addAction(tr("Order History..."),this,SLOT(orderAudit()))
+ ->setEnabled(req->hasRight(req->RGetOrderAudit));
+
QWidget*w;
setCentralWidget(w=new QWidget);
QVBoxLayout *vl;
updateData();
}
+void MOrderWindow::voucherAudit()
+{
+ QModelIndexList lst=m_table->selectionModel()->selectedIndexes();
+ if(lst.size()<1)return;
+ QModelIndex idx=m_model->index(lst[0].row(),0);
+ QString id=m_model->data(idx).toString();
+ if(id=="")return;
+ int type=m_model->data(idx,Qt::UserRole).toInt();
+ if(type!=ITEM_VOUCHER){
+ QMessageBox::warning(this,tr("Warning"),tr("The selected item is not a voucher."));
+ }
+ //get data
+ MTGetVoucherAudit va=req->queryGetVoucherAudit(id);
+ if(va.getvoucher().size()==0){
+ QMessageBox::warning(this,tr("No Data"),tr("No audit data found for this voucher."));
+ return;
+ }
+ //display construction
+ QList<MOVoucherAudit>vlist=va.getvoucher();
+ qDebug()<<"got # vouchers:"<<vlist.size();
+ QDialog d(this);
+ d.setWindowTitle(tr("Voucher Audit: %1").arg(id));
+ d.setSizeGripEnabled(true);
+ d.resize(800,600);
+ QHBoxLayout*hl;
+ QVBoxLayout*vl;
+ d.setLayout(vl=new QVBoxLayout);
+ QTableView*tab;
+ QStandardItemModel*model;
+ vl->addWidget(tab=new QTableView,1);
+ tab->setEditTriggers(QAbstractItemView::NoEditTriggers);
+ tab->setModel(model=new QStandardItemModel(tab));
+ vl->addLayout(hl=new QHBoxLayout);
+ hl->addStretch(1);
+ QPushButton*p;
+ hl->addWidget(p=new QPushButton(tr("Close")));
+ connect(p,SIGNAL(clicked()),&d,SLOT(accept()));
+ //enter data
+ model->insertRows(0,vlist.size());
+// model->insertColumns(0,5);
+ model->setHorizontalHeaderLabels(QStringList()
+ <<tr("Date/Time")
+ <<tr("User")
+ <<tr("Transaction")
+ <<tr("Value")
+ <<tr("Price")
+ <<tr("Comment")
+ );
+ for(int i=0;i<vlist.size();i++){
+ model->setData(model->index(i,0),unix2dateTime(vlist[i].audittime()));
+ model->setData(model->index(i,1),vlist[i].audituname().value());
+ model->setData(model->index(i,2),vlist[i].audittransaction().value());
+ model->setData(model->index(i,3),vlist[i].valueString());
+ model->setData(model->index(i,4),vlist[i].priceString());
+ model->setData(model->index(i,5),vlist[i].comment().value());
+ }
+ tab->resizeColumnsToContents();
+ //show
+ d.exec();
+}
+
+void MOrderWindow::orderAudit()
+{
+ MTGetOrderAudit oa=req->queryGetOrderAudit(m_order.orderid());
+ qDebug()<<"order lines"<<oa.getorder().size()<<"ticket lines"<<oa.gettickets().size()<<"voucher lines"<<oa.getvouchers().size();
+}
+
/*************************************************************************************/