-->
<Wolf>
<Table name="cart">
- <!--the cookie for this cart-->
<Column name="cartid" type="string:32" primarykey="yes">
+ the cookie for this cart
<Call lang="php" method="WebCart::getNewCartId()"/>
</Column>
- <!--when the cart expires-->
- <Column name="timeout" type="int64" notnull="yes"/>
- <!--shipping address during order process-->
- <Column name="shippingaddress" type="text"/>
- <!--customer comments during order process-->
- <Column name="ordercomments" type="text"/>
+ <Column name="timeout" type="int64" notnull="yes">when the cart expires</Column>
+ <Column name="customerid" type="int32" foreignkey="customer:customerid" null="yes">
+ ID of the customer connected to this cart.
+ </Column>
+ <Column name="invoiceaddress" type="int64" foreignkey="address:addressid" null="yes">
+ If not null: the address the invoice goes to.
+ </Column>
+ <Column name="deliveryaddress" type="int64" foreignkey="address:addressid" null="yes">
+ If not null: the address the delivery goes to.
+ If null: assumed to be identical to invoiceaddress.
+ </Column>
+ <Column name="comment" type="text" null="yes">customer comments during order process</Column>
</Table>
- <Table name="cart_ticket">
+ <Table name="cartticket">
<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="amount" type="int32" notnull="yes"/>
<!-- Column name="seating" type="string:32" null="yes"/ -->
</Table>
- <Table name="cart_voucher">
+ <Table name="cartvoucher">
<Column name="cvid" type="seq64" primarykey="yes"/>
<Column name="cartid" type="string:32" notnull="yes" foreignkey="cart:cartid"/>
- <!--voucher value-->
- <Column name="value" type="int32" notnull="yes"/>
+ <Column name="value" type="int32" notnull="yes">voucher value in cents</Column>
</Table>
- <Table name="cart_item">
+ <Table name="cartitem">
<Column name="ciid" type="seq64" primarykey="yes"/>
<Column name="cartid" type="string:32" notnull="yes" foreignkey="cart:cartid"/>
<Column name="productid" type="int32" foreignkey="product:productid" notnull="yes"/>
<Property name="price" type="int" optional="1"/>
<Property name="status" type="TicketValidationState" optional="1"/>
<Property name="maxamount" type="int" optional="1"/>
+ <Property name="cartid" type="astring" optional="1">The cartID as used by the web user interface, this property must not be interpreted while the server attempts to create an order from this cart, the server must preserve it unchanged</Property>
+
+ <Mapping table="cartticket">
+ <Doc>this mapping is used by the web user interface to generate the cart object</Doc>
+ <Map property="cartid"/>
+ <Map property="eventid"/>
+ <Map property="pricecategoryid"/>
+ <Map property="amount"/>
+ </Mapping>
</Class>
<Property name="value" type="int"/>
<Property name="price" type="int" optional="1"/>
<Property name="status" type="ValidationState" optional="1"/>
+ <Property name="cartid" type="astring">optional property that is used by the web user interface to identify the cart that is handled</Property>
+
+ <Mapping table="cartvoucher">
+ <Map property="cartid"/>
+ <Map property="value"/>
+ <Map property="cartlineid" column="cvid"/>
+ <Map property="amount"><Call lang="php" method="1"/></Map>
+ </Mapping>
</Class>
- <Class name="CartItem"/>
+ <Class name="CartItem">
+ <!-- TODO: implement something here! -->
+ <Mapping table="cartitem"/>
+ </Class>
<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>
<Property name="vouchers" type="List:CartVoucher"/>
<Property name="items" type="List:CartItem"/>
</Class>
+
+ <Class name="WebCart">
+ <!-- hint: there are two classes:
+ inc/renderer/cart_listing.php - WebCart - is the UI part, which cares about rendering the cart to the user
+ inc/wext/webcart.php - WOWebCart - is the backend part, that cares about conversion to/from the database -->
+ <Abstract lang="php"/>
+ <Doc>The cart as used by the web user interface, this maps into the cart tables. This class is never used by the </Doc>
+ <Property name="cartid" type="astring">The cart ID of this session</Property>
+ <Property name="customerid" type="int32">The customer of this cart</Property>
+ <Property name="deliveryaddressid" type="int64">The address to deliver to (mandatory)</Property>
+ <Property name="invoiceaddressid" type="int64">The address to send the invoice to if different from the delivery address (optional)</Property>
+ <Property name="comment" type="string">optional comments from the customer</Property>
+
+ <!-- calculated properties -->
+ <Property name="customer" type="Customer">The customer of this cart</Property>
+ <Property name="deliveryaddress" type="Address">The address to deliver to (mandatory)</Property>
+ <Property name="invoiceaddress" type="Address">The address to send the invoice to if different from the delivery address (optional)</Property>
+
+ <Property name="tickets" type="List:CartTicket">tickets inside this cart as seen in the DB</Property>
+ <Property name="vouchers" type="List:CartVoucher">vouchers inside this cart as seen in the DB</Property>
+ <Property name="items" type="List:CartItem">shop items inside this cart as seen in the DB</Property>
+
+ <Mapping table="cart">
+ <Map property="cartid"/>
+ <Map property="customerid"/>
+ <Map property="deliveryaddressid" column="deliveryaddress"/>
+ <Map property="invoiceaddressid" column="invoiceaddress"/>
+ <Map property="comment"/>
+ <Map property="customer">
+ <Call lang="php" method="WOCustomer::fromTablecustomer(WTcustomer::getFromDB($data->prop_customerid))"/>
+ </Map>
+ <Map property="deliveryaddress">
+ <Call lang="php" method="WOAddress::fromTableaddress(WTaddress::getFromDB($data->prop_deliveryaddressid))"/>
+ </Map>
+ <Map property="invoiceaddress">
+ <Call lang="php" method="WOAddress::fromTableaddress(WTaddress::getFromDB($data->prop_invoiceaddressid))"/>
+ </Map>
+ <Map property="tickets">
+ <Call lang="php" method="WOCartTicket::fromTableArraycartticket(WTcartticket::selectFromDB('cartid='.$GLOBALS['db']->escapeString($table->cartid)))"/>
+ </Map>
+ <Map property="vouchers">
+ <Call lang="php" method="WOCartVoucher::fromTableArraycartvoucher(WTcartvoucher::selectFromDB('cartid='.$GLOBALS['db']->escapeString($table->cartid)))"/>
+ </Map>
+ <Map property="items">
+ <Call lang="php" method="WOCartItem::fromTableArraycartitem(WTcartitem::selectFromDB('cartid='.$GLOBALS['db']->escapeString($table->cartid)))"/>
+ </Map>
+ </Mapping>
+ </Class>
</Wolf>
\ No newline at end of file
--- /dev/null
+../../doc/logo.png
\ No newline at end of file
private function __construct($file)
{
- global $template;
-
- $this->configFile = $template.$file;
+ $this->configFile = $file;
$this->config = array();
$this->readConfig();
}
- /** returns the instance of the Config Manager */
- public static function singleton($file)
+ /**used by language manager to initialize this*/
+ public static function initialize($file)
{
if(!self::$instance) {
- self::$instance = new ConfigManager($file);
- }
-
- return self::$instance;
+ self::$instance = new ConfigManager($file);
+ }
+ return self::$instance;
+ }
+
+ /** returns the instance of the Config Manager */
+ public static function singleton()
+ {
+ return self::$instance;
}
/** reads the configuration values from the file */
// +----------------------------------------------------------------------
//
+define("COOKIE_LANGUAGE", "ms_lang");
+
/** function to replace gettext */
function i18n($key)
{
$this->lang=$l;
break;
}
-
- $this->setLanguageConfig();
+ //make sure config manager is initialized
+ $this->config = ConfigManager::initialize($this->templateFolder()."lang.po");
}
/** returns the instance of the Language Manager */
return self::$instance;
}
- /** set language */
- public function setLanguage($language)
+ /** returns the configured language template folder*/
+ public function templateFolder()
{
- $this->lang = $language;
- setcookie(COOKIE_LANGUAGE, $language, 0);
-
- $this->setLanguageConfig();
- }
-
- private function setLanguageConfig() {
- global $template;
-
- $template = $this->templateFolder.$this->lang."/";
-
- $this->config = ConfigManager::singleton("lang.po");
+ return $this->templateFolder.$this->lang."/";
}
/** returns date in current language, default: ISO-date */
{
return $this->config->get($key);
}
+
+ /** returns all supported languages */
+ static public function getLanguages()
+ {
+ global $template;
+ $d=dir($template);
+ $r=array();
+ while(false !== ($e=$d->read())){
+ if(preg_match('/^[a-z]+$/',$e)>0 && $e!="C")
+ $r[]=$e;
+ }
+ return $r;
+ }
+
+ /** checks parameters, sets a language cookie returns home*/
+ static public function setLanguage()
+ {
+ global $HTTPARGS;
+ if(!isset($HTTPARGS['lang']))redirectHome();
+ $l=$HTTPARGS['lang'];
+ if(!in_array($l,self::getLanguages()))redirectHome();
+ //set the cookie for ~10 years
+ setCookie(COOKIE_LANGUAGE,$l,time()+316224000);
+ redirectHome();
+ }
}
+//make sure it exists
+LanguageManager::singleton();
+
?>
<?
+define("COOKIE_WEBSESSION", "msmoke_session");
+
/** creates a web session to authorize a customer */
class Websession {
$url.=urlencode($k)."=".urlencode($v);
}
Header("Location: ".$url);
+ print("<html>\n<head>\n<meta http-equiv=\"refresh\" content=\"0; URL=".$url."\" />\n");
+ print("<title>Redirect</title>\n</head><body>\n");
+ print("If you are not automatically redirected, please click ");
+ print("<a href=\"".$url."\">here</a>.\n</body></html>");
+ exit();
}
?>
+++ /dev/null
-<?php
-// +----------------------------------------------------------------------
-// | PHP Source
-// +----------------------------------------------------------------------
-// | Copyright (C) 2007 by Peter Keller <peter@silmor.de>
-// +----------------------------------------------------------------------
-// |
-// | Copyright: See COPYING file that comes with this distribution
-// +----------------------------------------------------------------------
-//
-
-define("COOKIE_CART", "ms_cartid");
-define("COOKIE_WEBSESSION", "ms_websession");
-define("COOKIE_LANGUAGE", "ms_lang");
-
-$lang = LanguageManager::singleton();
-
-?>
const cartIdName = "smoke_cartid";
/**called from index.php - add tickets to cart*/
-static function addTickets(){
+static public function addTickets(){
global $HTTPARGS;
$cart=self::getOrCreateCart();
- echo $cart;
+// echo $cart;
+
+ redirectHome(array("mode"=>"cart","cartid"=>$cart));
+}
+
+/**returns the current cart ID, or an empty string if there is no cart, automatically updates its timeout*/
+static public function getCart(){
+ global $CartTimeout;
+ $c=self::findCart();
+ if($c!=""){
+ $crt=WTcart::getFromDB($c);
+ $crt->timeout=time()+$CartTimeout;
+ $crt->update();
+ }
+ return $c;
}
-/**returns the current cart ID, or an empty string if there is no cart*/
-static function getCart(){
+/**returns the current cart ID, or an empty string if there is no cart, does not update*/
+static protected function findCart(){
global $HTTPARGS,$_COOKIE;
if(self::$cartid!==false)return self::$cartid;
//search GET/POST parms
/**return existing cart or create a new one*/
static public function getOrCreateCart(){
global $CartTimeout;
- //try to find it
+ //try to find it, if found update it
self::getCart();
+ //found?
if(self::$cartid==""){
//none there, create it
$c=WTcart::newRow();
return self::$cartid;
}
-/** \internal called to generate a new cart*/
+/** \internal called to generate a new cart ID, used by WTcart to generate the primary key*/
static public function getNewCartId(){
do{
//generate ID
}while(true);
}
-//end of WebCart
-};
-
/** creates the cart overview */
-function createCartOverview()
+static public function createCartOverview()
{
- global $parser;
-
- $error = ErrorManager::singleton();
- $lang = LanguageManager::singleton();
-
- $cart = new Cart($_COOKIE[COOKIE_CART]);
-
- $p = new Parser("cart.html");
-
- $tablerows = "";
- $totalsum = 0;
- $hiddenfields = "";
+ global $twig,$basevars;
- // get tickets from cart
- foreach ($cart->getTickets() as $ticket)
- {
- $cartRowTmpl = $p->getVar("ROW");
- $event = $ticket->eventObject();
-
- // set event details
- $p->setVars($event->getParserData());
-
- // if no error exists set values of database, else values of submit
- if (!$error->exists()) {
- $p->setVar("AMOUNT", $ticket->getAmount());
- } else {
- $ticketAmounts = $_POST["ms_amount"];
- $eventIDs = $_POST["ms_event"];
- $amountValue = $ticketAmounts[array_search($event->getEventId(),$eventIDs)];
- $p->setVar("AMOUNT", $amountValue);
- }
-
- // set submit functionality
- $p->setVar("linkDELETEROW", "index.php?mode=cart&action=deleteEvent&event=".$event->getEventId());
- $p->setVar("fieldAMOUNT", "ms_amount[]");
-
- // fill hidden fields
- $hiddenfields .= "<input type=\"hidden\" name=\"ms_event[]\" value=\"".$event->getEventId()."\" />\n";
-
- $rowsum = $ticket->getAmount()*$event->getDefaultPrice();
- $p->setVar("ROWSUM", $lang->getPrice($rowsum));
-
- $totalsum += $rowsum;
-
- $tablerows .= $p->parse($cartRowTmpl);
- }
-
- // if no tickets in cart set EMPTYROWS and disable order button
- if (count($cart->getTickets()) == 0) {
- $tablerows = $p->getVar("EMPTYROWS");
- $p->setVar("attribDISABLED", "disabled=\"disabled\"");
- } else {
- $p->setVar("attribDISABLED", "");
+ //get cart id and check it
+ $cartid=self::getCart();
+ if($cartid==""){
+ $p=$twig->loadTemplate("carterror.html");
+ return $p->render($basevars);
}
- $p->setVar("TABLEROWS", $tablerows);
- $p->setVar("TOTALSUM", $lang->getPrice($totalsum));
-
- // set buttons
- $p->setVar("buttonSAVE", "ms_save");
- $p->setVar("buttonORDER", "ms_goToOrder");
-
- // set hidden fields
- if ($_GET["isOrder"] == "true")
- $hiddenfields .= "<input type=\"hidden\" name=\"ms_isOrder\" value=\"true\" />\n";
-
- $p->setVar("IS_HIDDEN", "true");
- $p->setVar("HIDDENAREA", $hiddenfields);
-
- // set error message
- if ($error->exists()) {
- $p->setVar("IS_ERROR", "true");
- $p->setVar("ERRORAREA", $error->getAllFormatted());
+ //cart is ok, now display it
+ $cart = WOWebCart::fromTablecart(WTcart::getFromDB($cartid));
+ if(!is_a($cart,"WOWebCart")){
+ //ooops. internal problem
+ $p=$twig->loadTemplate("carterror.html");
+ return $p->render($basevars);
}
+ $p = $twig->loadTemplate("cart.html");
+ $list=$basevars;
+ $list["cart"]=$cart->getParserData();
+
// create page
- $parser->setVAR("PAGE", $p->parseFile("cart.html"));
+ return $p->render($list);
}
+
+//end of WebCart
+};
+
?>
\ 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
-// +----------------------------------------------------------------------
-//
-
-// forward to order login when order button in cart is pressed
-if (isset($_POST["ms_goToOrder"])) {
- if ($_POST["ms_isOrder"] == "true")
- redirectHome(array("mode"=>"orderOverview"));
- else
- redirectHome(array("mode"=>"orderLogin"));
- exit();
-}
-
-/** adds an event to the cart */
-function addEventToCart()
-{
-// $error = ErrorManager::singleton();
-
- if (isset($_POST["ms_save"])) {
- $event = new Event(($_GET["event"]+0));
- $availableTickets = $event->availableTicketAmount();
- if (empty($_POST["ms_amount"])) {
- $error->add(i18n("Please insert the number of tickets!"));
- return;
- } elseif (!is_numeric($_POST["ms_amount"])) {
- $error->add(i18n("Please insert a number!"));
- return;
- } elseif (!$event->exists()) {
- $error->add(i18n("The event does not exist!"));
- return;
- } else if ($availableTickets == 0) {
- $error->add(i18n("No more tickets for this event available!"));
- return;
- } else {
- $cart = new Cart($_COOKIE[COOKIE_CART]);
- if (!$cart->isValid()) {
- $cart = new Cart();
- setcookie(COOKIE_CART, $cart->getCartId(), 0);
- }
-
- // check if event is already booked
- $cartTicket = $cart->getTicketsByEvent($event->getEventId());
-
- // if event is not booked
- if ($cartTicket == false) {
- // check if enough tickets available
- if ($availableTickets < ($_POST["ms_amount"]+0)) {
- $error->add(string_format(i18n("Only {1} tickets left!"), array("$availableTickets")));
- return;
- }
-
- // add tickets to cart
- $cart->addTickets(($event->getEventId()+0), ($_POST["ms_amount"]+0));
- } else {
- // check if enough tickets available
- if ($availableTickets < ($_POST["ms_amount"] + $cartTicket->getAmount())) {
- $ticketsLeft = $availableTickets - $cartTicket->getAmount();
- if ($ticketsLeft > 0)
- $error->add(string_format(i18n("Only {1} more tickets left!"),array("$ticketsLeft")));
- else
- $error->add(i18n("No more tickets for this event available!"));
- return;
- }
-
- // set tickets to cartTicket
- $cartTicket->changeAmount($cartTicket->getAmount() + $_POST["ms_amount"]);
- }
-
- redirectHome(array("mode"=>"cart"));
- exit();
- }
- }
-}
-
-/** deletes an event from the cart */
-function deleteEventFromCart()
-{
- if ($_GET["action"]=="deleteEvent") {
- $cart = new Cart($_COOKIE[COOKIE_CART]);
- // check if cart valid
- if ($cart->isValid()) {
- // get cart ticket
- $cartTicket = $cart->getTicketsByEvent($_GET["event"]+0);
- if ($cartTicket != false) {
- $cartTicket->changeAmount(0);
- }
- }
- }
-}
-
-/** modifies the amount of tickets in the cart */
-function changeTicketAmountInCart()
-{
- $error = ErrorManager::singleton();
-
- if (isset($_POST["ms_save"])) {
-
- $cart = new Cart($_COOKIE[COOKIE_CART]);
- // check if cart valid
- if ($cart->isValid()) {
-
- // get event IDs and amounts
- $eventIDs = $_POST["ms_event"];
- $ticketAmounts = $_POST["ms_amount"];
-
- $num = count($eventIDs);
-
- // check for errors in input
- for ($i=0; $i < $num; $i++) {
- $line = $i + 1;
- if (empty($ticketAmounts[$i]) || !is_numeric($ticketAmounts[$i])) {
- $error->add(string_format(i18n("Please enter an amount in line {1}!"), array("$line")));
- }
- }
-
- if ($error->exists())
- return;
-
- // iterate over events
- for ($i=0; $i < $num; $i++) {
- // get eventID and belonging amount
- $eventID = $eventIDs[$i]+0;
- $amount = $ticketAmounts[$i]+0;
-
- $cartTicket = $cart->getTicketsByEvent($eventID);
-
- // check if amount changed
- if ($cartTicket->getAmount() != $amount) {
- // check if enough tickets available
- $event = $cartTicket->eventObject();
- if ($event->availableTicketAmount() >= $amount) {
- $cartTicket->changeAmount($amount);
- } else {
- $title = $event->getTitle();
- $availableTickets = $event->availableTicketAmount();
- $error->add(string_format(i18n("Event {1} has only {2} tickets left."), array("\"$title\"", "$availableTickets")));
- }
- }
- }
- }
- }
-}
-
-/** checks order login for valid values */
-function checkOrderLogin()
-{
- $error = ErrorManager::singleton();
-
- if (isset($_POST["ms_loginContinue"])) {
- // if user isn't registered
- if ($_POST["ms_isCustomer"] == "false") {
- if (!isEmail($_POST["ms_email"])) {
- $error->add(i18n("Please enter a correct email address!"));
- return;
- }
-
- // check if eMail already registered
- $customer = new Customer();
- if ($customer->getByMail($_POST["ms_email"])) {
- $error->add(i18n("eMail already registered!"));
- return;
- }
-
- // go to user registration
- redirectHome(array("mode"=>"customerRegistration","email"=>$_POST["ms_email"]));
- exit();
-
- // if user is registered
- } elseif ($_POST["ms_isCustomer"] == "true") {
- if (!isEmail($_POST["ms_email"])) {
- $error->add(i18n("Please enter a valid email address!"));
- }
- if (empty($_POST["ms_password"])) {
- $error->add(i18n("Please enter a password!"));
- }
- if ($error->exists())
- return;
-
- //check if user really available and password correct
- $customer = new Customer();
- $customer->getByMail($_POST["ms_email"]);
- if ($customer->authenticate($_POST["ms_password"])) {
- // create web session for user
- $session = new Websession();
- $session->createSession($customer->getID());
-
- // go to order overview
- redirectHome(array("mode"=>"orderOverview"));
- exit();
- } else {
- $error->add(i18n("eMail or Password wrong"));
- return;
- }
-
- // if radio button is not checked
- } else {
- $error->add(i18n("Please specify whether you are a registered user!"));
- return;
- }
- }
-}
-
-/** checks the data for a new user */
-function registerUser()
-{
- $error = ErrorManager::singleton();
-
- if (isset($_POST["ms_custRegister"])) {
-
- // check if eMail already registered
- $customer = new Customer();
- if ($customer->getByMail($_POST["ms_custEmail"])) {
- $error->add(i18n("eMail already registered!"));
- return;
- }
-
- // check if email is a valid address
- if (!isEmail($_POST["ms_custEmail"])) {
- $error->add(i18n("Please enter a valid email address!"));
- }
-
- // check if name is not empty
- if (empty($_POST["ms_custName"])) {
- $error->add(i18n("Please enter a name!"));
- }
-
- // check if address is not empty
- if (empty($_POST["ms_custAddress"])) {
- $error->add(i18n("Please enter an address!"));
- }
-
- // check if contact data is not empty
- //if (empty($_POST["ms_custContact"])) {
- // $error->add(i18n("Please enter a phone number!"));
- //}
-
- // check if passwords are not empty and equal
- if (empty($_POST["ms_custPasswd"]) || ($_POST["ms_custPasswd"] != $_POST["ms_custPasswd2"])) {
- $error->add(i18n("Passwords are empty or not equal!"));
- }
-
- // if error then exit
- if ($error->exists()) {
- return;
- }
-
- $customer = new Customer();
- $customer->create($_POST["ms_custName"]);
- $customer->setMail($_POST["ms_custEmail"]);
- $customer->setAddress($_POST["ms_custAddress"]);
- $customer->setPassword($_POST["ms_custPasswd"]);
-
- if (!empty($_POST["ms_custContact"])) {
- $customer->setContact($_POST["ms_custContact"]);
- }
-
- // create web session for user
- $session = new Websession();
- $session->createSession($customer->getID());
-
- // redirect to overview page
- redirectHome(array("mode"=>"orderOverview"));
- exit();
- }
-}
-
-/** saves the shipping address */
-function saveShippingAddress()
-{
- if (isset($_POST["ms_saveShippingAddress"])) {
-
- // check if loggedin
- $session = new WebSession();
- if (!$session->isAuthorized()) {
- redirectHome();
- exit();
- }
-
- $cart = new Cart($_COOKIE[COOKIE_CART]);
- if ($cart->isValid()) {
- $cart->addShippingAddress($_POST["ms_shippingAddress"]);
- }
-
- redirectHome(array("mode"=>"orderOverview"));
- } else if (isset($_POST["ms_cancelShippingAddress"])) {
- redirectHome(array("mode"=>"orderOverview"));
- exit();
- }
-}
-
-/** saves the order comments */
-function saveOrderComments()
-{
- if (isset($_POST["ms_saveComments"])) {
-
- // check if loggedin
- $session = new WebSession();
- if (!$session->isAuthorized()) {
- redirectHome();
- exit();
- }
-
- $cart = new Cart($_COOKIE[COOKIE_CART]);
- if ($cart->isValid()) {
- $cart->addOrderComments($_POST["ms_comments"]);
- }
-
- redirectHome(array("mode"=>"orderOverview"));
- } else if (isset($_POST["ms_cancelComments"])) {
- redirectHome(array("mode"=>"orderOverview"));
- exit();
- }
-}
-
-/** orders the tickets */
-function orderTickets()
-{
- if (isset($_POST["ms_orderTickets"])) {
-
- $error = ErrorManager::singleton();
-
- // check if loggedin
- $session = new WebSession();
- if (!$session->isAuthorized()) {
- redirectHome();
- exit();
- }
-
- $cart = new Cart($_COOKIE[COOKIE_CART]);
- if ($cart->isValid()) {
- $check=$cart->orderCheck();
- if(count($check)>0){
- foreach($check as $err)
- $error->add($err->toString());
- return;
- }
- $order=new Order;
- $order->setCustomer($session->getCustomer());
- $order->emptyCart($cart);
- $ret=$order->placeOrder();
- if($ret===false){
- $error->add(i18n("Can't order!"));
- return;
- }
- $cart->destroyCart();
- setcookie(COOKIE_CART, "", 1);
- } else {
- $error->add(i18n("Cart is not valid!"));
- }
- }
-}
-
-function sendOrderConfirmationMail($order)
-{
- $p = new Parser("orderconfirmationmail.html");
-
-
- //unfortunately incomplete - now we guess what he meant...
-// $p->setVar(
-}
-?>
\ No newline at end of file
wob_autoclass("WOShipping","inc/wext/shipping.php");
wob_autoclass("WOTemplate","inc/wext/template.php");
wob_autoclass("WOTicket","inc/wext/ticket.php");
+wob_autoclass("WOWebCart","inc/wext/webcart.php");
wob_autoclass("MSmokeTransaction","inc/wext/transaction.php");
?>
\ No newline at end of file
{
global $session,$basevars;
$lang = LanguageManager::singleton();
- $ret=array(
- "date"=>$lang->getDate($this->getstart()),
- "time"=>$lang->getTime($this->getstart()),
- "place"=>$this->getroom(),
- "name"=>$this->gettitle(),
- "artist"=>$this->getartist()->getname(),
- "ID"=>$this->getid(),
- "description"=>$this->getdescription(),
- "availabletickets"=>$this->getamountFree(),
- "prices" => array()
- );
+ $ret= $this->propertyArray();
+ $ret["date"]=$lang->getDate($this->getstart());
+ $ret["time"]=$lang->getTime($this->getstart());
+ $ret["place"]=$this->getroom();
+ $ret["name"]=$this->gettitle();
+ $ret["artistname"]=$this->getartist()->getname();
+ $ret["ID"]=$this->getid();
+ $ret["availabletickets"]=$this->getamountFree();
//list all available prices
+ $ret["prices"] = array();
foreach($this->getprice() as $price){
//not those unavailable via web
if(!$session->checkFlags($price->getflags()))continue;
//fill in data
- $ret['prices'][]=array(
- "price"=>$lang->getPrice($price->getprice()),
- "pricecents"=>$price->getprice(),
- "categoryid"=>$price->getpricecategoryid(),
- "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()."]"),
- );
+ $p=$price->propertyArray();
+ $p["price"]=$lang->getPrice($price->getprice());
+ $p["pricecents"]=$price->getprice();
+ $p["categoryid"]=$price->getpricecategoryid();
+ $p["categoryname"]=$price->getpricecategory()->getname();
+ //get max tickets, current amount, amount free
+ $p["maxtickets"]=$price->getmaxavailable();
+ $p["ticketsblock"]=$price->getamountticketsblock();
+ $p["ticketsavailable"]=($price->getmaxavailable()-$price->getamountticketsblock());
+ //little helper for forms
+ $p["amountinputfield"]=($basevars['inputnames']['amountTickets']."[".$price->getpricecategoryid()."]");
+ //copy to my own array
+ $ret['prices'][]=$p;
}
//return result
return $ret;
--- /dev/null
+<?
+//
+// PHP Implementation: web cart
+//
+// Description:
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2010
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+class WOWebCart extends WOWebCartAbstract
+{
+
+ public function getParserData()
+ {
+ return $this->propertyArray();
+ }
+
+};
+
+?>
\ No newline at end of file
//basics
include('inc/loader.php');
include('inc/loader_nonadmin.php');
-//load class-files
-include('./inc/classes/autoload.php');
+//load web-UI specific class-files
+include('inc/classes/autoload.php');
+include("inc/rendering/autoload.php");
//load external Twig library
require_once 'inc/Twig/Autoloader.php';
Twig_Autoloader::register();
//load globals
-include('inc/global_variables.php');
include('inc/global_functions.php');
-include("inc/rendering/autoload.php");
-
-//include process script (TODO: rework to be autoloaded)
-include('inc/rendering/submit.php');
//unify arguments
$HTTPARGS=$_GET;
Session::setWebSession();
//initialize TWIG
-$loader = new Twig_Loader_Filesystem($template);
+$loader = new Twig_Loader_Filesystem(LanguageManager::singleton()->templateFolder());
$twig = new Twig_Environment($loader, $twigoptions );
foreach($twigextensions as $te)$twig->addExtension($te);
-$cartid=WebCart::getCart();
-// if($cartid!="")$carturl="cartid=$cartid&";else $carturl="";
-
//basic variables shared by all templates
// script URLs
$basevars['script']['root']=$_SERVER['SCRIPT_NAME'];
$basevars['script']['index']=$_SERVER['SCRIPT_NAME']."?mode=index";
$basevars['script']['eventDetails']=$_SERVER['SCRIPT_NAME']."?mode=eventDetails&event=";
$basevars['script']['eventOrder']=$_SERVER['SCRIPT_NAME']."?mode=eventOrder&event=";
-//$basevars['script']['cart']=$_SERVER['SCRIPT_NAME']."?mode=cart";
+$basevars['script']['cart']=$_SERVER['SCRIPT_NAME']."?mode=cart";
+$basevars['script']['mycart']=$_SERVER['SCRIPT_NAME']."?mode=mycart";
//$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']['setlanguage']=$_SERVER['SCRIPT_NAME']."?mode=setlanguage&lang=";
// form elements
$basevars['inputnames']['amountTickets']="amountTickets";
$basevars['inputnames']['event']="event";
$basevars['inputnames']['mode']="mode";
$basevars['inputnames']['cartid']=WebCart::cartIdName;
$basevars['cartcookie']=WebCart::cartIdName;
+// other info
+$basevars['languages']=LanguageManager::getLanguages();
//strings that are used to compose the overall layout
$page="(internal error: no page text yet, probably no template defined)";
case "eventOrder":
WebCart::addTickets();
break;
-/* case "cart":
- deleteEventFromCart();
- changeTicketAmountInCart();
- createCartOverview();
+ case "mycart":
+ //make sure cart exists
+ WebCart::getOrCreateCart();
+ //fall through to show it
+ case "cart":
+ $page=WebCart::createCartOverview();
break;
- case "orderLogin":
+/* case "orderLogin":
checkOrderLogin();
createOrderLogin();
break;
saveOrderComments();
editOrderComments();
break;*/
+ case "setlanguage":
+ LanguageManager::setLanguage();
+ break;
default:
$page=EventRender::createEventList();
break;
+++ /dev/null
-../doc/logo.png
\ No newline at end of file
-<h1>Warenkorb</h1>
+{# Example Template for MagicSmoke
+ ================================
+ this one is called to show the cart
+#}
-<div id="ms_form">
-<form action="@FULLURL@" method="POST">
-<table class="ms_Table">
-<tr>
-<th> </th>
-<th>Veranstaltung</th>
-<th>Datum</th>
-<th>Uhrzeit</th>
-<th>Kartenpreis</th>
-<th>Anzahl</th>
-<th>Summe</th>
-</tr>
+{% extends 'layout.html' %}
-@TABLEROWS@
+{% block title %}Cart{% endblock %}
-#set:ROW:
-<tr>
-<td><a href="@linkDELETEROW@">Löschen</a></td>
-<td><a href="@LINK@">@EVENTNAME@</a></td>
-<td>@DATE@</td>
-<td class="ms_AlignRight">@TIME@</td>
-<td class="ms_AlignRight">@PRICE@ €</td>
-<td class="ms_AlignRight"><input type="text" id="ms_textfield_amount" name="@fieldAMOUNT@" size="2" maxlength="2" value="@AMOUNT@"></td>
-<td class="ms_AlignRight">@ROWSUM@ €</td>
-</tr>
-#endset
+{% block page %}
-#set:EMPTYROWS:
-<tr><td colspan="7">Sie haben keine Veranstaltungen im Warenkorb.</td></tr>
-#endset
+
+ {{cart.cartid}}
+
+ <a href="{{script.root}}">Continue Shopping</a><p/>
-<tr>
-<td colspan="6" class="ms_AlignRight"><b>Summe:</b></td>
-<td class="ms_AlignRight">@TOTALSUM@ €</td>
-</tr>
-</table>
-
-<div class="ms_ButtonArea">
-<input type="submit" id="ms_button_save" name="@buttonSAVE@" value="Aktualisieren" />
-<input type="submit" id="ms_button_order" name="@buttonORDER@" @attribDISABLED@ value="Zur Bestellung" />
-</div>
-#if:IS_HIDDEN==true
-@HIDDENAREA@
-#endif
-</form>
-
-#if:IS_ERROR==true
-@ERRORAREA@
-#endif
-
-</div>
\ No newline at end of file
+{% endblock %}
--- /dev/null
+{# Example Template for MagicSmoke
+ ================================
+ this one is called to create an error message if the cart expired or the user does not have cookies
+#}
+
+{% extends 'layout.html' %}
+
+{% block title %}No Cart Available{% endblock %}
+
+{% block page %}
+
+ <h1>I'm Sorry</h1>
+
+ Your cart expired or your browser does not have cookies enabled.<p/>
+
+ Please make sure cookies are enabled and then try again.<p/>
+
+ <a href="{{script.root}}">Back to Index</a><p/>
+
+{% endblock %}
<h2>{{event.name}}</h2>
{{event.date}} {{event.time}}, {{event.place}}<br/>
- Artist: {{event.artist}}<br/>
+ Artist: {{event.artistname}}<br/>
{{event.description}}<br/>
<form action="{{script.eventOrder}}{{event.ID}}" method="POST">
<table>
{% for event in events %}
<h2>{{event.name}}</h2>
{{event.date}} {{event.time}}, {{event.place}}<br/>
- Artist: {{event.artist}}<br/>
+ Artist: {{event.artistname}}<br/>
{{event.description}}<br/>
Price:
{% for price in event.prices %}
<html>
<head>
-
<title>{% block title %}{% endblock %} - Magic Smoke Example Layout</title>
<link rel="stylesheet" type="text/css" href="styles/style.css">
</head>
<body>
+<!-- Begin Menu -->
+<p align="right">
+<a href="{{script.root}}">Ticket Shop</a> |
+<a href="{{script.mycart}}">My Shoping Cart</a> |
+Language:
+{% for lang in languages %}
+ <a href="{{script.setlanguage}}{{lang}}"><img src="images/{{lang}}.png" alt="{{lang}}"/></a>
+{% endfor %}
+</p>
+<!-- End Menu -->
+
<h1>{% display title %} - Magic Smoke Example Layout</h1>
<!-- Begin Form -->
<!-- End Form -->
<hr/>
-<img src="logo.png">
-powered by MagicSmoke.<p>
+<!-- Website Admins: you must preserve the following lines (or offer similar ones, see below) -->
+<p style="font-size: 60%; color: #606060;">
+<img src="images/logo.png" align="left" />
+powered by <a href="http://smoke.silmor.de" target="_new">MagicSmoke</a>.<br/>
You can get the sources of MagicSmoke via Subversion:<br/>
-<tt>svn co https://silmor.de/svn/misc/smoke/trunk smoke</tt><p>
+<tt>svn co https://silmor.de/svn/misc/smoke/trunk smoke</tt></p>
+<!-- end of lines that must be preserved -->
-<b>Note to admins of MagicSmoke based Web-Sites:</b><br/>
+<p><b>Note to admins of MagicSmoke based Web-Sites:</b><br/>
Some lines like the ones above must be visible in any web-page that is rendered by MagicSmoke or
your modifications of it. If you modify MagicSmoke you must give the users the possibility to download
your modifications (as well).<br/>
-See COPYING.AGPL for details.
+See COPYING.AGPL for details.</p>
+</body>
</html>