From 01e8cfc65d740ef3f34e84e2598d2fcd705243ef Mon Sep 17 00:00:00 2001 From: konrad Date: Fri, 8 Jan 2010 18:10:02 +0000 Subject: [PATCH] reenable entrance tab some minor touchups git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@409 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- src/dialogs/eventsummary.cpp | 2 +- src/dialogs/orderwin.cpp | 2 +- src/mwin/entrancetab.cpp | 192 +++++++++++++++++++++++++++++++++-------- src/mwin/entrancetab.h | 16 ++++- src/mwin/overview.cpp | 27 ++----- src/mwin/overview.h | 2 +- wob/order.wolf | 37 ++++++++ www/inc/wext/cart.php | 66 +++++++------- www/inc/wext/customer.php | 32 ++++---- www/inc/wext/event.php | 15 +++- www/inc/wext/order.php | 8 +- www/inc/wext/ticket.php | 63 ++++++++++++++ 12 files changed, 343 insertions(+), 119 deletions(-) diff --git a/src/dialogs/eventsummary.cpp b/src/dialogs/eventsummary.cpp index 756d680..bf08b43 100644 --- a/src/dialogs/eventsummary.cpp +++ b/src/dialogs/eventsummary.cpp @@ -137,7 +137,7 @@ void MEventSummary::getSummaryData() if(!maptickets.contains(p)) maptickets.insert(p,Tickets(p)); //count up - if(ticks[j].status().value()&MOTicket::MaskUsable){ + if(ticks[j].status().value()&MOTicket::MaskBlock){ ntotaltickets++; ntotalmoney+=ticks[j].price(); maptickets[p].bought++; diff --git a/src/dialogs/orderwin.cpp b/src/dialogs/orderwin.cpp index 4e84726..aa995bc 100644 --- a/src/dialogs/orderwin.cpp +++ b/src/dialogs/orderwin.cpp @@ -278,7 +278,7 @@ void MOrderWindow::printTickets(QList ticketsin) //reduce ticket list to usable ones QList tickets; for(int i=0;i #include #include +#include #include #include #include +#include MEntranceTab::MEntranceTab(QString pk) { profilekey=pk; QVBoxLayout*vl;QHBoxLayout*hl; - QPushButton*p; //Entrance Control Tab setLayout(vl=new QVBoxLayout); vl->addWidget(entranceevent=new QComboBox,0); @@ -37,18 +39,60 @@ MEntranceTab::MEntranceTab(QString pk) vl->addSpacing(30); vl->addWidget(new QLabel(tr("Enter or scan Ticket-ID:")),0); vl->addWidget(entrancescan=new QLineEdit,0); - connect(entrancescan,SIGNAL(editingFinished()),this,SLOT(entranceValidate())); + connect(entrancescan,SIGNAL(returnPressed()),this,SLOT(entranceValidate())); vl->addWidget(entrancelabel=new QLabel(" "),10); entrancelabel->setAutoFillBackground(true); QFont fnt=entrancelabel->font(); fnt.setBold(true);fnt.setPointSize(24); entrancelabel->setFont(fnt); entrancelabel->setAlignment(Qt::AlignCenter); + + vl->addSpacing(10); + vl->addLayout(hl=new QHBoxLayout,0); + hl->addStretch(10); + hl->addWidget(orderbtn=new QPushButton(tr("Open Order"))); + connect(orderbtn,SIGNAL(clicked()),this,SLOT(openOrder())); + vl->addSpacing(20); + vl->addLayout(hl=new QHBoxLayout,0); + hl->addWidget(new QLabel(tr("Total:"))); + hl->addWidget(amtotal=new QLabel("0")); + hl->addStretch(1); + hl->addWidget(new QLabel(tr("Used:"))); + hl->addWidget(amused=new QLabel("0")); + hl->addStretch(1); + hl->addWidget(new QLabel(tr("Unused:"))); + hl->addWidget(amopen=new QLabel("0")); + hl->addStretch(1); + hl->addWidget(new QLabel(tr("Reserved:"))); + hl->addWidget(amreserved=new QLabel("0")); + + QTimer*tm=new QTimer(this); + connect(tm,SIGNAL(timeout()),this,SLOT(resetLabel())); + tm->setSingleShot(false); + tm->start(10000); } +/**while the object lives the tab handed to it is disabled, it automatically reenables when the disable object dies; it also refocuses the scan line*/ +class METUtility +{ + private: + MEntranceTab*widget; + public: + /**disables the widget*/ + METUtility(MEntranceTab*w){widget=w;w->setEnabled(false);} + /**enables the widget*/ + ~METUtility(){ + widget->setEnabled(true); + widget->entrancelabel->setEnabled(true); + widget->entrancescan->setText(""); + QTimer::singleShot(1,widget->entrancescan,SLOT(setFocus())); + QTimer::singleShot(1,widget->entrancelabel,SLOT(update())); + } +}; + void MEntranceTab::entranceValidate() -{/*TODO +{ //get event ID int ci=entranceevent->currentIndex(); if(ci<0)return; @@ -58,6 +102,8 @@ void MEntranceTab::entranceValidate() entrancescan->setText(""); //avoid spurious events if(tid=="")return; + //get serious + METUtility mdis(this); //avoid double scans QDateTime now=QDateTime::currentDateTime(); if(tid==lastbarcode && lastbcscan.addSecs(20)>=now) @@ -71,43 +117,113 @@ void MEntranceTab::entranceValidate() entrancelabel->setPalette(pal); entrancelabel->setText(tr("searching...","entrance control")); //ask the server - MTicket tick(req,tid); + MTUseTicket ut=MTUseTicket::query(tid,cev); + MOTicketUse tuse=ut.getticketuse(); //decide what to do - if(!tick.isValid()){ - entrancelabel->setText(tr("Ticket \"%1\" Not Valid").arg(tid)); - pal.setColor(rl,Qt::red); - }else - if(tick.eventID()!=cev){ - entrancelabel->setText(tr("Ticket \"%1\" is not for this event.").arg(tid)); - pal.setColor(rl,Qt::red); - }else - if(tick.status()==MTicket::Used){ - entrancelabel->setText(tr("Ticket \"%1\" has already been used").arg(tid)); - pal.setColor(rl,Qt::magenta); - }else - if(tick.status()!=MTicket::Bought){ - entrancelabel->setText(tr("Ticket \"%1\" has not been bought.").arg(tid)); - pal.setColor(rl,Qt::red); - }else - if(tick.paymentStatus()==MTicket::PSOk){ - entrancelabel->setText(tr("Ticket \"%1\" Ok").arg(tid)); - pal.setColor(rl,Qt::green); - tick.markUsed(); - }else - if(tick.paymentStatus()==MTicket::PSNeedRefund){ - entrancelabel->setText(tr("Ticket \"%1\" Ok; the Order has a refund").arg(tid)); - pal.setColor(rl,Qt::green); - tick.markUsed(); - }else - if(tick.paymentStatus()==MTicket::PSNeedPayment){ - entrancelabel->setText(tr("Ticket \"%1\" is not paid for!").arg(tid)); - pal.setColor(rl,Qt::red); - }else{ - entrancelabel->setText(tr("Ticket \"%1\" cannot be accepted, please check the order!").arg(tid)); - pal.setColor(rl,Qt::red); + switch(tuse.usestatus().value()){ + case MOTicketUse::NotFound: + entrancelabel->setText(tr("Ticket \"%1\" Not Valid").arg(tid)); + pal.setColor(rl,Qt::red); + break; + case MOTicketUse::WrongEvent: + entrancelabel->setText(tr("Ticket \"%1\" is not for this event.").arg(tid)); + pal.setColor(rl,Qt::red); + break; + case MOTicketUse::AlreadyUsed: + entrancelabel->setText(tr("Ticket \"%1\" has already been used").arg(tid)); + pal.setColor(rl,Qt::magenta); + break; + case MOTicketUse::NotUsable: + entrancelabel->setText(tr("Ticket \"%1\" has not been bought.").arg(tid)); + pal.setColor(rl,Qt::red); + break; + case MOTicketUse::Ok: + entrancelabel->setText(tr("Ticket \"%1\" Ok").arg(tid)); + pal.setColor(rl,Qt::green); + break; + case MOTicketUse::Unpaid: + entrancelabel->setText(tr("Ticket \"%1\" is not paid for!").arg(tid)); + pal.setColor(rl,Qt::red); + break; + default: + entrancelabel->setText(tr("Ticket \"%1\" cannot be accepted, please check the order!").arg(tid)); + pal.setColor(rl,Qt::red); + break; } entrancelabel->setPalette(pal); - entrancescan->setFocus(Qt::OtherFocusReason); - entrancescan->setText("");*/ + amtotal->setText(QString::number(tuse.amounttickets())); + amused->setText(QString::number(tuse.amountused())); + amopen->setText(QString::number(tuse.amountopen())); + amreserved->setText(QString::number(tuse.amountreserved())); + if(tuse.usestatus().value()!=MOTicketUse::NotFound) + orderbtn->setEnabled(req->hasRight(req->RGetOrderByBarcode)); + else + orderbtn->setEnabled(false); +} + +void MEntranceTab::initialize() +{ + METUtility mdis(this); + //check whether an update should be forced + QDateTime now=QDateTime::currentDateTime(); + if(lasteventupdate.addSecs(3600)>now)return; + //get currently displayed event + int ci=entranceevent->currentIndex(); + int cev=-1; + if(ci>=0)cev=entranceevent->itemData(ci).toInt(); + ci=-1; + //get event list + MTGetEntranceEvents gee=MTGetEntranceEvents::query(); + if(gee.hasError())return; + lasteventupdate=now; + QListevlst=gee.getevents(); + //fill combobox from eventmodel + entranceevent->clear(); + for(int i=0;iaddItem(ev,eid); + if(eid==cev)ci=i; + } + if(ci>=0)entranceevent->setCurrentIndex(ci); + else resetAmounts(); + orderbtn->setEnabled(false); } + +void MEntranceTab::resetLabel() +{ + QDateTime now=QDateTime::currentDateTime(); + if(lastbcscan.addSecs(300)<=now){ + //reset timer + lastbarcode=""; + lastbcscan=now; + //reset label + entrancelabel->setText(" "); + entrancelabel->setPalette(QLabel().palette()); + //reset buttons + orderbtn->setEnabled(false); + } +} + +void MEntranceTab::openOrder() +{ + if(lastbarcode=="")return; + MTGetOrderByBarcode obt=MTGetOrderByBarcode::query(lastbarcode); + if(obt.hasError()){ + QMessageBox::warning(this,tr("Warning"),tr("Error while retrieving order: %s").arg(obt.errorString())); + return; + } + MOrderWindow *ow=new MOrderWindow(this,obt.getorder()); + ow->show(); + //reset, just in case the user is fast + lastbcscan=lastbcscan.addSecs(-20); +} + +void MEntranceTab::resetAmounts() +{ + amtotal->setText("0"); + amused->setText("0"); + amopen->setText("0"); + amreserved->setText("0"); +} \ No newline at end of file diff --git a/src/mwin/entrancetab.h b/src/mwin/entrancetab.h index 219fae9..f679404 100644 --- a/src/mwin/entrancetab.h +++ b/src/mwin/entrancetab.h @@ -19,6 +19,7 @@ class QComboBox; class QLabel; class QLineEdit; +class QPushButton; class QStandardItemModel; class MSInterface; @@ -30,20 +31,33 @@ class MEntranceTab:public QWidget public: /**construct the window with web-request/session handler and QSettings-key for current profile*/ MEntranceTab(QString); + public slots: + /**initializes the tab*/ + void initialize(); private slots: /**react on entry in Entrance tab*/ void entranceValidate(); - + /**resets the display after a timeout*/ + void resetLabel(); + /**tries to open the order of the current barcode*/ + void openOrder(); + /**resets the amount labels*/ + void resetAmounts(); private: + friend class METUtility; //the profile associated with this session QString profilekey; //widgets QLabel*entrancelabel; QComboBox*entranceevent; QLineEdit*entrancescan; + QPushButton*orderbtn; + QLabel*amtotal,*amused,*amopen,*amreserved; //barcode cache QString lastbarcode; QDateTime lastbcscan; + //event update timeout + QDateTime lasteventupdate; }; #endif diff --git a/src/mwin/overview.cpp b/src/mwin/overview.cpp index ddfd59e..336a92c 100644 --- a/src/mwin/overview.cpp +++ b/src/mwin/overview.cpp @@ -78,7 +78,7 @@ MOverview::MOverview(QString pk) //tabs setCentralWidget(tab=new QTabWidget); - connect(tab,SIGNAL(currentChanged(int)),this,SLOT(tabChanged())); + connect(tab,SIGNAL(currentChanged(int)),this,SLOT(tabChanged(int))); //Event tab tab->addTab(eventtab=new MEventsTab(pk),tr("Events")); @@ -205,28 +205,13 @@ void MOverview::editShipping() updateShipping();*/ } -void MOverview::tabChanged() -{/*TODO: partly re-activate, partly move to entrancetab.cpp +void MOverview::tabChanged(int idx) +{ + qDebug("tab index %i",idx); QWidget*w=tab->currentWidget(); if(w==entrancetab){ - //fill combobox from eventmodel - int ci=entranceevent->currentIndex(); - int cev=-1; - if(ci>=0)cev=entranceevent->itemData(ci).toInt(); - ci=-1; - entranceevent->clear(); - for(int i=0;irowCount();i++){ - QString ev=eventmodel->data(eventmodel->index(i,0)).toString()+" "+ - eventmodel->data(eventmodel->index(i,1)).toString(); - int eid=eventmodel->data(eventmodel->index(i,0),Qt::UserRole).toInt(); - entranceevent->addItem(ev,eid); - if(eid==cev)ci=i; - } - if(ci>=0)entranceevent->setCurrentIndex(ci); - //set focus on scanner - entrancescan->setFocus(Qt::OtherFocusReason); - entrancescan->setText(""); - }*/ + entrancetab->initialize(); + } } void MOverview::ticketReturn() diff --git a/src/mwin/overview.h b/src/mwin/overview.h index 5b722e5..476077d 100644 --- a/src/mwin/overview.h +++ b/src/mwin/overview.h @@ -65,7 +65,7 @@ class MOverview:public QMainWindow void editShipping(); /**generic check which tab is active*/ - void tabChanged(); + void tabChanged(int); /**return a ticket*/ void ticketReturn(); diff --git a/wob/order.wolf b/wob/order.wolf index c10c8ed..bcdd67d 100644 --- a/wob/order.wolf +++ b/wob/order.wolf @@ -585,4 +585,41 @@ + + + + Objects of this class are sent back as response to UseTicket + The ticket, if found. + + The ticket was ok and has been marked as Used + The ticket has not been found or the barcode belongs to a voucher + The ticket belongs to the wrong event. + The ticket has already been used. + The ticket is only reserved or has been given back, it cannot be used. + The order of this ticket has not been paid for yet. + The given event ID is invalid. + + The result of the UseTicket operation + The amount of usable/used tickets in this event + The amount of used tickets in the event (after the operation) + The amount of tickets for the event that have not been used yet. + The amount of tickets for the event that could be used, but are only reserved until now. + + + + The ticket to be used + The event to use it on + + + + + + + + This is a convenience transaction: it returns all events that are likely to be chosen at an entrance barcode scanner; this includes all events starting at max. within the next 24 hours that and that have not ended yet + + + + + \ No newline at end of file diff --git a/www/inc/wext/cart.php b/www/inc/wext/cart.php index e8253c6..c7ffe7a 100644 --- a/www/inc/wext/cart.php +++ b/www/inc/wext/cart.php @@ -58,7 +58,7 @@ class WOCartOrder extends WOCartOrderAbstract $very&=$cart->verifyTickets($trans,$tsalestop); if($isreserve){ - if(count($cart->get_vouchers())>0 || count($cart->get_items())>0){ + if(count($cart->getvouchers())>0 || count($cart->getitems())>0){ $trans->abortWithError(tr("Reservations must not contain anything but tickets.")); return; } @@ -69,11 +69,11 @@ class WOCartOrder extends WOCartOrderAbstract //verification successful? if(!$very){ //no: set verified cart and return to caller - $cart->set_status(WOCartOrder::Invalid); + $cart->setstatus(WOCartOrder::Invalid); $trans->setcart($cart); return; } - $cart->set_status(WOCartOrder::Ok); + $cart->setstatus(WOCartOrder::Ok); //create order $ord=$cart->createOrderOnDB($trans,$isreserve); @@ -166,52 +166,52 @@ class WOCartOrder extends WOCartOrderAbstract if($salestop>0)$now+=$salestop*3600; foreach($this->prop_tickets as &$tick){ //assume ok - $tick->set_status(WOCartTicket::Ok); + $tick->setstatus(WOCartTicket::Ok); //check event exists - $evid=$tick->get_eventid(); + $evid=$tick->geteventid(); $ev=WTevent::getFromDB($evid); if(!is_a($ev,"WTevent")){ - $tick->set_status(WOCartTicket::Invalid); + $tick->setstatus(WOCartTicket::Invalid); $ret=false; continue; } if(!array_key_exists($evid,$evseats)) $evseats[$evid]=$this->eventTicketStatistics($evid,$ev->capacity,$evprice); //verify price category, set price - $pcid=$tick->get_pricecategoryid(); + $pcid=$tick->getpricecategoryid(); if(!array_key_exists($pcid,$evseats[$evid])){ - $tick->set_status(WOCartTicket::Invalid); + $tick->setstatus(WOCartTicket::Invalid); $ret=false; continue; } - $tick->set_price($evprice[$evid][$pcid]); + $tick->setprice($evprice[$evid][$pcid]); //check enough seats for event // print_r($evseats);print_r($tick); - if($tick->get_amount() > $evseats[$evid]["all"]){ - $tick->set_status(WOCartTicket::Exhausted); - $tick->set_maxamount($evseats[$evid]["all"]); + if($tick->getamount() > $evseats[$evid]["all"]){ + $tick->setstatus(WOCartTicket::Exhausted); + $tick->setmaxamount($evseats[$evid]["all"]); $ret=false; } - $evseats[$evid]["all"]-=$tick->get_amount(); + $evseats[$evid]["all"]-=$tick->getamount(); //check enough seats for category - if($tick->get_amount() > $evseats[$evid][$pcid]){ - $tick->set_status(WOCartTicket::Exhausted); - $tick->set_maxamount($evseats[$evid][$pcid]); + if($tick->getamount() > $evseats[$evid][$pcid]){ + $tick->setstatus(WOCartTicket::Exhausted); + $tick->setmaxamount($evseats[$evid][$pcid]); $ret=false; } // print("......\n"); // print_r($evseats);print_r($tick); - $evseats[$evid][$pcid]-=$tick->get_amount(); + $evseats[$evid][$pcid]-=$tick->getamount(); //check sale time if($salestop==self::AfterSale)continue; if($salestop==self::LateSale){ if($now>$ev->endtime){ - $tick->set_status(WOCartTicket::TooLate); + $tick->setstatus(WOCartTicket::TooLate); $ret=false; } }else{ if($now>$ev->starttime){ - $tick->set_status(WOCartTicket::TooLate); + $tick->setstatus(WOCartTicket::TooLate); $ret=false; } } @@ -229,31 +229,31 @@ class WOCartOrder extends WOCartOrderAbstract $ret=true; foreach($this->prop_vouchers as &$vou){ //assume ok - $vou->set_status(WOCartVoucher::Ok); + $vou->setstatus(WOCartVoucher::Ok); //check value - $vv=$vou->get_value()+0; + $vv=$vou->getvalue()+0; if($vv<=0){ - $vou->set_status(WOCartVoucher::InvalidValue); + $vou->setstatus(WOCartVoucher::InvalidValue); $ret=false; continue; } if(!$vanyval) if(!in_array($vv,$okvp)){ - $vou->set_status(WOCartVoucher::InvalidValue); + $vou->setstatus(WOCartVoucher::InvalidValue); $ret=false; continue; } //check price if($vdiffprice){ - $vp=$vou->get_price()+0; + $vp=$vou->getprice()+0; if($vp<0){ - $vou->set_status(WOCartVoucher::InvalidPrice); + $vou->setstatus(WOCartVoucher::InvalidPrice); $ret=false; continue; } }else{ //price to be ignored, so simply overwrite it - $vou->set_price($vv); + $vou->setprice($vv); } } return $ret; @@ -299,21 +299,21 @@ class WOCartOrder extends WOCartOrderAbstract foreach($this->prop_tickets as $tick){ $tck=WTticket::newRow(); $tck->orderid=$ord->orderid; - $tck->eventid=$tick->get_eventid(); - $tck->price=$tick->get_price(); - $tck->pricecategoryid=$tick->get_pricecategoryid(); + $tck->eventid=$tick->geteventid(); + $tck->price=$tick->getprice(); + $tck->pricecategoryid=$tick->getpricecategoryid(); $tck->status=$tstat; - for($i=0;$i<$tick->get_amount();$i++) + for($i=0;$i<$tick->getamount();$i++) $tck->insert(); } //create vouchers foreach($this->prop_vouchers as $vou){ $v=WTvoucher::newRow(); $v->orderid=$ord->orderid; - $v->price=$vou->get_price(); - $v->value=$vou->get_value(); + $v->price=$vou->getprice(); + $v->value=$vou->getvalue(); $v->isused=false; - for($i=0;$i<$vou->get_amount();$i++) + for($i=0;$i<$vou->getamount();$i++) $v->insert(); } //TODO: create items diff --git a/www/inc/wext/customer.php b/www/inc/wext/customer.php index 9835b79..8f8e308 100644 --- a/www/inc/wext/customer.php +++ b/www/inc/wext/customer.php @@ -27,15 +27,15 @@ class WOCustomer extends WOCustomerAbstract $cc->toTablecustomer($ct); $ct->revert("customerid"); $ct->insert(); - $cc->set_id($ct->customerid); + $cc->setid($ct->customerid); //create addresses - foreach($cc->get_addresses() as $addr){ + foreach($cc->getaddresses() as $addr){ //skip addresses that are deleted - if($addr->get_isdeleted())continue; + if($addr->getisdeleted())continue; $at=WTaddress::newRow(); $addr->toTableaddress($at); $at->revert("addressid"); - $at->customerid=$cc->get_id(); + $at->customerid=$cc->getid(); if($at->insert()===false){ $trans->abortWithError("Database Error: ".$db->lastError()); return; @@ -43,11 +43,11 @@ class WOCustomer extends WOCustomerAbstract // print_r($at); } //create contacts - foreach($cc->get_contacts() as $cont){ + foreach($cc->getcontacts() as $cont){ $cn=WTcontact::newRow(); $cont->toTablecontact($cn); $cn->revert("contactid"); - $cn->customerid=$cc->get_id(); + $cn->customerid=$cc->getid(); $cn->insert(); } @@ -64,7 +64,7 @@ class WOCustomer extends WOCustomerAbstract $trans->abortWithError(tr("Not a valid customer object.")); return; } - $ct=WTcustomer::getFromDB($cc->get_id()); + $ct=WTcustomer::getFromDB($cc->getid()); if(!is_a($ct,"WTcustomer")){ $trans->abortWithError(tr("Customer does not exist in the database.")); return; @@ -73,15 +73,15 @@ class WOCustomer extends WOCustomerAbstract $cc->toTablecustomer($ct); if($ct->isChanged())$ct->update(); //sync addresses - foreach($cc->get_addresses() as $addr){ - $at=WTaddress::getFromDB($addr->get_addressid()); + foreach($cc->getaddresses() as $addr){ + $at=WTaddress::getFromDB($addr->getaddressid()); //new address? $na=false; if(!is_a($at,"WTaddress")){ $na=true; $at=WTaddress::newRow(); } - if($at->customerid != $cc->get_id())$na=true; + if($at->customerid != $cc->getid())$na=true; //push data $addr->toTableaddress($at); $at->revert("customerid"); @@ -90,7 +90,7 @@ class WOCustomer extends WOCustomerAbstract //its new, force insert $at->addressid=null; $at->isdeleted=0; - $at->customerid=$cc->get_id(); + $at->customerid=$cc->getid(); if($at->insert()===false){ $trans->abortWithError("Database Error: ".$db->lastError()); return; @@ -102,22 +102,22 @@ class WOCustomer extends WOCustomerAbstract } //sync contacts $cnlist=array(); - foreach($cc->get_contacts() as $cont){ - $cn=WTcontact::getFromDB($cont->get_contactid()); + foreach($cc->getcontacts() as $cont){ + $cn=WTcontact::getFromDB($cont->getcontactid()); //new one? $nc=false; if(!is_a($cn,"WTcontact")){ $cn=WTcontact::newRow(); $nc=true; } - if($cn->customerid != $cc->get_id())$nc=true; + if($cn->customerid != $cc->getid())$nc=true; //push data $cont->toTablecontact($cn); $cn->revert("contactid"); $cn->revert("customerid"); if($nc){ //new one, insert - $cn->customerid=$cc->get_id(); + $cn->customerid=$cc->getid(); $cn->insert(); }else{ //known one, update @@ -127,7 +127,7 @@ class WOCustomer extends WOCustomerAbstract $cnlist[]=$cn->contactid; } //remove deleted contacts - $cns=WTcontact::selectFromDB("customerid=".$db->escapeInt($cc->get_id())); + $cns=WTcontact::selectFromDB("customerid=".$db->escapeInt($cc->getid())); foreach($cns as $cn){ if(!in_array($cn->contactid,$cnlist)) $cn->deleteFromDB(); diff --git a/www/inc/wext/event.php b/www/inc/wext/event.php index afb9747..b4e2311 100644 --- a/www/inc/wext/event.php +++ b/www/inc/wext/event.php @@ -84,7 +84,7 @@ class WOEvent extends WOEventAbstract $trans->abortWithError(tr("The event to be changed must be a valid event object!")); return; } - $tab=WTevent::getFromDB($evt->get_id()); + $tab=WTevent::getFromDB($evt->getid()); if($tab === false){ $trans->abortWithError(tr("The event is not valid.")); return; @@ -121,7 +121,7 @@ class WOEvent extends WOEventAbstract $dbids[]=$p->pricecategoryid; } $evids=array(); - foreach($this->prop_price as $p)$evids[]=$p->get_pricecategoryid(); + foreach($this->prop_price as $p)$evids[]=$p->getpricecategoryid(); //delete unneeded ones foreach($dbprc as $p){ if(!in_array($p->pricecategoryid,$evids)){ @@ -130,7 +130,7 @@ class WOEvent extends WOEventAbstract } //create new ones, change existing ones foreach($this->prop_price as $p){ - $pcid=$p->get_pricecategoryid(); + $pcid=$p->getpricecategoryid(); if(in_array($pcid,$dbids)){ //exists in DB, compare $pp=$dbp[$pcid]; @@ -199,6 +199,15 @@ class WOEvent extends WOEventAbstract $olst=WOOrder::fromTableArrayorder(WTorder::selectFromDB("orderid in ".$db->escapeIntList($oidl),"ORDER BY orderid")); $trans->setorders($olst); } + + /**called by the GetEntranceEvents transaction*/ + public static function getEntranceEvents($trans) + { + $start=time()+24*3600; + $end=time(); + global $db; + $trans->setevents(WOEvent::fromTableArrayevent(WTevent::selectFromDB("starttime<=".$db->escapeInt($start)." AND endtime>=".$db->escapeInt($end)))); + } }; ?> \ No newline at end of file diff --git a/www/inc/wext/order.php b/www/inc/wext/order.php index ff1e1bc..d2cc241 100644 --- a/www/inc/wext/order.php +++ b/www/inc/wext/order.php @@ -33,7 +33,7 @@ class WOOrderInfo extends WOOrderInfoAbstract //get vouchers $itms=WOVoucher::fromTableArrayvoucher(WTvoucher::selectFromDB("orderid=".$db->escapeInt($this->prop_orderid))); foreach($itms as $it) - $prc+=$it->get_price(); + $prc+=$it->getprice(); //get others $itms=WTitem::selectFromDB("orderid=".$db->escapeInt($this->prop_orderid)); foreach($itms as $it) @@ -138,10 +138,10 @@ class WOOrder extends WOOrderAbstract $prc+=$it->amountToPay(); //add vouchers foreach($this->prop_vouchers as $it) - $prc+=$it->get_price(); + $prc+=$it->getprice(); //add items foreach($this->prop_items as $it) - $prc+=$it->get_totalprice(); + $prc+=$it->gettotalprice(); //return return $prc; } @@ -318,7 +318,7 @@ class WOOrder extends WOOrderAbstract $trans->abortWithError(tr("Voucher is not valid!")); return; } - if($vord->get_amountdue()>0){ + if($vord->getamountdue()>0){ $trans->abortWithError(tr("Voucher cannot be used: it has not been paid for.")); return; } diff --git a/www/inc/wext/ticket.php b/www/inc/wext/ticket.php index f56de70..331c963 100644 --- a/www/inc/wext/ticket.php +++ b/www/inc/wext/ticket.php @@ -13,6 +13,8 @@ class WOTicket extends WOTicketAbstract { + /**returns the amount that is to be paid for this ticket: + if it is to be paid it is equal to the price, otherwise zero*/ public function amountToPay() { if($this->prop_status & self::MaskPay) @@ -20,6 +22,67 @@ class WOTicket extends WOTicketAbstract else return 0; } + + /**called from the UseTicket transaction*/ + public static function useTicket($trans) + { + global $db; + //create result object + $ret=new WOTicketUse; + //check event + $evid=$trans->geteventid(); + $evt=WTevent::getFromDB($evid); + if(!is_a($evt,"WTevent")){ + $ret->setusestatus(WOTicketUse::InvalidEvent); + $trans->ticketuse($ret); + return; + } + //find ticket itself + $tick=WTticket::getFromDB($trans->getticketid()); + if(!is_a($tick,"WTticket")){ + $ret->setusestatus(WOTicketUse::NotFound); + }else{ + if($tick->eventid != $evid){ + $ret->setusestatus(WOTicketUse::WrongEvent); + }else + if($tick->status == WTticket::Ordered){ + //check order pay status + $ord=WOOrder::fromTableorder(WTorder::getFromDB($tick->orderid)); + if($ord->getamountdue()>0){ + $ret->setusestatus(WOTicketUse::Unpaid); + }else{ + //ok, update ticket + $ret->setusestatus(WOTicketUse::Ok); + $tick->status = WTticket::Used; + $tick->update(); + } + }else + if($tick->status == WTticket::Used){ + $ret->setusestatus(WOTicketUse::AlreadyUsed); + }else{ + $ret->setusestatus(WOTicketUse::NotUsable); + } + $ret->setticket(WOTicket::fromTableticket($tick)); + } + //get event statistics data + $ticks=WTticket::selectFromDB("eventid=".$db->escapeInt($evid)); + $am=0; + $amus=0; + $amop=0; + $amrs=0; + foreach($ticks as $tick){ + if(($tick->status & WTticket::MaskUsable)>0)$am++; + if($tick->status == WTticket::Ordered)$amop++; + if($tick->status == WTticket::Used)$amus++; + if($tick->status == WTticket::Reserved)$amrs++; + } + $ret->setamounttickets($am); + $ret->setamountused($amus); + $ret->setamountopen($amop); + $ret->setamountreserved($amrs); + //return + $trans->setticketuse($ret); + } }; ?> \ No newline at end of file -- 1.7.2.5