From add525ace8622fa6f9f1aff9c471aa7e15bdad9c Mon Sep 17 00:00:00 2001 From: peter Date: Sat, 3 Nov 2007 16:24:26 +0000 Subject: [PATCH] - add cart functionality git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@65 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- www/inc/cart.php | 4 +- www/inc/config_manager.php | 2 +- www/inc/error.php | 6 ++++- www/inc/event_listing.php | 2 +- www/inc/submit.php | 9 ++++--- www/index.php | 4 +++ www/template/de/cart.html | 44 +++++++++++++++++++++++++++++++++++++ www/template/de/definition.html | 11 ++++++++- www/template/de/eventdetails.html | 6 +--- www/template/de/lang.conf | 6 ++++- 10 files changed, 79 insertions(+), 15 deletions(-) create mode 100644 www/template/de/cart.html diff --git a/www/inc/cart.php b/www/inc/cart.php index 628b147..8f5164c 100644 --- a/www/inc/cart.php +++ b/www/inc/cart.php @@ -153,10 +153,10 @@ class Cart { global $db; if($this->cartid===false)return array(); - $res=$db->select("cart_ticket","*","where cartid=".$db->escapeString($this->cartid)); + $res=$db->select("cart_ticket","*","cartid=".$db->escapeString($this->cartid)); $ret=array(); if(count($res)>0) - foreach($res as $k=>$tc) + foreach($res as $k => $tc) $ret[]=new CartTicket($tc["ctid"],$tc["cartid"],$tc["eventid"],$tc["amount"]); return $ret; } diff --git a/www/inc/config_manager.php b/www/inc/config_manager.php index 0e21f38..f422fec 100644 --- a/www/inc/config_manager.php +++ b/www/inc/config_manager.php @@ -14,7 +14,7 @@ class ConfigManager private $configFile; private $config; - public function __construct($file = "lang.conf") + public function __construct($file) { global $template; diff --git a/www/inc/error.php b/www/inc/error.php index 914f0b2..591a4fc 100644 --- a/www/inc/error.php +++ b/www/inc/error.php @@ -42,7 +42,11 @@ class ErrorManager $p->setVar("MESSAGE", $message); $messages .= $p->parse($errorTmpl); } - return $messages; + + $errorArea = $p->getVar("ERRORAREA"); + $p->setVar("ERRORMESSAGES", $messages); + + return $p->parse($errorArea); } /** returns true if errors exist */ diff --git a/www/inc/event_listing.php b/www/inc/event_listing.php index ccb6f89..f04c2ca 100644 --- a/www/inc/event_listing.php +++ b/www/inc/event_listing.php @@ -59,7 +59,7 @@ function createEventDetails() // set error message if ($error->exists()) { $p->setVar("ERROR", "true"); - $p->setVar("ERRORMESSAGE", $error->getAllFormatted()); + $p->setVar("ERRORAREA", $error->getAllFormatted()); } // create page diff --git a/www/inc/submit.php b/www/inc/submit.php index 6cc8d93..c646cb2 100644 --- a/www/inc/submit.php +++ b/www/inc/submit.php @@ -13,18 +13,19 @@ function addEventToCart() { global $error; + global $lang; $COOKIE_NAME = "ms_cartid"; if (isset($_POST["ms_save"])) { $event = new Event($_GET["event"]); if (empty($_POST["ms_amount"])) { - $error->add("Bitte geben Sie eine Kartenmenge an!"); + $error->add($lang->getErrMsg("100")); return; } elseif (!is_numeric($_POST["ms_amount"])) { - $error->add("Bitte geben Sie eine Zahl ein!"); + $error->add($lang->getErrMsg("000")); return; } elseif (!$event->exists()) { - $error->add("Veranstaltung nicht vorhanden!"); + $error->add($lang->getErrMsg("200")); return; } else { $cart = new Cart($_COOKIE[$COOKIE_NAME]); @@ -35,7 +36,7 @@ function addEventToCart() $cart->addTickets($event->getEventId(), $_POST["ms_amount"]); - Header("Location: index.php"); + Header("Location: index.php?mode=cart"); } } } diff --git a/www/index.php b/www/index.php index e7bb2cb..89d7d0a 100644 --- a/www/index.php +++ b/www/index.php @@ -8,6 +8,7 @@ include('inc/submit.php'); //include display scripts include('inc/event_listing.php'); +include('inc/cart_listing.php'); //set common basics $mode="index"; @@ -25,6 +26,9 @@ switch($mode){ addEventToCart(); createEventDetails(); break; + case "cart": + createCartOverview(); + break; default: createEventList(); break; diff --git a/www/template/de/cart.html b/www/template/de/cart.html new file mode 100644 index 0000000..969b5c1 --- /dev/null +++ b/www/template/de/cart.html @@ -0,0 +1,44 @@ +

Warenkorb

+ +
+
+ + + + + + + + + + +@TABLEROWS@ + + + + +
 VeranstaltungDatumUhrzeitKartenpreisAnzahlSumme
Summe:@TOTALSUM@ €
+ +#set:ROW: + +Löschen +@EVENTNAME@ +@DATE@ +@TIME@ +@PRICE@ € + +@ROWSUM@ € + +#endset + +
+ + +
+
+ +#if:ERROR==true +@ERRORAREA@ +#endif + +
\ No newline at end of file diff --git a/www/template/de/definition.html b/www/template/de/definition.html index 0b80387..8619d2f 100644 --- a/www/template/de/definition.html +++ b/www/template/de/definition.html @@ -1,5 +1,14 @@ #set:ERROR: -
+
  • @MESSAGE@ +
  • +#endset + +#set:ERRORAREA: +
    +Folgende Fehler sind aufgetreten: +
      +@ERRORMESSAGES@ +
    #endset \ No newline at end of file diff --git a/www/template/de/eventdetails.html b/www/template/de/eventdetails.html index 7202661..329cd7a 100644 --- a/www/template/de/eventdetails.html +++ b/www/template/de/eventdetails.html @@ -24,7 +24,7 @@
    -
    @TIME@ Uhr
    +
    @TIME@
    @@ -47,9 +47,7 @@ #if:ERROR==true -
    -@ERRORMESSAGE@ -
    +@ERRORAREA@ #endif
    \ No newline at end of file diff --git a/www/template/de/lang.conf b/www/template/de/lang.conf index f3b6c9a..6a468c0 100644 --- a/www/template/de/lang.conf +++ b/www/template/de/lang.conf @@ -7,4 +7,8 @@ DecimalPoint = . ThousandSeparator = , # Error messages -ERR001 = Test \ No newline at end of file +ERR000 = Bitte geben Sie eine Zahl ein! + +ERR100 = Bitte geben Sie eine Kartenmenge an! + +ERR200 = Veranstaltung nicht vorhanden! \ No newline at end of file -- 1.7.2.5