From e2f04dbfa609c17ae32269906a267b5c6c0faf41 Mon Sep 17 00:00:00 2001 From: konrad Date: Fri, 1 Jan 2010 15:46:28 +0000 Subject: [PATCH] print bills git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@387 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- src/dialogs/dialogs.pri | 2 - src/dialogs/moneylog.cpp | 54 ----------------- src/dialogs/moneylog.h | 27 --------- src/dialogs/orderwin.cpp | 147 +++++++++++++++++----------------------------- src/dialogs/orderwin.h | 5 -- src/mwin/overview.cpp | 18 ------ src/mwin/overview.h | 5 -- src/wext/MOOrder.cpp | 5 ++ src/wext/MOOrder.h | 3 + 9 files changed, 63 insertions(+), 203 deletions(-) delete mode 100644 src/dialogs/moneylog.cpp delete mode 100644 src/dialogs/moneylog.h diff --git a/src/dialogs/dialogs.pri b/src/dialogs/dialogs.pri index 0e72244..d8208c7 100644 --- a/src/dialogs/dialogs.pri +++ b/src/dialogs/dialogs.pri @@ -3,7 +3,6 @@ HEADERS += \ dialogs/eventedit.h \ dialogs/eventsummary.h \ dialogs/orderwin.h \ - dialogs/moneylog.h \ dialogs/login.h \ dialogs/shipping.h \ dialogs/customerdlg.h \ @@ -15,7 +14,6 @@ SOURCES += \ dialogs/eventedit.cpp \ dialogs/eventsummary.cpp \ dialogs/orderwin.cpp \ - dialogs/moneylog.cpp \ dialogs/login.cpp \ dialogs/shipping.cpp \ dialogs/customerdlg.cpp \ diff --git a/src/dialogs/moneylog.cpp b/src/dialogs/moneylog.cpp deleted file mode 100644 index 98846a5..0000000 --- a/src/dialogs/moneylog.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// -// C++ Implementation: moneylog -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2008 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#include "moneylog.h" -#include "msinterface.h" -#include "misc.h" - -#include -#include -#include - -MMoneyLog::MMoneyLog(QWidget*pa,QString q) - :QDialog(pa) -{ - //set title - QStringList sl=q.split("\n"); - sl[0][0]=sl[0][0].toUpper(); - setWindowTitle(tr("Money Log of %1 %2").arg(sl[0]).arg(sl[1])); - - //layout - QVBoxLayout*vl; - QHBoxLayout*hl; - QTextEdit*text; - QPushButton*p; - setLayout(vl=new QVBoxLayout); - vl->addWidget(text=new QTextEdit,10); - text->setReadOnly(true); - vl->addSpacing(15); - vl->addLayout(hl=new QHBoxLayout,0); - hl->addStretch(10); - hl->addWidget(p=new QPushButton(tr("Close"))); - connect(p,SIGNAL(clicked()),this,SLOT(accept())); - - //query - /*TODO - if(req->request("moneylog",q.toAscii())){ - if(req->responseStatus()==MWebRequest::Ok){ - text->setPlainText(QString::fromUtf8(req->responseBody())); - }else{ - text->setHtml("

Error

"+htmlize(QString::fromUtf8(req->responseBody()))); - } - }else{ - text->setHtml("

Low Level Error

Request failed."); - }*/ -} \ No newline at end of file diff --git a/src/dialogs/moneylog.h b/src/dialogs/moneylog.h deleted file mode 100644 index fbdc415..0000000 --- a/src/dialogs/moneylog.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// C++ Interface: moneylog -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2008 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#ifndef MAGICSMOKE_MONEYLOG_H -#define MAGICSMOKE_MONEYLOG_H - -#include - - -class MMoneyLog:public QDialog -{ - Q_OBJECT - public: - MMoneyLog(QWidget*,QString); -}; - - -#endif diff --git a/src/dialogs/orderwin.cpp b/src/dialogs/orderwin.cpp index ba78dcf..6e6fdea 100644 --- a/src/dialogs/orderwin.cpp +++ b/src/dialogs/orderwin.cpp @@ -13,7 +13,6 @@ #include "centbox.h" #include "labeldlg.h" #include "misc.h" -#include "moneylog.h" #include "odtrender.h" #include "orderwin.h" #include "ticketrender.h" @@ -70,11 +69,6 @@ MOrderWindow::MOrderWindow(QWidget*par,const MOOrder&o) m->addAction(tr("Change Sh&ipping Method..."),this,SLOT(changeShipping())) ->setEnabled(req->hasRight(req->ROrderChangeShipping)); m->addSeparator(); - m->addAction(tr("MoneyLog for Order..."),this,SLOT(moneyLogOrder())) - ->setEnabled(req->hasRole("moneylog")); - m->addAction(tr("MoneyLog for selected Voucher..."),this,SLOT(moneyLogVoucher())) - ->setEnabled(req->hasRole("moneylog")); - m->addSeparator(); m->addAction(tr("&Close"),this,SLOT(close())); m=mb->addMenu(tr("&Payment")); @@ -405,19 +399,19 @@ void MOrderWindow::storePrinter(QPrinter&prn,QString key) } void MOrderWindow::printBill() -{/*TODO +{ //get template - MTemplate tf=req->getTemplate("bill"); + MTemplate tf=req->templateStore()->getTemplate("bill"); if(!tf.isValid()){ QMessageBox::warning(this,tr("Warning"),tr("Unable to get template file (bill). Giving up.")); return; } //mark order as shipped? - if(m_order.orderStatus()==MOrder::Placed) + if(m_order.status()==MOOrder::Placed) if(QMessageBox::question(this,tr("Mark as shipped?"),tr("Mark this order as shipped now?"),QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes)==QMessageBox::Yes){ - m_order.shipOrder(); - m_state->setText(m_order.orderStatusString()); - m_sentdate->setText(m_order.sentDateTimeStr()); + MTOrderMarkShipped ms=req->queryOrderMarkShipped(m_order.orderid(),-1); + if(!ms.hasError())m_order=ms.getorder(); + updateData(); } //print bill initPrintBuffer(); @@ -426,13 +420,13 @@ void MOrderWindow::printBill() connect(&rend,SIGNAL(getLoopIterations(QString,int&)),this,SLOT(getLoopIterations(QString,int&))); connect(&rend,SIGNAL(getLoopVariable(QString,int,QString,MOdtRenderer::VarType&,QVariant&)),this,SLOT(getLoopVariable(QString,int,QString,MOdtRenderer::VarType&,QVariant&))); rend.renderToPrinter(); - donePrintBuffer();*/ + donePrintBuffer(); } void MOrderWindow::saveBill() -{/*TODO +{ //get template - MTemplate tf=req->getTemplate("bill"); + MTemplate tf=req->templateStore()->getTemplate("bill"); if(!tf.isValid()){ QMessageBox::warning(this,tr("Warning"),tr("Unable to get template file (bill). Giving up.")); return; @@ -451,11 +445,11 @@ void MOrderWindow::saveBill() fname=fn[0]; } //mark order as shipped? - if(m_order.orderStatus()==MOrder::Placed) + if(m_order.status()==MOOrder::Placed) if(QMessageBox::question(this,tr("Mark as shipped?"),tr("Mark this order as shipped now?"),QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes)==QMessageBox::Yes){ - m_order.shipOrder(); - m_state->setText(m_order.orderStatusString()); - m_sentdate->setText(m_order.sentDateTimeStr()); + MTOrderMarkShipped ms=req->queryOrderMarkShipped(m_order.orderid(),-1); + if(!ms.hasError())m_order=ms.getorder(); + updateData(); } //render bill initPrintBuffer(); @@ -464,48 +458,44 @@ void MOrderWindow::saveBill() connect(&rend,SIGNAL(getLoopIterations(QString,int&)),this,SLOT(getLoopIterations(QString,int&))); connect(&rend,SIGNAL(getLoopVariable(QString,int,QString,MOdtRenderer::VarType&,QVariant&)),this,SLOT(getLoopVariable(QString,int,QString,MOdtRenderer::VarType&,QVariant&))); rend.renderToFile(fname); - donePrintBuffer();*/ + donePrintBuffer(); } void MOrderWindow::getVariable(QString vn,MOdtRenderer::VarType& av,QVariant&value) -{/*TODO +{ if(vn=="ORDERDATE"){ - value=m_order.orderDateTime().toTime_t(); + value=m_order.ordertime().value(); av=MOdtRenderer::DateVar; }else if(vn=="ORDERDATETIME"){ - value=m_order.orderDateTime().toTime_t(); + value=m_order.ordertime().value(); av=MOdtRenderer::DateTimeVar; }else if(vn=="SENTDATE"){ - value=m_order.sentDateTime().toTime_t(); + value=m_order.senttime().value(); av=MOdtRenderer::DateVar; }else if(vn=="SENTDATETIME"){ - value=m_order.sentDateTime().toTime_t(); + value=m_order.senttime().value(); av=MOdtRenderer::DateTimeVar; }else - if(vn=="CUSTOMERID")value=QString::number(m_order.customerID());else - if(vn=="ORDERID")value=QString::number(m_order.orderID());else - if(vn=="ADDRESS")value=m_order.customer().address();else - if(vn=="FULLADDRESS")value=m_order.customer().getNameAddress();else - if(vn=="NAME")value=m_order.customer().name();else - if(vn=="DELIVERYADDRESS")value=m_order.deliveryAddress();else - if(vn=="FINALADDRESS"){ - QString v=m_order.deliveryAddress(); - if(v.trimmed()=="")v=m_order.customer().getNameAddress(); - value=v; - }else + if(vn=="CUSTOMERID")value=QString::number(m_order.customerid());else + if(vn=="ORDERID")value=QString::number(m_order.orderid());else + if(vn=="ADDRESS")value=m_order.fullInvoiceAddress();else + if(vn=="FULLADDRESS")value=m_order.fullInvoiceAddress();else + if(vn=="NAME")value=m_order.customer().value().fullName();else + if(vn=="DELIVERYADDRESS")value=m_order.fullDeliveryAddress();else + if(vn=="FINALADDRESS")value=m_order.fullDeliveryAddress();else if(vn=="TOTALPRICE"){ - value=m_order.totalPrice(); + value=m_order.totalprice().value(); av=MOdtRenderer::MoneyVar; }else if(vn=="AMOUNTPAID"){ - value=m_order.amountPaid(); + value=m_order.amountpaid().value(); av=MOdtRenderer::MoneyVar; }else - if(vn=="SELLER")value=m_order.seller();else - if(vn=="COMMENT")value=m_order.comment();else + if(vn=="SELLER")value=m_order.soldby().value();else + if(vn=="COMMENT")value=m_order.comments().value();else if(vn=="AMOUNTTOPAY"){ value=m_order.amountToPay(); av=MOdtRenderer::MoneyVar; @@ -527,14 +517,14 @@ void MOrderWindow::getVariable(QString vn,MOdtRenderer::VarType& av,QVariant&val av=MOdtRenderer::IntVar; }else if(vn=="ADDRESSLINES"){ - value=m_order.customer().address().split("\n").size(); + value=m_order.fullInvoiceAddress().split("\n").size(); av=MOdtRenderer::IntVar; }else - if(vn=="SHIPPING")value=m_order.shipping().description();else + if(vn=="SHIPPING")value=m_order.shippingtype().value().description().value();else if(vn=="SHIPPINGPRICE"){ - value=m_order.shipping().price(); + value=m_order.shippingtype().value().cost().value(); av=MOdtRenderer::MoneyVar; - }*/ + } } void MOrderWindow::getLoopIterations(QString loopname,int&iterations) @@ -542,7 +532,7 @@ void MOrderWindow::getLoopIterations(QString loopname,int&iterations) if(loopname=="TICKETS")iterations=printBuffer.tickets.size(); if(loopname=="ACCTICKETS")iterations=printBuffer.tickinfo.size(); if(loopname=="VOUCHERS")iterations=printBuffer.vouchers.size(); -// if(loopname=="ADDRESSLINES")iterations=m_order.customer_().address().split("\n").size(); + if(loopname=="ADDRESSLINES")iterations=m_order.fullInvoiceAddress().split("\n").size(); } void MOrderWindow::getLoopVariable(QString loopname,int it,QString vn,MOdtRenderer::VarType& av,QVariant&value) { @@ -555,21 +545,21 @@ void MOrderWindow::getLoopVariable(QString loopname,int it,QString vn,MOdtRender av=MOdtRenderer::MoneyVar; }else if(vn=="ID")value=tickets[it].ticketid().value();else - if(vn=="TITLE");//value=tickets[it].event().title().value();else - if(vn=="ARTIST");//value=tickets[it].event().artist().value().name().value();else + if(vn=="TITLE")value=tickets[it].event().title().value();else + if(vn=="ARTIST")value=tickets[it].event().artist().value().name().value();else if(vn=="DATE"){ -// value=tickets[it].event().start().value(); + value=tickets[it].event().start().value(); av=MOdtRenderer::DateVar; }else if(vn=="STARTTIME"){ -// value=tickets[it].event().start().value(); + value=tickets[it].event().start().value(); av=MOdtRenderer::DateTimeVar; }else if(vn=="ENDTIME"){ -// value=tickets[it].event().end().value(); + value=tickets[it].event().end().value(); av=MOdtRenderer::DateTimeVar; }else - if(vn=="ROOM");//value=tickets[it].event().room().value(); + if(vn=="ROOM")value=tickets[it].event().room().value(); }else if(loopname=="ACCTICKETS"){ QList &tickets=printBuffer.tickinfo; if(it<0 || it>=tickets.size())return; @@ -582,21 +572,21 @@ void MOrderWindow::getLoopVariable(QString loopname,int it,QString vn,MOdtRender value=tickets[it].proto.price().value()*tickets[it].amount; av=MOdtRenderer::MoneyVar; }else - if(vn=="TITLE");//value=tickets[it].proto.event().title().value();else - if(vn=="ARTIST");//value=tickets[it].proto.event().artist().value().name().value();else + if(vn=="TITLE")value=tickets[it].proto.event().title().value();else + if(vn=="ARTIST")value=tickets[it].proto.event().artist().value().name().value();else if(vn=="DATE"){ -// value=tickets[it].proto.event().start().value(); + value=tickets[it].proto.event().start().value(); av=MOdtRenderer::DateVar; }else if(vn=="STARTTIME"){ -// value=tickets[it].proto.event().start().value(); + value=tickets[it].proto.event().start().value(); av=MOdtRenderer::DateTimeVar; }else if(vn=="ENDTIME"){ -// value=tickets[it].proto.event().end().value(); + value=tickets[it].proto.event().end().value(); av=MOdtRenderer::DateTimeVar; }else - if(vn=="ROOM");//value=tickets[it].proto.event().room().value();else + if(vn=="ROOM")value=tickets[it].proto.event().room().value();else if(vn=="AMOUNT"){ value=tickets[it].amount; av=MOdtRenderer::IntVar; @@ -614,7 +604,7 @@ void MOrderWindow::getLoopVariable(QString loopname,int it,QString vn,MOdtRender }else if(vn=="ID")value=printBuffer.vouchers[it].voucherid().value(); }else if(loopname=="ADDRESSLINES"){ - QStringList lst;//=m_order.customer_().address().split("\n"); + QStringList lst=m_order.fullInvoiceAddress().split("\n"); if(it<0 || it>=lst.size())return; value=lst[it]; }else @@ -636,17 +626,17 @@ static inline bool compare(const MOTicket&a,const MOTicket&b) } void MOrderWindow::initPrintBuffer() -{/*TODO: +{ //clear donePrintBuffer(); //get tickets (only valid ones) - QListtlst=m_order.tickets(); + QListtlst=m_order.tickets(); for(int i=0;ivlst=m_order.vouchers(); + QListvlst=m_order.vouchers(); for(int i=0;i0||vlst[i].value()>0) + printBuffer.vouchers.append(vlst[i]); } void MOrderWindow::payment() @@ -898,7 +888,6 @@ void MOrderWindow::changeComments() QVBoxLayout*vl; d.setLayout(vl=new QVBoxLayout); QTextEdit*te; - QLabel*lab; vl->addWidget(te=new QTextEdit,1); te->setPlainText(cmt); vl->addSpacing(15); @@ -976,32 +965,6 @@ void MOrderWindow::changeShipping() updateData(); } -void MOrderWindow::moneyLogOrder() -{ - if(m_order.orderid()<0)return; - MMoneyLog ml(this,"order\n"+QString::number(m_order.orderid())); - ml.exec(); -} - -void MOrderWindow::moneyLogVoucher() -{ - if(m_order.orderid()<0)return; - //get selection - if(!m_order.isValid())return; - //get ticket selection - 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){ - MMoneyLog ml(this,"voucher\n"+id); - ml.exec(); - }else - QMessageBox::warning(this,tr("Warning"),tr("This is not a voucher, cannot show the money log.")); -} - /*************************************************************************************/ diff --git a/src/dialogs/orderwin.h b/src/dialogs/orderwin.h index 91c724e..663281f 100644 --- a/src/dialogs/orderwin.h +++ b/src/dialogs/orderwin.h @@ -93,11 +93,6 @@ class MOrderWindow:public QMainWindow /**create a new order*/ void createOrder(Create mode=CreateOrder); - /**money log for the order*/ - void moneyLogOrder(); - /**money log for a voucher*/ - void moneyLogVoucher(); - private: MOOrder m_order; bool m_changed; diff --git a/src/mwin/overview.cpp b/src/mwin/overview.cpp index c979702..3eb19ae 100644 --- a/src/mwin/overview.cpp +++ b/src/mwin/overview.cpp @@ -11,7 +11,6 @@ // #include "main.h" -#include "moneylog.h" #include "msinterface.h" #include "passwdchg.h" @@ -118,9 +117,6 @@ MOverview::MOverview(QString pk) m->addAction(tr("Edit &Shipping Options..."),this,SLOT(editShipping())); m->addSeparator(); m->addAction(tr("&Deduct from voucher..."),this,SLOT(deductVoucher())); - m->addSeparator(); - m->addAction(tr("&Money Log for voucher..."),this,SLOT(moneylogVoucher())); - m->addAction(tr("Money Log for &user..."),this,SLOT(moneylogUser())); m=mb->addMenu(tr("C&onfigure")); m->addAction(tr("&Auto-Refresh settings..."),this,SLOT(setRefresh())); @@ -529,20 +525,6 @@ void MOverview::backupSettings() } } -void MOverview::moneylogVoucher() -{/*TODO - QString vid=QInputDialog::getText(this,tr("Voucher ID"),tr("Please enter voucher ID to show log:")); - if(vid!="") - MMoneyLog(this,req,"voucher\n"+vid).exec();*/ -} - -void MOverview::moneylogUser() -{/*TODO - QString vid=QInputDialog::getText(this,tr("User"),tr("Please enter login name of user to show log:")); - if(vid!="") - MMoneyLog(this,req,"user\n"+vid).exec();*/ -} - /**********************************************/ diff --git a/src/mwin/overview.h b/src/mwin/overview.h index f905efa..fe9db3b 100644 --- a/src/mwin/overview.h +++ b/src/mwin/overview.h @@ -76,11 +76,6 @@ class MOverview:public QMainWindow /**deduct some money from a voucher (to pay outside the system)*/ void deductVoucher(); - /**money log for voucher*/ - void moneylogVoucher(); - /**money log for user*/ - void moneylogUser(); - /**refresh data that we can refresh*/ void refreshData(); /**set refresh timeout*/ diff --git a/src/wext/MOOrder.cpp b/src/wext/MOOrder.cpp index 9f103a8..211f007 100644 --- a/src/wext/MOOrder.cpp +++ b/src/wext/MOOrder.cpp @@ -60,6 +60,11 @@ bool MOOrder::isSent()const return status()!=Placed; } +QDateTime MOOrder::orderDateTime() +{ + if(ordertime().value()==0)return QDateTime(); + return QDateTime::fromTime_t(ordertime()); +} QString MOOrder::orderDateTimeStr() { diff --git a/src/wext/MOOrder.h b/src/wext/MOOrder.h index f7d1b07..36dcca5 100644 --- a/src/wext/MOOrder.h +++ b/src/wext/MOOrder.h @@ -68,6 +68,9 @@ class MOOrder:public MOOrderAbstract /**returns how much there is to be refunded, as localized string*/ QString amountToRefundStr()const{return cent2str(amountToRefund());} + /**return the order date+time*/ + QDateTime orderDateTime(); + /**returns the order date+time as string*/ QString orderDateTimeStr(); -- 1.7.2.5