NEW: Add third order printer to TakePOS

This commit is contained in:
jove@bisquerra.com 2020-10-12 22:07:05 +02:00
parent ad461a098b
commit 54f9ed6346
3 changed files with 71 additions and 0 deletions

View File

@ -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 '</table></td>';
print '</tr>';
}
//Printer3
print '<table class="liste nohover" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 3</td><td></td><td class="right">';
print '</td></tr>';
$nbofentries = (count($data) - 1);
print '<form action="orderprinters.php">';
if ($nbofentries > 0)
{
print '<tr class="pair"><td colspan="3">';
print '<input type="hidden" name="action" value="SavePrinter3">';
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 '<input type="checkbox" name="printer3[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
}
print '</td></tr>';
} else {
print '<tr class="pair">';
print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
print '<td valign="middle">';
print $langs->trans("NoCategoryYet");
print '</td>';
print '<td>&nbsp;</td>';
print '</table></td>';
print '</tr>';
}
print "</table>";
print '<input type="submit" value="'.$langs->trans("Save").'"></form>';

View File

@ -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 '<td>';
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 '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 3</td>';
print '<td>';
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 '</td></tr>';
}
$printer->listPrintersTemplates();
$templates = array();

View File

@ -532,8 +532,10 @@ if ($action == "order" and $placeid != 0)
$footerorder = '</tbody></table>'.dol_print_date(dol_now(), 'dayhour').'<br></html>';
$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 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty;
if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer3 .= "<br>(".$line->array_options['options_order_notes'].")";
$order_receipt_printer3 .= '</td></tr>';
}
}
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 = '';