From bc11d79f4b5d307a1ed3175ae406b49a518845f2 Mon Sep 17 00:00:00 2001 From: konrad Date: Fri, 1 Jan 2010 18:01:02 +0000 Subject: [PATCH] change ticket price git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@392 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- src/dialogs/orderwin.cpp | 20 +++++++++++--------- wob/order.wolf | 15 +++++++++++++++ www/inc/wext/order.php | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 9 deletions(-) diff --git a/src/dialogs/orderwin.cpp b/src/dialogs/orderwin.cpp index c80d394..4e84726 100644 --- a/src/dialogs/orderwin.cpp +++ b/src/dialogs/orderwin.cpp @@ -59,7 +59,7 @@ MOrderWindow::MOrderWindow(QWidget*par,const MOOrder&o) m_ship=m->addAction(tr("&Mark Order as Shipped..."),this,SLOT(shipOrder())); m->addSeparator(); m->addAction(tr("Ch&ange Item-Price..."),this,SLOT(changeItem())) - ->setEnabled(req->hasRole("changeticketprice")); + ->setEnabled(req->hasRight(req->RChangeTicketPrice)); m->addAction(tr("&Return Item..."),this,SLOT(itemReturn())) ->setEnabled(req->hasRight(req->RReturnTicketVoucher)); m->addAction(tr("Add Commen&t..."),this,SLOT(addComment())) @@ -715,8 +715,7 @@ void MOrderWindow::refund() } void MOrderWindow::changeItem() -{/*TODO - if(!m_order.isValid())return; +{ //get ticket selection QModelIndexList lst=m_table->selectionModel()->selectedIndexes(); if(lst.size()<1)return; @@ -727,24 +726,27 @@ void MOrderWindow::changeItem() if(type==ITEM_TICKET){ //find ticket QListtickets=m_order.tickets(); - MTicket tick; + MOTicket tick; for(int i=0;iqueryChangeTicketPrice(id,pay); + if(ctp.hasError()){ + QMessageBox::warning(this,tr("Warning"),tr("Error while attempting to change ticket price: %1").arg(ctp.errorString())); + return; + } + m_order=ctp.getorder(); + updateData(); }else{ QMessageBox::warning(this,tr("Warning"),tr("Cannot change this item type.")); return; } - m_total->setText(m_order.totalPriceString()); - updateTable();*/ } void MOrderWindow::itemReturn() diff --git a/wob/order.wolf b/wob/order.wolf index 70edefd..bb36af6 100644 --- a/wob/order.wolf +++ b/wob/order.wolf @@ -98,6 +98,8 @@ Masking value: combines Block+Pay - the ticket can be used to watch a show or is already being used. Masking value: if this bit is set the ticket can still be cancelled. + + Masking value: if this bit is set the ticket can still be changed (price, event, etc.). Currently an alias for MaskReturnable. @@ -528,6 +530,19 @@ + + users with this privilege can change the price of used tickets - usually a ticket has to be changed before it is used + users with this privilege can change the price for tickets that are for past events + + + + + + + the order that ownes the changed ticket, in case this is called from the order window + + + diff --git a/www/inc/wext/order.php b/www/inc/wext/order.php index 1bec613..123fb37 100644 --- a/www/inc/wext/order.php +++ b/www/inc/wext/order.php @@ -523,6 +523,38 @@ class WOOrder extends WOOrderAbstract //return $trans->setorder(WOOrder::fromTableorder($ord)); } + + /**called from the ChangeTicketPrice transaction*/ + static public function changeTicketPrice($trans) + { + //get ticket + $tick=WTticket::getFromDB($trans->getbarcode()); + if($tick===false){ + $trans->abortWithError(tr("Invalid ticket ID.")); + return; + } + //verify ticket + $ok = (($tick->status & WTticket::MaskChangeable) || + ($tick->status==WTticket::Used && $trans->havePrivilege(WTrChangeTicketPrice::Priv_ChangeUsedTicket))); + if(!$ok){ + $trans->abortWithError(tr("The ticket cannot be changed anymore or you do not have the privilege.")); + return; + } + $event=WTevent::getFromDB($tick->eventid); + if($event===false){ + $trans->abortWithError(tr("Internal error: ticket for unknown event.")); + return; + } + if($event->starttime < time() && !$trans->havePrivilege(WTrChangeTicketPrice::Priv_ChangePastTicket)){ + $trans->abortWithError(tr("The ticket is for an event in the past and you do not have the privilege to change it.")); + return; + } + //change ticket + $tick->price=$trans->getprice(); + $tick->update(); + //return order + $trans->setorder(WOOrder::fromTableorder(WTorder::getFromDB($tick->orderid))); + } }; ?> \ No newline at end of file -- 1.7.2.5