fix price category change of tickets: don't over
authorKonrad Rosenbaum <konrad@silmor.de>
Wed, 18 Nov 2015 18:50:14 +0000 (19:50 +0100)
committerKonrad Rosenbaum <konrad@silmor.de>
Wed, 18 Nov 2015 18:50:14 +0000 (19:50 +0100)
www/inc/wext/order.php

index 64543cf..04c1deb 100644 (file)
@@ -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;