From f090256ae8d5aa71f1fd2a54a9865f14f8d6be9a Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 17 Mar 2008 21:04:41 +0000 Subject: [PATCH] - added first part of final ordering git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@129 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- www/inc/classes/cart.php | 24 +++++++++++++++++------- www/inc/rendering/submit.php | 15 +++++++++------ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/www/inc/classes/cart.php b/www/inc/classes/cart.php index d69396f..2f41c87 100644 --- a/www/inc/classes/cart.php +++ b/www/inc/classes/cart.php @@ -106,14 +106,14 @@ class CartError /**returns a nice printable string*/ public function toString() { - $ret="Error: "; + $ret=i18n("Error: "); switch($this->etype){ - case CE_NOITEMS:$ret.="No items in cart.";break; - case CE_EVENTCANCELLED:$ret.="Event has been cancelled.";break; - case CE_EVENTNOTICKETS:$ret.="No more tickets available.";break; - case CE_EVENTUNKNOWN:$ret.="Unknown Event.";break; - case CE_EVENTOVER:$ret.="Cannot order tickets from past.";break; - case CE_INVALIDVOUCHER:$ret="Voucher is invalid.";break; + case CE_NOITEMS:$ret.=i18n("No items in cart.");break; + case CE_EVENTCANCELLED:$ret.=i18n("Event has been cancelled.");break; + case CE_EVENTNOTICKETS:$ret.=i18n("No more tickets available.");break; + case CE_EVENTUNKNOWN:$ret.=i18n("Unknown Event.");break; + case CE_EVENTOVER:$ret.=i18n("Cannot order tickets from past.");break; + case CE_INVALIDVOUCHER:$ret=i18n("Voucher is invalid.");break; } return $ret; } @@ -279,6 +279,16 @@ class Cart } } + /**deletes a cart and all its tickets */ + public function destroyCart() + { + global $db; + if ($this->isValid()) { + $db->deleteRows("cart_ticket", "cartid=".$db->escapeInt($this->cartid)); + $db->deleteRows("cart", "cartid=".$db->escapeInt($this->cartid)); + } + } + /**adds the shipping address to the cart*/ public function addShippingAddress($address) { diff --git a/www/inc/rendering/submit.php b/www/inc/rendering/submit.php index 06f7009..5e3f3c8 100644 --- a/www/inc/rendering/submit.php +++ b/www/inc/rendering/submit.php @@ -319,10 +319,13 @@ function saveOrderComments() } } +/** orders the tickets */ function orderTickets() { if (isset($_POST["ms_orderTickets"])) { + $error = ErrorManager::singleton(); + // check if loggedin $session = new WebSession(); if (!$session->isAuthorized()) { @@ -334,10 +337,8 @@ function orderTickets() if ($cart->isValid()) { $check=$cart->orderCheck(); if(count($check)>0){ - //TODO: do something useful with that... - print("cart failed order check"); foreach($check as $err) - print($err->toString()); + $error->add($err->toString()); return; } $order=new Order; @@ -345,11 +346,13 @@ function orderTickets() $order->emptyCart($cart); $ret=$order->placeOrder(); if($ret===false){ - //TODO: panic properly! - print("unable to order!"); + $error->add(i18n("Can't order!")); return; } - //TODO: destroy cart + $cart->destroyCart(); + setcookie(COOKIE_CART, "", 1); + } else { + $error->add(i18n("Cart is not valid!")); } } } -- 1.7.2.5