Attributes and tags are the same as for the <tt>geteventdata</tt> response. Except that the <tt>id</tt> attribute may contain the value <tt>"new"</tt> to create a new event, a negative integer is not allowed.<p>
-The response contains the ID of the new/changed event if the status is "Ok". In the case of failure the status will be "Error" and an optional reason for the failure may be in the body.
+The response contains the ID of the new/changed event if the status is "Ok". In the case of failure the status will be "Error" and an optional reason for the failure may be in the body.<p>
+
+The request must not change the cancellation status of an event - the attribute "cancelled" is ignored and the element "CancelReason" may be ignored if it violates the current status.<p>
<h3>Getting a Ticket Summary of an Event</h3>
</pre>
+<h3>Cancelling an Event</h3>
+
+The <tt>cancelevent</tt> transaction can be used to cancel an event. This transaction is not reversible. The request contains the event-ID and the cancel reason separated by a newline, the response is empty.
+
+
<!-- ************************************************************************************
************************************************************************************
************************************************************************************ -->
{
return QDateTime::fromTime_t(m_endtime).toString(QCoreApplication::translate("MEvent","yyyy-MM-dd hh:mm ap","date/time format"));
}
+
+bool MEvent::cancelEvent(QString cr)
+{
+ QByteArray rq=QByteArray::number(eventid)+"\n"+cr.toUtf8();
+ if(!req->request("cancelevent",rq))return false;
+ return req->responseStatus()==MWebRequest::Ok;
+}
bool isComplete()const{return m_complete;}
/**forces the event to believe it is valid and complete; used for saving new events*/
void makeValid(){m_valid=true;m_complete=true;}
+
+ /**requests to cancel the event from the DB; expects reason as argument; returns true on success*/
+ bool cancelEvent(QString);
private:
//used by both constructors:
void initFromElement(QDomElement&);
price->setValidator(new QRegExpValidator(event.priceRegExp(),this));
price->setText(event.priceString());
- gl->addWidget(cancelcheck=new QCheckBox(tr("Cancel Event:")),++lctr,0);
+ gl->addWidget(cancelcheck=new QCheckBox(tr("Event Cancelled:")),++lctr,0);
cancelcheck->setChecked(event.isCancelled());
+ cancelcheck->setEnabled(false);
gl->addWidget(cancelreason=new QLineEdit,lctr,1);
cancelreason->setEnabled(event.isCancelled());
cancelreason->setText(event.cancelReason());
vl->addWidget(p=new QPushButton(tr("Ticket Summary...")),0);
connect(p,SIGNAL(clicked()),this,SLOT(eventSummary()));
p->setEnabled(req->hasRole("eventsummary"));
+ vl->addSpacing(15);
+ vl->addWidget(p=new QPushButton(tr("Cancel Event...")),0);
+ p->setEnabled(req->hasRole("cancelevent"));
+ connect(p,SIGNAL(clicked()),this,SLOT(eventCancel()));
vl->addStretch(10);
//Shopping Cart Tab
ed.exec();
}
+void MOverview::eventCancel()
+{
+ int id;
+ QModelIndexList ilst=eventtable->selectionModel()->selectedIndexes();
+ if(ilst.size()<1)return;
+ QModelIndex idx=eventmodel->index(ilst[0].row(),0);
+ id=eventmodel->data(idx,Qt::UserRole).toInt();
+ if(id<0)return;
+ MEvent ev(req,id);
+ if(ev.isValid()){
+ bool ok;
+ QString r=QInputDialog::getText(this,tr("Cancel Event"),tr("Please enter a reason to cancel event \"%1\" or abort:").arg(ev.title()),QLineEdit::Normal,"",&ok);
+ if(!ok)return;
+ if(ev.cancelEvent(r))
+ QMessageBox::information(this,tr("Event Cancelled"),tr("The event \"%1\" has been cancelled. Please inform everybody who bought a ticket.").arg(ev.title()));
+ else
+ QMessageBox::warning(this,tr("Warning"),tr("Unable to cancel event \"%1\".").arg(ev.title()));
+ }
+}
+
void MOverview::updateUsers()
{
QList<MUser>usl=req->getAllUsers();
void eventOrderTicket();
/**open event summary*/
void eventSummary();
+ /**cancel the event*/
+ void eventCancel();
/**get all orders, update list*/
void updateOrders();
$end=trim($doc->getAttribute("end"))+0;
$capacity=trim($doc->getAttribute("capacity"))+0;
$defaultprice=trim($doc->getAttribute("defaultprice"))+0;
- $cancelled=trim($doc->getAttribute("cancelled"));
$title=$artist=$description=$room=$cancelreason="";
foreach($doc->getElementsByTagName("Title") as $el)
foreach($el->childNodes as $cn)
echo "Invalid Event ID, must be positive integer or 'new'.";
return;
}
- if($cancelled!="true" && $cancelled!="false"){
- header("X-MagicSmoke-Status: Error");
- echo "Event neither cancelled, nor non-cancelled.";
- return;
- }
if($title==""){
header("X-MagicSmoke-Status: Error");
echo "Empty Title.";
$data["roomid"]=$room;
$data["capacity"]=$capacity;
$data["defaultprice"]=$defaultprice;
- if($cancelled=="true")
- $data["cancelreason"]=$cancelreason." ";
- else
- $data["cancelreason"]=false;
if($eventid=="new"){
//create event
$eventid=$db->insert("event",$data);
}else{
//check ID
$eventid=$eventid+0;
- $res=$db->select("event","eventid","eventid=".$eventid);
+ $res=$db->select("event","eventid,cancelreason","eventid=".$eventid);
if(count($res)==0){
header("X-MagicSmoke-Status: Error");
echo "Invalid Event: eventid does not exist in database.";
$db->rollbackTransaction();
return;
}
+ if($res[0]["cancelreason"]!==NULL && $res[0]["cancelreason"]!="")
+ $data["cancelreason"]=$cancelreason." ";
$db->update("event",$data,"eventid=".$eventid);
}
$db->commitTransaction();
print($xml->saveXml());
}
+function cancelEventXml($data)
+{
+ $lst=explode("\n",$data);
+ if(count($lst)!=2){
+ header("X-MagicSmoke-Status: Error");
+ die(tr("Malformed request."));
+ }
+ $eid=trim($lst[0]);
+ if(!is_numeric($eid)){
+ header("X-MagicSmoke-Status: Error");
+ die(tr("The event id must be numeric."));
+ }
+ $eid=$eid+0;
+ if($eid<0){
+ header("X-MagicSmoke-Status: Error");
+ die(tr("Invalid event id."));
+ }
+ //check event id
+ global $db;
+ $db->beginTransaction();
+ $res=$db->select("event","eventid,cancelreason","eventid=".$db->escapeInt($eid));
+ if(count($res)<1){
+ header("X-MagicSmoke-Status: Error");
+ $db->rollbackTransaction();
+ die(tr("Invalid event id."));
+ }
+ //update cancelreason
+ $db->update("event",array("cancelreason"=>(trim($lst[1])." ")),"eventid=".$db->escapeInt($eid));
+ //propagate to tickets (does not hurt to do this multiple times)
+ $db->update("ticket",array("status"=>TICKET_CANCELLED),"eventid=".$db->escapeInt($eid)." AND status!=".$db->escapeInt(TICKET_USED));
+ $db->commitTransaction();
+ header("X-MagicSmoke-Status: Ok");
+}
+
?>
\ No newline at end of file
//all requests below here need a role entry in the DB
tr("getusers"),tr("setuserdescription"),tr("getuseracl"),tr("setuseracl"),tr("getuserhosts"),tr("setuserhosts"),tr("adduser"),tr("deleteuser"),tr("setmypasswd"),tr("setpasswd"),//user management
tr("gethosts"),tr("sethost"),tr("addhost"),tr("deletehost"), //host management
- tr("geteventlist"),tr("geteventdata"),tr("seteventdata"),tr("eventsummary"), //event infos
+ tr("geteventlist"),tr("geteventdata"),tr("seteventdata"),tr("eventsummary"),tr("cancelevent"),//event infos
tr("getroomdata"),tr("setroomdata"),//room infos
tr("getcustomerlist"),tr("getcustomer"),tr("setcustomer"), //customer info
tr("checkorder"),tr("createorder"),tr("createsale"),tr("getorderlist"),tr("getorder"),tr("orderpay"),tr("orderrefund"), //sell/order stuff
exit();
}
+//cancel an event
+if($SMOKEREQUEST=="cancelevent"){
+ cancelEventXml(trim($REQUESTDATA));
+ exit();
+}
+
//get room
if($SMOKEREQUEST=="getroomdata"){
getRoomsXml($REQUESTDATA);