2
0
forked from Wavyzz/dolibarr

Merge pull request #13176 from andreubisquerra/master

Add orders to Receipt Printer module
This commit is contained in:
Laurent Destailleur
2020-02-23 22:44:14 +01:00
committed by GitHub
2 changed files with 46 additions and 4 deletions

View File

@@ -49,6 +49,8 @@
* <dol_print_object_tax> Print object total tax
* <dol_print_object_local_tax> Print object local tax
* <dol_print_object_total> Print object total
* <dol_print_order_lines_printer1> Print order lines for Printer1
* <dol_print_order_lines_printer2> Print order lines for Printer2
* <dol_print_payment> Print payment method
*
* Code which can be placed everywhere
@@ -188,6 +190,8 @@ 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_value_customer_firstname',
'dol_value_customer_lastname',
'dol_value_customer_mail',
@@ -720,6 +724,28 @@ class dolReceiptPrinter extends Printer
case 'DOL_BEEP':
$this->printer->getPrintConnector() -> write("\x1e");
break;
case 'DOL_PRINT_ORDER_LINES_PRINTER1':
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)
{
$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;
default:
$this->printer->text($vals[$tplline]['tag']);
$this->printer->text($vals[$tplline]['value']);

View File

@@ -441,6 +441,10 @@ if ($action == "updatereduction")
if ($action == "order" and $placeid != 0)
{
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter"){
require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
$printer = new dolReceiptPrinter($db);
}
$headerorder = '<html><br><b>'.$langs->trans('Place').' '.$place.'<br><table width="65%"><thead><tr><th class="left">'.$langs->trans("Label").'</th><th class="right">'.$langs->trans("Qty").'</th></tr></thead><tbody>';
$footerorder = '</tbody></table>'.dol_print_date(dol_now(), 'dayhour').'<br></html>';
@@ -458,13 +462,20 @@ if ($action == "order" and $placeid != 0)
$result = array_intersect($catsprinter1, $existing);
$count = count($result);
if ($count > 0) {
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where rowid=".$line->id;
$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 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty;
if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer1 .= "<br>(".$line->array_options['options_order_notes'].")";
$order_receipt_printer1 .= '</td></tr>';
}
}
if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter"){
$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
}
$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
foreach ($invoice->lines as $line)
{
@@ -476,15 +487,20 @@ if ($action == "order" and $placeid != 0)
$result = array_intersect($catsprinter2, $existing);
$count = count($result);
if ($count > 0) {
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where rowid=".$line->id;
$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 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty;
if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer2 .= "<br>(".$line->array_options['options_order_notes'].")";
$order_receipt_printer2 .= '</td></tr>';
}
}
$invoice->fetch($placeid);
if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter"){
$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
}
$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
}
$sectionwithinvoicelink = '';