m->addAction(tr("C&ancel Order..."),this,SLOT(cancelOrder()))
->setEnabled(req->hasRight(req->RCancelOrder));
m->addAction(tr("&Mark Order as Shipped..."),this,SLOT(shipOrder()))
- ->setEnabled(req->hasRole("ordershipped"));
+ ->setEnabled(req->hasRight(req->ROrderMarkShipped));
m->addSeparator();
m->addAction(tr("Ch&ange Item-Price..."),this,SLOT(changeItem()))
->setEnabled(req->hasRole("changeticketprice"));
}
void MOrderWindow::shipOrder()
-{/*TODO
+{
if(QMessageBox::question(this,tr("Mark as shipped?"),tr("Mark this order as shipped now?"),QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes)==QMessageBox::Yes){
QDateTime tm=QDateTime::currentDateTime();
- if(req->hasRole("_explicitshipdate")){
+ if(req->hasRight(req->POrderMarkShipped_SetTime)){
QDialog d;
d.setWindowTitle(tr("Set shipping time"));
QHBoxLayout*hl;
if(d.exec()!=QDialog::Accepted)return;
tm=dte->dateTime();
}
- m_order.shipOrder(tm);
+ MTOrderMarkShipped ms=req->queryOrderMarkShipped(m_order.orderid(),tm.toTime_t());
+ if(ms.hasError()){
+ QMessageBox::warning(this,tr("Warning"),tr("Error while marking order as shipped: %1").arg(ms.errorString()));
+ return;
+ }
+ m_order=ms.getorder();
m_state->setText(m_order.orderStatusString());
m_sentdate->setText(m_order.sentDateTimeStr());
- }*/
+ }
}
void MOrderWindow::changeComment()
</Output>
</Transaction>
+ <Transaction name="OrderMarkShipped">
+ <Privilege name="SetTime"/>
+ <Input>
+ <Var name="orderid" type="int">The order to be marked</Var>
+ <Var name="shiptime" type="int64">The time when it was shipped. If the user does not have the SetTime privilege or if this property is <=0 the current date/time is set instead.</Var>
+ </Input>
+ <Call lang="php" method="WOOrder::markAsShipped($this);"/>
+ <Output>
+ <Var name="order" type="Order">a fresh copy of the changed order</Var>
+ </Output>
+ </Transaction>
+
<Transaction name="GetAllShipping">
<Input/>
<Call lang="php" method="$this->setshipping(WOShipping::fromTableArrayshipping(WTshipping::selectFromDB()));"/>
//return order
$trans->setorder(WOOrder::fromTableorder($ord));
}
+
+ /**called from the OrderMarkShipped transaction*/
+ public static function markAsShipped($trans)
+ {
+ //get order
+ $ord=WTorder::getFromDB($trans->getorderid());
+ if($ord===false){
+ $trans->abortWithError(tr("Order ID is not valid."));
+ return;
+ }
+ if($ord->senttime !== null && $ord->senttime > 0){
+ $trans->abortWithError(tr("Order has already been shipped."));
+ return;
+ }
+ if($ord->status != WTorder::Placed){
+ $trans->abortWithError(tr("Order is in the wrong state."));
+ return;
+ }
+ //get timestamp
+ $tm=time();
+ if($trans->havePrivilege(WtrOrderMarkShipped::Priv_SetTime)){
+ $tmt=$trans->getshiptime();
+ if($tmt!==false && $tmt >0)
+ $tm=$tmt;
+ }
+ //update
+ $ord->senttime=$tm;
+ $ord->status=WTorder::Sent;
+ $ord->update();
+ //return
+ $trans->setorder(WOOrder::fromTableorder($ord));
+ }
};
?>
\ No newline at end of file