Ticket: Use printer templates from config
This commit is contained in:
		@@ -726,10 +726,7 @@ void ATBDeviceControllerPlugin::onNewVoltage(uint32_t voltage)
 | 
			
		||||
 */
 | 
			
		||||
void ATBDeviceControllerPlugin::requestPrintTicket(nsDeviceControllerInterface::TICKET_VARIANT ticketVariant, const QHash<QString, QVariant> & printingData)
 | 
			
		||||
{
 | 
			
		||||
    QList<quint8> templateList;
 | 
			
		||||
 | 
			
		||||
    // TODO: read template list from .ini
 | 
			
		||||
 | 
			
		||||
    QList<quint8> templateList = this->ticketTemplateList[ticketVariant];
 | 
			
		||||
 | 
			
		||||
    // DEBUG
 | 
			
		||||
    qCritical() << "------------------------------------------------------------------------";
 | 
			
		||||
 
 | 
			
		||||
@@ -50,25 +50,42 @@ bool Ticket::initNew(TICKET_VARIANT ticketVariant, const QList<quint8> & templat
 | 
			
		||||
    qCritical() << "      -> " << ticketVariant;
 | 
			
		||||
 | 
			
		||||
    int multiplicatorInt = 1;  // default
 | 
			
		||||
    quint8 headerTemplate;
 | 
			
		||||
    quint8 multiTemplate;
 | 
			
		||||
    quint8 footerTemplate;
 | 
			
		||||
 | 
			
		||||
    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:
 | 
			
		||||
        this->_templateList << 21 << 22 << 23;
 | 
			
		||||
        if (templateList.isEmpty()) {
 | 
			
		||||
            this->_templateList << 21 << 22 << 23;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            this->_templateList = templateList;
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
    case TICKET_VARIANT::STOP_RECEIPT:
 | 
			
		||||
        this->_templateList << 24 << 25 << 26;
 | 
			
		||||
        if (templateList.isEmpty()) {
 | 
			
		||||
            this->_templateList << 24 << 25 << 26;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            this->_templateList = templateList;
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
    case TICKET_VARIANT::FINE_PAYMENT:
 | 
			
		||||
        this->_templateList << 24 << 25 << 26;
 | 
			
		||||
        if (templateList.isEmpty()) {
 | 
			
		||||
            this->_templateList << 24 << 25 << 26;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            this->_templateList = templateList;
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
    case TICKET_VARIANT::FREE_TICKET:
 | 
			
		||||
        this->_templateList << 24 << 25 << 26;
 | 
			
		||||
        if (templateList.isEmpty()) {
 | 
			
		||||
            this->_templateList << 24 << 25 << 26;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            this->_templateList = templateList;
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
    case TICKET_VARIANT::FOOD_STAMP:
 | 
			
		||||
         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();
 | 
			
		||||
         }
 | 
			
		||||
 | 
			
		||||
         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")) {
 | 
			
		||||
             multiplicatorInt = printingData["multiplicator"].toInt();
 | 
			
		||||
             for (int i = 1; i < multiplicatorInt; i++) {
 | 
			
		||||
                 this->_templateList << 1;
 | 
			
		||||
                 this->_templateList << multiTemplate;
 | 
			
		||||
             }
 | 
			
		||||
             // last template:
 | 
			
		||||
             this->_templateList << 2;
 | 
			
		||||
             this->_templateList << footerTemplate;
 | 
			
		||||
         }
 | 
			
		||||
         else {
 | 
			
		||||
             this->_templateList = templateList;
 | 
			
		||||
         }
 | 
			
		||||
 | 
			
		||||
         // DEBUG FOOD_STAMP:
 | 
			
		||||
         qCritical() << "     --> printingData[\"multiplicator\"]" << multiplicatorInt;
 | 
			
		||||
 | 
			
		||||
        break;
 | 
			
		||||
    default:
 | 
			
		||||
        this->_templateList = templateList;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user