admin command: ChangeComments
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Fri, 1 Jan 2010 13:15:55 +0000 (13:15 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Fri, 1 Jan 2010 13:15:55 +0000 (13:15 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@385 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

src/dialogs/orderwin.cpp
src/dialogs/orderwin.h
wob/order.wolf
www/inc/wext/order.php

index 69e94c5..ba78dcf 100644 (file)
@@ -63,8 +63,10 @@ MOrderWindow::MOrderWindow(QWidget*par,const MOOrder&o)
         ->setEnabled(req->hasRole("changeticketprice"));
        m->addAction(tr("&Return Item..."),this,SLOT(itemReturn()))
         ->setEnabled(req->hasRole("ticketreturn"));
-       m->addAction(tr("Add Commen&t..."),this,SLOT(changeComment()))
+       m->addAction(tr("Add Commen&t..."),this,SLOT(addComment()))
         ->setEnabled(req->hasRight(req->ROrderAddComment));
+       if(req->hasRight(req->ROrderChangeComments))
+        m->addAction(tr("Change C&omments..."),this,SLOT(changeComments()));
        m->addAction(tr("Change Sh&ipping Method..."),this,SLOT(changeShipping()))
         ->setEnabled(req->hasRight(req->ROrderChangeShipping));
        m->addSeparator();
@@ -887,7 +889,40 @@ void MOrderWindow::shipOrder()
        }
 }
 
-void MOrderWindow::changeComment()
+void MOrderWindow::changeComments()
+{
+       //create editor dialog
+       QString cmt=m_order.comments();
+       QDialog d;
+       d.setWindowTitle(tr("Change comments: order %1").arg(m_order.orderid()));
+       QVBoxLayout*vl;
+       d.setLayout(vl=new QVBoxLayout);
+       QTextEdit*te;
+       QLabel*lab;
+       vl->addWidget(te=new QTextEdit,1);
+       te->setPlainText(cmt);
+       vl->addSpacing(15);
+       QHBoxLayout*hl;
+       vl->addLayout(hl=new QHBoxLayout,0);
+       hl->addStretch(10);
+       QPushButton*p;
+       hl->addWidget(p=new QPushButton(tr("&Save")));
+       connect(p,SIGNAL(clicked()),&d,SLOT(accept()));
+       hl->addWidget(p=new QPushButton(tr("&Cancel")));
+       connect(p,SIGNAL(clicked()),&d,SLOT(reject()));
+       //get status
+       if(d.exec()!=QDialog::Accepted)return;
+       //send to server
+       MTOrderChangeComments ac=req->queryOrderChangeComments(m_order.orderid(),te->toPlainText());
+       if(ac.hasError()){
+               QMessageBox::warning(this,tr("Warning"),tr("There was a problem uploading the new comment: %1").arg(ac.errorString()));
+               return;
+       }
+       m_order=ac.getorder();
+       //reset display
+       updateData();
+}
+void MOrderWindow::addComment()
 {
        //create editor dialog
        QString cmt=m_order.comments();
index bdff567..91c724e 100644 (file)
@@ -78,7 +78,9 @@ class MOrderWindow:public QMainWindow
                void itemReturn();
                
                /**change the comment on the order*/
-               void changeComment();
+               void addComment();
+               /**change the comment on the order*/
+               void changeComments();
                
                /**change the shipping option*/
                void changeShipping();
index 80af929..2016357 100644 (file)
        </Transaction>
        
        <Transaction name="OrderAddComment">
+               <Doc>Add a comment to the end of the comments field. Most users will only have this right.</Doc>
                <Input>
                        <Var name="orderid" type="int">the order to be commented upon</Var>
                        <Var name="comment" type="string">the comment</Var>
                        <Var name="order" type="Order">a fresh copy of the changed order</Var>
                </Output>
        </Transaction>
+       <Transaction name="OrderChangeComments">
+               <Doc>For privileges users: edit the complete comments field, overwrite it.</Doc>
+               <Input>
+                       <Var name="orderid" type="int">the order to be commented upon</Var>
+                       <Var name="comments" type="string">the comments</Var>
+               </Input>
+               <Call lang="php" method="WOOrder::changeComments($this);"/>
+               <Output>
+                       <Var name="order" type="Order">a fresh copy of the changed order</Var>
+               </Output>
+       </Transaction>
        
        <Transaction name="GetAllShipping">
                <Input/>
index 54c584c..b17875b 100644 (file)
@@ -246,6 +246,23 @@ class WOOrder extends WOOrderAbstract
                $trans->setorder(WOOrder::fromTableorder($ord));
        }
        
+       /**called from the OrderChangeComments transaction*/
+       public static function changeComments($trans)
+       {
+               global $session;
+               //get order
+               $ord=WTorder::getFromDB($trans->getorderid());
+               if($ord===false){
+                       $trans->abortWithError(tr("Order ID is not valid."));
+                       return;
+               }
+               //modify comment
+               $ord->comments=trim($trans->getcomments()."");
+               $ord->update();
+               //return
+               $trans->setorder(WOOrder::fromTableorder($ord));
+       }
+       
        /**called from the OrderPay transaction*/
        public static function payForOrder($trans)
        {