From: konrad Date: Fri, 1 Jan 2010 16:11:01 +0000 (+0000) Subject: reservation to order X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=7dcc2bb3e5bc045ca085c2b65bd510deaad6e05f;p=web%2Fkonrad%2Fsmoke.git reservation to order git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@388 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/src/dialogs/orderwin.cpp b/src/dialogs/orderwin.cpp index 6e6fdea..d4c5338 100644 --- a/src/dialogs/orderwin.cpp +++ b/src/dialogs/orderwin.cpp @@ -815,33 +815,18 @@ void MOrderWindow::cancelOrder() m_state->setText(m_order.orderStatusString());*/ } -void MOrderWindow::createOrder(Create mode) -{/*TODO - MOrder ord; - //handle reservation changes specially - if(m_order.orderStatus()==MOrder::Reserved){ - bool ok=false; - ord=m_order; - switch(mode){ - case CreateOrder:ok=ord.reservationToOrder();break; - case CreateSale:ok=ord.reservationToSale();break; - default:ok=false; - } - if(!ok)return; - }else{ - //handle case of new order - switch(mode){ - case CreateSale:ord=m_order.createSale();break; - case CreateOrder:ord=m_order.createOrder();break; - case CreateReservation:ord=m_order.createReservation();break; - } - if(!ord.isValid())return; +void MOrderWindow::createOrder() +{ + //sanity check + if(m_order.status()!=MOOrder::Reserved)return; + //call server + MTReservationToOrder ro=req->queryReservationToOrder(m_order.orderid()); + if(ro.hasError()){ + QMessageBox::warning(this,tr("Warning"),tr("Error while changing order status: %1").arg(ro.errorString())); + return; } - //display final order - MOrderWindow *ow=new MOrderWindow(parentWidget(),req,ord); - ow->show(); - //undisplay self - close();*/ + m_order=ro.getorder(); + updateData(); } void MOrderWindow::shipOrder() diff --git a/src/dialogs/orderwin.h b/src/dialogs/orderwin.h index 663281f..8d40e82 100644 --- a/src/dialogs/orderwin.h +++ b/src/dialogs/orderwin.h @@ -33,10 +33,6 @@ class MOrderWindow:public QMainWindow /**creates the order window*/ MOrderWindow(QWidget*,const MOOrder&); - private: - /**helper enum for create* methods*/ - enum Create{CreateOrder,CreateSale,CreateReservation}; - private slots: /**internal: updates the labels and the ticket table*/ void updateData(); @@ -90,8 +86,8 @@ class MOrderWindow:public QMainWindow /**mark as shipped*/ void shipOrder(); - /**create a new order*/ - void createOrder(Create mode=CreateOrder); + /**create a new order from a reservation*/ + void createOrder(); private: MOOrder m_order; diff --git a/wob/order.wolf b/wob/order.wolf index 2016357..c6cbefb 100644 --- a/wob/order.wolf +++ b/wob/order.wolf @@ -410,7 +410,15 @@ - + + + + + + + + + diff --git a/www/inc/wext/order.php b/www/inc/wext/order.php index b17875b..718cc9e 100644 --- a/www/inc/wext/order.php +++ b/www/inc/wext/order.php @@ -377,6 +377,27 @@ class WOOrder extends WOOrderAbstract $trans->setorder(WOOrder::fromTableorder($ord)); $trans->setamount($pay); } + + /**called from the ReservationToOrder transaction*/ + public static function reservation2Order($trans) + { + //get order + $ord=WTorder::getFromDB($trans->getorderid()); + if($ord===false){ + $trans->abortWithError(tr("Invalid Order ID.")); + return; + } + //check state + if($ord->status != WTorder::Reserved){ + $trans->abortWithError(tr("This order is not a reservation.")); + return; + } + //change state + $ord->status = WTorder::Sold; + $ord->update(); + //return + $trans->setorder(WOOrder::fromTableorder($ord)); + } }; ?> \ No newline at end of file