From b086d12a76bd45c052877a3e1cf636232cb8cfe0 Mon Sep 17 00:00:00 2001 From: konrad Date: Sat, 17 Nov 2007 18:11:21 +0000 Subject: [PATCH] add some rudimentary ticket support git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@74 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- www/inc/db_scheme.php | 12 ------------ www/inc/event.php | 23 ++++++++++++++++++++++- www/inc/loader_nonadmin.php | 1 + www/inc/ticket.php | 26 ++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 www/inc/ticket.php diff --git a/www/inc/db_scheme.php b/www/inc/db_scheme.php index 96eb752..dee17b0 100644 --- a/www/inc/db_scheme.php +++ b/www/inc/db_scheme.php @@ -232,16 +232,4 @@ class DbScheme { } }; $dbScheme=new DbScheme; - -/**ticket has been reserved by a seller*/ -define("TICKET_RESERVED",0); -/**ticket is part of an order or has been sold independently*/ -define("TICKET_SOLD",10); -/**ticket has been used*/ -define("TICKET_USED",20); -/**the ticket has been paid, not used, but is to be reimbursed*/ -define("TICKET_REVERSE",30); -/**ticket has been cancelled*/ -define("TICKET_CANCELLED",40); - ?> \ No newline at end of file diff --git a/www/inc/event.php b/www/inc/event.php index e6d9db6..2e5cabc 100644 --- a/www/inc/event.php +++ b/www/inc/event.php @@ -116,13 +116,34 @@ class Event public function getDescription(){return $this->description;} /**returns the reason why the event is cancelled if isCancelled() returns true*/ public function getCancelReason(){return $this->cancelreason;} - /**returns the data in an array*/ + + /**returns the data in an array suitable for the web-page-renderer*/ public function getParserData() { $lang = LanguageManager::singleton(); return array("DATE"=>$lang->getDate($this->getStartTime()), "TIME"=>$lang->getTime($this->getStartTime()), "PLACE"=>$this->getRoomId(), "EVENTNAME"=>$this->getTitle(), "ARTIST"=>$this->getArtist(),"PRICE"=>$lang->getPrice($this->getDefaultPrice()), "ID"=>$this->getEventId(), "DESCRIPTION"=>$this->getDescription()); } + + /**returns how many tickets can still be sold*/ + public function availableTicketAmount() + { + global $db; + //is it valid? + if($this->evid<0)return 0; + //is it cancelled? + if($this->isCancelled())return 0; + //is it already over? + if(time()>$this->endtime)return 0; + //get existing tickets + $res=$db->select("ticket","status","eventid=".$db->escapeInt($this->evid)); + $amt=0; + if(count($res)>0) + foreach($res as $tk){ + if(!($tk["status"]&TICKET_CANCELLED))$amt++; + } + return $this->capacity - $amt; + } }; /**machine-function: get the requested events as XML data*/ diff --git a/www/inc/loader_nonadmin.php b/www/inc/loader_nonadmin.php index 13e48b1..c0a2c65 100644 --- a/www/inc/loader_nonadmin.php +++ b/www/inc/loader_nonadmin.php @@ -7,6 +7,7 @@ include('./inc/event.php'); include('./inc/room.php'); include("./inc/random.php"); include("./inc/order.php"); +include("./inc/ticket.php"); include("./inc/cart.php"); include('./inc/error.php'); include('./inc/language_manager.php'); diff --git a/www/inc/ticket.php b/www/inc/ticket.php new file mode 100644 index 0000000..ff3a28c --- /dev/null +++ b/www/inc/ticket.php @@ -0,0 +1,26 @@ +, (C) 2007 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + + +/**ticket has been reserved by a seller*/ +define("TICKET_RESERVED",1); +/**ticket is part of an order or has been sold independently*/ +define("TICKET_SOLD",2); +/**ticket has been used*/ +define("TICKET_USED",4); +/**the ticket has been paid*/ +define("TICKET_PAID",8); +/**ticket has been cancelled by some entity*/ +define("TICKET_CANCELLED",16); + +?> \ No newline at end of file -- 1.7.2.5