vl->addLayout(hl=new QHBoxLayout,0);
hl->addStretch(10);
hl->addWidget(p=new QPushButton(tr("Order")));
- p->setEnabled(req->hasRight(req->RCreateOrder));
+ p->setEnabled(req->hasRight(req->RCreateOrder)&&req->hasRight(req->PCreateOrder_CanOrder));
connect(p,SIGNAL(clicked()),this,SLOT(cartOrder()));
+ hl->addWidget(p=new QPushButton(tr("Sell")));
+ p->setEnabled(req->hasRight(req->RCreateOrder)&&req->hasRight(req->PCreateOrder_CanSell));
+ connect(p,SIGNAL(clicked()),this,SLOT(cartSell()));
hl->addWidget(p=new QPushButton(tr("Reserve")));
p->setEnabled(req->hasRight(req->RCreateReservation));
connect(p,SIGNAL(clicked()),this,SLOT(cartReserve()));
cartmodel->removeRow(idx.row());
}
-void MCartTab::cartOrder(bool isreserve)
+void MCartTab::cartOrder(bool isreserve,bool issale)
{
//sanity checks
if(!canorder(isreserve))return;
/////
//send
MOOrder ord;
- if(!orderExecute(cord,ord,isreserve))return;
+ if(!orderExecute(cord,ord,isreserve,issale))return;
/////
//everything ok, move on
if(!ord.orderid().isNull()){
cartOrder(true);
}
+void MCartTab::cartSell()
+{
+ cartOrder(false,true);
+}
+
bool MCartTab::canorder(bool isreserve)
{
//basics
}
}
-bool MCartTab::orderExecute(MOCartOrder&cord,MOOrder&ord,bool isreserve)
+bool MCartTab::orderExecute(MOCartOrder&cord,MOOrder&ord,bool isreserve,bool issale)
{
if(isreserve){
MTCreateReservation co=req->queryCreateReservation(cord);
ord=co.getorder();
cord=co.getcart();
}else{
- MTCreateOrder co=req->queryCreateOrder(cord);
+ MTCreateOrder co=req->queryCreateOrder(cord,issale);
if(co.hasError()){
QMessageBox::warning(this,tr("Warning"),tr("Error while creating order: %1").arg(co.errorString()));
return false;
/**remove item from the cart*/
void cartRemoveItem();
/**create the order on the server*/
- void cartOrder(bool isreserve=false);
+ void cartOrder(bool isreserve=false,bool issale=false);
/**create a reservation on the server*/
void cartReserve();
+ /**create a sale on the server*/
+ void cartSell();
/**reset the colors of the tab*/
void resetColor(bool addronly=false);
/**helper for order: turns the cart table into order items*/
void cartTableToOrder(MOCartOrder&);
/**helper for order: makes the actual order or reserve; returns the result in the first two parameters; returns false if the transaction was aborted and processing should stop here*/
- bool orderExecute(MOCartOrder&cart,MOOrder&order,bool isreserve);
+ bool orderExecute(MOCartOrder&cart,MOOrder&order,bool isreserve,bool issale);
/**helper for order: verifies customer properties*/
void verifyOrderCustomer(MOCartOrder&);
/**helper for order: verifies tickets*/
</Transaction>
<Transaction name="CreateOrder">
- <Doc>CreateOrder creates orders that are queued to be executed immediately, they may contain tickets, vouchers, or shopping items</Doc>
+ <Doc>CreateOrder creates orders that are queued to be executed immediately or sales that are marked executed and paid for immediately; they may contain tickets, vouchers, or shopping items</Doc>
<Privilege name="AnyVoucherValue">users with this privilege can create vouchers with arbitrary value</Privilege>
<Privilege name="DiffVoucherValuePrice">users with this privilege can create vouchers with a price (what the customer pays) different from its value (what the customer can buy with it)</Privilege>
- <Privilege name="LateSale">users with this privilege can sell tickets until the event is over, otherwise a configurable limit applies</Privilege>
+ <Privilege name="LateSale">users with this privilege can sell/order tickets until the event is over, otherwise a configurable limit applies</Privilege>
<Privilege name="AfterTheFactSale">users with this privilege can sell tickets for past events - be careful to give this privilege only to very few special users, it is an invitation to mistakes!</Privilege>
+ <Privilege name="CanOrder">users with this privilege may use this transaction to create orders</Privilege>
+ <Privilege name="CanSell">users with this privilege may use this transaction to create sales</Privilege>
<Input>
<Var name="cart" type="CartOrder">The cart contents</Var>
+ <Var name="issale" type="bool">true if this is a sale, false if this is an order</Var>
</Input>
<Call lang="php" method="WOCartOrder::createOrder($this);"/>
<Output>
//get permissions
global $db;
$isreserve=false;
+ $issale=false;
$vanyval=false;
$vdiffprice=false;
$tsalestop=0;
$tsalestop=self::LateSale;
if($trans->havePrivilege(WTrCreateOrder::Priv_AfterTheFactSale))
$tsalestop=self::AfterSale;
+ $issale=$trans->getissale();
+ if($issale){
+ if(!$trans->havePrivilege(WTrCreateOrder::Priv_CanSell)){
+ $trans->abortWithError(tr("Lacking privileges to create a sale."));
+ return;
+ }
+ }else{
+ if(!$trans->havePrivilege(WTrCreateOrder::Priv_CanOrder)){
+ $trans->abortWithError(tr("Lacking privileges to create an order."));
+ return;
+ }
+ }
}else
if(is_a($trans,"WTrCreateReservation")){
$isreserve=true;
if($trans->havePrivilege(WTrCreateReservation::Priv_LateReserve))
$tsalestop=0;
}else{
- $trans->abortWithError(tr("CreateSale called from an unknown transaction."));
+ $trans->abortWithError(tr("CreateOrder called from an unknown transaction."));
return;
}
//verify necessary elements and content
}
$cart->setstatus(WOCartOrder::Ok);
//create order
- $ord=$cart->createOrderOnDB($trans,$isreserve);
+ $ord=$cart->createOrderOnDB($trans,$isreserve,$issale);
//return verified cart and order
$trans->setorder($ord);
}
/**helper function for createOrder: creates the order on the database*/
- private function createOrderOnDB($trans,$isreserve)
+ private function createOrderOnDB($trans,$isreserve,$issale)
{
global $session;
//create order
$v->insert();
}
//TODO: create items
+ //for sales: update amountpaid and mark shipped
+ if($issale){
+ $oo=WOOrder::fromTableorder($ord);
+ $ord->amountpaid=$oo->getTotalPrice();
+ $ord->senttime=$ord->ordertime;
+ $ord->update();
+ }
//update address use
$ad=WTaddress::getFromDB($ord->invoiceaddress);
if(is_a($ad,"WTaddress")){