/**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();
/**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);
}
/**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
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
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");
}
}
//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
.blocksatz {text-align:justify;}\r
\r
.ms_Form {border: none;}\r
-.ms_FormRow {margin-top: 5px; margin-bottom: 5px;}\r
-.ms_FormRow label {font-weight:bold;width:150px;float:left;}\r
+.ms_FormRow {clear:both; padding-top: 5px; padding-bottom: 5px; }\r
+.ms_FormRow label {font-weight:bold; width:150px; float:left;}\r
\r
.ms_Table {border-collapse: collapse;}\r
.ms_Table th {padding: 7px; border: 1px solid black; text-align: center;}\r
<fieldset class="ms_Form">
<div class="ms_FormRow">
<label for="ms_text_event">Veranstaltung:</label>
-<span id="ms_text_event">@EVENTNAME@</span>
+<div id="ms_text_event">@EVENTNAME@</div>
</div>
<div class="ms_FormRow">
-<label for="ms_text_place">Ort:</label>
-<span id="ms_text_place">@PLACE@</span>
+<label for="ms_text_artist">Künstler:</label>
+<div id="ms_text_artist">@ARTIST@</div>
</div>
<div class="ms_FormRow">
-<label for="ms_text_artist">Künstler:</label>
-<span id="ms_text_artist">@ARTIST@</span>
+<label for="ms_text_place">Ort:</label>
+<div id="ms_text_place">@PLACE@</div>
</div>
<div class="ms_FormRow">
<label for="ms_text_date">Datum:</label>
-<span id="ms_text_date">@DATE@</span>
+<div id="ms_text_date">@DATE@</div>
</div>
<div class="ms_FormRow">
<label for="ms_text_time">Uhrzeit:</label>
-<span id="ms_text_time">@TIME@ Uhr</span>
+<div id="ms_text_time">@TIME@ Uhr</div>
</div>
<div class="ms_FormRow">
<label for="ms_text_information">Information:</label>
-<span id="ms_text_information">@DESCRIPTION@</span>
+<div id="ms_text_information">@DESCRIPTION@</div>
</div>
<div class="ms_FormRow">
<label for="ms_text_price">Kartenpreis:</label>
-<span id="ms_text_price">@PRICE@ €</span>
+<div id="ms_text_price">@PRICE@ €</div>
</div>
<div class="ms_FormRow">
<label for="ms_textfield_amount">Kartenanzahl:</label>