$timeout = time()+$CartTimeout ;
// print $timeout;
- $db->insert("cart",array("cartid"=>$id,"timeout"=>$timeout,"shippingaddress"=>"test"));
+ $db->insert("cart",array("cartid"=>$id,"timeout"=>$timeout));
$db->commitTransaction();
}else{
//check that cart exists
{
global $db;
if ($this->isValid()) {
- $db->update("cart", array("shippingaddress"=>$db->escapeString($address)), "cartid=".$db->escapeString($this->cartid));
+ $db->update("cart", array("shippingaddress"=>$address), "cartid=".$db->escapeString($this->cartid));
+ }
+ }
+
+ /**adds the customer comments to the cart*/
+ public function addOrderComments($comment)
+ {
+ global $db;
+ if ($this->isValid()) {
+ $db->update("cart", array("ordercomments"=>$comment), "cartid=".$db->escapeString($this->cartid));
}
}
return false;
}
}
+
+ /**returns the customer comments for the cart*/
+ public function getOrderComments()
+ {
+ global $db;
+ if ($this->isValid()) {
+ $res = $db->select("cart", "ordercomments", "cartid=".$db->escapeString($this->cartid));
+ if (count($res) > 0)
+ return $res[0]["ordercomments"];
+ else
+ return false;
+ }
+ }
};
?>
\ No newline at end of file
$this->id=false;
if($id!==false){
- if ($this->getByID($id)) {
- $res=$db->select("customer", "*", "customerid=".$db->escapeInt($id));
- if (count($res) == 1) {
- $this->email = $res[0]["email"];
- $this->name = $res[0]["name"];
- $this->address = $res[0]["address"];
- $this->contact = $res[0]["contact"];
- }
- }
+ $this->getByID($id);
}
}
/** returns the name of the customer */
public function getName()
{
+ global $db;
if($this->id===false)
return "";
- else
- return $this->name;
+ else {
+ $res = $db->select("customer", "name", "customerid=".$db->escapeInt($this->id));
+ if (count($res) > 0)
+ return $res[0]["name"];
+ else
+ return "";
+ }
}
/** returns the email address of the customer */
public function getEmail()
{
+ global $db;
if($this->id===false)
return "";
- else
- return $this->email;
+ else {
+ $res = $db->select("webuser", "email", "customerid=".$db->escapeInt($this->id));
+ if (count($res) > 0)
+ return $res[0]["email"];
+ else
+ return "";
+ }
+
}
/** returns the address of the customer */
public function getAddress()
{
+ global $db;
if($this->id===false)
return "";
- else
- return $this->address;
+ else {
+ $res = $db->select("customer", "address", "customerid=".$db->escapeInt($this->id));
+ if (count($res) > 0)
+ return $res[0]["address"];
+ else
+ return "";
+ }
+
}
/** returns the contact data of the customer */
public function getContact()
{
+ global $db;
if($this->id===false)
return "";
- else
- return $this->contact;
+ else {
+ $res = $db->select("customer", "contact", "customerid=".$db->escapeInt($this->id));
+ if (count($res) > 0)
+ return $res[0]["contact"];
+ else
+ return "";
+ }
+
}
/**returns the data in an array suitable for the web-page-renderer*/
//when the cart expires
"timeout" => array("int32","notnull"),
//shipping address during order process
- "shippingaddress" => array("text")
+ "shippingaddress" => array("text"),
+ //customer comments during order process
+ "ordercomments" => array("text")
);
//buying tickets
$this->scheme["cart_ticket"]=array(
--- /dev/null
+<?php
+// +----------------------------------------------------------------------
+// | PHP Source
+// +----------------------------------------------------------------------
+// | Copyright (C) 2008 by Peter Keller <peter@silmor.de>
+// +----------------------------------------------------------------------
+// |
+// | Copyright: See COPYING file that comes with this distribution
+// +----------------------------------------------------------------------
+//
+
+/** checks if a variable is empty, needs to be used to check class methods */
+function isEmpty($var)
+{
+ return empty($var);
+}
+
+/** checks if given value is a valid email address */
+function isEmail($value)
+{
+ return ereg("^[a-zA-Z0-9\._-]+@[a-zA-Z0-9\._-]+$", $value);
+}
+
+
+?>
$parser->setVAR("PAGE", $localParser->parseFile("customerregistration.html"));
}
+/**creates the overview of an order */
function createOrderOverview()
{
global $parser;
// set cart overview
$cart = new Cart($_COOKIE[COOKIE_CART]);
+ if ($cart->isValid()) {
+ // renew cart
+ $cart->renewCart();
+
+ $shippingAddress = "";
+ $comments = "";
+
+ if (!isEmpty($shippingAddress = $cart->getShippingAddress()))
+ $shippingAddress .= " (<a href=index.php?mode=editShippingAddress>".i18n("Change")."</a>)";
+ else
+ $shippingAddress = "(<a href=index.php?mode=editShippingAddress>".i18n("Add")."</a>)";
+
+ if (!isEmpty($comments = $cart->getOrderComments()))
+ $comments .= " (<a href=index.php?mode=editOrderComments>".i18n("Change")."</a>)";
+ else
+ $comments = "(<a href=index.php?mode=editOrderComments>".i18n("Add")."</a>)";
+
+ $p->setVar("CUST_SHIPPINGADDRESS", $shippingAddress);
+ $p->setVar("CUST_COMMENTS", $comments);
+ }
$tablerows = "";
$totalsum = 0;
$p->setVar("TABLEROWS", $tablerows);
$p->setVar("TOTALSUM", $lang->getPrice($totalsum));
+ // set edit links
+ $p->setVar("linkEDIT_SHIPPINGADDRESS", "index.php?mode=editShippingAddress");
+ $p->setVar("linkEDIT_COMMENTS", "index.php?mode=editOrderComments");
+
// set buttons
+
// create page
$parser->setVAR("PAGE", $p->parseFile("orderoverview.html"));
}
+/** creates the form to edit the shipping address */
+function editShippingAddress()
+{
+ global $parser;
+
+ $p = new Parser("editshippingaddress.html");
+
+ // check if loggedin
+ $session = new WebSession();
+ if (!$session->isAuthorized()) {
+ Header("Location: index.php");
+ exit();
+ }
+
+ // get shipping address
+ $cart = new Cart($_COOKIE[COOKIE_CART]);
+ if ($cart->isValid()) {
+ $p->setVar("SHIPPINGADDRESS", $cart->getShippingAddress());
+ }
+
+ // set input fields
+ $p->setVar("fieldSHIPPINGADDRESS", "ms_shippingAddress");
+
+ // set buttons
+ $p->setVar("buttonSAVE_SHIPPINGADDRESS", "ms_saveShippingAddress");
+ $p->setVar("buttonCANCEL_SHIPPINGADDRESS", "ms_cancelShippingAddress");
+
+ // create page
+ $parser->setVAR("PAGE", $p->parseFile("editshippingaddress.html"));
+}
+
+/** creates the form to edit the order comments */
+function editOrderComments()
+{
+ global $parser;
+
+ $p = new Parser("editordercomments.html");
+
+ // check if loggedin
+ $session = new WebSession();
+ if (!$session->isAuthorized()) {
+ Header("Location: index.php");
+ exit();
+ }
+
+ // get shipping address
+ $cart = new Cart($_COOKIE[COOKIE_CART]);
+ if ($cart->isValid()) {
+ $p->setVar("COMMENTS", $cart->getOrderComments());
+ }
+
+ // set input fields
+ $p->setVar("fieldCOMMENTS", "ms_comments");
+
+ // set buttons
+ $p->setVar("buttonSAVE_COMMENTS", "ms_saveComments");
+ $p->setVar("buttonCANCEL_COMMENTS", "ms_cancelComments");
+
+ // create page
+ $parser->setVAR("PAGE", $p->parseFile("editordercomments.html"));
+}
+
?>
\ No newline at end of file
}
}
-/** checks if given value is a valid email address */
-function isEmail($value)
+/** saves the shipping address */
+function saveShippingAddress()
{
- return ereg("^[a-zA-Z0-9\._-]+@[a-zA-Z0-9\._-]+$", $value);
+ $error = ErrorManager::singleton();
+
+ if (isset($_POST["ms_saveShippingAddress"])) {
+
+ // check if loggedin
+ $session = new WebSession();
+ if (!$session->isAuthorized()) {
+ Header("Location: index.php");
+ exit();
+ }
+
+ $cart = new Cart($_COOKIE[COOKIE_CART]);
+ if ($cart->isValid()) {
+ $cart->addShippingAddress($_POST["ms_shippingAddress"]);
+ }
+
+ Header("Location: index.php?mode=orderOverview");
+ } else if (isset($_POST["ms_cancelShippingAddress"])) {
+ Header("Location: index.php?mode=orderOverview");
+ exit();
+ }
}
+/** saves the order comments */
+function saveOrderComments()
+{
+ if (isset($_POST["ms_saveComments"])) {
+
+ // check if loggedin
+ $session = new WebSession();
+ if (!$session->isAuthorized()) {
+ Header("Location: index.php");
+ exit();
+ }
+
+ $cart = new Cart($_COOKIE[COOKIE_CART]);
+ if ($cart->isValid()) {
+ $cart->addOrderComments($_POST["ms_comments"]);
+ }
+
+ Header("Location: index.php?mode=orderOverview");
+ } else if (isset($_POST["ms_cancelComments"])) {
+ Header("Location: index.php?mode=orderOverview");
+ exit();
+ }
+}
?>
\ No newline at end of file
include('inc/loader.php');
include('inc/loader_nonadmin.php');
include('inc/global_variables.php');
+include('inc/global_functions.php');
//include process script
include('inc/rendering/submit.php');
case "orderOverview":
createOrderOverview();
break;
+ case "editShippingAddress":
+ saveShippingAddress();
+ editShippingAddress();
+ break;
+ case "editOrderComments":
+ saveOrderComments();
+ editOrderComments();
+ break;
default:
createEventList();
break;
--- /dev/null
+<h1>Hinweis ändern</h1>
+<div id="ms_form">
+<form action="@FULLURL@" method="POST">
+<fieldset class="ms_Form">
+<div class="ms_FormRow">
+<textarea id="ms_textfield_comments" name="@fieldCOMMENTS@" rows="3">@COMMENTS@</textarea>
+</div>
+</fieldset>
+
+<div class="ms_ButtonArea">
+<input type="submit" id="ms_button_save" name="@buttonSAVE_COMMENTS@" value="Speichern" />
+<input type="submit" id="ms_button_cancel" name="@buttonCANCEL_COMMENTS@" value="Abbrechen" />
+</div>
+
+</form>
+</div>
\ No newline at end of file
--- /dev/null
+<h1>Lieferadresse ändern</h1>
+<div id="ms_form">
+<form action="@FULLURL@" method="POST">
+<fieldset class="ms_Form">
+<div class="ms_FormRow">
+<label for="ms_textfield_shippingaddress">Adresse:</label>
+<textarea id="ms_textfield_shippingaddress" name="@fieldSHIPPINGADDRESS@" rows="3">@SHIPPINGADDRESS@</textarea>
+</div>
+</fieldset>
+
+<div class="ms_ButtonArea">
+<input type="submit" id="ms_button_save" name="@buttonSAVE_SHIPPINGADDRESS@" value="Speichern" />
+<input type="submit" id="ms_button_cancel" name="@buttonCANCEL_SHIPPINGADDRESS@" value="Abbrechen" />
+</div>
+</form>
+
+</div>
\ No newline at end of file
</div>
<div class="ms_FormRow">
<label for="ms_text_shippingAddress">Lieferadresse:</label>
-<span id="ms_textfield_shippingAddress"> </span>
+<span id="ms_textfield_shippingAddress">@CUST_SHIPPINGADDRESS@</span>
</div>
<div class="ms_FormRow">
<label for="ms_text_phone">Tel-Nr:</label>
</div>
<div class="ms_FormRow">
<label for="ms_text_comment">Hinweis:</label>
-<span id="ms_text_comment"></span>
+<span id="ms_text_comment">@CUST_COMMENTS@</span>
</div>
</fieldset>
</div>