can print from takepos

This commit is contained in:
Frédéric FRANCE 2019-11-03 15:06:20 +01:00
parent 5a3347104f
commit b048a2b408
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
4 changed files with 52 additions and 22 deletions

View File

@ -82,6 +82,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_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);
dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha'));
@ -201,12 +203,25 @@ if (! empty($conf->stock->enabled))
$printer->listprinters();
$printers = array();
foreach ($printer->listprinters as $key => $value) {
$printers[$key] = $value['name'];
$printers[$value['rowid']] = $value['name'];
}
print '<tr class="oddeven"><td>'.$langs->trans("TakeposTerminalPrinterToUse").'</td>';
print '<td>';
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 '</td></tr>';
$printer->listPrintersTemplates();
$templates = array();
foreach ($printer->listprinterstemplates as $key => $value) {
$templates[$value['rowid']] = $value['name'];
}
print '<tr class="oddeven"><td>'.$langs->trans("TakeposTerminalTemplateToUseForInvoicesTicket").'</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 '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("TakeposTerminalTemplateToUseForOrdersTicket").'</td>';
print '<td>';
print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal, $templates, (empty($conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal})?'0':$conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal}), 1);
print '</td></tr>';
}
}

View File

@ -22,7 +22,7 @@
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
@ -36,6 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$category = GETPOST('category', 'alpha');
$action = GETPOST('action', 'alpha');
$term = GETPOST('term', 'alpha');
$id = GETPOST('id', 'int');
/*
@ -81,4 +82,24 @@ elseif ($action=="search" && $term != '') {
else {
echo 'Failed to search product : '.$db->lasterror();
}
} elseif ($action == "opendrawer" && $term != '') {
require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
$printer = new dolReceiptPrinter($db);
// chek printer for terminal
if ($conf->global->{'TAKEPOS_PRINTER_TO_USE'.$term} > 0) {
$printer->initPrinter($conf->global->{'TAKEPOS_PRINTER_TO_USE'.$term});
// open cashdrawer
$printer->pulse();
$printer->close();
}
} elseif ($action == "printinvoiceticket" && $term != '' && $id > 0) {
require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$printer = new dolReceiptPrinter($db);
// check printer for terminal
if ($conf->global->{'TAKEPOS_PRINTER_TO_USE'.$term} > 0 && $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term} > 0) {
$object = new Facture($db);
$object->fetch($id);
$ret = $printer->sendToPrinter($object, $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term}, $conf->global->{'TAKEPOS_PRINTER_TO_USE'.$term});
}
}

View File

@ -554,16 +554,11 @@ function TakeposPrinting(id){
});
}
function DolibarrTakeposPrinting(id) {
console.log('Printing ticket ' + id)
var receipt;
// $.get("receipt.php?facid="+id, function(data, status) {
// receipt=data.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '');
// $.ajax({
// type: "POST",
// url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>:8111/print',
// data: receipt
// });
// });
console.log('Printing invoice ticket ' + id)
$.ajax({
type: "GET",
url: "<?php print dol_buildpath('/takepos/ajax/ajax.php', 1).'?action=printinvoiceticket&term='.$_SESSION["takeposterminal"].'&id='; ?>" + id,
});
}
</script>

View File

@ -539,19 +539,18 @@ function TakeposPrintingTemp(){
function OpenDrawer(){
console.log("OpenDrawer");
$.ajax({
type: "POST",
url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER;?>:8111/print',
data: "opendrawer"
});
type: "POST",
url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER;?>:8111/print',
data: "opendrawer"
});
}
function DolibarrOpenDrawer(){
function DolibarrOpenDrawer() {
console.log("DolibarrOpenDrawer");
// $.ajax({
// type: "POST",
// url: 'http://',
// data: "opendrawer"
// });
$.ajax({
type: "GET",
url: "<?php print dol_buildpath('/takepos/ajax/ajax.php', 1).'?action=opendrawer&term='.$_SESSION["takeposterminal"]; ?>",
});
}
function MoreActions(totalactions){