From: peter Date: Sun, 21 Oct 2007 21:46:48 +0000 (+0000) Subject: - added functionality to submit X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=4e6c2ca83dacc63ff899ccbe6bc15cfba0cb7ae4;p=web%2Fkonrad%2Fsmoke.git - added functionality to submit git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@63 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/www/inc/cart.php b/www/inc/cart.php index 8fd4777..628b147 100644 --- a/www/inc/cart.php +++ b/www/inc/cart.php @@ -151,6 +151,7 @@ class Cart /**use this to get all existing tickets in this cart, then manipulate the tickets directly*/ public function getTickets() { + global $db; if($this->cartid===false)return array(); $res=$db->select("cart_ticket","*","where cartid=".$db->escapeString($this->cartid)); $ret=array(); @@ -163,13 +164,14 @@ class Cart /**use this to add tickets, returns new CartTicket object or false if the event does not exist or is cancelled*/ public function addTickets($eventid,$amount) { + global $db; //sanity check if($amount<=0)return false; //check that ticket can be sold $event=new Event($eventid); if($event->isCancelled())return false; //insert into cart - $nid=$db->insert("cart_ticket",array("cartid"=>$this->cartid,"eventid"=$eventid,"amount"=>$amount)); + $nid=$db->insert("cart_ticket",array("cartid"=>$this->cartid,"eventid"=>$eventid,"amount"=>$amount)); if($nid===false)return false; return new CartTicket($nid,$this->cartid,$eventid,$amount); } @@ -177,6 +179,7 @@ class Cart /**checks that the whole content of the cart can be ordered; returns an empty array on success or an array of CartError objects on failure*/ public function orderCheck() { + global $db; //TODO: extend to differentiate online, shop and direct sale $ret=array(); //go through events diff --git a/www/inc/loader_nonadmin.php b/www/inc/loader_nonadmin.php index ce0d6d3..7ae349c 100644 --- a/www/inc/loader_nonadmin.php +++ b/www/inc/loader_nonadmin.php @@ -7,4 +7,9 @@ include('./inc/event.php'); include('./inc/room.php'); include("./inc/random.php"); include("./inc/order.php"); +include("./inc/cart.php"); +include('inc/error.php'); +include('inc/language_manager.php'); +include('inc/parser.php'); + ?> \ No newline at end of file diff --git a/www/inc/submit.php b/www/inc/submit.php index 272a2ab..6cc8d93 100644 --- a/www/inc/submit.php +++ b/www/inc/submit.php @@ -13,13 +13,28 @@ function addEventToCart() { global $error; + $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!"); return; + } elseif (!is_numeric($_POST["ms_amount"])) { + $error->add("Bitte geben Sie eine Zahl ein!"); + return; + } elseif (!$event->exists()) { + $error->add("Veranstaltung nicht vorhanden!"); + return; } else { - // TODO: add to cart + $cart = new Cart($_COOKIE[$COOKIE_NAME]); + if (!$cart->isValid()) { + $cart = new Cart(); + setcookie($COOKIE_NAME, $cart->getCartId(), 0); + } + + $cart->addTickets($event->getEventId(), $_POST["ms_amount"]); + Header("Location: index.php"); } } diff --git a/www/index.php b/www/index.php index eb72b5f..e7bb2cb 100644 --- a/www/index.php +++ b/www/index.php @@ -2,11 +2,8 @@ //basics include('inc/loader.php'); include('inc/loader_nonadmin.php'); -include('inc/parser.php'); -include('inc/error.php'); -include('inc/language_manager.php'); -//include +//include process script include('inc/submit.php'); //include display scripts diff --git a/www/styles/style.css b/www/styles/style.css index 1c757d0..2ce3b02 100644 --- a/www/styles/style.css +++ b/www/styles/style.css @@ -33,8 +33,8 @@ p {line-height:130%; margin-left:30px; margin-right:30px; margin-top:15px; mar .blocksatz {text-align:justify;} .ms_Form {border: none;} -.ms_FormRow {margin-top: 5px; margin-bottom: 5px;} -.ms_FormRow label {font-weight:bold;width:150px;float:left;} +.ms_FormRow {clear:both; padding-top: 5px; padding-bottom: 5px; } +.ms_FormRow label {font-weight:bold; width:150px; float:left;} .ms_Table {border-collapse: collapse;} .ms_Table th {padding: 7px; border: 1px solid black; text-align: center;} diff --git a/www/template/de/eventdetails.html b/www/template/de/eventdetails.html index b462bf3..7202661 100644 --- a/www/template/de/eventdetails.html +++ b/www/template/de/eventdetails.html @@ -8,31 +8,31 @@
-@EVENTNAME@ +
@EVENTNAME@
- -@PLACE@ + +
@ARTIST@
- -@ARTIST@ + +
@PLACE@
-@DATE@ +
@DATE@
-@TIME@ Uhr +
@TIME@ Uhr
-@DESCRIPTION@ +
@DESCRIPTION@
-@PRICE@ € +
@PRICE@ €