explicit setting of shipping time
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sun, 7 Dec 2008 16:53:55 +0000 (16:53 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sun, 7 Dec 2008 16:53:55 +0000 (16:53 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@210 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

src/order.cpp
src/order.h
src/orderwin.cpp
www/inc/classes/order.php
www/inc/machine/version.inc
www/machine.php

index 3713b93..0ad8987 100644 (file)
@@ -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;
index be58101..170de63 100644 (file)
@@ -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);
index b3e4d61..43432f8 100644 (file)
@@ -21,6 +21,7 @@
 #include <QApplication>
 #include <QBoxLayout>
 #include <QComboBox>
+#include <QDateTimeEdit>
 #include <QDoubleSpinBox>
 #include <QFileDialog>
 #include <QGridLayout>
@@ -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());
        }
index 7377551..12eebdb 100644 (file)
@@ -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{
index 6589908..c510b27 100644 (file)
@@ -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)
index 7714643..dab527c 100644 (file)
@@ -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::
 */