if($this->eventid===false)return false;
return new Event($this->eventid);
}
+
+ /**returns a nice printable string*/
+ public function toString()
+ {
+ $ret="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;
+ }
+ return $ret;
+ }
};
/**this class represents a shopping cart*/
$ret=array();
//go through events
global $db;
+ $itemcnt=0;
$res=$db->select("cart_ticket","*","cartid=".$db->escapeString($this->cartid));
$orderstop=($db->getConfig("OrderStop")+0)*3600;
if(count($res)>0)
$res=$db->select("cart_voucher", "cvid,value", "cartid=".$db->escapeString($this->cartid));
foreach($res as $k=>$vc){
if(in_array("".$vc["value"],$validvouchers))
- $itmcnt++;
+ $itemcnt++;
else
$ret[]=new CartError(CE_INVALIDVOUCHER);
}
//check that we have something to order
- if($itmcnt<=0)
+ if($itemcnt<=0)
$ret[]=new CartError(CE_NOITEMS);
//return...
return $ret;
$this->newtickets[$eid]=$amt;
}
//TODO: get vouchers
+
+ //get other fields
+ $this->deliveryaddress=$cart->getShippingAddress();
+ $this->comment=$cart->getOrderComments();
return true;
}
}
/**sets the customer of this order; returns true on success, false on failure*/
- public function setCustomerid($cust)
+ public function setCustomerId($cust)
{
return $this->setCustomer(new Customer($cust));
}
public function placeOrder($isSale=false)
{
//sanity check
+ print(1);
if(!$this->canChange())return false;
if((count($this->newtickets)+count($this->newvouchers))==0)return false;
+ print("a");
global $db,$session;
$db->beginTransaction();
if(!$this->validateOrder()){
$db->rollbackTransaction();
return false;
}
+ print(2);
//create order
$this->status=ORDER_PLACED;
if(isset($session))$usr=$session->getUser();
$this->ordertime=time();
$this->amountpaid=0;
$this->orderid=$db->insert("order",array("customerid"=>$this->customerid,"soldby"=>$usr,"deliveryaddress"=>$this->deliveryaddress,"status"=>$this->status,"ordertime"=>$this->ordertime,"comments"=>$this->comment,"amountpaid"=>0));
+ print(3);
//orderid ok?
if($this->orderid===false){
$db->rollbackTransaction();
$this->status=ORDER_SENT;
$this->amountpaid=$totalprice;
}
+ print(4);
//end
$db->commitTransaction();
return true;
$cart = new Cart($_COOKIE[COOKIE_CART]);
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());
+ return;
+ }
+ $order=new Order;
+ $order->setCustomer($session->getCustomer());
+ $order->emptyCart($cart);
+ $ret=$order->placeOrder();
+ if($ret===false){
+ //TODO: panic properly!
+ print("unable to order!");
+ return;
+ }
+ //TODO: destroy cart
}
}
}
createCustomerRegistration();
break;
case "orderOverview":
+ orderTickets();
createOrderOverview();
break;
case "editShippingAddress":
</div>
<div class="ms_FormRow">
<label for="ms_textfield_amount">Kartenanzahl:</label>
-<input type="text" id="ms_textfield_amount" name="@fieldAMOUNT@" size="2" maxlength="2"/>
+<input type="text" id="ms_textfield_amount" name="@fieldAMOUNT@" size="2" maxlength="2" value="1"/>
</div>
</fieldset>
#endset