-Subproject commit f40058f8f817598e0533e9c57c6a4a0d3517afd9
+Subproject commit 6a565edd00675310f956428a83791b8ba3f16a7b
widget()->adjustSize();
}
+void MAddressListWidget::preselect(const MOAddress& addr)
+{
+ for(int i=0;i<m_addr.size();i++){
+ if(m_addr[i].addressid()==addr.addressid()){
+ preselect(i);
+ break;
+ }
+ }
+}
+
void MAddressListWidget::createAddress()
{
MAddressDialog d(this);
MAddressChoiceDialog::MAddressChoiceDialog(QWidget*par,const MOCustomer&c)
:QDialog(par),m_cust(c)
{
- m_needupdate=false;
+ m_needupdate=m_unsel=false;
setWindowTitle(tr("Chose an Address"));
QHBoxLayout*hl;
QVBoxLayout*vl;
connect(m_lwidget,SIGNAL(addressCreated(const MOAddress&)),this,SLOT(changed()));
connect(m_lwidget,SIGNAL(addressEdited(const MOAddress&)),this,SLOT(changed()));
//on selection: first update customer, then close window
- connect(m_lwidget,SIGNAL(addressSelected(qint64)),this,SLOT(updateCustomer()),Qt::DirectConnection);
+ connect(m_lwidget,SIGNAL(addressSelected(qint64)), this,SLOT(updateCustomer()), Qt::DirectConnection);
- vl->addLayout(hl=new QHBoxLayout,0);
+ vl->addLayout(m_btnlayout=hl=new QHBoxLayout,0);
hl->addStretch(10);
QPushButton*p;
hl->addWidget(p=new QPushButton(tr("Add Address")),0);
connect(p,SIGNAL(clicked()),this,SLOT(reject()));
}
-MOAddress MAddressChoiceDialog::address()const{return m_lwidget->selection();}
-qint64 MAddressChoiceDialog::addressId()const{return m_lwidget->selection().addressid();}
+void MAddressChoiceDialog::addUnselectButton(const QString& t)
+{
+ m_btnlayout->insertSpacing(2,20);
+ QPushButton*p;
+ m_btnlayout->insertWidget(3,p=new QPushButton(t));
+ connect(p,SIGNAL(clicked()),this,SLOT(unselect()));
+}
+
+MOAddress MAddressChoiceDialog::address()const
+{
+ if(m_unsel)return MOAddress();
+ else return m_lwidget->selection();
+}
+
+qint64 MAddressChoiceDialog::addressId()const
+{
+ if(m_unsel)return -1;
+ else return address().addressid();
+}
void MAddressChoiceDialog::changed(){m_needupdate=true;}
void MAddressChoiceDialog::updateCustomer()
//close dialog successfully
accept();
}
+
+void MAddressChoiceDialog::preselect(const MOAddress& addr)
+{
+ m_lwidget->preselect(addr);
+}
+
+void MAddressChoiceDialog::unselect()
+{
+ m_unsel=true;
+ accept();
+}
#include "MOCustomerInfo"
#include "MOCustomer"
+class QHBoxLayout;
class QLineEdit;
class QListView;
class QSortFilterProxyModel;
/**pre-selects an address by its position in the current address list, this method should only be called once!*/
void preselect(int);
+ ///alias: pre-selects an address if it is present in the list of displayed addresses
+ void preselect(const MOAddress&);
+
private slots:
/**internal: used to change an address after editing*/
void addrEdit(int);
/**internal: used to remember the selected address*/
void addrSel(const MOAddress&);
- /**internal: add an address widget, if the boolean is true it is also made visible*/
- void addAddr(const MOAddress&,bool v=false);
+ /**internal: add an address widget,
+ \param vis if true the routine ensures the widget is in the visible part of the scrollarea
+ \param mark if true marks the address with a color
+ */
+ void addAddr(const MOAddress&,bool vis=false);
private:
QList<MOAddress>m_addr;
/**creates the dialog*/
MAddressChoiceDialog(QWidget*,const MOCustomer&);
- /**returns the chosen address*/
+ /**returns the chosen address or an invalid address if none was chosen*/
MOAddress address()const;
- /**returns the ID of the chosen address*/
+ /**returns the ID of the chosen address or -1 if the unselect button was used*/
qint64 addressId()const;
/**returns the (modified) customer object*/
MOCustomer customer()const{return m_cust;}
+ public slots:
+ ///pre-select an address
+ void preselect(const MOAddress&);
+ ///add an unselect button
+ void addUnselectButton(const QString&);
private slots:
/**internal: notified if there is a change to the address list*/
void changed();
/**internal: updates the customer if necessary*/
void updateCustomer();
+ ///unselect button pressed
+ void unselect();
private:
MOCustomer m_cust;
- bool m_needupdate;
+ bool m_needupdate,m_unsel;
MAddressListWidget*m_lwidget;
+ QHBoxLayout*m_btnlayout;
};
/**dialog for editing exactly one address*/
#include "ticketrender.h"
#include "msinterface.h"
#include "templates.h"
+#include "customerdlg.h"
#include "MOEvent"
->setEnabled(req->hasRight(req->RChangeTicketPriceCategory));
m->addAction(tr("&Return Item..."),this,SLOT(itemReturn()))
->setEnabled(req->hasRight(req->RReturnTicketVoucher));
+ m->addSeparator();
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->addAction(tr("Change Invoice Address..."),this,SLOT(changeInvAddr()))
+ ->setEnabled(req->hasRight(req->RChangeOrderAddress));
+ m->addAction(tr("Change Delivery Address..."),this,SLOT(changeDelAddr()))
+ ->setEnabled(req->hasRight(req->RChangeOrderAddress));
m->addSeparator();
m->addAction(tr("&Close"),this,SLOT(close()));
updateData();
}
+void MOrderWindow::changeDelAddr()
+{
+ //get customer
+ MAddressChoiceDialog d(this,m_order.customer().value());
+ d.preselect(m_order.deliveryaddress());
+ d.addUnselectButton(tr("No Delivery Address"));
+ if(d.exec()!=QDialog::Accepted)return;
+ //send data
+ MTChangeOrderAddress oa=req->queryChangeOrderAddress(m_order.orderid(), false,-1, true,d.addressId());
+ if(oa.hasError()){
+ QMessageBox::warning(this,tr("Warning"),tr("Unable to set address, server error: %1").arg(oa.errorString()));
+ return;
+ }
+ m_daddr->setText(d.address().fullAddress());
+}
+
+void MOrderWindow::changeInvAddr()
+{
+ //get customer
+ MAddressChoiceDialog d(this,m_order.customer().value());
+ d.preselect(m_order.invoiceaddress());
+ d.addUnselectButton(tr("No Invoice Address"));
+ if(d.exec()!=QDialog::Accepted)return;
+ //send data
+ MTChangeOrderAddress oa=req->queryChangeOrderAddress(m_order.orderid(), true,d.addressId(), false,-1);
+ if(oa.hasError()){
+ QMessageBox::warning(this,tr("Warning"),tr("Unable to set address, server error: %1").arg(oa.errorString()));
+ return;
+ }
+ m_iaddr->setText(d.address().fullAddress());
+}
+
void MOrderWindow::voucherAudit()
{
QModelIndexList lst=m_table->selectionModel()->selectedIndexes();
/**change the shipping option*/
void changeShipping();
+ ///change the invoice address
+ void changeInvAddr();
+ ///change the delivery address
+ void changeDelAddr();
+
/**cancel the order*/
void cancelOrder();
/**mark as shipped*/
<Preset><V col="rolename" val="OrderAdvanced"/><V col="rightname" val="OrderRefund"/></Preset>
<Preset><V col="rolename" val="OrderAdvanced"/><V col="rightname" val="ResetCustomerPassword"/></Preset>
<Preset><V col="rolename" val="OrderAdvanced"/><V col="rightname" val="ReturnTicketVoucher"/></Preset>
+ <Preset><V col="rolename" val="OrderAdvanced"/><V col="rightname" val="ChangeOrderAddress"/></Preset>
<Preset><V col="rolename" val="OrderCancelling"/><V col="rightname" val="CancelOrder"/></Preset>
<Preset><V col="rolename" val="OrderCancelling"/><V col="rightname" val="OrderChangeShipping"/></Preset>
<Preset><V col="rolename" val="OrderCancelling"/><V col="rightname" val="ReturnTicketVoucher"/></Preset>
<Preset><V col="rolename" val="OrderHighPrivilege"/><V col="rightname" val="ReturnTicketVoucher:ReturnPastTicket"/></Preset>
<Preset><V col="rolename" val="OrderHighPrivilege"/><V col="rightname" val="UseTicket"/></Preset>
<Preset><V col="rolename" val="OrderHighPrivilege"/><V col="rightname" val="UseVoucher"/></Preset>
+ <Preset><V col="rolename" val="OrderHighPrivilege"/><V col="rightname" val="ChangeOrderAddress"/></Preset>
<Preset><V col="rolename" val="OrderListing"/><V col="rightname" val="GetOrder"/></Preset>
<Preset><V col="rolename" val="OrderListing"/><V col="rightname" val="GetOrderByBarcode"/></Preset>
<Preset><V col="rolename" val="OrderListing"/><V col="rightname" val="GetOrderList"/></Preset>
<Var name="order" type="Order">the order that ownes the changed ticket, in case this is called from the order window</Var>
</Output>
</Transaction>
+
+ <Transaction name="ChangeOrderAddress">
+ <Doc>Mildly privileged users: change the delivery and/or invoice address of an order.</Doc>
+ <Input>
+ <Var name="orderid" type="int">the ID of the order, this is mandatory</Var>
+ <Var name="setinvoiceaddr" type="bool">if true: the value in invoiceaddr is actually used, if false: the invoice address is left unchanged</Var>
+ <Var name="invoiceaddr" type="int">the ID of the invoice address, <0 for deleting the invoice address</Var>
+ <Var name="setdeliveryaddr" type="bool">if true: the value in deliveryaddr is actually used, if false: the delivery address is left unchanged</Var>
+ <Var name="deliveryaddr" type="int">the ID of the delivery address, <0 for deleting the delivery address</Var>
+ </Input>
+ <Call lang="php" method="WOOrder::changeAddress($this);"/>
+ <Output>
+ <Var name="order" type="Order">the order after the change has become active.</Var>
+ </Output>
+ </Transaction>
<Transaction name="GetAllShipping" updating="no">
<Doc>Returns a list of all shipping methods that the user has access to. This transaction is sensitive to flags, like "anyshipping".</Doc>
//send mail
mail($ct->email,$subject,$mailtext,$mailheader);
}
+
+ ///change the addresses on the order, called by ChangeOrderAddress transaction
+ static public function changeAddress($trans)
+ {
+ global $db;
+ $oid=$trans->getorderid();
+ $ord=WTorder::getFromDB($oid);
+ if(!is_a($ord,"WTorder")){
+ $trans->abortWithError(tr("Order does not exist."));
+ return;
+ }
+ //invoice address
+ $cid=$ord->customerid;
+ if($trans->getsetinvoiceaddr()){
+ $iad=$trans->getinvoiceaddr();
+ if($iad<0){
+ $ord->invoiceaddress=null;
+ }else{
+ $addr=WTaddress::getFromDB($iad);
+ if(!is_a($addr,"WTaddress")){
+ $trans->abortWithError(tr("Invalid address ID"));
+ return;
+ }
+ if($addr->customerid!=$cid){
+ $trans->abortWithError(tr("Address does not match customer."));
+ return;
+ }
+ $ord->invoiceaddress=$iad;
+ }
+ }
+ //same with delivery address
+ if($trans->getsetdeliveryaddr()){
+ $dad=$trans->getdeliveryaddr();
+ if($dad<0){
+ $ord->deliveryaddress=null;
+ }else{
+ $addr=WTaddress::getFromDB($dad);
+ if(!is_a($addr,"WTaddress")){
+ $trans->abortWithError(tr("Invalid address ID"));
+ return;
+ }
+ if($addr->customerid!=$cid){
+ $trans->abortWithError(tr("Address does not match customer."));
+ return;
+ }
+ $ord->deliveryaddress=$dad;
+ }
+ }
+ //send to DB
+ $ord->update();
+ //fetch and deliver result
+ $trans->setorder(WOOrder::fromTableorder(WTorder::getFromDB($oid)/*$ord*/));
+ }
};
?>
\ No newline at end of file