<pre>
<EventList>
- <Event id="0" start="1190543432">blechsalat</Event>
- <Event id="1" start="1191419769">stringsalat</Event>
+ <Event id="0" start="1190543432" sold="11" capacity="20" reserved="2">blechsalat</Event>
+ <Event id="1" start="1191419769" sold="11" capacity="20" reserved="2">stringsalat</Event>
</EventList>
</pre>
Each event is encapsulated in an <tt>Event</tt> tag. The events have no specific order. The <tt>id</tt> attribute contains the internal ID of the event that can be used to reference it in other requests. The <tt>start</tt> attribute contains the start time of the event as Unix timestamp. The text of the <tt>Event</tt> tag contains the title of the event.<p>
+There are 3 optional attributes: <tt>capacity</tt> contains the maximum number of seats for this event, <tt>sold</tt> the number of tickets that have been sold and <tt>reserved</tt> the number of tickets that have been reserved.<p>
+
<h3>Getting Detailed Event Data</h3>
The <tt>geteventdata</tt> transaction returns detailed data about the event. The request body contains a space separated list of event IDs. The response looks like:<p>
req=0;
eventid=-1;
m_starttime=m_endtime=m_capacity=m_defaultprice=0;
+ m_sold=m_reserved=-1;
m_valid=m_complete=false;
}
m_starttime=QDateTime::currentDateTime().toTime_t();
m_endtime=m_starttime+3600;
m_capacity=10;
+ m_sold=m_reserved=-1;
m_defaultprice=100;
m_valid=false;
m_roomid=m_title=m_artist=m_description=m_cancelreason="";
m_endtime=e.m_endtime;
m_roomid=e.m_roomid;
m_capacity=e.m_capacity;
+ m_sold=e.m_sold;
+ m_reserved=e.m_reserved;
m_defaultprice=e.m_defaultprice;
m_cancelreason=e.m_cancelreason;
m_valid=e.m_valid;
m_starttime=QDateTime::currentDateTime().toTime_t();
m_endtime=m_starttime+3600;
m_capacity=10;
+ m_sold=m_reserved=-1;
m_defaultprice=100;
m_valid=false;
m_roomid=m_title=m_artist=m_description=m_cancelreason="";
m_starttime=el.attribute("start","0").toInt();
m_endtime=el.attribute("end","0").toInt();
m_capacity=el.attribute("capacity","0").toInt();
+ m_sold=el.attribute("sold","-1").toInt();
+ m_reserved=el.attribute("reserved","-1").toInt();
m_defaultprice=el.attribute("defaultprice","0").toInt();
bool iscancel=el.attribute("cancelled","false")=="true";
//get title (if element exists this is a complete list, otherwise only preview)
QString room()const{return m_roomid;}
/**returns the amount of tickets than can be sold for this event, initially this should be a copy of the rooms capacity*/
int capacity()const{return m_capacity;}
+ /**returns how many tickets have been sold (if not available: -1)*/
+ int amountSold()const{return m_sold;}
+ /**returns how many tickets have been reserved (if not available: -1)*/
+ int amountReserved()const{return m_reserved;}
/**returns the normal price of tickets in cent*/
int price()const{return m_defaultprice;}
/**returns whether the event is cancelled*/
QString m_roomid;
//initially a copy from room, can be adjusted
int m_capacity;
+ //contains amount of sold/reserved tickets if available; -1 otherwise
+ int m_sold,m_reserved;
//default pricing in cents
int m_defaultprice;
//if not null/empty: event has been cancelled
{
QList<MEvent>evl=req->getAllEvents();
eventmodel->clear();
- eventmodel->insertColumns(0,2);
+ eventmodel->insertColumns(0,6);
eventmodel->insertRows(0,evl.size());
- eventmodel->setHorizontalHeaderLabels(QStringList()<<tr("Start Time")<<tr("Title"));
+ eventmodel->setHorizontalHeaderLabels(QStringList()<<tr("Start Time")<<tr("Title")<<tr("Capacity")<<tr("Sold")<<tr("Reserved")<<tr("Free"));
for(int i=0;i<evl.size();i++){
eventmodel->setData(eventmodel->index(i,0),evl[i].eventId(),Qt::UserRole);
eventmodel->setData(eventmodel->index(i,0),QDateTime::fromTime_t(evl[i].startTime()).toString(tr("ddd MMMM d yyyy, h:mm ap","time format")));
eventmodel->setData(eventmodel->index(i,1),evl[i].title());
+ eventmodel->setData(eventmodel->index(i,2),evl[i].capacity());
+ eventmodel->setData(eventmodel->index(i,3),evl[i].amountSold());
+ eventmodel->setData(eventmodel->index(i,4),evl[i].amountReserved());
+ eventmodel->setData(eventmodel->index(i,5),evl[i].capacity()-evl[i].amountSold()-evl[i].amountReserved());
}
- eventtable->resizeColumnToContents(0);
- eventtable->resizeColumnToContents(1);
+ eventtable->resizeColumnsToContents();
}
void MOverview::closeEvent(QCloseEvent*ce)
f=f.toLower();
QRegExp fregexp("[a-z0-9_\\.]+");
if(!fregexp.exactMatch(f))return "";
- //do we need an update?
+ //basics
QString dname=dataDir()+"/templates/";
QSettings set;
set.beginGroup("templates/"+profileid);
+ //do we need an update?
QDateTime last=QDateTime::fromTime_t(set.value("lastupdate",0).toInt()+300);
- if(last<QDateTime::currentDateTime()){do{
+ if(last<QDateTime::currentDateTime()){do{//pseudo-loop, so we can use break instead of goto
//get local info
set.beginGroup("checksum");
QStringList files=set.childKeys();
for(int i=0;i<files.size();i++)
fmap.insert(files[i],set.value(files[i]).toString());
set.endGroup();
- //get remote info
+ //get remote info, assume it is still valid if unable to retrieve it
if(!request("gettemplatelist",""))break;
if(responseStatus()!=Ok)break;
+ //remember update time
+ set.setValue("lastupdate",QDateTime::currentDateTime().toTime_t());
+ //parse info
QDomDocument doc;
if(!doc.setContent(responseBody()))break;
//prune old stuff
return false;
if(responseStatus()!=Ok)
return false;
+ //delete it from cache, so it is retrieved again
+ QSettings().remove("templates/"+profileid+"/checksum/"+n);
+ QFile(dataDir()+"/templates/"+n).remove();
+ //return success
return true;
}
function getAllEvents()
{
global $db;
- return $db->select("event","eventid,title,starttime","","ORDER BY starttime");
+ return $db->select("event","eventid,title,starttime,capacity","","ORDER BY starttime");
}
/**Get an overview of events: returns an array of array("eventid"=>int); used by createEventList; returns only events in the future and ordered*/
/**Machine-wrapper for getAllEvents() */
function getAllEventsXml()
{
+ global $db;
$all=getAllEvents();
if($all===false){
header("X-MagicSmoke-Status: Error");
if(count($all)>0)
foreach($all as $k => $ev){
$nod=$xml->createElement("Event",$ev["title"]);
+ //set direct attributes
$nod->setAttribute("id",$ev["eventid"]);
$nod->setAttribute("start",$ev["starttime"]);
+ $nod->setAttribute("capacity",$ev["capacity"]);
+ //find out how many tickets are sold/reserved
+ $res=$db->select("ticket","status","eventid=".$db->escapeInt($ev["eventid"]));
+ if($res===false){
+ $nod->setAttribute("sold",0);
+ $nod->setAttribute("reserved",0);
+ }else{
+ $cnt=0;
+ $rsv=0;
+ foreach($res as $tc){
+ if(($tc["status"] & TICKET_USABLE) == TICKET_USABLE)$cnt++;
+ if($tc["status"]==TICKET_RESERVED)$rsv++;
+ }
+ $nod->setAttribute("sold",$cnt);
+ $nod->setAttribute("reserved",$rsv);
+ }
$root->appendChild($nod);
}
$xml->appendChild($root);
//
//masks
-/**mask: ticket is blocked (can be used or is used)*/
+/**mask: ticket is blocked (is blocking a seat)*/
define("TICKET_MBLOCK",0x100); //dec: 256
/**mask: ticket must be paid or is paid*/
define("TICKET_MPAY",0x200); //dec: 512
+/**mask: ticket is usable by a customer (blocking plus (to be) paid)*/
+define("TICKET_USABLE",0x300); //dec: 768
/**ticket has been reserved by a seller*/
-define("TICKET_RESERVED",0x101); //dec: 257
+define("TICKET_RESERVED",0x301); //dec: 769
/**ticket is part of an order or has been sold independently*/
define("TICKET_BOUGHT",0x302); //dec: 770
/**ticket has been used*/