user auditing
authorKonrad Rosenbaum <konrad@silmor.de>
Thu, 5 Jan 2012 12:50:59 +0000 (13:50 +0100)
committerKonrad Rosenbaum <konrad@silmor.de>
Thu, 5 Jan 2012 12:50:59 +0000 (13:50 +0100)
13 files changed:
pack
src/dialogs/orderauditdlg.cpp
src/dialogs/orderauditdlg.h
src/dialogs/orderwin.cpp
src/mwin/overview.cpp
src/mwin/overview.h
wob/classes/order.wolf
wob/magicsmoke.wolf
wob/transact/audit.wolf [new file with mode: 0644]
wob/transact/order.wolf
www/inc/wext/autoload.php
www/inc/wext/order.php
www/inc/wext/ticket.php

diff --git a/pack b/pack
index 6a565ed..f2a3ae9 160000 (submodule)
--- a/pack
+++ b/pack
@@ -1 +1 @@
-Subproject commit 6a565edd00675310f956428a83791b8ba3f16a7b
+Subproject commit f2a3ae94fd26f7789ccfd33036512f513ba0c32a
index 72a96fc..78a17b8 100644 (file)
 //
 
 #include "orderauditdlg_p.h"
+#include "orderwin.h"
 
 #include "formula.h"
 #include "main.h"
 
+#include "msinterface.h"
+
 #include <DPtr>
 #include <QBoxLayout>
 #include <QComboBox>
 #include <QDomDocument>
 #include <QDomElement>
 #include <QFile>
+#include <QLabel>
+#include <QMessageBox>
 #include <QPushButton>
 #include <QStandardItemModel>
+#include <QTableView>
 #include <QTreeView>
+#include <QHeaderView>
 
 
 class MOAAuditList:public QList<MOAParcel>
@@ -89,6 +96,20 @@ protected:
 };
 DEFINE_DPTR(MOrderAuditDialog);
 
+void MOrderAuditDialog::openOrderAuditDialog(qint64 oid,QWidget*parent)
+{
+       MTGetOrderAudit oa=req->queryGetOrderAudit(oid);
+//     qDebug()<<"order lines"<<oa.getorder().size()<<"ticket lines"<<oa.gettickets().size()<<"voucher lines"<<oa.getvouchers().size();
+       if(oa.hasError()){
+               QMessageBox::warning(parent,tr("Warning"),tr("Error while retrieving audit data: %1").arg(oa.errorString()));
+               return;
+       }
+       if(oa.getorder().size()==0)
+               QMessageBox::warning(parent,tr("Warning"),tr("Sorry, no audit data available."));
+       else
+               MOrderAuditDialog(oa,parent).exec();
+}
+
 MOrderAuditDialog::MOrderAuditDialog(MTGetOrderAudit& audit, QWidget* parent)
        : QDialog(parent)
 {
@@ -249,3 +270,307 @@ void MOrderAuditDialog::getProfiles()
                qDebug()<<"loading backup config";
        }
 }
+
+void MOrderAuditDialog::openTicketAuditDialog(QString id,QWidget*parent)
+{
+       //get data
+       MTGetTicketAudit va=req->queryGetTicketAudit(id);
+       if(va.getticket().size()==0){
+               QMessageBox::warning(parent,tr("No Data"),tr("No audit data found for this ticket."));
+               return;
+       }
+       //display construction
+       QList<MOTicketAudit>tlist=va.getticket();
+       QList<MOEvent>elist=va.getevent();
+       qDebug()<<"got # tickets:"<<tlist.size();
+       QDialog d(parent);
+       d.setWindowTitle(tr("Ticket 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,tlist.size());
+//     model->insertColumns(0,5);
+       model->setHorizontalHeaderLabels(QStringList()
+               <<tr("Date/Time")
+               <<tr("User")
+               <<tr("Transaction")
+               <<tr("Price")
+               <<tr("Event Date")
+               <<tr("Event")
+               );
+       for(int i=0;i<tlist.size();i++){
+               int eid=tlist[i].eventid();
+               MOEvent ev;
+               foreach(MOEvent e,elist)
+                       if(e.eventid()==eid)ev=e;
+               model->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
+       QList<MOVoucherAudit>vlist=va.getvoucher();
+       qDebug()<<"got # vouchers:"<<vlist.size();
+       QDialog d(parent);
+       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 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<MOOrderAudit> ords=gua.getorders();
+       d->mmorder->insertColumns(0,3);
+       d->mmorder->setHorizontalHeaderLabels(QStringList()<<tr("Order ID")<<tr("Action")<<tr("Time"));
+       d->mmorder->insertRows(0,ords.size());
+       for(int i=0;i<ords.size();i++){
+               d->mmorder->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<MOTicketAudit> ticks=gua.gettickets();
+       d->mmtick->insertColumns(0,4);
+       d->mmtick->setHorizontalHeaderLabels(QStringList()<<tr("Order ID")<<tr("Ticket")<<tr("Action")<<tr("Time"));
+       d->mmtick->insertRows(0,ticks.size());
+       for(int i=0;i<ticks.size();i++){
+               d->mmtick->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<MOVoucherAudit> vous=gua.getvouchers();
+       d->mmvouch->insertColumns(0,4);
+       d->mmvouch->setHorizontalHeaderLabels(QStringList()<<tr("Order ID")<<tr("Voucher")<<tr("Action")<<tr("Time"));
+       d->mmvouch->insertRows(0,vous.size());
+       for(int i=0;i<vous.size();i++){
+               d->mmvouch->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);
+}
index edbb942..2bf890f 100644 (file)
@@ -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
index 1953906..5c57eb8 100644 (file)
@@ -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
-       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();
+       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
-       QList<MOTicketAudit>tlist=va.getticket();
-       QList<MOEvent>elist=va.getevent();
-       qDebug()<<"got # tickets:"<<tlist.size();
-       QDialog d(this);
-       d.setWindowTitle(tr("Ticket 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,tlist.size());
-//     model->insertColumns(0,5);
-       model->setHorizontalHeaderLabels(QStringList()
-               <<tr("Date/Time")
-               <<tr("User")
-               <<tr("Transaction")
-               <<tr("Price")
-               <<tr("Event Date")
-               <<tr("Event")
-               );
-       for(int i=0;i<tlist.size();i++){
-               int eid=tlist[i].eventid();
-               MOEvent ev;
-               foreach(MOEvent e,elist)
-                       if(e.eventid()==eid)ev=e;
-               model->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"<<oa.getorder().size()<<"ticket lines"<<oa.gettickets().size()<<"voucher lines"<<oa.getvouchers().size();
-       if(oa.hasError()){
-               QMessageBox::warning(this,tr("Warning"),tr("Error while retrieving audit data: %1").arg(oa.errorString()));
-               return;
-       }
-       if(oa.getorder().size()==0)
-               QMessageBox::warning(this,tr("Warning"),tr("Sorry, no audit data available."));
-       else
-               MOrderAuditDialog(oa,this).exec();
+       MOrderAuditDialog::openOrderAuditDialog(m_order.orderid());
 }
 
 
index 5781a49..4007e34 100644 (file)
@@ -19,6 +19,7 @@
 #include "wizard.h"
 #include "backupdlg.h"
 #include "payedit.h"
+#include "orderauditdlg.h"
 
 #include "aclwin.h"
 #include "carttab.h"
@@ -52,6 +53,8 @@
 #include <QSpinBox>
 #include <QStatusBar>
 #include <QTabWidget>
+#include <QFormLayout>
+#include <QDateTimeEdit>
 
 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()){
+                       QList<MOUser>ul=gau.getusers();
+                       foreach(MOUser u,ul)names<<u.name();
+               }else
+                       qDebug()<<"error while retrieving user names, will fall back to manual entering"<<gau.errorString();
+       }
+       //get user id
+       QDialog d(this);
+       d.setWindowTitle(tr("Audit User","audit dialog"));
+       QFormLayout *fl;
+       d.setLayout(fl=new QFormLayout);
+       QLineEdit*uline=0;QComboBox*ucombo=0;
+       if(names.size()>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);
+}
index cfa13d0..7b6c623 100644 (file)
@@ -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();
index f4b36a6..340cd76 100644 (file)
        </Class>
        
        <Class name="TicketAudit" base="Ticket">
+               <Abstract lang="php"/>
                <Property name="audittime" type="int64"/>
                <Property name="audituname" type="astring"/>
                <Property name="audittransaction" type="string"/>
+               <Property name="eventname" type="string"/>
+               <Property name="eventstart" type="int64"/>
                <Mapping table="ticket_audit">
                        <Map column="ticketid"/>
                        <Map column="price"/>
@@ -65,6 +68,9 @@
                        <Map property="pricecategory">
                                <Call lang="php" method="WOPriceCategory::fromTablepricecategory(WTpricecategory::getFromDB($table->pricecategoryid))"/>
                        </Map>
+                       <Map property="eventname">
+                               <Call lang="php" method="$data->geteventnamefromdb()"/>
+                       </Map>
                        <Map column="audittime"/>
                        <Map column="audituname"/>
                        <Map column="audittransaction"/>
                </Mapping>
        </Class>
        
+       <Class name="ItemAudit" base="ItemInfo">
+               <Property name="audittime" type="int64"/>
+               <Property name="audituname" type="astring"/>
+               <Property name="audittransaction" type="astring"/>
+               <Mapping table="item_audit">
+                       <Map cplumn="audittime"/>
+                       <Map column="audituname"/>
+                       <Map column="audittransaction"/>
+                       <Map column="itemid"/>
+                       <Map column="productid"/>
+                       <Map column="orderid"/>
+                       <Map column="amount"/>
+                       <Map column="totalprice"/>
+                       <Map property="productname">
+                               <Call lang="php" method="WTproduct::getFromDB($data->prop_productid)->name"/>
+                       </Map>
+               </Mapping>
+       </Class>
+       
        <Class name="Order" abstract="yes">
                <Doc>This class represents an order in its entirety, including any items sold in it.</Doc>
                <Enum name="OrderState" refColumn="order:status" />
index 0e16043..5728acb 100644 (file)
@@ -46,6 +46,7 @@
        <Include file="transact/customer.wolf"/>
        <Include file="transact/event.wolf"/>
        <Include file="transact/order.wolf"/>
+       <Include file="transact/audit.wolf"/>
        <Include file="transact/cart.wolf"/>
        <Include file="transact/template.wolf"/>
 </Wolf>
diff --git a/wob/transact/audit.wolf b/wob/transact/audit.wolf
new file mode 100644 (file)
index 0000000..551974c
--- /dev/null
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Order Audit MagicSmoke WOLF
+  - Tables and Comm Objects for Orders, Tickets, Vouchers, etc.
+  -
+  - (c) Konrad Rosenbaum, 2012
+  - this file is protected under the GNU AGPLv3 or at your option any newer
+  - see COPYING.AGPL for details
+  -->
+<Wolf>
+       <Transaction name="GetTicketAudit" updating="no">
+               <Doc>returns all audit data for a ticket (when it was bought, changed prices, when it was used)</Doc>
+               <Input>
+                       <Var name="ticketid" type="astring"/>
+               </Input>
+               <Call lang="php" method="WOTicket::GetTicketAuditTransaction($this);"/>
+               <Output>
+                       <Var name="ticket" type="List:TicketAudit"/>
+                       <Var name="event" type="List:Event"/>
+               </Output>
+       </Transaction>
+       
+       <Transaction name="GetVoucherAudit" updating="no">
+               <Doc>returns all audit data for a voucher (when it was bought, when it was used and for what)</Doc>
+               <Input>
+                       <Var name="voucherid" type="astring"/>
+               </Input>
+               <Call lang="php" method="WOVoucher::GetVoucherAuditTransaction($this);"/>
+               <Output>
+                       <Var name="voucher" type="List:VoucherAudit"/>
+               </Output>
+       </Transaction>
+       
+       <Transaction name="GetOrderAudit" updating="no">
+               <Doc>returns all audit data for an order (when it was created, who handled it, when it was paid and how, ...</Doc>
+               <Input>
+                       <Var name="orderid" type="int"/>
+               </Input>
+               <Call lang="php" method="WOOrder::getOrderAuditTransaction($this);"/>
+               <Output>
+                       <Var name="order" type="List:OrderAudit"/>
+                       <Var name="tickets" type="List:TicketAudit"/>
+                       <Var name="vouchers" type="List:VoucherAudit"/>
+               </Output>
+       </Transaction>
+       
+       
+       <Transaction name="GetUserAudit" updating="no">
+               <Doc>returns all order related data the user has touched</Doc>
+               <Input>
+                       <Var name="uname" type="astring"/>
+                       <Var name="oldest" type="int64"/>
+               </Input>
+               <Call lang="php" method="WOOrder::getUserAuditTransaction($this);"/>
+               <Output>
+                       <Var name="uname" type="astring"/>
+                       <Var name="orders" type="List:OrderAudit"/>
+                       <Var name="tickets" type="List:TicketAudit"/>
+                       <Var name="vouchers" type="List:VoucherAudit"/>
+                       <Var name="items" type="List:ItemAudit"/>
+               </Output>
+       </Transaction>
+</Wolf>
\ No newline at end of file
index 21f1232..2bceab6 100644 (file)
@@ -2,7 +2,7 @@
 <!-- Order MagicSmoke WOLF
   - Tables and Comm Objects for Orders, Tickets, Vouchers, etc.
   -
-  - (c) Konrad Rosenbaum, 2009-2011
+  - (c) Konrad Rosenbaum, 2009-2012
   - this file is protected under the GNU AGPLv3 or at your option any newer
   - see COPYING.AGPL for details
   -->
                </Output>
        </Transaction>
 
-       <Transaction name="GetTicketAudit" updating="no">
-               <Doc>returns all audit data for a ticket (when it was bought, changed prices, when it was used)</Doc>
-               <Input>
-                       <Var name="ticketid" type="astring"/>
-               </Input>
-               <Call lang="php" method="WOTicket::GetTicketAuditTransaction($this);"/>
-               <Output>
-                       <Var name="ticket" type="List:TicketAudit"/>
-                       <Var name="event" type="List:Event"/>
-               </Output>
-       </Transaction>
-       
        <Transaction name="GetVoucher" updating="no">
                <Doc>returns a specific voucher with detailed info</Doc>
                <Input>
                </Output>
        </Transaction>
        
-       <Transaction name="GetVoucherAudit" updating="no">
-               <Doc>returns all audit data for a voucher (when it was bought, when it was used and for what)</Doc>
-               <Input>
-                       <Var name="voucherid" type="astring"/>
-               </Input>
-               <Call lang="php" method="WOVoucher::GetVoucherAuditTransaction($this);"/>
-               <Output>
-                       <Var name="voucher" type="List:VoucherAudit"/>
-               </Output>
-       </Transaction>
-       
-       <Transaction name="GetOrderAudit" updating="no">
-               <Doc>returns all audit data for an order (when it was created, who handled it, when it was paid and how, ...</Doc>
-               <Input>
-                       <Var name="orderid" type="int"/>
-               </Input>
-               <Call lang="php" method="WOOrder::getOrderAuditTransaction($this);"/>
-               <Output>
-                       <Var name="order" type="List:OrderAudit"/>
-                       <Var name="tickets" type="List:TicketAudit"/>
-                       <Var name="vouchers" type="List:VoucherAudit"/>
-               </Output>
-       </Transaction>
-       
        <Transaction name="GetOrder" updating="no">
                <Doc>get details for an order by its ID</Doc>
                <Input>
index acb2bbb..a343947 100644 (file)
@@ -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");
index e20881c..338fd72 100644 (file)
@@ -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
index a775df3..8c972c6 100644 (file)
@@ -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