diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 6ea04d4a548..7c5f72e12c6 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -49,8 +49,7 @@ * Print object total tax * Print object local tax * Print object total - * Print order lines for Printer1 - * Print order lines for Printer2 + * Print order lines for Printer * Print payment method * * Code which can be placed everywhere @@ -134,6 +133,12 @@ class dolReceiptPrinter extends Printer public $printer; public $template; + /** + * Number of order printer + * @var int + */ + public $orderprinter; + /** * @var string Error code (or message) */ @@ -191,8 +196,7 @@ class dolReceiptPrinter extends Printer 'dol_print_object_local_tax', 'dol_print_object_total', 'dol_print_object_number', - 'dol_print_order_lines_printer1', - 'dol_print_order_lines_printer2', + 'dol_print_order_lines', 'dol_value_customer_firstname', 'dol_value_customer_lastname', 'dol_value_customer_mail', @@ -726,20 +730,9 @@ class dolReceiptPrinter extends Printer case 'DOL_BEEP': $this->printer->getPrintConnector() -> write("\x1e"); break; - case 'DOL_PRINT_ORDER_LINES_PRINTER1': + case 'DOL_PRINT_ORDER_LINES': foreach ($object->lines as $line) { - if ($line->special_code == 1) - { - $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1; - $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); - $this->printer->text(strip_tags(htmlspecialchars_decode($line->desc))."\n"); - } - } - break; - case 'DOL_PRINT_ORDER_LINES_PRINTER2': - foreach ($object->lines as $line) { - if ($line->special_code == 2) + if ($line->special_code==$this->orderprinter) { $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1; $spaces = str_repeat(' ', $spacestoadd); diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index c83f57173e5..10a679615a9 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -41,7 +41,7 @@ if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY'.$terminal.'_id'])) // Security check if (!$user->admin) accessforbidden(); -$langs->loadLangs(array("admin", "cashdesk")); +$langs->loadLangs(array("admin", "cashdesk", "printing")); global $db; @@ -85,6 +85,8 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "CASHDESK_ID_WAREHOUSE".$terminaltouse, (GETPOST('CASHDESK_ID_WAREHOUSE'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_WAREHOUSE'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK".$terminaltouse, GETPOST('CASHDESK_NO_DECREASE_STOCK'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_PRINTER_TO_USE".$terminaltouse, GETPOST('TAKEPOS_PRINTER_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER1_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER2_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES".$terminaltouse, GETPOST('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS".$terminaltouse, GETPOST('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); @@ -234,9 +236,13 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { print $form->selectarray('TAKEPOS_PRINTER_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_PRINTER_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_PRINTER_TO_USE'.$terminal}), 1); print ''; if ($conf->global->TAKEPOS_ORDER_PRINTERS) { - print ''.$langs->trans("OrderPrinterToUse").''; + print ''.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 1'; print ''; - print $form->selectarray('TAKEPOS_ORDER_PRINTER_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_ORDER_PRINTER_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_ORDER_PRINTER_TO_USE'.$terminal}), 1); + print $form->selectarray('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal}), 1); + print ''; + print ''.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 2'; + print ''; + print $form->selectarray('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal}), 1); print ''; } $printer->listPrintersTemplates(); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 2e85f8c2afa..95766802b76 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -526,6 +526,7 @@ if ($action == "order" and $placeid != 0) $result = array_intersect($catsprinter1, $existing); $count = count($result); if ($count > 0) { + $linestoprint++; $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='1' where rowid=".$line->id; //Set to print on printer 1 $db->query($sql); $order_receipt_printer1 .= ''.$line->product_label.''.$line->qty; @@ -533,17 +534,18 @@ if ($action == "order" and $placeid != 0) $order_receipt_printer1 .= ''; } } - if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $count > 0) { + if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $linestoprint > 0) { $invoice->fetch($placeid); //Reload object before send to printer - $ret = $printer->sendToPrinter($invoice, $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION["takeposterminal"]}, $conf->global->{'TAKEPOS_PRINTER_TO_USE'.$_SESSION["takeposterminal"]}); // PRINT TO PRINTER 1 + $printer->orderprinter=1; + $ret = $printer->sendToPrinter($invoice, $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION["takeposterminal"]}, $conf->global->{'TAKEPOS_ORDER_PRINTER1_TO_USE'.$_SESSION["takeposterminal"]}); // PRINT TO PRINTER 1 } $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id; // Set as printed $db->query($sql); $invoice->fetch($placeid); //Reload object after set lines as printed + $linestoprint=0; foreach ($invoice->lines as $line) { - $count=0; if ($line->special_code == "4") { continue; } @@ -552,6 +554,7 @@ if ($action == "order" and $placeid != 0) $result = array_intersect($catsprinter2, $existing); $count = count($result); if ($count > 0) { + $linestoprint++; $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='2' where rowid=".$line->id; //Set to print on printer 2 $db->query($sql); $order_receipt_printer2 .= ''.$line->product_label.''.$line->qty; @@ -559,9 +562,10 @@ if ($action == "order" and $placeid != 0) $order_receipt_printer2 .= ''; } } - if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $count > 0) { + if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $linestoprint > 0) { $invoice->fetch($placeid); //Reload object before send to printer - $ret = $printer->sendToPrinter($invoice, $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION["takeposterminal"]}, $conf->global->{'TAKEPOS_PRINTER_TO_USE'.$_SESSION["takeposterminal"]}); // PRINT TO PRINTER 2 + $printer->orderprinter=2; + $ret = $printer->sendToPrinter($invoice, $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION["takeposterminal"]}, $conf->global->{'TAKEPOS_ORDER_PRINTER2_TO_USE'.$_SESSION["takeposterminal"]}); // PRINT TO PRINTER 2 } $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id; // Set as printed $db->query($sql);