Compatibility with new TakePOS connector
This commit is contained in:
parent
350d694181
commit
a5ffac1935
@ -41,7 +41,7 @@ if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY'.$terminal.'_id']))
|
|||||||
// Security check
|
// Security check
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) accessforbidden();
|
||||||
|
|
||||||
$langs->loadLangs(array("admin", "cashdesk", "printing"));
|
$langs->loadLangs(array("admin", "cashdesk", "printing", "receiptprinter"));
|
||||||
|
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TA
|
|||||||
foreach ($printer->listprinterstemplates as $key => $value) {
|
foreach ($printer->listprinterstemplates as $key => $value) {
|
||||||
$templates[$value['rowid']] = $value['name'];
|
$templates[$value['rowid']] = $value['name'];
|
||||||
}
|
}
|
||||||
print '<tr class="oddeven"><td>'.$langs->trans("MainTemplateToUse").'</td>';
|
print '<tr class="oddeven"><td>'.$langs->trans("MainTemplateToUse").' (<a href="'.DOL_URL_ROOT.'/admin/receiptprinter.php?mode=template">'.$langs->trans("SetupReceiptTemplate").'</a>)</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal, $templates, (empty($conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal}), 1);
|
print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal, $templates, (empty($conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal}), 1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|||||||
@ -672,7 +672,7 @@ if ($action == "updatereduction")
|
|||||||
if ($action == "order" and $placeid != 0)
|
if ($action == "order" and $placeid != 0)
|
||||||
{
|
{
|
||||||
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||||
if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") {
|
if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
|
||||||
$printer = new dolReceiptPrinter($db);
|
$printer = new dolReceiptPrinter($db);
|
||||||
}
|
}
|
||||||
@ -703,10 +703,13 @@ if ($action == "order" and $placeid != 0)
|
|||||||
$order_receipt_printer1 .= '</td></tr>';
|
$order_receipt_printer1 .= '</td></tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $linestoprint > 0) {
|
if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) {
|
||||||
$invoice->fetch($placeid); //Reload object before send to printer
|
$invoice->fetch($placeid); //Reload object before send to printer
|
||||||
$printer->orderprinter = 1;
|
$printer->orderprinter = 1;
|
||||||
|
echo "<script>";
|
||||||
|
echo "var orderprinter1esc='";
|
||||||
$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
|
$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
|
||||||
|
echo "';</script>";
|
||||||
}
|
}
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id; // Set as printed
|
$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);
|
$db->query($sql);
|
||||||
@ -731,10 +734,13 @@ if ($action == "order" and $placeid != 0)
|
|||||||
$order_receipt_printer2 .= '</td></tr>';
|
$order_receipt_printer2 .= '</td></tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $linestoprint > 0) {
|
if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) {
|
||||||
$invoice->fetch($placeid); //Reload object before send to printer
|
$invoice->fetch($placeid); //Reload object before send to printer
|
||||||
$printer->orderprinter = 2;
|
$printer->orderprinter = 2;
|
||||||
|
echo "<script>";
|
||||||
|
echo "var orderprinter2esc='";
|
||||||
$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
|
$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
|
||||||
|
echo "';</script>";
|
||||||
}
|
}
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id; // Set as printed
|
$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);
|
$db->query($sql);
|
||||||
@ -759,10 +765,13 @@ if ($action == "order" and $placeid != 0)
|
|||||||
$order_receipt_printer3 .= '</td></tr>';
|
$order_receipt_printer3 .= '</td></tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $linestoprint > 0) {
|
if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) {
|
||||||
$invoice->fetch($placeid); //Reload object before send to printer
|
$invoice->fetch($placeid); //Reload object before send to printer
|
||||||
$printer->orderprinter = 3;
|
$printer->orderprinter = 3;
|
||||||
|
echo "<script>";
|
||||||
|
echo "var orderprinter3esc='";
|
||||||
$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
|
$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
|
||||||
|
echo "';</script>";
|
||||||
}
|
}
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='3' and fk_facture=".$invoice->id; // Set as printed
|
$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);
|
$db->query($sql);
|
||||||
@ -841,25 +850,59 @@ $(document).ready(function() {
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if ($action == "order" and $order_receipt_printer1 != "") {
|
if ($action == "order" and $order_receipt_printer1 != "") {
|
||||||
?>
|
if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true){
|
||||||
$.ajax({
|
?>
|
||||||
type: "POST",
|
$.ajax({
|
||||||
url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
|
type: "POST",
|
||||||
data: '<?php
|
url: '<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php',
|
||||||
print $headerorder.$order_receipt_printer1.$footerorder; ?>'
|
data: 'invoice='+orderprinter1esc
|
||||||
});
|
});
|
||||||
<?php
|
<?php
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
?>
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
|
||||||
|
data: '<?php
|
||||||
|
print $headerorder.$order_receipt_printer1.$footerorder; ?>'
|
||||||
|
});
|
||||||
|
<?php
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == "order" and $order_receipt_printer2 != "") {
|
if ($action == "order" and $order_receipt_printer2 != "") {
|
||||||
?>
|
if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true){
|
||||||
$.ajax({
|
?>
|
||||||
type: "POST",
|
$.ajax({
|
||||||
url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print2',
|
type: "POST",
|
||||||
data: '<?php
|
url: '<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php?printer=2',
|
||||||
print $headerorder.$order_receipt_printer2.$footerorder; ?>'
|
data: 'invoice='+orderprinter2esc
|
||||||
});
|
});
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
?>
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print2',
|
||||||
|
data: '<?php
|
||||||
|
print $headerorder.$order_receipt_printer2.$footerorder; ?>'
|
||||||
|
});
|
||||||
<?php
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == "order" and $order_receipt_printer3 != "") {
|
||||||
|
if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true){
|
||||||
|
?>
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: '<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php?printer=3',
|
||||||
|
data: 'invoice='+orderprinter3esc
|
||||||
|
});
|
||||||
|
<?php
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set focus to search field
|
// Set focus to search field
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user