From 96949b35c4bcfa696ca38f650f74d23b0e0a812b Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Thu, 5 Jan 2012 13:50:59 +0100 Subject: [PATCH] user auditing --- pack | 2 +- src/dialogs/orderauditdlg.cpp | 325 +++++++++++++++++++++++++++++++++++++++++ src/dialogs/orderauditdlg.h | 25 +++ src/dialogs/orderwin.cpp | 114 +-------------- src/mwin/overview.cpp | 104 ++++++++++++- src/mwin/overview.h | 9 + wob/classes/order.wolf | 25 +++ wob/magicsmoke.wolf | 1 + wob/transact/audit.wolf | 62 ++++++++ wob/transact/order.wolf | 38 +----- www/inc/wext/autoload.php | 1 + www/inc/wext/order.php | 23 +++ www/inc/wext/ticket.php | 11 ++ 13 files changed, 585 insertions(+), 155 deletions(-) create mode 100644 wob/transact/audit.wolf diff --git a/pack b/pack index 6a565ed..f2a3ae9 160000 --- a/pack +++ b/pack @@ -1 +1 @@ -Subproject commit 6a565edd00675310f956428a83791b8ba3f16a7b +Subproject commit f2a3ae94fd26f7789ccfd33036512f513ba0c32a diff --git a/src/dialogs/orderauditdlg.cpp b/src/dialogs/orderauditdlg.cpp index 72a96fc..78a17b8 100644 --- a/src/dialogs/orderauditdlg.cpp +++ b/src/dialogs/orderauditdlg.cpp @@ -11,10 +11,13 @@ // #include "orderauditdlg_p.h" +#include "orderwin.h" #include "formula.h" #include "main.h" +#include "msinterface.h" + #include #include #include @@ -22,9 +25,13 @@ #include #include #include +#include +#include #include #include +#include #include +#include class MOAAuditList:public QList @@ -89,6 +96,20 @@ protected: }; DEFINE_DPTR(MOrderAuditDialog); +void MOrderAuditDialog::openOrderAuditDialog(qint64 oid,QWidget*parent) +{ + MTGetOrderAudit oa=req->queryGetOrderAudit(oid); +// qDebug()<<"order lines"<queryGetTicketAudit(id); + if(va.getticket().size()==0){ + QMessageBox::warning(parent,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 MOrderAuditDialog::openVoucherAuditDialog(QString id,QWidget*parent) +{ + //get data + MTGetVoucherAudit va=req->queryGetVoucherAudit(id); + if(va.getvoucher().size()==0){ + QMessageBox::warning(parent,tr("No Data"),tr("No audit data found for this voucher.")); + return; + } + //display construction + QListvlist=va.getvoucher(); + qDebug()<<"got # vouchers:"<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() + <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 MOrderAuditDialog::openUserAuditDialog(QString uid, qint64 oldest, QWidget* parent) +{ + MTGetUserAudit gua=req->queryGetUserAudit(uid,oldest); + if(gua.hasError()){ + QMessageBox::warning(parent,tr("Warning"),tr("Unable to get user audit data: %1").arg(gua.errorString())); + return; + } + MUserAuditDialog(gua,parent).exec(); +} + +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +class DPTR_CLASS_NAME(MUserAuditDialog) +{ +protected: + friend class MUserAuditDialog; + QTableView*morder,*mtick,*mvouch; + QStandardItemModel*mmorder,*mmtick,*mmvouch; +}; +DEFINE_DPTR(MUserAuditDialog); + + +MUserAuditDialog::MUserAuditDialog(const MTGetUserAudit& gua, QWidget* parent, Qt::WindowFlags f) + : QDialog(parent, f) +{ + setWindowTitle(tr("User Audit: %1").arg(gua.getuname())); + setSizeGripEnabled(true); + resize(800,600); + QVBoxLayout*vl; + setLayout(vl=new QVBoxLayout); + QTabWidget*tab; + vl->addWidget(tab=new QTabWidget,1); + vl->addSpacing(15); + QHBoxLayout*hl; + vl->addLayout(hl=new QHBoxLayout); + hl->addStretch(1); + QPushButton*p; + hl->addWidget(p=new QPushButton(tr("Close"))); + connect(p,SIGNAL(clicked()),this,SLOT(accept())); + + //order tab + QWidget*w; + tab->addTab(w=new QWidget,tr("Orders")); + w->setLayout(hl=new QHBoxLayout); + hl->addWidget(d->morder=new QTableView); + d->morder->setModel(d->mmorder=new QStandardItemModel(this)); + d->morder->setEditTriggers(QAbstractItemView::NoEditTriggers); + QList ords=gua.getorders(); + d->mmorder->insertColumns(0,3); + d->mmorder->setHorizontalHeaderLabels(QStringList()<mmorder->insertRows(0,ords.size()); + for(int i=0;immorder->setData(d->mmorder->index(i,0),ords[i].orderid().value()); + d->mmorder->setData(d->mmorder->index(i,1),ords[i].audittransaction().value()); + d->mmorder->setData(d->mmorder->index(i,2),unix2dateTime(ords[i].audittime())); + } + d->morder->resizeColumnsToContents(); + d->morder->verticalHeader()->hide(); + hl->addLayout(vl=new QVBoxLayout); + vl->addWidget(p=new QPushButton(tr("Show Order"))); + connect(p,SIGNAL(clicked()),this,SLOT(showorder())); + vl->addWidget(p=new QPushButton(tr("Audit Order"))); + connect(p,SIGNAL(clicked()),this,SLOT(auditorder())); + vl->addStretch(1); + + //ticket tab + tab->addTab(w=new QWidget,tr("Tickets")); + w->setLayout(hl=new QHBoxLayout); + hl->addWidget(d->mtick=new QTableView); + d->mtick->setModel(d->mmtick=new QStandardItemModel(this)); + d->mtick->setEditTriggers(QAbstractItemView::NoEditTriggers); + QList ticks=gua.gettickets(); + d->mmtick->insertColumns(0,4); + d->mmtick->setHorizontalHeaderLabels(QStringList()<mmtick->insertRows(0,ticks.size()); + for(int i=0;immtick->setData(d->mmtick->index(i,0),ticks[i].orderid().value()); + d->mmtick->setData(d->mmtick->index(i,1),ticks[i].ticketid().value()); + d->mmtick->setData(d->mmtick->index(i,2),ticks[i].audittransaction().value()); + d->mmtick->setData(d->mmtick->index(i,3),unix2dateTime(ticks[i].audittime())); + } + d->mtick->resizeColumnsToContents(); + d->mtick->verticalHeader()->hide(); + hl->addLayout(vl=new QVBoxLayout); + vl->addWidget(p=new QPushButton(tr("Show Order"))); + connect(p,SIGNAL(clicked()),this,SLOT(showorderbyticket())); + vl->addWidget(p=new QPushButton(tr("Audit Order"))); + connect(p,SIGNAL(clicked()),this,SLOT(auditorderbyticket())); + vl->addSpacing(10); + vl->addWidget(p=new QPushButton(tr("Audit Ticket"))); + connect(p,SIGNAL(clicked()),this,SLOT(auditticket())); + vl->addStretch(1); + + //voucher tab + tab->addTab(w=new QWidget,tr("Vouchers")); + w->setLayout(hl=new QHBoxLayout); + hl->addWidget(d->mvouch=new QTableView); + d->mvouch->setModel(d->mmvouch=new QStandardItemModel(this)); + d->mvouch->setEditTriggers(QAbstractItemView::NoEditTriggers); + QList vous=gua.getvouchers(); + d->mmvouch->insertColumns(0,4); + d->mmvouch->setHorizontalHeaderLabels(QStringList()<mmvouch->insertRows(0,vous.size()); + for(int i=0;immvouch->setData(d->mmvouch->index(i,0),vous[i].orderid().value()); + d->mmvouch->setData(d->mmvouch->index(i,1),vous[i].voucherid().value()); + d->mmvouch->setData(d->mmvouch->index(i,2),vous[i].audittransaction().value()); + d->mmvouch->setData(d->mmvouch->index(i,3),unix2dateTime(vous[i].audittime())); + } + d->mvouch->resizeColumnsToContents(); + d->mvouch->verticalHeader()->hide(); + hl->addLayout(vl=new QVBoxLayout); + vl->addWidget(p=new QPushButton(tr("Show Order"))); + connect(p,SIGNAL(clicked()),this,SLOT(showorderbyvoucher())); + vl->addWidget(p=new QPushButton(tr("Audit Order"))); + connect(p,SIGNAL(clicked()),this,SLOT(auditorderbyvoucher())); + vl->addSpacing(10); + vl->addWidget(p=new QPushButton(tr("Audit Voucher"))); + connect(p,SIGNAL(clicked()),this,SLOT(auditvoucher())); + vl->addStretch(1); + + //TODO: item tab +} + +void MUserAuditDialog::showorder(qint64 oid) +{ + if(oid<0){ + QModelIndex idx=d->morder->currentIndex(); + if(!idx.isValid())return; + oid=d->mmorder->data(d->mmorder->index(idx.row(),0)).toLongLong(); + } + //get it + MTGetOrder go=req->queryGetOrder(oid); + if(go.hasError()){ + QMessageBox::warning(this,tr("Warning"),tr("Unable to retrieve order: %1").arg(go.errorString())); + return; + } + //show it + MOrderWindow *ow=new MOrderWindow(this,go.getorder()); + ow->show(); +} + +void MUserAuditDialog::auditorder(qint64 oid) +{ + if(oid<0){ + QModelIndex idx=d->morder->currentIndex(); + if(!idx.isValid())return; + oid=d->mmorder->data(d->mmorder->index(idx.row(),0)).toLongLong(); + } + //get it + MOrderAuditDialog::openOrderAuditDialog(oid,this); +} + +void MUserAuditDialog::showorderbyticket() +{ + QModelIndex idx=d->mtick->currentIndex(); + if(!idx.isValid())return; + showorder(d->mmtick->data(d->mmtick->index(idx.row(),0)).toLongLong()); +} + +void MUserAuditDialog::auditorderbyticket() +{ + QModelIndex idx=d->mtick->currentIndex(); + if(!idx.isValid())return; + auditorder(d->mmtick->data(d->mmtick->index(idx.row(),0)).toLongLong()); +} + +void MUserAuditDialog::showorderbyvoucher() +{ + QModelIndex idx=d->mvouch->currentIndex(); + if(!idx.isValid())return; + showorder(d->mmvouch->data(d->mmvouch->index(idx.row(),0)).toLongLong()); +} + +void MUserAuditDialog::auditorderbyvoucher() +{ + QModelIndex idx=d->mvouch->currentIndex(); + if(!idx.isValid())return; + auditorder(d->mmvouch->data(d->mmvouch->index(idx.row(),0)).toLongLong()); +} + +void MUserAuditDialog::auditvoucher() +{ + QModelIndex idx=d->mvouch->currentIndex(); + if(!idx.isValid())return; + MOrderAuditDialog::openVoucherAuditDialog(d->mmvouch->data(d->mmvouch->index(idx.row(),1)).toString(),this); +} + +void MUserAuditDialog::auditticket() +{ + QModelIndex idx=d->mtick->currentIndex(); + if(!idx.isValid())return; + MOrderAuditDialog::openTicketAuditDialog(d->mmtick->data(d->mmtick->index(idx.row(),1)).toString(),this); +} diff --git a/src/dialogs/orderauditdlg.h b/src/dialogs/orderauditdlg.h index edbb942..2bf890f 100644 --- a/src/dialogs/orderauditdlg.h +++ b/src/dialogs/orderauditdlg.h @@ -24,10 +24,35 @@ class MOrderAuditDialog:public QDialog public: MOrderAuditDialog(MTGetOrderAudit&audit,QWidget*parent=0); virtual ~MOrderAuditDialog(); + + static void openOrderAuditDialog(qint64,QWidget*parent=0); + + static void openVoucherAuditDialog(QString,QWidget*parent=0); + static void openTicketAuditDialog(QString,QWidget*parent=0); + + static void openUserAuditDialog(QString,qint64,QWidget*parent=0); private slots: void getProfiles(); void calcPrices(); void drawdata(); }; +class MTGetUserAudit; +class MUserAuditDialog:public QDialog +{ + Q_OBJECT + DECLARE_DPTR(d); + public: + MUserAuditDialog(const MTGetUserAudit&,QWidget* parent = 0, Qt::WindowFlags f = 0); + private slots: + void showorder(qint64 oid=-1); + void showorderbyticket(); + void showorderbyvoucher(); + void auditorder(qint64 oid=-1); + void auditorderbyticket(); + void auditorderbyvoucher(); + void auditvoucher(); + void auditticket(); +}; + #endif diff --git a/src/dialogs/orderwin.cpp b/src/dialogs/orderwin.cpp index 1953906..5c57eb8 100644 --- a/src/dialogs/orderwin.cpp +++ b/src/dialogs/orderwin.cpp @@ -1091,54 +1091,7 @@ void MOrderWindow::voucherAudit() QMessageBox::warning(this,tr("Warning"),tr("The selected item is not a voucher.")); return; } - //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 - QListvlist=va.getvoucher(); - qDebug()<<"got # vouchers:"<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() - <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(); + MOrderAuditDialog::openVoucherAuditDialog(id); } void MOrderWindow::ticketAudit() @@ -1153,73 +1106,12 @@ void MOrderWindow::ticketAudit() 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(); + MOrderAuditDialog::openTicketAuditDialog(id); } void MOrderWindow::orderAudit() { - MTGetOrderAudit oa=req->queryGetOrderAudit(m_order.orderid()); -// qDebug()<<"order lines"< #include #include +#include +#include MOverview::MOverview(QString pk) :MTabWin(pk) @@ -95,9 +98,11 @@ MOverview::MOverview(QString pk) ->setEnabled(req->hasRight(req->RDeductVoucher)); m2->addAction(tr("&Empty voucher..."),this,SLOT(emptyVoucher())) ->setEnabled(req->hasRight(req->REmptyVoucher)); - m->addAction(tr("&Edit Shipping Options..."),this,SLOT(editShipping())) + + m2=m->addMenu(tr("&Options")); + m2->addAction(tr("Edit &Shipping Options..."),this,SLOT(editShipping())) ->setEnabled(req->hasRight(req->RGetAllShipping)); - m->addAction(tr("Edit &Payment Options..."),this,SLOT(editPayment())) + m2->addAction(tr("Edit &Payment Options..."),this,SLOT(editPayment())) ->setEnabled(req->hasRight(req->RGetPaymentTypes)); m2=m->addMenu(tr("&Templates")); @@ -106,10 +111,11 @@ MOverview::MOverview(QString pk) m2->addAction(tr("&Update Templates Now"),req,SLOT(updateTemplates())) ->setEnabled(req->hasRight(req->RGetTemplateList)); - m2=m->addMenu(tr("&Configuration")); - m2->addAction(tr("&Auto-Refresh settings..."),this,SLOT(setRefresh())); - m2->addAction(tr("&Server Access settings..."),this,SLOT(webSettings())); - m2->addAction(tr("&Display settings..."),this,SLOT(displaySettings())); + m2=m->addMenu(tr("A&udit")); + m2->addAction(tr("&Order Audit..."),this,SLOT(orderAudit())); + m2->addAction(tr("&Ticket Audit..."),this,SLOT(ticketAudit())); + m2->addAction(tr("&Voucher Audit..."),this,SLOT(voucherAudit())); + m2->addAction(tr("&User Audit..."),this,SLOT(userAudit())); m2=m->addMenu(tr("&Administration")); m2->addAction(tr("&User Administration..."),this,SLOT(aclWindow())) @@ -120,6 +126,11 @@ MOverview::MOverview(QString pk) m2->addAction(tr("&Backup now..."),this,SLOT(doBackup())) ->setEnabled(req->hasRight(req->RBackup)); + m2=m->addMenu(tr("&Configuration")); + m2->addAction(tr("&Auto-Refresh settings..."),this,SLOT(setRefresh())); + m2->addAction(tr("&Server Access settings..."),this,SLOT(webSettings())); + m2->addAction(tr("&Display settings..."),this,SLOT(displaySettings())); + //make sure webrequest knows its settings webSettings(false); @@ -589,3 +600,84 @@ void MOverview::wizardMode() wiz.exec(); show(); } + +void MOverview::orderAudit() +{ + //get order ID + bool ok; + qint64 oid=QInputDialog::getInt(this, tr("Order ID"), tr("Please enter the ID of the order you want to audit:"), 0, 0, 2147483647, 1, &ok); + if(!ok)return; + //open dialog + MOrderAuditDialog::openOrderAuditDialog(oid); +} + +void MOverview::ticketAudit() +{ + //get ticket ID + bool ok; + QString id=QInputDialog::getText ( this, tr("Ticket ID"), tr("Please enter the ID of the ticket you want to audit:"),QLineEdit::Normal, QString(), &ok); + if(!ok || id.isEmpty())return; + //open dialog + MOrderAuditDialog::openTicketAuditDialog(id); +} + +void MOverview::voucherAudit() +{ + //get voicher ID + bool ok; + QString id=QInputDialog::getText ( this, tr("Voucher ID"), tr("Please enter the ID of the voucher you want to audit:"),QLineEdit::Normal, QString(), &ok); + if(!ok || id.isEmpty())return; + //open dialog + MOrderAuditDialog::openVoucherAuditDialog(id); +} + +void MOverview::userAudit() +{ + QString uid; + QStringList names; + //can we query the users? + if(req->hasRight(req->RGetAllUsers)){ + MTGetAllUsers gau=req->queryGetAllUsers(); + if(!gau.hasError()){ + QListul=gau.getusers(); + foreach(MOUser u,ul)names<0){ + fl->addRow(tr("User Name:","audit dialog"),ucombo=new QComboBox); + ucombo->addItems(names); + }else{ + fl->addRow(tr("User Name:","audit dialog"),uline=new QLineEdit); + uline->setText(req->currentUser()); + } + QDateEdit *oldest; + fl->addRow(tr("Earliest Info","audit dialog"),oldest=new QDateEdit); + oldest->setDate(QDate::currentDate()); + oldest->setMaximumDate(QDate::currentDate()); + oldest->setCalendarPopup(true); + fl->addRow(new QLabel(" ")); + QHBoxLayout*hl; + fl->addRow(hl=new QHBoxLayout); + hl->addStretch(1); + QPushButton*p; + hl->addWidget(p=new QPushButton("Ok")); + connect(p,SIGNAL(clicked()),&d,SLOT(accept())); + hl->addWidget(p=new QPushButton("Cancel")); + connect(p,SIGNAL(clicked()),&d,SLOT(reject())); + if(d.exec()!=QDialog::Accepted)return; + if(uline)uid=uline->text(); + if(ucombo)uid=ucombo->currentText(); + if(uid.isEmpty()){ + QMessageBox::warning(this,tr("Warning"),tr("Cannot query an empty user name.","audit dialog")); + return; + } + //audit + MOrderAuditDialog::openUserAuditDialog(uid,oldest->dateTime().toTime_t(),this); +} diff --git a/src/mwin/overview.h b/src/mwin/overview.h index cfa13d0..7b6c623 100644 --- a/src/mwin/overview.h +++ b/src/mwin/overview.h @@ -77,6 +77,15 @@ class MOverview:public MTabWin ///\internal run init scripts void runStartupScript(); + ///start order audit + void orderAudit(); + ///ticket audit + void ticketAudit(); + ///voucher audit + void voucherAudit(); + ///user audit + void userAudit(); + public slots: /**manage customers*/ void customerMgmt(); diff --git a/wob/classes/order.wolf b/wob/classes/order.wolf index f4b36a6..340cd76 100644 --- a/wob/classes/order.wolf +++ b/wob/classes/order.wolf @@ -52,9 +52,12 @@ + + + @@ -65,6 +68,9 @@ + + + @@ -141,6 +147,25 @@ + + + + + + + + + + + + + + + + + + + This class represents an order in its entirety, including any items sold in it. diff --git a/wob/magicsmoke.wolf b/wob/magicsmoke.wolf index 0e16043..5728acb 100644 --- a/wob/magicsmoke.wolf +++ b/wob/magicsmoke.wolf @@ -46,6 +46,7 @@ + diff --git a/wob/transact/audit.wolf b/wob/transact/audit.wolf new file mode 100644 index 0000000..551974c --- /dev/null +++ b/wob/transact/audit.wolf @@ -0,0 +1,62 @@ + + + + + returns all audit data for a ticket (when it was bought, changed prices, when it was used) + + + + + + + + + + + + returns all audit data for a voucher (when it was bought, when it was used and for what) + + + + + + + + + + + returns all audit data for an order (when it was created, who handled it, when it was paid and how, ... + + + + + + + + + + + + + + returns all order related data the user has touched + + + + + + + + + + + + + + \ No newline at end of file diff --git a/wob/transact/order.wolf b/wob/transact/order.wolf index 21f1232..2bceab6 100644 --- a/wob/transact/order.wolf +++ b/wob/transact/order.wolf @@ -2,7 +2,7 @@ @@ -18,18 +18,6 @@ - - returns all audit data for a ticket (when it was bought, changed prices, when it was used) - - - - - - - - - - returns a specific voucher with detailed info @@ -41,30 +29,6 @@ - - returns all audit data for a voucher (when it was bought, when it was used and for what) - - - - - - - - - - - returns all audit data for an order (when it was created, who handled it, when it was paid and how, ... - - - - - - - - - - - get details for an order by its ID diff --git a/www/inc/wext/autoload.php b/www/inc/wext/autoload.php index acb2bbb..a343947 100644 --- a/www/inc/wext/autoload.php +++ b/www/inc/wext/autoload.php @@ -19,6 +19,7 @@ wob_autoclass("WOServerFormat","inc/wext/format.php"); wob_autoclass("WOShipping","inc/wext/shipping.php"); wob_autoclass("WOTemplate","inc/wext/template.php"); wob_autoclass("WOTicket","inc/wext/ticket.php"); +wob_autoclass("WOTicketAudit","inc/wext/ticket.php"); wob_autoclass("WOVoucher","inc/wext/voucher.php"); wob_autoclass("WOWebCart","inc/wext/webcart.php"); wob_autoclass("WOWebSession","inc/wext/websession.php"); diff --git a/www/inc/wext/order.php b/www/inc/wext/order.php index e20881c..338fd72 100644 --- a/www/inc/wext/order.php +++ b/www/inc/wext/order.php @@ -915,6 +915,29 @@ class WOOrder extends WOOrderAbstract $db->setConfig("defaultpaytype",$dpt); $trans->setdefaultpaytype(WOPaymentType::fromTablepaymenttype($pt)); } + + static public function getUserAuditTransaction($trans) + { + //check user exists + $uname=$trans->getuname(); + $oldest=$trans->getoldest(); + $user=WTuser::getFromDB($uname); + if(!is_a($user,"WTuser")){ + $trans->abortWithError(tr("User does not exist.")); + return; + } + //remember user name + $trans->setuname($uname); + //get order pieces that match + global $db; + $trans->setorders(WOOrderAudit::fromTableArrayorder_audit(WTorder_audit::selectFromDB("audituname=".$db->escapeString($uname)." AND audittime>=".$db->escapeInt($oldest),"ORDER BY auditid"))); + //get tickets + $trans->settickets(WOTicketAudit::fromTableArrayticket_audit(WTticket_audit::selectFromDB("audituname=".$db->escapeString($uname)." AND audittime>=".$db->escapeInt($oldest),"ORDER BY auditid"))); + //get vouchers + $trans->setvouchers(WOVoucherAudit::fromTableArrayvoucher_audit(WTvoucher_audit::selectFromDB("audituname=".$db->escapeString($uname)." AND audittime>=".$db->escapeInt($oldest),"ORDER BY auditid"))); + //get items + $trans->setitems(WOItemAudit::fromTableArrayitem_audit(WTitem_audit::selectFromDB("audituname=".$db->escapeString($uname)." AND audittime>=".$db->escapeInt($oldest),"ORDER BY auditid"))); + } }; ?> \ No newline at end of file diff --git a/www/inc/wext/ticket.php b/www/inc/wext/ticket.php index a775df3..8c972c6 100644 --- a/www/inc/wext/ticket.php +++ b/www/inc/wext/ticket.php @@ -100,4 +100,15 @@ class WOTicket extends WOTicketAbstract } }; +class WOTicketAudit extends WOTicketAuditAbstract +{ + //helper for DB mapper + protected function geteventnamefromdb() + { + $ev=WTevent::getFromDB($this->prop_eventid); + $this->prop_eventstart=$ev->starttime; + return $ev->title; + } +}; + ?> \ No newline at end of file -- 1.7.2.5