global $db;
//sanity check
if($amount<=0)return false;
+ $this->renewCart();
//check that ticket can be sold
$event=new Event($eventid);
if($event->isCancelled())return false;
global $db;
$res=$db->select("cart_ticket","*","where cartid=".$db->escapeString($this->cartid));
if(count($res)>0)
- foreach($res as $k=>$tc)
- $ret[]=new CartTicket($tc["cartid"],$tc["eventid"],$tc["amount"]);
+ foreach($res as $k=>$tc){
+ $evt=new Event($tc["eventid"]);
+ //TODO: add more checks (event over, cancelled, etc.pp.)
+ if($evt->availableTicketAmount()<$tc["amount"])
+ $ret[]=new CartError(CE_EVENTNOTICKETS,$tc["eventid"]);
+ }
//vouchers are ok by default, just check amount
$itmcnt=count($res);
$res=$db->select("cart_voucher","cvid","where cartid=".$db->escapeString($this->cartid));
//return...
return $ret;
}
+
+ /**makes sure the cart continues to exist*/
+ public function renewCart()
+ {
+ global $db;
+ $db->update("cart",array("timeout"=>(time()+$CartTimeout)),"cartid=".$db->escapeInt($this->cartid));
+ }
};
?>
\ No newline at end of file