<Column name="cartid" type="string:32" notnull="yes" foreignkey="cart:cartid" primarykey="yes"/>
<!--tickets in the cart-->
<Column name="eventid" type="int32" notnull="yes" foreignkey="event:eventid" primarykey="yes"/>
+ <Column name="pricecategoryid" type="int32" foreignkey="pricecategory:pricecategoryid" primarykey="yes"/>
<Column name="amount" type="int32" notnull="yes"/>
- <Column name="seating" type="string:32" null="yes"/>
+ <!-- Column name="seating" type="string:32" null="yes"/ -->
</Table>
<Table name="cart_voucher">
<Column name="cvid" type="seq64" primarykey="yes"/>
<Class name="CartItem"/>
<Class name="CartOrder">
+ <Doc>The cart as used from the remote (non-web) system, this is a transaction object, it has no equivalent inside the database.</Doc>
<Abstract lang="php"/>
<Enum name="ValidationState">
<Value name="Ok">The cart has been processed successfully</Value>
wob_autoclass('LanguageManager','./inc/classes/language_manager.php');
wob_autoclass('ConfigManager','./inc/classes/config_manager.php');
wob_autoclass('Websession','./inc/classes/websession.php');
-wob_autoclass('ErrorManager','./inc/classes/error.php');
?>
\ No newline at end of file
+++ /dev/null
-<?php
-// +----------------------------------------------------------------------
-// | PHP Source
-// +----------------------------------------------------------------------
-// | Copyright (C) 2007 by Peter keller <peter@silmor.de>
-// +----------------------------------------------------------------------
-// |
-// | Copyright: See COPYING file that comes with this distribution
-// +----------------------------------------------------------------------
-//
-
-class ErrorManager
-{
- private $errorMessages;
- private static $instance;
-
- private function __construct()
- {
- $this->errorMessages = array();
- }
-
- /** returns the instance of the Error Manager */
- public static function singleton()
- {
- if(!self::$instance) {
- self::$instance = new ErrorManager();
- }
-
- return self::$instance;
- }
-
- /** add new error message */
- public function add($message)
- {
- $this->errorMessages[] = $message;
- }
-
- /** get all error messages in an array */
- public function getAll()
- {
- return $this->$errorMessages;
- }
-
- /** get all error messages formatted */
- public function getAllFormatted()
- {
- $p = new Parser("definition.html");
- $messages = "";
-
- foreach ($this->errorMessages as $message)
- {
- $errorTmpl = $p->getVar("ERROR");
- $p->setVar("MESSAGE", $message);
- $messages .= $p->parse($errorTmpl);
- }
-
- $errorArea = $p->getVar("ERRORAREA");
- $p->setVar("ERRORMESSAGES", $messages);
-
- return $p->parse($errorArea);
- }
-
- /** returns true if errors exist */
- public function exists()
- {
- if (count($this->errorMessages) > 0) {
- return true;
- }
- else {
- return false;
- }
- }
-}
-?>
\ No newline at end of file
define("COOKIE_LANGUAGE", "ms_lang");
$lang = LanguageManager::singleton();
-$error = ErrorManager::singleton();
?>
$this->sessid=$sid;
$this->user=$res[0]["uname"];
$this->initRights();
- $this->initFlags($res[0]["flags"]);
+ $this->initFlags();
}
$session=$this;
}
}
/**internal: retrieve and remember the flags of this user*/
- protected function initFlags($flg)
+ protected function initFlags()
{
global $db;
- $this->flags=explode(" ",$flg);
+ #user flags
+ $this->flags=array();
+ $res=$db->select("user","uname,flags","uname=".$db->escapeString($this->user));
+ if(count($res)>0)
+ $this->flags=explode(" ",$res[0]['flags']);
+ #role flags
$res=$db->select("userrole","role","uname=".$db->escapeString($this->user));
for($i=0;$i<count($res);$i++){
$res2=$db->select("role","flags","rolename=".$db->escapeString($res[$i][0]));
//create session and return
//get random bits
- randseed($rand);
$sid=getRandom(128);
//try to create entry
$db->beginTransaction();
/** creates the details of an event */
public static function createEventDetails()
{
- global $parser;
+ global $twig,$session,$basevars;
- $error = ErrorManager::singleton();
-
if (isset($_GET["event"])) {
$eventID = $_GET["event"]+0;
}
- $p = new Parser("eventdetails.html");
- $eventTmpl = $p->getVar("EVENT");
-
+ $p = $twig->loadTemplate("eventdetails.html");
+
// check if event exists
- $event = new Event($eventID);
- if (!$event->exists())
- {
- redirectHome(array());
- return;
- }
-
+ $trn=WTrGetEvent::execute($eventID);
+ $event = $trn->resultevent();
+ if(!is_a($event,"WoEvent"))
+ throw new Exception("Unknown Event");
+
// set event details
- $p->setVars($event->getParserData());
- $details = $p->parse($eventTmpl);
- $p->setVar("EVENTDETAILS",$details);
- $p->setVar("fieldAMOUNT", "ms_amount");
- $p->setVar("buttonSAVE", "ms_save");
+ $list=$basevars;
+ $list['event']=$event->getParserData();
- // set error message
- if ($error->exists()) {
- $p->setVar("ERROR", "true");
- $p->setVar("ERRORAREA", $error->getAllFormatted());
- }
-
// create page
- $parser->setVAR("PAGE", $p->parseFile("eventdetails.html"));
+ return $p->render($list);
}
//end of class
/** adds an event to the cart */
function addEventToCart()
{
- $error = ErrorManager::singleton();
+// $error = ErrorManager::singleton();
if (isset($_POST["ms_save"])) {
$event = new Event(($_GET["event"]+0));
/**returns the data in an array suitable for the web-page-renderer*/
public function getParserData()
{
- global $session;
+ global $session,$basevars;
$lang = LanguageManager::singleton();
$ret=array(
"date"=>$lang->getDate($this->getstart()),
"price"=>$lang->getPrice($price->getprice()),
"pricecents"=>$price->getprice(),
"categoryid"=>$price->getpricecategoryid(),
- "categoryname"=>$price->getpricecategory()->getname()
+ "categoryname"=>$price->getpricecategory()->getname(),
//TODO: get max tickets, current amount, amount free
+ "maxtickets"=>$price->getmaxavailable(),
+ "ticketsblock"=>$price->getamountticketsblock(),
+ "ticketsavailable"=>($price->getmaxavailable()-$price->getamountticketsblock()),
+ //little helper for forms
+ "amountinputfield"=>($basevars['inputnames']['amountTickets']."[".$price->getpricecategoryid()."]"),
);
}
//return result
//include process script (TODO: rework to be autoloaded)
include('inc/rendering/submit.php');
-//include display scripts (TODO: move to autoloading)
-include('inc/rendering/cart_listing.php');
-include('inc/rendering/order_listing.php');
-
//set common basics
$mode="index";
if(isset($_GET["mode"])){
$basevars['script']['root']=$_SERVER['SCRIPT_NAME'];
$basevars['script']['this']=$_SERVER['REQUEST_URI'];
$basevars['script']['eventDetails']=$_SERVER['SCRIPT_NAME']."?mode=eventDetails&event=";
-$basevars['script']['cart']=$_SERVER['SCRIPT_NAME']."?mode=cart";
-$basevars['script']['orderLogin']=$_SERVER['SCRIPT_NAME']."?mode=orderLogin";
-$basevars['script']['customerRegistration']=$_SERVER['SCRIPT_NAME']."?mode=customerRegistration";
-$basevars['script']['orderOverview']=$_SERVER['SCRIPT_NAME']."?mode=orderOverview";
-$basevars['script']['editShippingAddress']=$_SERVER['SCRIPT_NAME']."?mode=editShippingAddress";
-$basevars['script']['editOrderComments']=$_SERVER['SCRIPT_NAME']."?mode=editOrderComments";
+$basevars['script']['eventOrder']=$_SERVER['SCRIPT_NAME']."?mode=eventOrder&event=";
+//$basevars['script']['cart']=$_SERVER['SCRIPT_NAME']."?mode=cart";
+//$basevars['script']['orderLogin']=$_SERVER['SCRIPT_NAME']."?mode=orderLogin";
+//$basevars['script']['customerRegistration']=$_SERVER['SCRIPT_NAME']."?mode=customerRegistration";
+//$basevars['script']['orderOverview']=$_SERVER['SCRIPT_NAME']."?mode=orderOverview";
+//$basevars['script']['editShippingAddress']=$_SERVER['SCRIPT_NAME']."?mode=editShippingAddress";
+//$basevars['script']['editOrderComments']=$_SERVER['SCRIPT_NAME']."?mode=editOrderComments";
+// form elements
+$basevars['inputnames']['amountTickets']="amountTickets";
+$basevars['inputnames']['event']="event";
+$basevars['inputnames']['mode']="mode";
//strings that are used to compose the overall layout
$page="(internal error: no page text yet)";
//get page template and process it
switch($mode){
case "eventDetails":
- addEventToCart();
- EventRender::createEventDetails();
+ $page=EventRender::createEventDetails();
break;
- case "cart":
+ case "eventOrder":
+ $page=
+/* case "cart":
deleteEventFromCart();
changeTicketAmountInCart();
createCartOverview();
case "editOrderComments":
saveOrderComments();
editOrderComments();
- break;
+ break;*/
default:
$page=EventRender::createEventList();
break;
-<h1>Veranstaltungsdetails</h1>
-<div id="ms_form">
-<form action="@FULLURL@" method="POST">
+{# Example Template for MagicSmoke
+ ================================
+ this one is called to create the event detail/order page
+#}
-@EVENTDETAILS@
+{% extends 'layout.html' %}
-#set:EVENT:
-<fieldset class="ms_Form">
-<div class="ms_FormRow">
-<label for="ms_text_event">Veranstaltung:</label>
-<div id="ms_text_event">@EVENTNAME@</div>
-</div>
-<div class="ms_FormRow">
-<label for="ms_text_artist">Künstler:</label>
-<div id="ms_text_artist">@ARTIST@</div>
-</div>
-<div class="ms_FormRow">
-<label for="ms_text_place">Ort:</label>
-<div id="ms_text_place">@PLACE@</div>
-</div>
-<div class="ms_FormRow">
-<label for="ms_text_date">Datum:</label>
-<div id="ms_text_date">@DATE@</div>
-</div>
-<div class="ms_FormRow">
-<label for="ms_text_time">Uhrzeit:</label>
-<div id="ms_text_time">@TIME@</div>
-</div>
-<div class="ms_FormRow">
-<label for="ms_text_information">Information:</label>
-<div id="ms_text_information">@DESCRIPTION@</div>
-</div>
-<div class="ms_FormRow">
-<label for="ms_text_price">Kartenpreis:</label>
-<div id="ms_text_price">@PRICE@ €</div>
-</div>
-<div class="ms_FormRow">
-<label for="ms_textfield_amount">Kartenanzahl:</label>
-<input type="text" id="ms_textfield_amount" name="@fieldAMOUNT@" size="2" maxlength="2" value="1"/>
-</div>
-</fieldset>
-#endset
+{% block title %}{{event.name}}{% endblock %}
-<div class="ms_ButtonArea">
-<input type="submit" id="ms_button_save" name="@buttonSAVE@" value="In den Warenkorb" />
-</div>
-</form>
+{% block page %}
-#if:ERROR==true
-@ERRORAREA@
-#endif
+ <h2>{{event.name}}</h2>
+ {{event.date}} {{event.time}}, {{event.place}}<br/>
+ Artist: {{event.artist}}<br/>
+ {{event.description}}<br/>
+ <form action="{{script.eventOrder}}{{event.ID}}" method="GET">
+ <table>
+ <tr><td>Price:</td><td>Amount:</td></tr>
+ {% for price in event.prices %}
+ <tr><td>{{price.price}} ({{price.categoryname}})</td>
+ <td><select name="{{price.amountinputfield}}">
+ {% for i in 0 .. price.ticketsavailable %}
+ <option>{{i}}</option>
+ {% endfor %}
+ </select></td></tr>
+ {% endfor %}</table><br/>
+ <input type="submit" value="add to cart" />
+ </form>
-</div>
\ No newline at end of file
+{% endblock %}