From 8a765bf5fd32d12e2a798818a51cb572ac66c489 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Thu, 5 Nov 2015 16:20:35 +0100 Subject: [PATCH] wip --- htdocs/admin/receiptprinter.php | 6 +++--- htdocs/core/class/dolreceiptprinter.class.php | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 8e3c7388adf..eb4a2da0570 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -425,7 +425,7 @@ if ($mode == 'template' && $user->admin) } // to remove after test -$object->date = '2015-11-02 22:30:25'; +$object->date_time = '2015-11-02 22:30:25'; $object->id = 1234; $object->customer_firstname = 'John'; $object->customer_lastname = 'Deuf'; @@ -433,8 +433,8 @@ $object->vendor_firstname = 'Jim'; $object->vendor_lastname = 'Big'; $object->barcode = '3700123862396'; -//$printer->sendToPrinter($object, 1, 16); -//setEventMessages($printer->error, $printer->errors, 'errors'); +$printer->sendToPrinter($object, 1, 16); +setEventMessages($printer->error, $printer->errors, 'errors'); llxFooter(); diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 5271950706a..5afb24fe43e 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -429,6 +429,7 @@ class dolReceiptPrinter extends Escpos $this->template = str_replace('', $object->customer_account_balance, $this->template); $this->template = str_replace('', $object->vendor_firstname, $this->template); $this->template = str_replace('', $object->vendor_lastname, $this->template); + $this->template = str_replace('', $object->date_time, $this->template); // parse template $p = xml_parser_create(); @@ -438,6 +439,7 @@ class dolReceiptPrinter extends Escpos //print '
'.print_r($vals, true).'
'; // print ticket $level = 0; + $html = '
';
         $ret = $this->InitPrinter($printerid);
         if ($ret>0) {
             setEventMessages($this->error, $this->errors, 'errors');
@@ -446,33 +448,37 @@ class dolReceiptPrinter extends Escpos
                 switch ($vals[$line]['tag']) {
                     case 'DOL_ALIGN_CENTER':
                         $this->printer->setJustification(Escpos::JUSTIFY_CENTER);
+                        $html.='
'; $this->printer->text($vals[$line]['value']); break; case 'DOL_ALIGN_RIGHT': $this->printer->setJustification(Escpos::JUSTIFY_RIGHT); + $html.=''; break; case 'DOL_ALIGN_LEFT': $this->printer->setJustification(Escpos::JUSTIFY_LEFT); + $html.=''; break; case 'DOL_OPEN_DRAWER': $this->printer->pulse(); + $html.= ' ϟ'.nl2br($vals[$line]['value']); break; case 'DOL_PRINT_BARCODE': // $vals[$line]['value'] -> barcode($content, $type) $this->printer->barcode($object->barcode); break; - case 'DOL_PRINT_DATE_TIME': - $this->printer->text($object->date); - break; case 'DOL_PRINT_QRCODE': // $vals[$line]['value'] -> qrCode($content, $ec, $size, $model) $this->printer->qrcode($vals[$line]['value']); + $html.='QRCODE: '.$vals[$line]['value']; break; case 'DOL_CUT_PAPER_FULL': $this->printer->cut(Escpos::CUT_FULL); + $html.= ' ✂'.nl2br($vals[$line]['value']); break; case 'DOL_CUT_PAPER_PARTIAL': $this->printer->cut(Escpos::CUT_PARTIAL); + $html.= ' ✂'.nl2br($vals[$line]['value']); break; case 'DOL_USE_FONT_A': $this->printer->setFont(Escpos::FONT_A); @@ -488,11 +494,14 @@ class dolReceiptPrinter extends Escpos break; default: $this->printer->text($vals[$line]['value']); + $html.= nl2br($vals[$line]['value']); $this->errors[] = 'UnknowTag: <'.strtolower($vals[$line]['tag']).'>'; $error++; break; } } + $html.= '
'; + print $html; // Close and print // uncomment next line to see content sent to printer //print '
'.print_r($this->connector, true).'
';