From a251efd40ea5438a90eb0e472ed62a8e300fa4c3 Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 2 Mar 2008 13:53:41 +0000 Subject: [PATCH] - added order overview git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@103 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- www/inc/classes/websession.php | 9 +++- www/inc/rendering/order_listing.php | 69 +++++++++++++++++++++++++++++++++ www/inc/rendering/submit.php | 9 +++- www/index.php | 3 + www/template/de/orderoverview.html | 72 +++++++++++++++++++++++++++++++++++ 5 files changed, 157 insertions(+), 5 deletions(-) create mode 100644 www/template/de/orderoverview.html diff --git a/www/inc/classes/websession.php b/www/inc/classes/websession.php index 3c65692..ad2ce16 100644 --- a/www/inc/classes/websession.php +++ b/www/inc/classes/websession.php @@ -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); } diff --git a/www/inc/rendering/order_listing.php b/www/inc/rendering/order_listing.php index 8f7b199..0ec3661 100644 --- a/www/inc/rendering/order_listing.php +++ b/www/inc/rendering/order_listing.php @@ -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 diff --git a/www/inc/rendering/submit.php b/www/inc/rendering/submit.php index 5dbf57b..d270f9d 100644 --- a/www/inc/rendering/submit.php +++ b/www/inc/rendering/submit.php @@ -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(); } } diff --git a/www/index.php b/www/index.php index 266b810..23e2d7f 100644 --- a/www/index.php +++ b/www/index.php @@ -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 index 0000000..7b123c3 --- /dev/null +++ b/www/template/de/orderoverview.html @@ -0,0 +1,72 @@ +

Bestellung - Übersicht

+
+
+

Nutzerdaten:

+
+
+ +@CUST_EMAIL@ +
+
+ +@CUST_NAME@ +
+
+ +@CUST_ADDRESS@ +
+
+ +  +
+
+ +@CUST_CONTACT@ +
+
+ + +
+
+
+
+

Karten:

+ + + + + + + + + +@TABLEROWS@ + +#set:ROW: + + + + + + + + +#endset + +#set:EMPTYROWS: + +#endset + + + + + +
VeranstaltungDatumUhrzeitKartenpreisAnzahlSumme
@EVENTNAME@@DATE@@TIME@@PRICE@ €@AMOUNT@@ROWSUM@ €
Sie haben keine Veranstaltungen im Warenkorb.
Summe:@TOTALSUM@ €
+
+ +
+
+ +
+
+
\ No newline at end of file -- 1.7.2.5