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()));
);
}
+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;
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();
</Output>
</Transaction>
+ <Transaction name="EmptyVoucher">
+ <Doc>Empties a voucher, makes it invalid for any further use, but also keeps the price tag.</Doc>
+ <Input>
+ <Var name="voucherid" type="astring">ID of the voucher</Var>
+ </Input>
+ <Call lang="php" method="WOOrder::emptyVoucher($this);"/>
+ <Output>
+ <Var name="voucher" type="Voucher">The voucher as it is left after emptying</Var>
+ </Output>
+ </Transaction>
+
<Transaction name="OrderChangeShipping">
<Doc>Changes the shipping option and/or price of an order</Doc>
$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