From 48237a607d1b9f0f999898b884b705acebecfe6a Mon Sep 17 00:00:00 2001 From: konrad Date: Fri, 1 Jan 2010 13:15:55 +0000 Subject: [PATCH] admin command: ChangeComments git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@385 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- src/dialogs/orderwin.cpp | 39 +++++++++++++++++++++++++++++++++++++-- src/dialogs/orderwin.h | 4 +++- wob/order.wolf | 12 ++++++++++++ www/inc/wext/order.php | 17 +++++++++++++++++ 4 files changed, 69 insertions(+), 3 deletions(-) diff --git a/src/dialogs/orderwin.cpp b/src/dialogs/orderwin.cpp index 69e94c5..ba78dcf 100644 --- a/src/dialogs/orderwin.cpp +++ b/src/dialogs/orderwin.cpp @@ -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(); diff --git a/src/dialogs/orderwin.h b/src/dialogs/orderwin.h index bdff567..91c724e 100644 --- a/src/dialogs/orderwin.h +++ b/src/dialogs/orderwin.h @@ -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(); diff --git a/wob/order.wolf b/wob/order.wolf index 80af929..2016357 100644 --- a/wob/order.wolf +++ b/wob/order.wolf @@ -477,6 +477,7 @@ + Add a comment to the end of the comments field. Most users will only have this right. the order to be commented upon the comment @@ -486,6 +487,17 @@ a fresh copy of the changed order + + For privileges users: edit the complete comments field, overwrite it. + + the order to be commented upon + the comments + + + + a fresh copy of the changed order + + diff --git a/www/inc/wext/order.php b/www/inc/wext/order.php index 54c584c..b17875b 100644 --- a/www/inc/wext/order.php +++ b/www/inc/wext/order.php @@ -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) { -- 1.7.2.5