- added order overview
authorpeter <peter@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sun, 2 Mar 2008 13:53:41 +0000 (13:53 +0000)
committerpeter <peter@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sun, 2 Mar 2008 13:53:41 +0000 (13:53 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@103 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

www/inc/classes/websession.php
www/inc/rendering/order_listing.php
www/inc/rendering/submit.php
www/index.php
www/template/de/orderoverview.html [new file with mode: 0644]

index 3c65692..ad2ce16 100644 (file)
@@ -17,7 +17,7 @@ class Websession {
                //default:
                $this->loggedin=false;
                $this->customerid=null;
-
+               
                //check cookie
                if(isset($_COOKIE[COOKIE_WEBSESSION])){
                        $res = $db->select("websession", "*", "sessionid=".$db->escapeString($_COOKIE[COOKIE_WEBSESSION]));
@@ -29,8 +29,9 @@ class Websession {
                                if ($customer->exists()) {
                                        $this->customerid = $customer->getID();
                                        $this->loggedin = true;
-                               } else
+                               } else {
                                        $this->destroySession();
+                               }
                        }
                }
        }
@@ -54,6 +55,7 @@ class Websession {
        public function createSession($customerId)
        {
                global $db;
+               global $WebSessionTimeout;
        
                $this->destroySession();
                
@@ -80,13 +82,14 @@ class Websession {
        }
        
        /** destroys the current session */
-       private function destroySession()
+       public function destroySession()
        {
                global $db;
                
                if($this->loggedin){
                        $db->deleteRows("websession", "sessionid=".$db->escapeString($this->sessionid));
                }
+
                setcookie(COOKIE_WEBSESSION, "", 1);
        }
        
index 8f7b199..0ec3661 100644 (file)
@@ -16,6 +16,10 @@ function createOrderLogin()
        
        $error = ErrorManager::singleton();
        
+       // delete last web session
+       $session = new WebSession();
+       $session->destroySession();
+       
        $localParser = new Parser("orderlogin.html");
        
        $localParser->setVar("fieldEMAIL", "ms_email");
@@ -98,4 +102,69 @@ function createCustomerRegistration()
        $parser->setVAR("PAGE", $localParser->parseFile("customerregistration.html"));
 }
 
+function createOrderOverview()
+{      
+       global $parser;
+       
+       $error = ErrorManager::singleton();
+       $lang = LanguageManager::singleton();
+
+       $p = new Parser("orderoverview.html");
+       
+       // check if loggedin
+       $session = new WebSession();
+       if (!$session->isAuthorized()) {
+               Header("Location: index.php");
+               exit();
+       }
+       
+       // set costumer data
+       $customer = $session->getCustomer();
+       $p->setVars($customer->getParserData());
+       
+       // set cart overview
+       $cart = new Cart($_COOKIE[COOKIE_CART]);
+       
+       $tablerows = "";
+       $totalsum = 0;
+       $hiddenfields = "";
+       
+       // get tickets from cart
+       foreach ($cart->getTickets() as $ticket)
+       {
+               $cartRowTmpl = $p->getVar("ROW");
+               $event = $ticket->eventObject();
+               
+               // set event details
+               $p->setVars($event->getParserData());
+               
+               // set amount
+               $p->setVar("AMOUNT", $ticket->getAmount());
+               
+               // set row sum
+               $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", "");
+       }
+       
+       $p->setVar("TABLEROWS", $tablerows);
+       $p->setVar("TOTALSUM", $lang->getPrice($totalsum));
+       
+       // set buttons
+       
+       // create page
+       $parser->setVAR("PAGE", $p->parseFile("orderoverview.html"));
+}
+
 ?>
\ No newline at end of file
index 5dbf57b..d270f9d 100644 (file)
@@ -184,14 +184,16 @@ function checkOrderLogin()
                        $customer = new Customer();
                        $customer->getByMail($_POST["ms_email"]);
                        if ($customer->authenticate($_POST["ms_password"])) {
-                               // create web session
+                               // create web session for user
                                $session = new Websession();
                                $session->createSession($customer->getID());
+                               
                                // go to order overview
-                               Header("Location: index.php?mode=userdata");
+                               Header("Location: index.php?mode=orderOverview");
                                exit();
                        } else {
                                $error->add(i18n("eMail or Password wrong"));
+                               return;
                        }
                        
                // if radio button is not checked
@@ -256,10 +258,13 @@ function registerUser()
                        $customer->setContact($_POST["ms_custContact"]);
                }
                
+               // create web session for user
                $session = new Websession();
                $session->createSession($customer->getID());
                
                // redirect to overview page
+               Header("Location: index.php?mode=orderOverview");
+               exit();
        }
 }
 
index 266b810..23e2d7f 100644 (file)
@@ -39,6 +39,9 @@ switch($mode){
                registerUser();
                createCustomerRegistration();
                break;
+       case "orderOverview":
+               createOrderOverview();
+               break;
        default:
                createEventList();
                break;
diff --git a/www/template/de/orderoverview.html b/www/template/de/orderoverview.html
new file mode 100644 (file)
index 0000000..7b123c3
--- /dev/null
@@ -0,0 +1,72 @@
+<h1>Bestellung - &Uuml;bersicht</h1>
+<div id="ms_overview">
+<div id="address">
+<h2>Nutzerdaten:</h2>
+<fieldset class="ms_Form">
+<div class="ms_FormRow">
+<label for="ms_text_email">E-Mail-Adresse:</label>
+<span id="ms_text_email">@CUST_EMAIL@</span>
+</div>
+<div class="ms_FormRow">
+<label for="ms_text_name">Name:</label>
+<span id="ms_text_name">@CUST_NAME@</span>
+</div>
+<div class="ms_FormRow">
+<label for="ms_text_address">Adresse:</label>
+<span id="ms_text_address">@CUST_ADDRESS@</span>
+</div>
+<div class="ms_FormRow">
+<label for="ms_text_shippingAddress">Lieferadresse:</label>
+<span id="ms_textfield_shippingAddress">&nbsp;</span>
+</div>
+<div class="ms_FormRow">
+<label for="ms_text_phone">Tel-Nr:</label>
+<span id="ms_text_phone">@CUST_CONTACT@</span>
+</div>
+<div class="ms_FormRow">
+<label for="ms_text_comment">Hinweis:</label>
+<span id="ms_text_comment"></span>
+</div>
+</fieldset>
+</div>
+<div id="tickets">
+<h2>Karten:</h2>
+<table class="ms_Table">
+<tr>
+<th>Veranstaltung</th>
+<th>Datum</th>
+<th>Uhrzeit</th>
+<th>Kartenpreis</th>
+<th>Anzahl</th>
+<th>Summe</th>
+</tr>
+@TABLEROWS@
+
+#set:ROW:
+<tr>
+<td><a href="@LINK@">@EVENTNAME@</a></td>
+<td>@DATE@</td>
+<td class="ms_AlignRight">@TIME@</td>
+<td class="ms_AlignRight">@PRICE@ &euro;</td>
+<td class="ms_AlignRight">@AMOUNT@</td>
+<td class="ms_AlignRight">@ROWSUM@ &euro;</td>
+</tr>
+#endset
+
+#set:EMPTYROWS:
+<tr><td colspan="6">Sie haben keine Veranstaltungen im Warenkorb.</td></tr>
+#endset
+
+<tr>
+<td colspan="5" class="ms_AlignRight"><b>Summe:</b></td>
+<td class="ms_AlignRight">@TOTALSUM@ &euro;</td>
+</tr>
+</table>
+</div>
+
+<form action="@FULLURL@" method="POST">
+<div class="ms_ButtonArea">
+<input type="submit" id="ms_button_order" name="ms_order" @attribDISABLED@ value="Jetzt bestellen!" />
+</div>
+</form>
+</div>
\ No newline at end of file