diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 9971343fd08..dd946c6a8ee 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -173,6 +173,25 @@ if ($action == 'testprinter' && $user->admin) { $action = ''; } +if ($action == 'testprinter2' && $user->admin) { + $error = 0; + if (empty($printerid)) { + $error++; + setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors'); + } + + if (!$error) { + // test + $ret = $printer->sendTestToPrinter($printerid, 1); + if ($ret == 0) { + setEventMessages($langs->trans("TestSentToPrinter", $printername), null); + } else { + setEventMessages($printer->error, $printer->errors, 'errors'); + } + } + $action = ''; +} + if ($action == 'testtemplate' && $user->admin) { $error = 0; // if (empty($printerid)) { @@ -299,7 +318,9 @@ if ($mode == 'config' && $user->admin) { print dol_get_fiche_head($head, $mode, $langs->trans("ModuleSetup"), -1, 'technic'); - print ''.$langs->trans("ReceiptPrinterDesc")."

\n"; + //print info_admin($langs->trans("ThisFeatureIsForESCPOSPrintersOnly")); + + print load_fiche_titre($langs->trans("ReceiptPrinterDesc"), '', '')."\n"; print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''."\n"; @@ -361,17 +382,23 @@ if ($mode == 'config' && $user->admin) { print ''; print ''; // edit icon - print ''; + print img_picto($langs->trans("TestPrinterDesc"), 'printer', 'class="paddingright paddingleft"').'TXT'; + print ''; + // test icon + print ''; + print img_picto($langs->trans("TestPrinterDesc2"), 'printer', 'class="paddingright paddingleft"').'IMG'; + print ''; + print ''; print ''; } } @@ -387,15 +414,15 @@ if ($mode == 'config' && $user->admin) { print '
'; - print load_fiche_titre($langs->trans("ReceiptPrinterTypeDesc"), '', '')."\n"; + print ''.$langs->trans("ReceiptPrinterTypeDesc").'...

'."\n"; print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
'.$langs->trans($printer->listprinters[$line]['fk_profile_name']).''.$printer->listprinters[$line]['parameter'].''; - print img_picto($langs->trans("Edit"), 'edit'); + print ''; + print ''; + print img_picto($langs->trans("Edit"), 'edit', 'class="paddingright"'); print ''; // delete icon print ''; - print img_picto($langs->trans("Delete"), 'delete'); + print img_picto($langs->trans("Delete"), 'delete', 'class="paddingright"'); print ''; // test icon print ''; - print img_picto($langs->trans("TestPrinter"), 'printer'); - print '
'."\n"; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print '
'.$langs->trans("CONNECTOR_DUMMY").':'.$langs->trans("CONNECTOR_DUMMY_HELP").'
'.$langs->trans("CONNECTOR_NETWORK_PRINT").':'.$langs->trans("CONNECTOR_NETWORK_PRINT_HELP").'
'.$langs->trans("CONNECTOR_FILE_PRINT").':'.$langs->trans("CONNECTOR_FILE_PRINT_HELP").'
'.$langs->trans("CONNECTOR_WINDOWS_PRINT").':'.$langs->trans("CONNECTOR_WINDOWS_PRINT_HELP").'
'.$langs->trans("CONNECTOR_CUPS_PRINT").':'.$langs->trans("CONNECTOR_CUPS_PRINT_HELP").'
'.$langs->trans("CONNECTOR_DUMMY").''.$langs->trans("CONNECTOR_DUMMY_HELP").'
'.$form->textwithpicto($langs->trans("CONNECTOR_NETWORK_PRINT"), $langs->trans("FromServerPointOfView")).''.$langs->trans("CONNECTOR_NETWORK_PRINT_HELP").'
'.$form->textwithpicto($langs->trans("CONNECTOR_FILE_PRINT"), $langs->trans("FromServerPointOfView")).''.$langs->trans("CONNECTOR_FILE_PRINT_HELP").'
'.$form->textwithpicto($langs->trans("CONNECTOR_WINDOWS_PRINT"), $langs->trans("FromServerPointOfView")).''.$langs->trans("CONNECTOR_WINDOWS_PRINT_HELP").'
'.$form->textwithpicto($langs->trans("CONNECTOR_CUPS_PRINT"), $langs->trans("FromServerPointOfView")).''.$langs->trans("CONNECTOR_CUPS_PRINT_HELP").'
'; print '
'; @@ -406,6 +433,10 @@ if ($mode == 'config' && $user->admin) { if ($mode == 'template' && $user->admin) { print dol_get_fiche_head($head, $mode, $langs->trans("ModuleSetup"), -1, 'technic'); + //print info_admin($langs->trans("ThisFeatureIsForESCPOSPrintersOnly")); + + print '
'; + print '
'; print ''; if ($action != 'edittemplate') { diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index ebca25d8464..90f30114394 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -569,13 +569,12 @@ class dolReceiptPrinter extends Printer /** * Function to Send Test page to Printer * - * @param int $printerid Printer id - * @return int 0 if OK; >0 if KO + * @param int $printerid Printer id + * @param int $addimgandbarcode Add image and barcode into the test + * @return int 0 if OK; >0 if KO */ - public function sendTestToPrinter($printerid) + public function sendTestToPrinter($printerid, $addimgandbarcode = 0) { - global $conf; - $error = 0; $img = EscposImage::load(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo_bw.png'); //$this->profile = CapabilityProfile::load("TM-T88IV"); @@ -584,11 +583,16 @@ class dolReceiptPrinter extends Printer setEventMessages($this->error, $this->errors, 'errors'); } else { try { - $this->printer->bitImage($img); + if ($addimgandbarcode) { + $this->printer->bitImage($img); + } $this->printer->text("Hello World!\n"); - $testStr = "1234567890"; - $this->printer->barcode($testStr); - //$this->printer->qrcode($testStr, Printer::QR_ECLEVEL_M, 5, Printer::QR_MODEL_1); + if ($addimgandbarcode) { + $testStr = "1234567890"; + $this->printer->barcode($testStr); + //$this->printer->qrcode($testStr, Printer::QR_ECLEVEL_M, 5, Printer::QR_MODEL_1); + } + $this->printer->text("\n"); $this->printer->text("Most simple example\n"); $this->printer->feed(); $this->printer->cut(); @@ -598,6 +602,7 @@ class dolReceiptPrinter extends Printer $data = $this->printer->connector->getData(); dol_syslog($data); } + // Close and print $this->printer->close(); } catch (Exception $e) { $this->errors[] = $e->getMessage(); diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 0c629b2dd01..dba0ab25634 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -155,3 +155,5 @@ LineDiscount=Line discount LineDiscountShort=Line disc. InvoiceDiscount=Invoice discount InvoiceDiscountShort=Invoice disc. +TestPrinterDesc=The server will send a simple test page to a ESC/POS printer +TestPrinterDesc2=The server will send an enhanced test page with image and barcode to a ESC/POS printer \ No newline at end of file diff --git a/htdocs/langs/fr_FR/receiptprinter.lang b/htdocs/langs/fr_FR/receiptprinter.lang index e58f1e57fb6..be970953852 100644 --- a/htdocs/langs/fr_FR/receiptprinter.lang +++ b/htdocs/langs/fr_FR/receiptprinter.lang @@ -9,6 +9,8 @@ ReceiptPrinterDesc=Réglage des imprimantes de tickets ReceiptPrinterTemplateDesc=Réglage des modèles ReceiptPrinterTypeDesc=Exemple de valeurs possibles pour le champ "Paramètres" selon le type de driver ReceiptPrinterProfileDesc=Description des imprimantes de tickets +ThisFeatureIsForESCPOSPrintersOnly=This feature is for ESC/POS printers only +FromServerPointOfView=From the web server point of view. This method must be reachable from the web server hosting. ListPrinters=Liste des imprimantes SetupReceiptTemplate=Réglage des modèles CONNECTOR_DUMMY=Imprimante Test