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.
This commit is contained in:
aurelien goudeneche 2018-12-07 00:40:00 +01:00 committed by GitHub
parent c861dcf470
commit 04dfc5dc8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 127 additions and 9 deletions

View File

@ -182,10 +182,71 @@ if ($action=="order" and $placeid!=0){
$db->query($sql);
$order_receipt_printer2.='<tr>'.$line->product_label.'<td align="right">'.$line->qty.'</td></tr>';
}
}
$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='<html><center><font size="4"><b>'.$mysocname.'</b><br>'.$mysocaddress.'<br>'.$mysoczip.' '.$mysoctown.'</font></center><br>'.$langs->trans("Phone").': '.$mysocphone.'<br>'.$mysocurl;
$header_ticket='<br><br>'.$langs->trans("Temporary ticket").'<br>'.$langs->trans("date").':<br>'.dol_print_date(dol_now(), 'dayhour').'<br>'.$langs->trans('Place').' '.$place.'<br><br><br><div width="100%" style="border-top-style: double;"></div>';
$body_ticket='<table width="100%"><thead><tr><th align="left">'.$langs->trans("Label").'</th><th align="left">'.$langs->trans("Qty").'</th><th align="left">'.$langs->trans("Price").'</th><th align="left">'.$langs->trans("TotalTTC").'</th></tr></thead>';
$footer_ticket='<br><br>'.$langs->trans("Cashier").': '.$user->firstname.'<br><center>'.$langs->trans("Thanks for your coming !").'</center></html>';
$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.='<tbody><tr><td align="left">'.$line->product_label.'</td><td align="left">'.$line->qty.'</td><td align="left">'.$line->total_ttc/$line->qty.'</td><td align="left">'.$line->total_ttc.'</td></tr></tbody>';
$ticket_total='</table><div width="100%" style="border-top-style: double;"></div><table align="right"><tr><th>'.$langs->trans("TotalHT").': '.price($invoice->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'</th></tr><tr><th>'.$langs->trans("TotalVAT").': '.price($invoice->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'</th></tr><tr><th>'.$langs->trans("TotalTTC").': '.price($invoice->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'</th></tr></tbody></table>';
}
}
$invoice->fetch($placeid);
}
?>
<style>
.selected {
@ -232,6 +293,32 @@ if ($action=="search"){
?>
});
$(document).ready(function(){
$('table tbody tr').click(function(){
$('table tbody tr').removeClass("selected");
$(this).addClass("selected");
if (selectedline==this.id) return; // If is already selected
else selectedline=this.id;
selectedtext=$('#'+selectedline).find("td:first").html();
});
<?php if ($action=="temp" and $ticket_printer1!=""){
?>
$.ajax({
type: "POST",
url: 'http://<?php print $conf->global->TAKEPOS_PRINT_SERVER;?>:8111/print',
data: '<?php print $header_soc.$header_ticket.$body_ticket.$ticket_printer1.$ticket_total.$footer_ticket; ?>'
});
<?php
}
if ($action=="search"){
?>
$('#search').focus();
<?php
}
?>
});
function Print(id){
$.colorbox({href:"receipt.php?facid="+id, width:"40%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("PrintTicket");?>"});
}

View File

@ -46,12 +46,14 @@ $object->fetch($facid);
<body>
<center>
<font size="4">
<?php echo $mysoc->name; ?>
<?php echo '<b>'.$mysoc->name.'</b>';?>
</font>
</center>
<br>
<p align="left">
<?php print dol_nl2br(dol_format_address($mysoc)); ?>
<?php print dol_nl2br(dol_format_address($mysoc)).'<br>'.$langs->trans("Phone").': '.$mysoc->phone;
?>
</p>
<p align="right">
<?php
@ -62,11 +64,12 @@ print $object->ref;
</p>
<br>
<table width="100%">
<table width="100%" style="border-top-style: double;">
<thead>
<tr>
<th align="center"><?php print $langs->trans("Label"); ?></th>
<th align="right"><?php print $langs->trans("Qty"); ?></th>
<th align="right"><?php print $langs->trans("Price"); ?></th>
<th align="right"><?php print $langs->trans("TotalTTC"); ?></th>
</tr>
</thead>
@ -78,6 +81,7 @@ print $object->ref;
<tr>
<td><?php echo $line->product_label;?></td>
<td align="right"><?php echo $line->qty;?></td>
<td align="right"><?php echo $line->total_ttc/$line->qty;?></td>
<td align="right"><?php echo price($line->total_ttc);?></td>
</tr>
<?php
@ -98,6 +102,15 @@ print $object->ref;
<th align="right"><?php echo ''.$langs->trans("TotalTTC").'</th><td align="right">'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n";?></td>
</tr>
</table>
<div style="border-top-style: double;">
<br>
<br>
<br>
<?php
echo $langs->trans("Cashier: ");
echo $user->firstname.'<br>'.$mysoc->url.'<br>';
echo '<center>'.$langs->trans("Thanks for your coming !").'</center>';
?>
<script type="text/javascript">
window.print();

View File

@ -292,6 +292,15 @@ function TakeposPrintingOrder(){
});
}
function TakeposPrintingTemp(){
$("#poslines").load("invoice.php?action=temp&place="+place, function() {
$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
});
}
function OpenDrawer(){
$.ajax({
type: "POST",
@ -347,14 +356,26 @@ $menus[$r++]=array('title'=>$langs->trans("ValidateBill"),
'action'=>'CloseBill();');
$menus[$r++]=array('title'=>$langs->trans("Logout"),
'action'=>'window.location.href=\''.DOL_URL_ROOT.'/user/logout.php\';');
//BAR RESTAURANT specified menu
if($conf->global->TAKEPOS_BAR_RESTAURANT){
$menus[$r++]=array('title'=>$langs->trans("Floors"),
'action'=>'Floors();');
if ($conf->global->TAKEPOS_ORDER_PRINTERS){
if ($conf->global->TAKEPOS_ORDER_PRINTERS){
$menus[$r++]=array('title'=>$langs->trans("Order"),
'action'=>'TakeposPrintingOrder();');
}
'action'=>'TakeposPrintingOrder();');}
//add temp ticket button
if ($conf->global->TAKEPOS_ORDER_PRINTERS){
$menus[$r++]=array('title'=>$langs->trans("Temporary ticket"),
'action'=>'TakeposPrintingTemp();');}
}
if ($conf->global->TAKEPOSCONNECTOR){
$menus[$r++]=array('title'=>$langs->trans("DOL_OPEN_DRAWER"),
'action'=>'OpenDrawer();');
@ -410,6 +431,3 @@ while ($count<32)
llxFooter();
$db->close();