From 0c6f22b3d0ccd83d45443b52d290359413d9f1ac Mon Sep 17 00:00:00 2001 From: konrad Date: Wed, 30 Dec 2009 20:06:10 +0000 Subject: [PATCH] implemented marking as shipped git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@380 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- src/dialogs/orderwin.cpp | 15 ++++++++++----- wob/order.wolf | 12 ++++++++++++ www/inc/wext/order.php | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/src/dialogs/orderwin.cpp b/src/dialogs/orderwin.cpp index 4a6f118..8cd7c5f 100644 --- a/src/dialogs/orderwin.cpp +++ b/src/dialogs/orderwin.cpp @@ -60,7 +60,7 @@ MOrderWindow::MOrderWindow(QWidget*par,const MOOrder&o) 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")); @@ -866,10 +866,10 @@ void MOrderWindow::createOrder(Create mode) } 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; @@ -890,10 +890,15 @@ void MOrderWindow::shipOrder() 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() diff --git a/wob/order.wolf b/wob/order.wolf index e706bae..70cd756 100644 --- a/wob/order.wolf +++ b/wob/order.wolf @@ -427,6 +427,18 @@ + + + + The order to be marked + 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. + + + + a fresh copy of the changed order + + + diff --git a/www/inc/wext/order.php b/www/inc/wext/order.php index 8e03f00..8a60598 100644 --- a/www/inc/wext/order.php +++ b/www/inc/wext/order.php @@ -190,6 +190,38 @@ class WOOrder extends WOOrderAbstract //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 -- 1.7.2.5