File name: <tt>eventsummary.odtt</tt><p>
-Loop: <tt>TICKETS</tt> - this loop iterated over the ticket price categories.<p>
+Loop: <tt>TICKETS</tt> - this loop iterates over the ticket price categories.<p>
Variables:
<table frame="1" border="1">
<tr><td>@UNUSED@</td><td>tickets that are still unused</td></tr>
<tr><td>@CANCELLED@</td><td>tickets that were cancelled</td></tr>
<tr><td>@TOTALMONEY@</td><td>the total amount of income for this event</td></tr>
+<tr><td>@TICKETS@</td><td>the amount of ticket lines in the overview</td></tr>
<tr/>
<tr><td>@TICKETS:PRICE@</td><td>the price of this category</td></tr>
<tr><td>@TICKETS:BOUGHT@</td><td>used+unused</td></tr>
<tr><td>@TICKETS:UNUSED@</td><td>tickets from this category that were not used</td></tr>
</table>
+<h2>Order Bills</h2>
+
+File name: <tt>bill.odtt</tt><p>
+
+Loop: <tt>TICKETS</tt> - this loop iterates over each ticket in the order.<p>
+
+(TODO: loop for vouchers)<p>
+
+Variables:
+<table frame="1" border="1">
+<tr><td><b>Variable</b></td><td><b>Description</b></td></tr>
+<tr><td>@ORDERDATE@</td><td>the date when this order has been generated</td></tr>
+<tr><td>@ORDERDATETIME@</td><td>the date and time when this order has been generated</td></tr>
+<tr><td>@SENTDATE@</td><td>the date when this order has been shipped</td></tr>
+<tr><td>@SENTDATETIME@</td><td>the date and time when this order has been shipped</td></tr>
+<tr><td>@CUSTOMERID@</td><td>the ID of the customer</td></tr>
+<tr><td>@ORDERID@</td><td>the ID of the order</td></tr>
+<tr><td>@ADDRESS@</td><td>the address of the customer</td></tr>
+<tr><td>@DELIVERYADDRESS@</td><td>the address it is shipped to, if different from the customers address</td></tr>
+<tr><td>@TOTALPRICE@</td><td>the total price of the order</td></tr>
+<tr><td>@AMOUNTPAID@</td><td>the amount that has already been paid</td></tr>
+<tr><td>@SELLER@</td><td>the login ID of the seller (it is not recommended to use this)</td></tr>
+<tr><td>@COMMENT@</td><td>the comment in the order (it is not recommended to use this)</td></tr>
+<tr><td>@AMOUNTTOPAY@</td><td>the amount that still needs to be paid</td></tr>
+<tr><td>@AMOUNTTOREFUND@</td><td>the amount that has to be refunded</td></tr>
+<tr><td>@TICKETS@</td><td>the amount of tickets in the order</td></tr>
+<tr/>
+<tr><td>@TICKETS:PRICE@</td><td>the price of this ticket</td></tr>
+<tr><td>@TICKETS:ID@</td><td>the ID of this ticket (barcode-string)</td></tr>
+<tr><td>@TICKETS:TITLE@</td><td>the title of the event for this ticket</td></tr>
+<tr><td>@TICKETS:ARTIST@</td><td>the artist of the event for this ticket</td></tr>
+<tr><td>@TICKETS:DATE@</td><td>the date of the event for this ticket</td></tr>
+<tr><td>@TICKETS:STARTTIME@</td><td>the date and start time of the event for this ticket</td></tr>
+<tr><td>@TICKETS:ENDTIME@</td><td>the end date and time of the event for this ticket</td></tr>
+<tr><td>@TICKETS:ROOM@</td><td>the room/place of the event for this ticket</td></tr>
+</table>
+
+
</html>
\ No newline at end of file
return QDateTime::fromTime_t(m_starttime).toString(QCoreApplication::translate("MEvent","yyyy-MM-dd hh:mm ap","date/time format"));
}
+QString MEvent::startDateString()const
+{
+ return QDateTime::fromTime_t(m_starttime).toString(QCoreApplication::translate("MEvent","yyyy-MM-dd","date format"));
+}
+
QString MEvent::endTimeString()const
{
return QDateTime::fromTime_t(m_endtime).toString(QCoreApplication::translate("MEvent","yyyy-MM-dd hh:mm ap","date/time format"));
int endTime()const{return m_endtime;}
/**returns the start time of the event as localized string*/
QString startTimeString()const;
+ /**returns the start date as localized string*/
+ QString startDateString()const;
/**returns the end time of the event as localized string*/
QString endTimeString()const;
/**returns the room of the event, the room must be one out of the list of valid rooms*/
/**returns whether the event is valid. an event can be invalid if it is uninitialized (negative ID) or the server request failed*/
bool isValid()const{return m_valid;}
- /**returns whether the event is complete - this depends on the amount of data sent by the server*/
+ /**returns whether the data stored in this event object is complete - this depends on the amount of data sent by the server*/
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;}
void MEventSummary::saveas()
{
+ QString tf=req->getTemplate("eventsummary.odtt");
+ if(tf==""){
+ QMessageBox::warning(this,tr("Warning"),tr("Unable to get template file (eventsummary.odtt). Giving up."));
+ return;
+ }
QFileDialog fd(this);
fd.setAcceptMode(QFileDialog::AcceptSave);
fd.setFileMode(QFileDialog::AnyFile);
if(fn.size()<1)return;
fname=fn[0];
}
- MOdtSignalRenderer rend("../examples/eventsummary.odtt");
+ MOdtSignalRenderer rend(tf);
connect(&rend,SIGNAL(getVariable(QString,QString&)),this,SLOT(getVariable(QString,QString&)));
connect(&rend,SIGNAL(getLoopIterations(QString,int&)),this,SLOT(getLoopIterations(QString,int&)));
connect(&rend,SIGNAL(getLoopVariable(QString,int,QString,QString&)),this,SLOT(getLoopVariable(QString,int,QString,QString&)));
value=QString::number(ntotalmoney/100)
+tr(".","decimal dot")
+QString().sprintf("%02d",ntotalmoney%100);
+ else
+ if(varname=="TICKETS")
+ value=QString::number(tickets.size());
}
void MEventSummary::getLoopIterations(QString loopname,int&iterations)
return 0;
}
+QString MOrder::amountToPayStr()const
+{
+ return cent2string(amountToPay());
+}
+
+QString MOrder::amountToRefundStr()const
+{
+ return cent2string(amountToRefund());
+}
+
bool MOrder::isSent()const
{
//only in placed mode there is a need for action, hence in all other modes we assume sent
/**returns how much there is to be paid, in cents*/
int amountToPay()const;
+ /**returns how much there is to be paid, as localized string*/
+ QString amountToPayStr()const;
+
/**returns how much there is to be refunded, in cents*/
int amountToRefund()const;
+ /**returns how much there is to be refunded, as localized string*/
+ QString amountToRefundStr()const;
+
/**returns whether the tickets of this order have already been shipped*/
bool isSent()const;
#include "webrequest.h"
#include "ticketrender.h"
#include "labeldlg.h"
+#include "odtrender.h"
#include <QBoxLayout>
#include <QComboBox>
+#include <QFileDialog>
#include <QGridLayout>
#include <QLabel>
#include <QMenu>
m->addAction(tr("Receive &Payment..."));
m->addAction(tr("&Refund..."));
m=mb->addMenu(tr("P&rinting"));
- m->addAction(tr("Print &Bill..."));
- m->addAction(tr("Save Bill &as file..."));
+ m->addAction(tr("Print &Bill..."),this,SLOT(printBill()));
+ m->addAction(tr("Save Bill &as file..."),this,SLOT(saveBill()));
m->addSeparator();
- m->addAction(tr("Print &Tickets..."));
+ m->addAction(tr("Print &Tickets..."),this,SLOT(printTickets()));
m->addAction(tr("Print &Current Ticket..."),this,SLOT(printCurrentTicket()));
m->addAction(tr("&View Tickets..."),this,SLOT(ticketView()));
}
+void MOrderWindow::printBill()
+{
+ QString tf=req->getTemplate("bill.odtt");
+ if(tf==""){
+ QMessageBox::warning(this,tr("Warning"),tr("Unable to get template file (bill.odtt). Giving up."));
+ return;
+ }
+ MOdtSignalRenderer rend(tf);
+ connect(&rend,SIGNAL(getVariable(QString,QString&)),this,SLOT(getVariable(QString,QString&)));
+ connect(&rend,SIGNAL(getLoopIterations(QString,int&)),this,SLOT(getLoopIterations(QString,int&)));
+ connect(&rend,SIGNAL(getLoopVariable(QString,int,QString,QString&)),this,SLOT(getLoopVariable(QString,int,QString,QString&)));
+ rend.renderToPrinter();
+}
+
+void MOrderWindow::saveBill()
+{
+ QString tf=req->getTemplate("eventsummary.odtt");
+ if(tf==""){
+ QMessageBox::warning(this,tr("Warning"),tr("Unable to get template file (eventsummary.odtt). Giving up."));
+ return;
+ }
+ QFileDialog fd(this);
+ fd.setAcceptMode(QFileDialog::AcceptSave);
+ fd.setFileMode(QFileDialog::AnyFile);
+ fd.setConfirmOverwrite(true);
+ fd.setFilter("Open Document Text (*.odt)");
+ fd.setDefaultSuffix("odt");
+ QString fname;
+ if(fd.exec()){
+ QStringList fn=fd.selectedFiles();
+ if(fn.size()<1)return;
+ fname=fn[0];
+ }
+ MOdtSignalRenderer rend(tf);
+ connect(&rend,SIGNAL(getVariable(QString,QString&)),this,SLOT(getVariable(QString,QString&)));
+ connect(&rend,SIGNAL(getLoopIterations(QString,int&)),this,SLOT(getLoopIterations(QString,int&)));
+ connect(&rend,SIGNAL(getLoopVariable(QString,int,QString,QString&)),this,SLOT(getLoopVariable(QString,int,QString,QString&)));
+ rend.renderToFile(fname);
+}
+
+void MOrderWindow::getVariable(QString vn,QString&value)
+{
+ if(vn=="ORDERDATE")value=m_order.orderDateStr();else
+ if(vn=="ORDERDATETIME")value=m_order.orderDateTimeStr();else
+ if(vn=="SENTDATE")value=m_order.sentDateStr();else
+ if(vn=="SENTDATETIME")value=m_order.sentDateTimeStr();else
+ if(vn=="CUSTOMERID")value=QString::number(m_order.customerID());else
+ if(vn=="ORDERID")value=QString::number(m_order.orderID());else
+ if(vn=="ADDRESS")value=m_order.customer().address();else
+ if(vn=="DELIVERYADDRESS")value=m_order.deliveryAddress();else
+ if(vn=="TOTALPRICE")value=m_order.totalPriceString();else
+ if(vn=="AMOUNTPAID")value=m_order.amountPaidString();else
+ if(vn=="SELLER")value=m_order.seller();else
+ if(vn=="COMMENT")value=m_order.comment();else
+ if(vn=="AMOUNTTOPAY")value=m_order.amountToPayStr();else
+ if(vn=="AMOUNTTOREFUND")value=m_order.amountToRefundStr();else
+ if(vn=="TICKETS")value=QString::number(m_ticketmodel->rowCount());
+}
+
+void MOrderWindow::getLoopIterations(QString loopname,int&iterations)
+{
+ if(loopname=="TICKETS")iterations=m_ticketmodel->rowCount();
+}
+void MOrderWindow::getLoopVariable(QString loopname,int it,QString vn,QString&value)
+{
+ if(loopname!="TICKETS")return;
+ if(it<0 || it>=m_ticketmodel->rowCount())return;
+
+ QList<MTicket>tickets=m_order.tickets();
+
+ if(vn=="PRICE")value=tickets[it].priceString();else
+ if(vn=="ID")value=tickets[it].ticketID();else
+ if(vn=="TITLE")value=tickets[it].event().title();else
+ if(vn=="ARTIST")value=tickets[it].event().artist();else
+ if(vn=="DATE")value=tickets[it].event().startDateString();else
+ if(vn=="STARTTIME")value=tickets[it].event().startTimeString();else
+ if(vn=="ENDTIME")value=tickets[it].event().endTimeString();else
+ if(vn=="ROOM")value=tickets[it].event().room();
+}
+
/*************************************************************************************/
void printTickets();
/**internal helper: print list of tickets*/
void printTickets(QList<MTicket>);
+
+ /**print a bill*/
+ void printBill();
+ /**save the bill as file*/
+ void saveBill();
+ /**callback for bill generator: variables; see MOdtSignalRenderer for details*/
+ void getVariable(QString varname,QString&value);
+ /**callback for bill generator: loops; see MOdtSignalRenderer for details*/
+ void getLoopIterations(QString loopname,int&iterations);
+ /**callback for bill generator: loop variables; see MOdtSignalRenderer for details*/
+ void getLoopVariable(QString loopname,int iteration,QString varname,QString&value);
+
private:
MWebRequest*req;