Changing Table Button Captions

(TEN.Table=$1)
How do I apply this to entities other than Table? I got seperate entity types for delivery and takeaway orders called Delivery and Takeaway.

TEN = “Ticket Entity Name”, Table is the Entity Type. So if you wanted to check against Customer name from Customer entity type, then (TEN.Customer=$1)

Here what I whipped-up this week for table captions. This sets a ticket tag (CustName) as a local variable for the table entity name so the DB doesn’t get hit every time the entity screen is loaded. The local settings are set/updated on login.

This works great on a single terminal. I’ve included instructions for adding a trigger for use in updating the local settings in a multi-terminal setting. Play with the timing of the trigger to see what works. I’ve yet to figure out how I’ll handle multi-department. I’ll update if/when I find a solution.

The following requires the “Advanced Ticket Actions” add-on module to be installed. You’ll find it in “Samba Market”.

Automation Command:
This button will be visible on the ticket for entering the customer’s name.
2020-06-03_09;34_1591198482_Samba.Presentation

  • Automation Command Name: NR Add Ticket Tag Name
  • Button Header: Name

Mapping:

  • Visible States: New,New Orders,Unpaid

Actions:
2020-06-03_09;00_1591196433_Samba.Presentation

  • Action Name: NR Update Ticket Tag
  • Action Type: Update Ticket Tag
  • Tag Name: [:settingName]
  • Tag Value: [:settingValue]

2020-06-03_09;00_1591196453_Idle

  • Action Name: TN Update Local Setting
  • Action Type: Update Program Setting
  • Setting Name: [:settingName]
  • Setting Value: [:settingValue]
  • Update Type: Update
  • Is Local: True

2020-06-03_09;01_1591196461_Samba.Presentation

  • Action Name: TN Execute Script
  • Action Type: Execute Script
  • Function: [:Function x.y()]
  • Run in Background: False

Rules:
2020-06-03_09;01_1591196503_Samba.Presentation

  • Rule Name: NR Update Ticket Tags Name
  • Event Name: Automation Command Executed

Custom Constraint:

  • Automation Command Name [Equals] NR Add Ticket Tag Name

Add Action: NR Update Ticket Tag

  • settingName: CustName
  • settingValue: [?Customer Name]

  • Rule Name: TN Ticket Name Set
  • Event Name: Ticket Closing

Custom Constraint:

  • '{LOCAL SETTING:{ENTITY NAME:Table}}' [Not Equals] '{TICKET TAG:CustName}'

Add Action: TN Update Local Setting

  • settingName: {ENTITY NAME:Table}
  • settingValue: {TICKET TAG:CustName}

2020-06-03_09;01_1591196516_Samba.Presentation

  • Rule Name: TN Clear Table Name
  • Event Name: Ticket Closing

Custom Constraint:

  • [=TN('{REMAINING TOTAL}')] [Equals] 0

Add Action: TN Update Local Setting

  • settingName: {ENTITY NAME:Table}

2020-06-03_09;02_1591196529_Samba.Presentation

  • Rule Name: TN Update Table Names on Login
  • Event Name: User Login

Add Action: TN Execute Script

  • Function y.x(): tablenames.update('{LOCAL SETTING:DEPARTMENT}')

Entity State Settings:
2020-06-03_09;05_1591196755_Samba.Presentation

  • Display Format: {LOCAL SETTING:$1}<br/>$1

Script:
2020-06-03_09;52_1591199526_Samba.Presentation

  • Script Name: TN Table Names
  • Handler: tablenames

Script Code:

function update(departmentName)
{
  departmentIDQuery = "SELECT Id FROM dbo.Departments WHERE Name = '"+departmentName+"'";
  departmentID = sql.Query(departmentIDQuery).First;
  
  q = "SELECT TE.EntityName, TE.Ticket_Id, T.TicketTags FROM dbo.Tickets T INNER JOIN dbo.TicketEntities TE ON TE.Ticket_Id = T.Id WHERE T.IsClosed = 0 AND T.DepartmentId = '"+departmentID+"'";
  r = sql.Query(q).Delimit('~').All;
  resultCount = r.Length;
  
  for (n = 0; n < resultCount; n++) 
  {
    resultList = r[n].split("~");
    tableName = resultList[0];
    tagsObj = JSON.parse(resultList[2]);
    tagsObjLength = tagsObj.length;
    
    for (nn = 0; nn < tagsObjLength; nn++)
    {
      tagName = tagsObj[nn].TN;
      tagValue = tagsObj[nn].TV;
      
      if (tagName == "CustName")
      {
        gqlCommand = 'mutation m {updateLocalSetting(name:"'+tableName+'",value:"'+tagValue+'"){name,value}}';
        gql.Exec(gqlCommand);
      }
    }
  }
  return "";
}

For multi-terminals in same department:

Trigger:
2020-06-03_09;04_1591196654_Samba.Presentation

Rule:
2020-06-03_09;02_1591196567_Samba.Presentation

Is there a way to use conditional expressions with this?
I use delivery department the same way as restaurant department to simplify tasks for the cashiers as much as possible.

Instead of tables, entities for delivery department is Orders. So I want the expression to check whether the entity name is Table or Orders and return the ticket value for each entity type.

Right now it only works for restaurant department.


Unfortunately, ternary expressions don’t work for display format.
image

I don’t know of a cleaner way to do it as I’m not too familiar with the reporting tags. But seeing as the ticket entity is either Table or Orders, try this for the ticket amount. Only one will return a value. I don’t know the cost of the queries when doubling-up on reporting tags.

{REPORT TICKET DETAILS:T.TotalAmount:(TEN.Tables=$1) and (TS.Status=Unpaid)}{REPORT TICKET DETAILS:T.TotalAmount:(TEN.Orders=$1) and (TS.Status=Unpaid)}

You can do like <if 1==1>True</if><if 1!=1>False</if>. This works here and on most other buttons and places ternary expressions don’t work.

I did something with this a couple years ago on this topic…

More details here:

3 Likes

Kickass! I see it pays to RTFM.

1 Like

Yeah, however the manual is pretty big lol

1 Like

That’s a interesting idea that Memo came up with, to use settings for table captions .

@Jesse, would it be easier for the sambapos system to update global settings upon ticket closing and recall all global setting on tables screen load? Or use report tags to recall info on table screen load?

I’m curious what would be more efficient. Thanks!

Edit:
Across a network environment.

I personally think to retrieve from database via report tags or otherwise, rather than the workaround storing in local settings. The database load over the network should be minimal, and unless you are experiencing slowness first, I think adding such script just adds complexity to something that should work without. I have used captions on tables before with report tags to retrieve ticket values and never noticed any noticeable performance - they update within 1 second from viewing the entity screen.

2 Likes

When the hardware can support it, absolutely. I had to come up with something different because one place refuses to upgrade any hardware let alone see if there are conflicting wifi channels. With 4 terminals, minimising hits to the DB and/or wifi traffic is necessary.

I think it’s best we leave this one alone… ;-]

I personally would use report tags. As long as they are not overly complex with parameterized searches etc then they should be very fast. Emre designed them to work fast. If speed is the #1 concern then I wouldn’t use anything there and just use color changing and hardcoded table numbers.

1 Like
<bold>$1</bold><br/>{REPORT TICKET DETAILS:T.RemainingAmount.Sum:((TEN.Table=$1) or (TEN.Takeaway=$1) or (TEN.Order=$1)) and T.RemainingAmount>0}{REPORT TICKET DETAILS:'<br/>'+[EN.Customer]:((TEN.Table=$1) or (TEN.Takeaway=$1) and (TCET=Customer)) and T.RemainingAmount>0 }{REPORT TICKET DETAILS:'<br/>'+[TT.Address]:(TEN.Order=$1) and T.RemainingAmount>0}

I figured out I could use ‘or’ for applying it to other entities. It works pretty well although it takes a couple of seconds to load during busy hours.

But there is an issue with a line break. There is one line break for each ticket added to a table. Here is one table with 3 tickets and two tables with a single ticket, one with a customer and one without. It seems the line break is appearing in the space for the customer name.

image

Hey everybody - still here quietly reading :grinning:

@Sarim yes you are correct this very temperamental and today I still do not understand how I managed to get it to display multiple line data. Trial and error is all I can add to this but you are on the right track…

1 Like

This is great but if I only want to show the customer’s first name?

Hi… If I only want to show the customer " First Name" , what should I replace the [EN.Cutomer] to?

Depends on what fields you have setup.
If you have single name field it’s not straight forward.
If you have first and last name fields it’s easier.

Hi JTR Tech,

I see that I have first name filed and Surname Field. but when I put [EN.Customer], the whole information comes up. I just want to know what should I replace " Customer " in order to just show the first name?

{ENTITY DATA:FieldName} should do the job where FieldName is the name of the custom entity field.

I will try.

Thx for your help… :slight_smile:

$1<br/>{REPORT TICKET DETAILS:TT.Waiter:(TEN.Table=$1) and T.RemainingAmount>0}
This is what I used to display waiters tagged to a table. You have to change your Tag name (Waiter) to your own.