From 61a7786494b0a91e14ae341cf41eea4395ae007b Mon Sep 17 00:00:00 2001 From: konrad Date: Fri, 14 May 2010 18:04:39 +0000 Subject: [PATCH] "big merge" - implemented empty voucher git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@451 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- src/mwin/overview.cpp | 16 ++++++++++++++++ src/mwin/overview.h | 2 ++ wob/order.wolf | 11 +++++++++++ www/inc/wext/order.php | 26 ++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 0 deletions(-) diff --git a/src/mwin/overview.cpp b/src/mwin/overview.cpp index 31967c5..8404d2a 100644 --- a/src/mwin/overview.cpp +++ b/src/mwin/overview.cpp @@ -117,6 +117,7 @@ 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->addAction(tr("&Empty voucher..."),this,SLOT(emptyVoucher())); m=mb->addMenu(tr("C&onfigure")); m->addAction(tr("&Auto-Refresh settings..."),this,SLOT(setRefresh())); @@ -266,6 +267,21 @@ void MOverview::deductVoucher() ); } +void MOverview::emptyVoucher() +{ + //get voucher ID + QString vid=QInputDialog::getText(this,tr("Invalidate Voucher"),tr("Please enter/scan the barcode of the voucher to invalidate/empty - the voucher will no longer be usable afterwards, but still has to be paid for.")); + if(vid=="")return; + //query server + MTEmptyVoucher dv=req->queryEmptyVoucher(vid); + if(dv.hasError()){ + QMessageBox::warning(this,tr("Warning"),tr("Unable to invalidate voucher: %1").arg(dv.errorString())); + return; + } + QMessageBox::information(this,tr("Invalidated Voucher"), + tr("The voucher '%1'has been invalidated.").arg(vid)); +} + void MOverview::refreshData() { QSettings set; diff --git a/src/mwin/overview.h b/src/mwin/overview.h index 8283e1c..63c2c13 100644 --- a/src/mwin/overview.h +++ b/src/mwin/overview.h @@ -71,6 +71,8 @@ class MOverview:public QMainWindow void ticketReturn(); /**deduct some money from a voucher (to pay outside the system)*/ void deductVoucher(); + /**empty/invalidate voucher*/ + void emptyVoucher(); /**refresh data that we can refresh*/ void refreshData(); diff --git a/wob/order.wolf b/wob/order.wolf index 2c6710d..fae345c 100644 --- a/wob/order.wolf +++ b/wob/order.wolf @@ -520,6 +520,17 @@ + + Empties a voucher, makes it invalid for any further use, but also keeps the price tag. + + ID of the voucher + + + + The voucher as it is left after emptying + + + Changes the shipping option and/or price of an order diff --git a/www/inc/wext/order.php b/www/inc/wext/order.php index 050f087..4ee24d1 100644 --- a/www/inc/wext/order.php +++ b/www/inc/wext/order.php @@ -610,6 +610,32 @@ class WOOrder extends WOOrderAbstract $trans->setamount($amt); $trans->setvoucher(WOVoucher::fromTablevoucher($vou)); } + + /**called from EmptyVoucher transaction*/ + static public function emptyVoucher($trans) + { + //get and verify voucher + $vou=WTvoucher::getFromDB($trans->getvoucherid()); + if($vou===false){ + $trans->abortWithError(tr("Voucher is not valid!")); + return; + } + $vord=WOOrder::fromTableorder(WTorder::getFromDB($vou->orderid)); + if($vord===false){ + $trans->abortWithError(tr("Voucher is not valid!")); + return; + } + if($vord->getamountdue()>0){ + $trans->abortWithError(tr("Voucher cannot be used: it has not been paid for.")); + return; + } + //empty it + $vou->value=0; + $vou->isused=true; + $vou->update(); + //return + $trans->setvoucher(WOVoucher::fromTablevoucher($vou)); + } }; ?> \ No newline at end of file -- 1.7.2.5