diff --git a/htdocs/takepos/admin/orderprinters.php b/htdocs/takepos/admin/orderprinters.php index b396655dea4..c7ebbebffb7 100644 --- a/htdocs/takepos/admin/orderprinters.php +++ b/htdocs/takepos/admin/orderprinters.php @@ -42,6 +42,7 @@ $catname = GETPOST('catname', 'alpha'); $action = GETPOST('action', 'aZ09'); $printer1 = GETPOST('printer1', 'alpha'); $printer2 = GETPOST('printer2', 'alpha'); +$printer3 = GETPOST('printer3', 'alpha'); if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility @@ -64,6 +65,14 @@ if ($action == "SavePrinter2") { dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_2", $printedcategories, 'chaine', 0, '', $conf->entity); } +if ($action == "SavePrinter3") { + $printedcategories = ";"; + if (is_array($printer3)) foreach ($printer3 as $cat) { + $printedcategories = $printedcategories.$cat.";"; + } + dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_3", $printedcategories, 'chaine', 0, '', $conf->entity); +} + /* * View @@ -206,6 +215,33 @@ if ($nbofentries > 0) print ''; print ''; } + +//Printer3 +print ''; +print ''; +$nbofentries = (count($data) - 1); +print ''; +if ($nbofentries > 0) +{ + print ''; +} else { + print ''; + print ''; + print ''; +} + print "
'.$langs->trans("Printer").' 3'; +print '
'; + print ''; + foreach ($data as $row) { + if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_3, ';'.$row["rowid"].';') !== false) $checked = 'checked'; else $checked = ''; + if ($row["fk_menu"] == 0) print ''.$row["label"].'
'; + } + print '
'; + print ''; + print ''; + print '
'.img_picto_common('', 'treemenu/branchbottom.gif').''; + print $langs->trans("NoCategoryYet"); + print ' 
"; print ''; diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index 384be4f8f13..108fdea0b64 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -87,6 +87,7 @@ if (GETPOST('action', 'alpha') == 'set') $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_ORDER_PRINTER3_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER3_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); @@ -242,6 +243,10 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { 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 ''; + print ''.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 3'; + print ''; + print $form->selectarray('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal}), 1); + print ''; } $printer->listPrintersTemplates(); $templates = array(); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index eee4faf9d43..82f97b88dc3 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -532,8 +532,10 @@ if ($action == "order" and $placeid != 0) $footerorder = ''.dol_print_date(dol_now(), 'dayhour').'
'; $order_receipt_printer1 = ""; $order_receipt_printer2 = ""; + $order_receipt_printer3 = ""; $catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1); $catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2); + $catsprinter3 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_3); foreach ($invoice->lines as $line) { if ($line->special_code == "4") { @@ -588,6 +590,34 @@ if ($action == "order" and $placeid != 0) $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); $invoice->fetch($placeid); //Reload object after set lines as printed + $linestoprint = 0; + + foreach ($invoice->lines as $line) + { + if ($line->special_code == "4") { + continue; + } + $c = new Categorie($db); + $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); + $result = array_intersect($catsprinter3, $existing); + $count = count($result); + if ($count > 0) { + $linestoprint++; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=".$line->id; //Set to print on printer 3 + $db->query($sql); + $order_receipt_printer3 .= ''.$line->product_label.''.$line->qty; + if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer3 .= "
(".$line->array_options['options_order_notes'].")"; + $order_receipt_printer3 .= ''; + } + } + if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $linestoprint > 0) { + $invoice->fetch($placeid); //Reload object before send to printer + $printer->orderprinter = 3; + $ret = $printer->sendToPrinter($invoice, $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION["takeposterminal"]}, $conf->global->{'TAKEPOS_ORDER_PRINTER3_TO_USE'.$_SESSION["takeposterminal"]}); // PRINT TO PRINTER 3 + } + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='3' and fk_facture=".$invoice->id; // Set as printed + $db->query($sql); + $invoice->fetch($placeid); //Reload object after set lines as printed } $sectionwithinvoicelink = '';