Quantcast
Channel: SambaClub Forum - Latest topics
Viewing all articles
Browse latest Browse all 8862

Calling script alot on ticket template causing hang

$
0
0

@Prodigy wrote:

I have just found out my first issue on v5.1.56 causing by calling a lot of scripts on Ticket Template and previewing it, it will causing the sambapos to hang/not responding.

The Ticket Template :

[LAYOUT]
-- General layout
<ec>
<BMP>C:\Users\Este\Documents\SambaPOS5\Logo.bmp
<el>
<J00>
<T>Ticket
<L00>Date: {TICKET DATE}
<L00>Time: {TIME}
<L00>Server: {USER NAME}
{ENTITIES}
<L00>Ticket No:{TICKET NO}
<F>-
{ORDERS}
<F>=
<EB>
{DISCOUNTS}
[<J10>Total Gift:| Rp {CALL:str.pad('{ORDER STATE TOTAL:Gift}','left',13," ")}]
{SERVICES}
<J10>Total:| Rp {CALL:str.pad('{TICKET TOTAL}','left',13," ")}
<F>=
<J00>{TICKET TAG:GCN}| Balance: Rp [=F(TN('{TICKET TAG:GCB}'))]
[<J00>Total FREE:| Rp {CALL:str.pad('{ORDER STATE TOTAL:Gift}','left',13," ")}
[<J00>Discounts:| Rp [=F(TN('{ORDER TAG TOTAL:Discount}')+TN('{ORDER TAG TOTAL:VIP Discount}')+TN('{ORDER TAG TOTAL:HH Discount}'))]]
[<J00>TOTAL SAVINGS:| Rp [=F(-1*(TN('{ORDER TAG TOTAL:Discount}')+TN('{ORDER TAG TOTAL:VIP Discount}')+TN('{ORDER TAG TOTAL:HH Discount}'))+TN('{ORDER STATE TOTAL:Gift}'))]]
{PAYMENTS}
<DB>
<F>=
[DISCOUNTS]
<J00>{CALCULATION NAME} %{CALCULATION AMOUNT}|{CALCULATION TOTAL}
[SERVICES]
<J00>{CALCULATION NAME}|{CALCULATION TOTAL}
[PAYMENTS]
<J00>{PAYMENT NAME}|Rp {CALL:str.pad('{PAYMENT AMOUNT}','left',13," ")}
[ORDERS]
-- Default format for orders
<L00>- {CALL:str.pad('{QUANTITY}','right',2," ")} {CALL:str.cut('{NAME}','30','1')}
<J00> {CALL:str.cut('{NAME}','30','2')} | Rp {CALL:str.pad('{TOTAL PRICE}','left',13," ")}
{ORDER TAGS}
[ORDERS:Gift]
-- Format for gifted orders
<L00>- {CALL:str.pad('{QUANTITY}','right',2," ")} {CALL:str.cut('{NAME}','30','1')}
<J00> {CALL:str.cut('{NAME}','30','2')} | **GIFT**
{ORDER TAGS}
[ORDERS:Void]
-- Nothing will print for void lines
[ORDER TAGS]
-- Format for order tags
<J00> * {ORDER TAG NAME} | {ORDER TAG PRICE}
[ENTITIES:Table]
-- Table entity format
<L00>Table: {ENTITY NAME}
[ENTITIES:Customer]
-- Customer entity format
<J00>Customer: {ENTITY NAME} | Phone : {ENTITY DATA:Phone}

The script :

function pad(s,d,l,c) {
  // s : input string
  // d : direction - left or right pad
  // l : length of output string
  // c : pad character (0," ")
  // ensure the input is a string, not a number
  s = ''+s+'';
  var outstring = "";
  var padding = "";
  // build string padding
  padding=Array(l+1).join(c);
  // pad the input right or left
  if (d=='right') {
    outstring = (s+padding).substring(0,padding.length);
  } else {
    outstring = (padding+s).slice(0-padding.length);
  }
  return outstring;
}
function cut(fullWord,maxLength,operation)
{
   var fullLength = fullWord.Length
   if (typeof(maxLength) == "undefined") { var maxLength = '30'; }
   if (maxLength == "0") { var maxLength = '30'; }
   var trimmedString1 = fullWord.substr(0, maxLength)
   trimmedString1 = trimmedString1.substr(0, Math.min(trimmedString1.length, trimmedString1.lastIndexOf(" ")));
   var trimmedString2 = fullWord.substr(Math.min(trimmedString1.length, trimmedString1.lastIndexOf(" ")), fullLength)
   trimmedString2 = trimmedString2.substr(trimmedString1.length-trimmedString1.lastIndexOf(" "), trimmedString2.length);
   if (operation == "1") { return trimmedString1; } 
   if (operation == "2") { return trimmedString2; } 
}

To reproduce add the script to automation, make a transaction with normal and gift on it, and the ticket template and click preview.

Printing the ticket which has the offending ticket template also caused hang.

Looks like the hang threshold is if the script call above 10 times, more than 10 it will hang

Posts: 8

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 8862

Trending Articles