add some rudimentary ticket support
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sat, 17 Nov 2007 18:11:21 +0000 (18:11 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sat, 17 Nov 2007 18:11:21 +0000 (18:11 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@74 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

www/inc/db_scheme.php
www/inc/event.php
www/inc/loader_nonadmin.php
www/inc/ticket.php [new file with mode: 0644]

index 96eb752..dee17b0 100644 (file)
@@ -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
index e6d9db6..2e5cabc 100644 (file)
@@ -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*/
index 13e48b1..c0a2c65 100644 (file)
@@ -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 (file)
index 0000000..ff3a28c
--- /dev/null
@@ -0,0 +1,26 @@
+<?
+//
+// PHP Implementation: ticket
+//
+// Description: 
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (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