From b6cd4d246a9dd405fa915bd848bfb3da68dd1c4a Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Thu, 29 Dec 2011 14:22:03 +0100 Subject: [PATCH] add ticket audit --- src/dialogs/orderwin.cpp | 70 ++++++++++++++++++++++++++++++++++++++++++++++ src/dialogs/orderwin.h | 2 + wob/db/user.wolf | 1 + wob/transact/order.wolf | 13 ++++++++ www/inc/wext/ticket.php | 16 ++++++++++ 5 files changed, 102 insertions(+), 0 deletions(-) diff --git a/src/dialogs/orderwin.cpp b/src/dialogs/orderwin.cpp index 347e61e..d9cd83e 100644 --- a/src/dialogs/orderwin.cpp +++ b/src/dialogs/orderwin.cpp @@ -129,6 +129,8 @@ MOrderWindow::MOrderWindow(QWidget*par,const MOOrder&o) m=mb->addMenu(tr("&Audit")); m->addAction(tr("Voucher History..."),this,SLOT(voucherAudit())) ->setEnabled(req->hasRight(req->RGetVoucherAudit)); + m->addAction(tr("Ticket History..."),this,SLOT(ticketAudit())) + ->setEnabled(req->hasRight(req->RGetTicketAudit)); m->addAction(tr("Order History..."),this,SLOT(orderAudit())) ->setEnabled(req->hasRight(req->RGetOrderAudit)); @@ -1077,6 +1079,7 @@ void MOrderWindow::voucherAudit() 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.")); + return; } //get data MTGetVoucherAudit va=req->queryGetVoucherAudit(id); @@ -1128,6 +1131,73 @@ void MOrderWindow::voucherAudit() d.exec(); } +void MOrderWindow::ticketAudit() +{ + 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_TICKET){ + QMessageBox::warning(this,tr("Warning"),tr("The selected item is not a ticket.")); + return; + } + //get data + MTGetTicketAudit va=req->queryGetTicketAudit(id); + if(va.getticket().size()==0){ + QMessageBox::warning(this,tr("No Data"),tr("No audit data found for this ticket.")); + return; + } + //display construction + QListtlist=va.getticket(); + QListelist=va.getevent(); + qDebug()<<"got # tickets:"<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,tlist.size()); +// model->insertColumns(0,5); + model->setHorizontalHeaderLabels(QStringList() + <setData(model->index(i,0),unix2dateTime(tlist[i].audittime())); + model->setData(model->index(i,1),tlist[i].audituname().value()); + model->setData(model->index(i,2),tlist[i].audittransaction().value()); + model->setData(model->index(i,3),tlist[i].priceString()); + model->setData(model->index(i,4),unix2dateTime(ev.start())); + model->setData(model->index(i,5),ev.title().value()); + } + tab->resizeColumnsToContents(); + //show + d.exec(); +} + void MOrderWindow::orderAudit() { MTGetOrderAudit oa=req->queryGetOrderAudit(m_order.orderid()); diff --git a/src/dialogs/orderwin.h b/src/dialogs/orderwin.h index a8861bf..a6f65eb 100644 --- a/src/dialogs/orderwin.h +++ b/src/dialogs/orderwin.h @@ -99,6 +99,8 @@ class MOrderWindow:public QMainWindow ///retrieve audit data for a voucher void voucherAudit(); + ///retrieve audit data for a ticket + void ticketAudit(); ///retrieve order audit void orderAudit(); diff --git a/wob/db/user.wolf b/wob/db/user.wolf index be6e851..94e46fb 100644 --- a/wob/db/user.wolf +++ b/wob/db/user.wolf @@ -78,6 +78,7 @@ + diff --git a/wob/transact/order.wolf b/wob/transact/order.wolf index 0e401fb..4de0d10 100644 --- a/wob/transact/order.wolf +++ b/wob/transact/order.wolf @@ -17,6 +17,18 @@ + + + returns all audit data for a ticket (when it was bought, changed prices, when it was used) + + + + + + + + + returns a specific voucher with detailed info @@ -225,6 +237,7 @@ ID of the order that is to be paid for ID of the voucher that is to be used for payment + diff --git a/www/inc/wext/ticket.php b/www/inc/wext/ticket.php index f80a5d3..a775df3 100644 --- a/www/inc/wext/ticket.php +++ b/www/inc/wext/ticket.php @@ -82,6 +82,22 @@ class WOTicket extends WOTicketAbstract { return WOEvent::fromTableevent(WTevent::getFromDB($this->geteventid())); } + + ///GetTicketAudit transaction + public static function GetTicketAuditTransaction($trans) + { + global $db; + //get ticket data + $tab=WTticket_audit::selectFromDB('ticketid='.$db->escapeString($trans->getticketid())); + $arr=WOTicketAudit::fromTableArrayticket_audit($tab); + $trans->setticket($arr); + //get associated event(s) + $evl=array(); + foreach($tab as $t) + if(!in_array($t->eventid,$evl)) + $evl[]=$t->eventid; + $trans->setevent(WOEvent::fromTableArrayevent(WTevent::selectFromDB("eventid IN ".$db->escapeIntList($evl)))); + } }; ?> \ No newline at end of file -- 1.7.2.5