From: konrad Date: Sun, 7 Dec 2008 16:53:55 +0000 (+0000) Subject: explicit setting of shipping time X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=160b67130580b21842b5a71dea76dd1a91760468;p=konrad%2Fsmoke.git explicit setting of shipping time git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@210 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/src/order.cpp b/src/order.cpp index 3713b93..0ad8987 100644 --- a/src/order.cpp +++ b/src/order.cpp @@ -555,9 +555,14 @@ bool MOrder::cancelOrder() return r; } -bool MOrder::shipOrder() +bool MOrder::shipOrder(QDateTime tm) { - if(!req->request("ordershipped",QByteArray::number(m_orderid)))return false; + QByteArray rq=QByteArray::number(m_orderid); + if(req->hasRole("_explicitshipdate")){ + rq+="\n"; + rq+=QByteArray::number(tm.toTime_t()); + } + if(!req->request("ordershipped",rq))return false; bool r=req->responseStatus()==MWebRequest::Ok; if(r){ m_status=Sent; diff --git a/src/order.h b/src/order.h index be58101..170de63 100644 --- a/src/order.h +++ b/src/order.h @@ -422,7 +422,7 @@ class MOrder bool cancelOrder(); /**mark the order as shipped; queries DB; returns true on success*/ - bool shipOrder(); + bool shipOrder(QDateTime tm=QDateTime::currentDateTime()); /**set a new comment and immediately send it to the server (will not set the comment if the server rejects it); returns whether setting was successful*/ bool sendComment(QString); diff --git a/src/orderwin.cpp b/src/orderwin.cpp index b3e4d61..43432f8 100644 --- a/src/orderwin.cpp +++ b/src/orderwin.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -836,7 +837,29 @@ void MOrderWindow::recheckOrder() void MOrderWindow::shipOrder() { if(QMessageBox::question(this,tr("Mark as shipped?"),tr("Mark this order as shipped now?"),QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes)==QMessageBox::Yes){ - m_order.shipOrder(); + QDateTime tm=QDateTime::currentDateTime(); + if(req->hasRole("_explicitshipdate")){ + QDialog d; + d.setWindowTitle(tr("Set shipping time")); + QHBoxLayout*hl; + QVBoxLayout*vl; + QPushButton*p; + QDateTimeEdit*dte; + d.setLayout(vl=new QVBoxLayout); + vl->addWidget(new QLabel(tr("Enter the shipping time:"))); + vl->addWidget(dte=new QDateTimeEdit(tm)); + vl->addSpacing(10); + vl->addStretch(10); + vl->addLayout(hl=new QHBoxLayout); + hl->addStretch(10); + hl->addWidget(p=new QPushButton(tr("OK"))); + connect(p,SIGNAL(clicked()),&d,SLOT(accept())); + hl->addWidget(p=new QPushButton(tr("Cancel"))); + connect(p,SIGNAL(clicked()),&d,SLOT(reject())); + if(d.exec()!=QDialog::Accepted)return; + tm=dte->dateTime(); + } + m_order.shipOrder(tm); m_state->setText(m_order.orderStatusString()); m_sentdate->setText(m_order.sentDateTimeStr()); } diff --git a/www/inc/classes/order.php b/www/inc/classes/order.php index 7377551..12eebdb 100644 --- a/www/inc/classes/order.php +++ b/www/inc/classes/order.php @@ -611,12 +611,13 @@ class Order } /**sets the order to being shipped, returns true on success*/ - public function setShipped() + public function setShipped($stm=-1) { if(!$this->isValid())return false; if($this->status!=ORDER_PLACED)return false; global $db; - $this->senttime=time(); + if($stm<0)$stm=time(); + $this->senttime=$stm; $db->update("order",array("status"=>ORDER_SENT,"senttime"=>$this->senttime),"orderid=".$db->escapeInt($this->orderid)); return true; } @@ -920,8 +921,10 @@ function orderPayXml($data,$factor) } //mark order as shipped -function orderShippedXml($oid) +function orderShippedXml($txt) { + $spl=split("\n",$txt); + $oid=trim($spl[0]); if(!is_numeric($oid)){ header("X-MagicSmoke-Status: Error"); die(tr("Order ID must be numeric.")); @@ -936,7 +939,16 @@ function orderShippedXml($oid) header("X-MagicSmoke-Status: Error"); die(tr("Order ID is invalid.")); } - if($ord->setShipped()){ + //check for date (-1=now) + global $session; + $sd=-1; + if(count($spl)>1 && $session->canExecute("_explicitshipdate")){ + $sd=trim($spl[1]); + if(is_numeric($sd))$sd=$sd+0; + else $sd=-1; + } + //set it + if($ord->setShipped($sd)){ header("X-MagicSmoke-Status: Ok"); print($ord->getSentTime()); }else{ diff --git a/www/inc/machine/version.inc b/www/inc/machine/version.inc index 6589908..c510b27 100644 --- a/www/inc/machine/version.inc +++ b/www/inc/machine/version.inc @@ -13,7 +13,7 @@ //minimum version that the server understands (4 hex digits) defversion(MINSERVER,0000) //current version of the server -defversion(CURSERVER,0004) +defversion(CURSERVER,0005) //current human readable version of the server defversion(HRSERVER,0.2 beta) @@ -21,7 +21,7 @@ defversion(HRSERVER,0.2 beta) //minimum version that the client requires defversion(MINCLIENT,0000) //current version of the client -defversion(CURCLIENT,0004) +defversion(CURCLIENT,0005) //current human readable version of the client defversion(HRCLIENT,0.2 beta) diff --git a/www/machine.php b/www/machine.php index 7714643..dab527c 100644 --- a/www/machine.php +++ b/www/machine.php @@ -57,7 +57,8 @@ $SPECIALROLES=array( tr("_anyshipping"),//user can assign any kind of shipping tr("_repriceshipping"),//user may alter shipping price tr("_anyvoucher"),//user may generate vouchers of any value/price, not just configured ones - tr("_anypricevoucher")//user may generate vouchers with price different from value + tr("_anypricevoucher"),//user may generate vouchers with price different from value + tr("_explicitshipdate")//user may set an explicit shipping date ); /* TRANSLATOR php:: */