From: Konrad Rosenbaum Date: Wed, 18 Nov 2015 18:50:14 +0000 (+0100) Subject: fix price category change of tickets: don't over X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=41007d55545a8b5b112e4e3bdb69f0bbcf5762f2;p=web%2Fkonrad%2Fsmoke.git fix price category change of tickets: don't over --- diff --git a/www/inc/wext/order.php b/www/inc/wext/order.php index 64543cf..04c1deb 100644 --- a/www/inc/wext/order.php +++ b/www/inc/wext/order.php @@ -662,6 +662,7 @@ class WOOrder extends WOOrderAbstract /**called from the ChangeTicketPriceCategory transaction*/ static public function changeTicketPriceCategory($trans) { + global $db; //get ticket $tick=WTticket::getFromDB($trans->getbarcode()); if($tick===false){ @@ -690,6 +691,15 @@ class WOOrder extends WOOrderAbstract $trans->abortWithError(tr("You do not have access to this category on this event.")); return; } + //make sure there are enough seats left in the category + $ticks=WTticket::selectFromDB("eventid=".$db->escapeInt($tick->eventid)." and pricecategoryid=".$db->escapeInt($prc->pricecategoryid)); + $tcount=0; + foreach($ticks as $t)if(($t->status & WTticket::MaskBlock)!=0)$tcount++; + if($tcount>=$prc->maxavailable){ + $trans->abortWithError(tr("No more tickets left in this category.")); + return; + } + //TODO: make sure seat allows the category //change ticket $tick->pricecategoryid=$prc->pricecategoryid; $tick->price=$prc->price;