POS - Print more customer details in receipts
Code snippetName: POS - Print more customer details in receipts
|
This code snippet is intended to ask to the user for more details to be printed in the receipt. For example invoice details,customer details, like the phone or other details needed in your store.
This code has been copied from the Openbravo POS forum message by Ronny G.
Add something like the following to Ticket.Buttons resource.
<button key="button.print" name="button.print" image="img.print" code="Script.PrintBill"/>
Create a text resource called Script.PrintBill and put this script:
myPlaceName = place; if (myPlaceName.equals("Prompt1_2")) { line = ticket.getLine(0); value = javax.swing.JOptionPane.showInputDialog("Enter your Prompt1", line.getProperty("Prompt1")); if (value != null) { // the user pressed OK line.setProperty("Prompt1", value); } value = javax.swing.JOptionPane.showInputDialog("Enter your Prompt2", line.getProperty("Prompt2")); if (value != null) { // the user pressed OK line.setProperty("Prompt2", value); } } else if (myPlaceName.equals("Prompt3")) { line = ticket.getLine(0); value = javax.swing.JOptionPane.showInputDialog("Enter Prompt3", line.getProperty("Prompt3")); if (value != null) { // the user pressed OK line.setProperty("Prompt3", value); } } else if (myPlaceName.equals("Prompt4")) { } sales.printTicket("Printer.TicketBill"); //Print Bill
Now create a text resource called Printer.TicketBill and put the ticket template in it.
Directly after
#foreach ($ticketline in $ticket.getLines())
put this code:
#if (($ticketline.getProperty("Prompt1", ""))!= "") <line> <text align ="left" length="30">Prompt1: ${ticketline.getProperty("Prompt1", "")}</text> </line> #end #if (($ticketline.getProperty("Prompt2", ""))!= "") <line> <text align ="left" length="30">Prompt2: ${ticketline.getProperty("Prompt2", "")}</text> </line> #end #if (($ticketline.getProperty("Prompt3", ""))!= "") <line> <text align ="left" length="30">Prompt3: ${ticketline.getProperty("Prompt3", "")}</text> </line> #end