->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();
}
}
-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();
</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/>
$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)
{