Ticket: Use printer templates from config
This commit is contained in:
parent
1abd6bfa90
commit
cbc0dd0ad6
@ -726,10 +726,7 @@ void ATBDeviceControllerPlugin::onNewVoltage(uint32_t voltage)
|
|||||||
*/
|
*/
|
||||||
void ATBDeviceControllerPlugin::requestPrintTicket(nsDeviceControllerInterface::TICKET_VARIANT ticketVariant, const QHash<QString, QVariant> & printingData)
|
void ATBDeviceControllerPlugin::requestPrintTicket(nsDeviceControllerInterface::TICKET_VARIANT ticketVariant, const QHash<QString, QVariant> & printingData)
|
||||||
{
|
{
|
||||||
QList<quint8> templateList;
|
QList<quint8> templateList = this->ticketTemplateList[ticketVariant];
|
||||||
|
|
||||||
// TODO: read template list from .ini
|
|
||||||
|
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
qCritical() << "------------------------------------------------------------------------";
|
qCritical() << "------------------------------------------------------------------------";
|
||||||
|
@ -50,25 +50,42 @@ bool Ticket::initNew(TICKET_VARIANT ticketVariant, const QList<quint8> & templat
|
|||||||
qCritical() << " -> " << ticketVariant;
|
qCritical() << " -> " << ticketVariant;
|
||||||
|
|
||||||
int multiplicatorInt = 1; // default
|
int multiplicatorInt = 1; // default
|
||||||
|
quint8 headerTemplate;
|
||||||
|
quint8 multiTemplate;
|
||||||
|
quint8 footerTemplate;
|
||||||
|
|
||||||
switch (this->ticketVariant) {
|
switch (this->ticketVariant) {
|
||||||
case TICKET_VARIANT::PARKING_TICKET:
|
|
||||||
break;
|
|
||||||
case TICKET_VARIANT::RECEIPT:
|
|
||||||
break;
|
|
||||||
case TICKET_VARIANT::ERROR_RECEIPT:
|
|
||||||
break;
|
|
||||||
case TICKET_VARIANT::START_RECEIPT:
|
case TICKET_VARIANT::START_RECEIPT:
|
||||||
this->_templateList << 21 << 22 << 23;
|
if (templateList.isEmpty()) {
|
||||||
|
this->_templateList << 21 << 22 << 23;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this->_templateList = templateList;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TICKET_VARIANT::STOP_RECEIPT:
|
case TICKET_VARIANT::STOP_RECEIPT:
|
||||||
this->_templateList << 24 << 25 << 26;
|
if (templateList.isEmpty()) {
|
||||||
|
this->_templateList << 24 << 25 << 26;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this->_templateList = templateList;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TICKET_VARIANT::FINE_PAYMENT:
|
case TICKET_VARIANT::FINE_PAYMENT:
|
||||||
this->_templateList << 24 << 25 << 26;
|
if (templateList.isEmpty()) {
|
||||||
|
this->_templateList << 24 << 25 << 26;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this->_templateList = templateList;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TICKET_VARIANT::FREE_TICKET:
|
case TICKET_VARIANT::FREE_TICKET:
|
||||||
this->_templateList << 24 << 25 << 26;
|
if (templateList.isEmpty()) {
|
||||||
|
this->_templateList << 24 << 25 << 26;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this->_templateList = templateList;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TICKET_VARIANT::FOOD_STAMP:
|
case TICKET_VARIANT::FOOD_STAMP:
|
||||||
if (printingData.contains("dyn1_list")) {
|
if (printingData.contains("dyn1_list")) {
|
||||||
@ -78,19 +95,52 @@ bool Ticket::initNew(TICKET_VARIANT ticketVariant, const QList<quint8> & templat
|
|||||||
this->dyn2List = printingData["dyn2_list"].toStringList();
|
this->dyn2List = printingData["dyn2_list"].toStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (templateList.isEmpty()) {
|
||||||
|
headerTemplate = 0;
|
||||||
|
multiTemplate = 1;
|
||||||
|
footerTemplate = 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (templateList.size() == 2) {
|
||||||
|
headerTemplate = 0;
|
||||||
|
multiTemplate = templateList.at(0);
|
||||||
|
footerTemplate = templateList.at(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (templateList.size() == 3) {
|
||||||
|
headerTemplate = templateList.at(0);
|
||||||
|
multiTemplate = templateList.at(1);
|
||||||
|
footerTemplate = templateList.at(2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
headerTemplate = 0;
|
||||||
|
multiTemplate = 1;
|
||||||
|
footerTemplate = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// header is optional:
|
||||||
|
if (headerTemplate != 0) {
|
||||||
|
this->_templateList << headerTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
if (printingData.contains("multiplicator")) {
|
if (printingData.contains("multiplicator")) {
|
||||||
multiplicatorInt = printingData["multiplicator"].toInt();
|
multiplicatorInt = printingData["multiplicator"].toInt();
|
||||||
for (int i = 1; i < multiplicatorInt; i++) {
|
for (int i = 1; i < multiplicatorInt; i++) {
|
||||||
this->_templateList << 1;
|
this->_templateList << multiTemplate;
|
||||||
}
|
}
|
||||||
// last template:
|
// last template:
|
||||||
this->_templateList << 2;
|
this->_templateList << footerTemplate;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this->_templateList = templateList;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEBUG FOOD_STAMP:
|
// DEBUG FOOD_STAMP:
|
||||||
qCritical() << " --> printingData[\"multiplicator\"]" << multiplicatorInt;
|
qCritical() << " --> printingData[\"multiplicator\"]" << multiplicatorInt;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
this->_templateList = templateList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user