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;
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);
#include <QApplication>
#include <QBoxLayout>
#include <QComboBox>
+#include <QDateTimeEdit>
#include <QDoubleSpinBox>
#include <QFileDialog>
#include <QGridLayout>
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());
}
}
/**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;
}
}
//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."));
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{
//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)
//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)
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::
*/