From 04dfc5dc8c5538036ce9d9c5a5eac8b462e10db9 Mon Sep 17 00:00:00 2001
From: aurelien goudeneche <44634756+AurelGDN@users.noreply.github.com>
Date: Fri, 7 Dec 2018 00:40:00 +0100
Subject: [PATCH] New: TakePOS +add Temporary ticket
New: TakePOS +add Temporary ticket with verbose invoice data (more exhaustive than the existing order printing)
+add some little invoice printing layouts improvements (Unit Price, Misc company Info, Cashier name, Table Border)
Temporary ticket is usefull in some restaurant when a customer ask for a bill from his table before to check it out. The waiter usually don't how the customer will pay (card,cash,cheque).
Works with the Andreu Bisquerra's java TakePOSconnector like the existing orderprinting so it doesn't affect the ulterior payment validation process and printing from CashDesk.
This feature needs the BAR/RESTAURANT order/printing to be enabled.
---
htdocs/takepos/invoice.php | 87 ++++++++++++++++++++++++++++++++++++++
htdocs/takepos/receipt.php | 19 +++++++--
htdocs/takepos/takepos.php | 30 ++++++++++---
3 files changed, 127 insertions(+), 9 deletions(-)
diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php
index 52d4864385f..b9043b28b7f 100644
--- a/htdocs/takepos/invoice.php
+++ b/htdocs/takepos/invoice.php
@@ -182,10 +182,71 @@ if ($action=="order" and $placeid!=0){
$db->query($sql);
$order_receipt_printer2.='
'.$line->product_label.'| '.$line->qty.' |
';
}
+
}
$invoice->fetch($placeid);
}
+//temporary ticket feature
+
+if ($action=="temp" and $placeid!=0){
+ require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
+
+// issues with special characters with jPosBoxprinting ->javascript, StringCleanCharts() temporarily fix them until to find a more elegant solution.
+
+ function StringCleanCharts($text) {
+ $utf8 = array(
+ '/[áàâãªä]/u' => 'a',
+ '/[ÁÀÂÃÄ]/u' => 'A',
+ '/[ÍÌÎÏ]/u' => 'I',
+ '/[íìîï]/u' => 'i',
+ '/[éèêë]/u' => 'e',
+ '/[ÉÈÊË]/u' => 'E',
+ '/[óòôõºö]/u' => 'o',
+ '/[ÓÒÔÕÖ]/u' => 'O',
+ '/[úùûü]/u' => 'u',
+ '/[ÚÙÛÜ]/u' => 'U',
+ '/ç/' => 'c',
+ '/Ç/' => 'C',
+ '/ñ/' => 'n',
+ '/Ñ/' => 'N',
+ '/–/' => '-', // UTF-8 hyphen to "normal" hyphen
+ '/[’‘‹›‚\']/u' => ' ', // Literally a single quote
+ '/[“”«»„]/u' => ' ', // Double quote
+ '/ /' => ' ', // nonbreaking space (equiv. to 0x160)
+
+ );
+ return preg_replace(array_keys($utf8), array_values($utf8), $text);
+ }
+
+ $mysocname=StringCleanCharts($mysoc->name);
+ $mysocaddress=StringCleanCharts($mysoc->address);
+ $mysoctown=StringCleanCharts($mysoc->town);
+ $mysoczip=StringCleanCharts($mysoc->zip);
+ $mysocphone=StringCleanCharts($mysoc->phone);
+ $mysocurl=StringCleanCharts($mysoc->url);
+ $header_soc=''.$mysocname.'
'.$mysocaddress.'
'.$mysoczip.' '.$mysoctown.'
'.$langs->trans("Phone").': '.$mysocphone.'
'.$mysocurl;
+ $header_ticket='
'.$langs->trans("Temporary ticket").'
'.$langs->trans("date").':
'.dol_print_date(dol_now(), 'dayhour').'
'.$langs->trans('Place').' '.$place.'
';
+ $body_ticket='| '.$langs->trans("Label").' | '.$langs->trans("Qty").' | '.$langs->trans("Price").' | '.$langs->trans("TotalTTC").' |
';
+ $footer_ticket='
'.$langs->trans("Cashier").': '.$user->firstname.'
'.$langs->trans("Thanks for your coming !").'';
+ $ticket_printer1="";
+ $catsprinter1 = explode(';',$conf->global->TAKEPOS_PRINTED_CATEGORIES_1);
+ foreach ($invoice->lines as $line){
+ if ($line->special_code=="3") continue;
+ $c = new Categorie($db);
+ $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
+ $result = array_intersect($catsprinter1, $existing);
+ $count=count($result);
+ if ($count>0){
+ $sql="UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=$line->rowid";
+ $db->query($sql);
+ $ticket_printer1.='| '.$line->product_label.' | '.$line->qty.' | '.$line->total_ttc/$line->qty.' | '.$line->total_ttc.' |
';
+ $ticket_total='
| '.$langs->trans("TotalHT").': '.price($invoice->total_ht, 1, '', 1, - 1, - 1, $conf->currency).' |
|---|
| '.$langs->trans("TotalVAT").': '.price($invoice->total_tva, 1, '', 1, - 1, - 1, $conf->currency).' |
|---|
| '.$langs->trans("TotalTTC").': '.price($invoice->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).' |
|---|
';
+ }
+ }
+
+ $invoice->fetch($placeid);
+}
?>