pieces of audit display
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sat, 25 Dec 2010 05:00:23 +0000 (05:00 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sat, 25 Dec 2010 05:00:23 +0000 (05:00 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@672 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

src/dialogs/orderwin.cpp
src/dialogs/orderwin.h
www/inc/wext/cart.php
www/inc/wext/order.php
www/inc/wext/voucher.php

index a935233..f273b4a 100644 (file)
@@ -119,6 +119,12 @@ MOrderWindow::MOrderWindow(QWidget*par,const MOOrder&o)
        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;
@@ -1022,6 +1028,73 @@ void MOrderWindow::changeShipping()
        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();
+}
+
 
 /*************************************************************************************/
 
index dd4881a..ef376b9 100644 (file)
@@ -91,6 +91,11 @@ class MOrderWindow:public QMainWindow
                /**create a new order from a reservation*/
                void createOrder();
                
+               ///retrieve audit data for a voucher
+               void voucherAudit();
+               ///retrieve order audit
+               void orderAudit();
+               
        private:
                MOOrder m_order;
                bool m_changed;
index 1c2de52..e1dbe2a 100644 (file)
@@ -25,6 +25,7 @@ class WOCartOrder extends WOCartOrderAbstract
                        $trans->abortWithError(tr("Not a valid cart object."));
                        return;
                }
+//             print_r($trans);
                //get permissions
                global $db;
                $isreserve=false;
index b3c653a..7cc905e 100644 (file)
@@ -689,6 +689,17 @@ class WOOrder extends WOOrderAbstract
                //return
                $trans->setvoucher(WOVoucher::fromTablevoucher($vou));
        }       
+       
+       ///order audit transaction
+       static public function getOrderAuditTransaction($trans)
+       {
+               global $db;
+               $oid=$trans->getorderid();
+               $w='orderid='.$db->escapeInt($oid);
+               $trans->setorder( WOOrderAudit::fromTableArrayorder_audit( WTorder_audit::selectFromDB($w)));
+               $trans->setvouchers( WOVoucherAudit::fromTableArrayvoucher_audit( WTvoucher_audit::selectFromDB($w)));
+               $trans->settickets( WOTicketAudit::fromTableArrayticket_audit( WTticket_audit::selectFromDB($w)));
+       }
 };
 
 ?>
\ No newline at end of file
index 6aecf5e..ddd1660 100644 (file)
@@ -10,6 +10,14 @@ class WOVoucher extends WOVoucherAbstract
                        return $inst->getcomment();
                else return null;
        }
+       
+       public static function GetVoucherAuditTransaction($trans)
+       {
+               global $db;
+               $tab=WTvoucher_audit::selectFromDB('voucherid='.$db->escapeString($trans->getvoucherid()));
+               $arr=WOVoucherAudit::fromTableArrayvoucher_audit($tab);
+               $trans->setvoucher($arr);
+       }
 };
 
 ?>
\ No newline at end of file