From: konrad Date: Tue, 29 Dec 2009 19:18:58 +0000 (+0000) Subject: order list tab itself is functional, sub-dialogs still missing X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=4fcd7f0504f40008568000babdbb6b674a032ff3;p=web%2Fkonrad%2Fsmoke.git order list tab itself is functional, sub-dialogs still missing git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@372 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/src/dialogs/eventsummary.cpp b/src/dialogs/eventsummary.cpp index 70caf5a..f850772 100644 --- a/src/dialogs/eventsummary.cpp +++ b/src/dialogs/eventsummary.cpp @@ -326,7 +326,7 @@ void MEventSummary::getLoopVariable(QString loopname,int iteration,QString varna if(!orders.contains(oid))return; if(varname=="CUSTOMERID")value=QString::number(orders[oid].orderid());else - if(varname=="CUSTOMER")value=orders[oid].customer().name().value();else + if(varname=="CUSTOMER")value=orders[oid].customer_().name().value();else if(varname=="FULLPRICE"){ value=orders[oid].totalprice().value(); av=MOdtRenderer::MoneyVar; diff --git a/src/dialogs/orderwin.cpp b/src/dialogs/orderwin.cpp index c79a98f..f5a25d9 100644 --- a/src/dialogs/orderwin.cpp +++ b/src/dialogs/orderwin.cpp @@ -123,7 +123,7 @@ MOrderWindow::MOrderWindow(QWidget*par,const MOrder&o) gl->addWidget(new QLabel(tr("Shipping Date:")),++rw,0); gl->addWidget(m_sentdate=new QLabel(m_order.sentDateTimeStr()),rw,1); gl->addWidget(new QLabel(tr("Customer:")),++rw,0); - gl->addWidget(new QLabel(m_order.customer().address()),rw,1); + gl->addWidget(new QLabel(m_order.customer_().address()),rw,1); gl->addWidget(new QLabel(tr("Delivery Address:")),++rw,0); //FIXME:gl->addWidget(lab=new QLabel(m_order.deliveryAddress()),rw,1); //lab->setWordWrap(true); @@ -526,7 +526,7 @@ void MOrderWindow::getLoopIterations(QString loopname,int&iterations) if(loopname=="TICKETS")iterations=printBuffer.tickets.size(); if(loopname=="ACCTICKETS")iterations=printBuffer.tickinfo.size(); if(loopname=="VOUCHERS")iterations=printBuffer.vouchers.size(); - if(loopname=="ADDRESSLINES")iterations=m_order.customer().address().split("\n").size(); + if(loopname=="ADDRESSLINES")iterations=m_order.customer_().address().split("\n").size(); } void MOrderWindow::getLoopVariable(QString loopname,int it,QString vn,MOdtRenderer::VarType& av,QVariant&value) { @@ -598,7 +598,7 @@ void MOrderWindow::getLoopVariable(QString loopname,int it,QString vn,MOdtRender }else if(vn=="ID")value=printBuffer.vouchers[it].voucherid().value(); }else if(loopname=="ADDRESSLINES"){ - QStringList lst=m_order.customer().address().split("\n"); + QStringList lst=m_order.customer_().address().split("\n"); if(it<0 || it>=lst.size())return; value=lst[it]; }else @@ -1071,7 +1071,7 @@ MShippingChange::MShippingChange(QWidget*pa,MOShipping s) int scid=0; for(int i=0;iaddItem(all[i].description()); - if(all[i].id().value()==cid) + if(all[i].shipid().value()==cid) scid=i+1; } opt->setCurrentIndex(scid); diff --git a/src/dialogs/shipping.cpp b/src/dialogs/shipping.cpp index 574912a..3274b55 100644 --- a/src/dialogs/shipping.cpp +++ b/src/dialogs/shipping.cpp @@ -74,11 +74,11 @@ void MShippingEditor::updateTable() model->insertRows(0,all.size()); model->setHorizontalHeaderLabels(QStringList()<setData(model->index(i,0),all[i].id().value()); + model->setData(model->index(i,0),all[i].shipid().value()); model->setData(model->index(i,1),all[i].description().value()); model->setData(model->index(i,2),cent2str(all[i].cost())); - model->setData(model->index(i,3),all[i].canuseweb().value()?tr("Yes"):tr("No")); - model->setData(model->index(i,4),all[i].canallusers().value()?tr("Yes"):tr("No")); +// model->setData(model->index(i,3),all[i].canuseweb().value()?tr("Yes"):tr("No")); +// model->setData(model->index(i,4),all[i].canallusers().value()?tr("Yes"):tr("No")); } table->resizeColumnsToContents(); } diff --git a/src/iface/order.cpp b/src/iface/order.cpp index 167628e..fc9b99c 100644 --- a/src/iface/order.cpp +++ b/src/iface/order.cpp @@ -34,7 +34,7 @@ bool MOrder::isValid()const return true; } -MCustomer MOrder::customer()const +MCustomer MOrder::customer_()const { return MCustomer(customerid()); } diff --git a/src/iface/order.h b/src/iface/order.h index d2c69ad..2b0aa11 100644 --- a/src/iface/order.h +++ b/src/iface/order.h @@ -148,7 +148,7 @@ class MOrder:public MOOrder bool isValid()const; /**returns a customer object (calls database!)*/ - MCustomer customer()const; + MCustomer customer_()const; /**returns whether this order is a reservation*/ bool isReservation()const; diff --git a/src/mwin/carttab.cpp b/src/mwin/carttab.cpp index 65fc145..2ab2287 100644 --- a/src/mwin/carttab.cpp +++ b/src/mwin/carttab.cpp @@ -120,7 +120,7 @@ void MCartTab::updateShipping() MTGetAllShipping sh=MTGetAllShipping::query(); QListship=sh.getshipping(); for(int i=0;iaddItem(ship[i].description(),(int)ship[i].id()); + cartship->addItem(ship[i].description(),(int)ship[i].shipid()); } void MCartTab::initCart() diff --git a/src/mwin/orderstab.cpp b/src/mwin/orderstab.cpp index 3baf879..0cb316f 100644 --- a/src/mwin/orderstab.cpp +++ b/src/mwin/orderstab.cpp @@ -75,7 +75,7 @@ MOrdersTab::MOrdersTab(QString pk) vl->addSpacing(15); vl->addWidget(p=new QPushButton(tr("Find by Ticket...")),0); connect(p,SIGNAL(clicked()),this,SLOT(orderByTicket())); - p->setEnabled(req->hasRole("orderbyticket")); + p->setEnabled(req->hasRight(req->RGetOrderByBarcode)); vl->addWidget(p=new QPushButton(tr("Find by Event...")),0); connect(p,SIGNAL(clicked()),this,SLOT(orderByEvent())); p->setEnabled(req->hasRight(req->RGetOrdersByEvents)); @@ -135,6 +135,10 @@ void MOrdersTab::addOrderToModel(const MOOrderInfo&ord,const QListsetData(ordermodel->index(cl,0),ord.orderid().value(),Qt::UserRole); ordermodel->setData(ordermodel->index(cl,1),ord.totalPriceString()); ordermodel->setData(ordermodel->index(cl,2),ord.amountPaidString()); + if(ord.amountpaid()setData(ordermodel->index(cl,2),QColor("#ff8080"),Qt::BackgroundRole); + if(ord.amountpaid()>ord.totalprice()) + ordermodel->setData(ordermodel->index(cl,2),QColor("#80ff80"),Qt::BackgroundRole); int cid=ord.customerid(); //TODO: make this more effective: for(int j=0;jrequest("orderbyticket",tid.toUtf8())){ - QMessageBox::warning(this,tr("Warning"),tr("Unable to query server.")); - return; - } - if(req->responseStatus()!=MSInterface::Ok){ - QMessageBox::warning(this,tr("Warning"),qApp->translate("php::",req->responseBody())); + MTGetOrderByBarcode obb=req->queryGetOrderByBarcode(tid); + if(obb.hasError()){ + QMessageBox::warning(this,tr("Warning"),tr("Error while searching for order: %1").arg(obb.errorString())); return; } - int id=req->responseBody().trimmed().toInt(&ok); - if(!ok || id<0){ - QMessageBox::warning(this,tr("Warning"),tr("Server returned an invalid order ID.")); + if(obb.getorder().isNull()){ + QMessageBox::warning(this,tr("Warning"),tr("Order for barcode '%1' not found.").arg(tid)); return; } //open order window - MOrderWindow *om=new MOrderWindow(this,req,MOrder(req,id)); + MOrderWindow *om=new MOrderWindow(this,obb.getorder().value()); om->setAttribute(Qt::WA_DeleteOnClose); - om->show();*/ + om->show(); } void MOrdersTab::orderByEvent() diff --git a/wob/order.wolf b/wob/order.wolf index 152e92e..a7563d5 100644 --- a/wob/order.wolf +++ b/wob/order.wolf @@ -144,6 +144,20 @@ + + This class encapsulates shipping types. + + + + + + + + + + + + This class represents the data of a ticket as stored in the database. @@ -209,7 +223,21 @@ used for basic info about items - + + + + + + + + + + + + + + + @@ -217,27 +245,66 @@ - - + + + + + + + - + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -327,24 +394,19 @@ + + + + + + + + + + - - - - - - - - - - - - - - - diff --git a/www/inc/wext/order.php b/www/inc/wext/order.php index ea91db8..69e88f7 100644 --- a/www/inc/wext/order.php +++ b/www/inc/wext/order.php @@ -120,6 +120,42 @@ class WOOrderInfo extends WOOrderInfoAbstract class WOOrder extends WOOrderAbstract { + /**analyses itself and returns price*/ + public function getTotalPrice() + { + //closed does not have a price + if($this->prop_status==self::Closed) + return 0; + $prc=$this->prop_shippingcosts; + //cancelled pais only shipping + if($this->prop_status==self::Cancelled) + return $prc; + //add tickets + foreach($this->prop_tickets as $it) + $prc+=$it->amountToPay(); + //add vouchers + foreach($this->prop_vouchers as $it) + $prc+=$it->getprice(); + //add items + foreach($this->prop_items as $it) + $prc+=$it->gettotalprice(); + //return + return $prc; + } + + /**called by GetOrderByBarcode transaction*/ + static public function getOrderByBarcode($trans) + { + global $db; + //find ticket + $res=$db->select("ticket","orderid","ticketid=".$db->escapeString($trans->getbarcode())); + //if none: find voucher + if(count($res)<1) + $res=$db->select("voucher","orderid","voucherid=".$db->escapeString($trans->getbarcode())); + //find order + if(count($res)>=0) + $trans->setorder(WOOrder::fromTableorder(WTorder::getFromDB($res[0]["orderid"]))); + } }; ?> \ No newline at end of file