- add cart functionality
authorpeter <peter@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sat, 3 Nov 2007 16:24:26 +0000 (16:24 +0000)
committerpeter <peter@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sat, 3 Nov 2007 16:24:26 +0000 (16:24 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@65 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

www/inc/cart.php
www/inc/config_manager.php
www/inc/error.php
www/inc/event_listing.php
www/inc/submit.php
www/index.php
www/template/de/cart.html [new file with mode: 0644]
www/template/de/definition.html
www/template/de/eventdetails.html
www/template/de/lang.conf

index 628b147..8f5164c 100644 (file)
@@ -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;
        }
index 0e21f38..f422fec 100644 (file)
@@ -14,7 +14,7 @@ class ConfigManager
        private $configFile;
        private $config;
        
-       public function __construct($file = "lang.conf")
+       public function __construct($file)
        {
                global $template;
                
index 914f0b2..591a4fc 100644 (file)
@@ -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 */
index ccb6f89..f04c2ca 100644 (file)
@@ -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
index 6cc8d93..c646cb2 100644 (file)
 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");
                }
        }
 }
index e7bb2cb..89d7d0a 100644 (file)
@@ -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 (file)
index 0000000..969b5c1
--- /dev/null
@@ -0,0 +1,44 @@
+<h1>Warenkorb</h1>
+
+<div id="ms_form">
+<form action="." method="POST">
+<table class="ms_Table">
+<tr>
+<th>&nbsp;</th>
+<th>Veranstaltung</th>
+<th>Datum</th>
+<th>Uhrzeit</th>
+<th>Kartenpreis</th>
+<th>Anzahl</th>
+<th>Summe</th>
+</tr>
+@TABLEROWS@
+<tr>
+<td colspan="6" class="ms_AlignRight"><b>Summe:</b></td>
+<td class="ms_AlignRight">@TOTALSUM@ &euro;</td>
+</tr>
+</table>
+
+#set:ROW:
+<tr>
+<td><a href=".">L&ouml;schen</a></td>
+<td><a href=".">@EVENTNAME@</a></td>
+<td>@DATE@</td>
+<td class="ms_AlignRight">@TIME@</td>
+<td class="ms_AlignRight">@PRICE@ &euro;</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@ &euro;</td>
+</tr>
+#endset
+
+<div class="ms_ButtonArea">
+<input type="submit" id="ms_button_save" name="@buttonSAVE@" value="Aktualisieren" />
+<input type="submit" id="ms_button_order" name="@buttonORDER@" value="Zur Bestellung" />
+</div>
+</form>
+
+#if:ERROR==true
+@ERRORAREA@
+#endif
+
+</div>
\ No newline at end of file
index 0b80387..8619d2f 100644 (file)
@@ -1,5 +1,14 @@
 #set:ERROR:
-<div>
+<li>
 @MESSAGE@
+</li>
+#endset
+
+#set:ERRORAREA:
+<div class="ms_ErrorArea">
+Folgende Fehler sind aufgetreten:
+<ul>
+@ERRORMESSAGES@
+<ul>
 </div>
 #endset
\ No newline at end of file
index 7202661..329cd7a 100644 (file)
@@ -24,7 +24,7 @@
 </div>
 <div class="ms_FormRow">
 <label for="ms_text_time">Uhrzeit:</label>
-<div id="ms_text_time">@TIME@ Uhr</div>
+<div id="ms_text_time">@TIME@</div>
 </div>
 <div class="ms_FormRow">
 <label for="ms_text_information">Information:</label>
@@ -47,9 +47,7 @@
 </form>
 
 #if:ERROR==true
-<div class="ms_ErrorArea">
-@ERRORMESSAGE@
-</div>
+@ERRORAREA@
 #endif
 
 </div>
\ No newline at end of file
index f3b6c9a..6a468c0 100644 (file)
@@ -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