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 01/14] 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=''; + $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.=''; + $ticket_total='
'.$langs->trans("Label").''.$langs->trans("Qty").''.$langs->trans("Price").''.$langs->trans("TotalTTC").'
'.$line->product_label.''.$line->qty.''.$line->total_ttc/$line->qty.''.$line->total_ttc.'
'.$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); +} ?> @@ -403,48 +398,51 @@ print '' . $langs->trans('Qty') . ''; print '' . $langs->trans('TotalHTShort') . ''; print "\n"; -if ($placeid > 0) -foreach($invoice->lines as $line) - { - print ''; - print '' . $line->product_label . $line->desc . ''; - print '' . $line->qty . ''; - print '' . price($line->total_ttc) . ''; - print ''; - } +if ($placeid > 0) { + foreach($invoice->lines as $line) + { + print ''; + print '' . $line->product_label . $line->desc . ''; + print '' . $line->qty . ''; + print '' . price($line->total_ttc) . ''; + print ''; + } +} print ''; print '

' . $langs->trans('TotalTTC'); -if ($conf->global->TAKEPOS_BAR_RESTAURANT) print " " . $langs->trans('Place') . " " . $place; +if ($conf->global->TAKEPOS_BAR_RESTAURANT) { print " " . $langs->trans('Place') . " " . $place; +} print ': ' . price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency) . ' 

'; // if ($invoice->socid != $conf->global->CASHDESK_ID_THIRDPARTY){ $soc = new Societe($db); -if ($invoice->socid > 0) $soc->fetch($invoice->socid); - else $soc->fetch($conf->global->CASHDESK_ID_THIRDPARTY); +if ($invoice->socid > 0) { $soc->fetch($invoice->socid); +} else { $soc->fetch($conf->global->CASHDESK_ID_THIRDPARTY); +} print '

'; print $langs->trans("Customer") . ': ' . $soc->name; print '

'; // } -if ($action == "valid") - { - print '

' . $invoice->facnumber . " " . $langs->trans('BillShortStatusValidated') . '

'; - if ($conf->global->TAKEPOSCONNECTOR) print '
'; - else print '
'; - } +if ($action == "valid") { + print '

' . $invoice->facnumber . " " . $langs->trans('BillShortStatusValidated') . '

'; + if ($conf->global->TAKEPOSCONNECTOR) { print '
'; + } else { print '
'; + } +} -if ($action == "search") - { - print '
+if ($action == "search") { + print '
'; - } +} print ''; From c5e773fcfd5218eb19f1bc38a34cd454201d1139 Mon Sep 17 00:00:00 2001 From: aurelien goudeneche <44634756+AurelGDN@users.noreply.github.com> Date: Fri, 7 Dec 2018 17:20:05 +0100 Subject: [PATCH 11/14] space cast statement fix --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index f276ee51040..16812d60b58 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -115,7 +115,7 @@ if (($action == "addline" || $action == "freezone") and $placeid == 0) { $invoice->date = dol_now(); $invoice->ref = "(PROV-POS)"; $invoice->module_source = 'takepos'; - $invoice->pos_source = (string)(empty($place) ? '0' : $place); + $invoice->pos_source = (string) (empty($place)?'0':$place); $placeid = $invoice->create($user); $sql = "UPDATE " . MAIN_DB_PREFIX . "facture set facnumber='(PROV-POS-" . $place . ")' where rowid=" . $placeid; $db->query($sql); From 5a5b2c8a6050e53d4080e091257a2e6773c611ac Mon Sep 17 00:00:00 2001 From: aurelien goudeneche <44634756+AurelGDN@users.noreply.github.com> Date: Fri, 7 Dec 2018 17:33:35 +0100 Subject: [PATCH 12/14] Revert wrong tag introduced with phpbcf fix --- htdocs/takepos/invoice.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 16812d60b58..9041b6bfd2f 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -183,8 +183,8 @@ if ($action == "updatereduction") { if ($action == "order" and $placeid != 0) { include_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $headerorder = '
' . $langs->trans('Place') . ' ' . $place . '
'; - $footerorder = '
' . $langs->trans("Label") . '' . $langs->trans("Qty") . '
' . dol_print_date(dol_now(), 'dayhour') . '
'; + $headerorder = '
' . $langs->trans('Place') . ' ' . $place . '
'; + $footerorder = '
' . $langs->trans("Label") . '' . $langs->trans("Qty") . '
' . dol_print_date(dol_now(), 'dayhour') . '
'; $order_receipt_printer1 = ""; $order_receipt_printer2 = ""; $catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1); @@ -260,10 +260,10 @@ if ($action == "temp" and $placeid != 0) { $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 . '


'; + $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 = ''; - $footer_ticket = '

' . $langs->trans("Cashier") . ': ' . $user->firstname . '
' . $langs->trans("Thanks for your coming !") . '
'; + $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) From b7ee2458a3cdaa1fc60911fb9061f08bba6a340f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 15 Dec 2018 16:10:44 +0100 Subject: [PATCH 13/14] Update invoice.php --- htdocs/takepos/invoice.php | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index a6bffd1f473..7bb30722460 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -20,21 +20,11 @@ // if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language // if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); - -if (!defined('NOCSRFCHECK')) { define('NOCSRFCHECK', '1'); -} - -if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); -} - -if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); -} - -if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', '1'); -} - -if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); -} +if (!defined('NOCSRFCHECK')) { define('NOCSRFCHECK', '1'); } +if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } +if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); } +if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', '1'); } +if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } require '../main.inc.php'; // Load $user and permissions From 8a01944a0cdc5f00c90959a0dc91953dcb62a58a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 15 Dec 2018 16:12:47 +0100 Subject: [PATCH 14/14] Update invoice.php --- htdocs/takepos/invoice.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 7bb30722460..cb288c7dcd0 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -297,8 +297,7 @@ if ($action == "order" and $order_receipt_printer1 != "") { ?> $.ajax({ type: "POST", - url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print', + url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print', data: '' }); @@ -309,8 +308,7 @@ if ($action == "order" and $order_receipt_printer2 != "") { ?> $.ajax({ type: "POST", - url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print2', + url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print2', data: '' }); @@ -340,8 +338,7 @@ if ($action == "temp" and $ticket_printer1 != "") { ?> $.ajax({ type: "POST", - url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print', + url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print', data: '' }); @@ -368,8 +365,7 @@ function TakeposPrinting(id){ receipt=data.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, ''); $.ajax({ type: "POST", - url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print', + url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print', data: receipt }); });
' . $langs->trans("Label") . '' . $langs->trans("Qty") . '' . $langs->trans("Price") . '' . $langs->trans("TotalTTC") . '