Compound Ticket Templates

Have brought this up before but can’t find the old topic.

What are people’s thought on compound ticket templates?

By which I mean you set a header and footer template etc and are able to ‘embed’ templates within other templates.
The advantage being you have a single header template which you set in your other ‘slave’ templates.
For example you want a plain over counter sale template and a registered customer template.
The orders formatting or footer might be different but with compound templates you only have one header template meaning to make a change to that part of the template you edit the master rather than needing to ensure multiple templates have a similar header/footer etc.

Hope that makes sense.

Think this would be a valuable tool as would personally prefer to have a sectionalised template that one big template with additional bulk like tersary expressions or calculations etc.

Another line of thought previously mentioned was a similar approach to menus/categories that you could setup compount menus allowing streamlined menu updates for consistency and ease of update. Again mentioned this before but couldn’t find the topic.

1 Like

I think it would be very useful, especially for standard headers / footers, and makes easier to update in one place. If you have a complex setup you might have many different ticket templates and if you want to just make a change, like a phone number or if you have a promo in the footer, it is a lot more time consuming to do it separately for each template.

I’m definitely behind this idea :smile:

It’s not the same I know but if you don’t want to wait for this feature you can accomplish the exact same thing through custom tasks right now. You would use custom task anytime you need to update templates. You can customize it with static header and footers and parameterize the body.

I have done this and it’s really great

In fact you could even simplify template building further. The task could ask for things like company name etc and the task will auto generate template with all correct formatting tags etc.

For those of you that use samba setups as a installer custom tasks should really be a high priority. I mean you could lockdown the settings and build s custom settings screen for your clients that uses tasks and execute task actions. This would allow you to micro manage what your clients can do as far as settings are concerned.

Not a bad idea @JTRTech. I just ran into this very thing when testing the v4/live.js Customer Display. I needed to modify 3 templates: Closed, Ticket, and Idle.

All have the same “header” which shows an image. When I wanted to change the image, or alter the width, I needed to edit 3 templates.

This was my work-around for creating a universal header in v5 …

Some JScript to build the “header string” …


Plop a {CALL:pt.header()} into the templates…


Now when I want to change the image of the header from “cbc.jpg” to “me.jpg”, I just edit the script…

function header() {
  var headerimage = "me.jpg";
  var s='';
  s+='<l><html>'+"\r\n";
  s+='<l><head>'+"\r\n";
  s+='<l><meta charset="UTF-8">'+"\r\n";
  s+='<l><script type="text/javascript" src="live.js#html"></script>'+"\r\n";
  s+='<l></head>'+"\r\n";
  s+='<l><body>'+"\r\n";
  s+='<l><center><img src="' + headerimage + '" width="50%" border="1"></center>'+"\r\n";

  return s;
}

2 Likes

Script was the most obvious work arround I was imagining but think an ‘official’ method would be a valuable tool.
Then use a tag like {PRINTER TEMPLATE:Header} as a ‘placeholder’

1 Like

Hey @Jesse
If you ever get bored (:innocent:) I would love to read a tutorial for configuration tasks as it would really highlight the power of Tasks. Just saying, not withstanding that there may be some already, I just not at that point in my SambaPOS evolution to be creating Tasks, but getting closer!

1 Like

I will prepare something yes. Maybe tonight I can show some of it.

1 Like

They are such a nice tool. They really shine when used with the action to execute them. They support jscript,SQL script, YAML and can support validation and just about anything can be set as parameters.

@QMcKay did you ever try using template tags within the script call?

Used script to call SQL entry for the template.

and called it within the template.

but unfortunately it drops raw test in and doesn’t process the tags :frowning:

Anyone have suggestions for a way round this?
emre any chance maybe of a harcoded template tag for embedding other templates?

I have been using Configuration Tasks to do this for a while that is my way around it. Works great and I dont have to edit any scripts if i ever need to make changes.

I really like the idea. For me, when designing my recipt I have some quite ‘bulky’ items, this such as company details, contact details, legal details etc…

Would it be possible for us to create our own subsections within a ticket template so we can bury the bulky items somewhere else, and focus on the core of our tickets.

For example (this is not my real example, but it highlights my point)
before

[LAYOUT]
-- General layout
<C>My Company Name inc.
<C>Street Address 1
<C>Street Address 2
<C>City, Country
<C>Phone
<C>Website
<C>Email
<T>Ticket
<L00>Date:{TICKET DATE}
<L00>Time:{TIME}
{ENTITIES}
<L00>Ticket No:{TICKET NO}
<F>-
{ORDERS}
<L>Did you know that some of
<L>The products you ordered today
<L>Could have been cheaper in our
<L>Happy Hour (5pm-8pm)
<L>For more information, ask your server
<F>=
<EB>
{DISCOUNTS}
.....

Desired new feature

[LAYOUT]
-- General layout
{SECTION:ADDRESS}
<T>Ticket
<L00>Date:{TICKET DATE}
<L00>Time:{TIME}
{ENTITIES}
<L00>Ticket No:{TICKET NO}
<F>-
{ORDERS}
{SECTION:HAPPY-HOUR}
<F>=
<EB>
{DISCOUNTS}
.....


[SECTION:ADDRESS]
<C>My Company Name inc.
<C>Street Address 1
<C>Street Address 2
<C>City, Country
<C>Phone
<C>Website
<C>Email

[SECTION:HAPPY-HOUR]
<L>Did you know that some of
<L>The products you ordered today
<L>Could have been cheaper in our
<L>Happy Hour (5pm-8pm)
<L>For more information, ask your server

As you can see, it makes the core template structure much more readable when making modifications.

1 Like

I think both are great ideas. The idea proposed by @JTRTech should be able to cover the idea by @mjb2000, even if they are slightly different ways to do similar things.

Best that Template Names and placeholders are not hard-coded to any specific keywords like “Header” or “Footer”, but to instead be able to use any Template within another Template.

So if you have a Template Named “My Business Info” (call it whatever you want), then you specify use of the Template in another Template with something like:

{PRINTER TEMPLATE:My Business Info}
1 Like

This bundled with ternary and square brackets we could create some quite complex dynamic templates where we would previously have had to create multiple print jobs and whole separate templates.

So you want printer template templates :slight_smile:

Generating printer templates by using a printer template won’t work fine as it leads to a chicken egg issue but if you think this is something needs to be discussed we can talk about adding a new “printer template generator” feature. Such stuff won’t be a big benefit for people in general. I even can’t think a useful tutorial example for that. I mean we need a really good reason to invest time to implement this.

PS: Template sections are hardcoded to match to sections of a ticket so adding custom sections needs a lot of restructuring. If I have to make a choice I’ll prefer to implement generator feature instead of changing it.

PS2: You can’t load stuff that changes template structure via CALL but it is possible to call a script that generates a specific part of printout. I mean if you can use CALL to pad strings you can also use it to generate a footer… if it is the case.

PS3: If you don’t agree about the chicken egg issue you can try writing a pseudo template to load TemplateAFooter if a customer is selected or TemplateBFooter if not. Please keep in mind we process {X} tags first and execute JS expressions later.