The Function field is the HandlerName, in your case @@PriceCheck.
In the case of executing JScript, Function field needs the JScript HandlerName and the FunctionName within the JScript handler.
The Parameters field in the case of SQL is a comma-separated list, so you should make that a [:variable] that you will populate from the Rule to feed in the BarCode.
In the @@PriceCheck script, you access the Parameters via an @indexNumber, so the SQL script would become the following (notice the @1 which is the first value of the Parameters list):
SELECT p.[Price]
FROM [MenuItemPrices] p
LEFT JOIN [MenuItemPortions] s ON s.[Id] = p.[MenuItemPortionId]
LEFT JOIN [MenuItems] m ON m.[Id] = s.[MenuItemId]
WHERE m.[Barcode]='@1'AND s.[Name]="Normal"
creates the program setting where a keypad appears to enter the barcode, this then starts an auto command to run the script
Executes the script using the details provided above Function = @@PriceCheck and Parameter = {SETTING:Price Check} which is the store value of the barcode from the first rule. This rule then generates another auto command to fire another rule with a display message action to display the price
This rule should display the price in a display message action, I dont think this rule is correct but i dont know if the previous two are correctly setup. this 3rd rule doesnt generate the show message box, nothing happens
Using a script and {CALL:xxx} you only need one rule and one action;
Script;
function checkPrice(inputBarcode) {
qry = "SELECT p.[Price] FROM [MenuItemPrices] p LEFT JOIN [MenuItemPortions] s ON s.[Id] = p.[MenuItemPortionId] LEFT JOIN [MenuItems] m ON m.[Id] = s.[MenuItemId] WHERE m.[Barcode]="+inputBarcode+"AND s.[Name]='Normal'";
var salesTicketCount = sql.Query(qry).First;
return salesTicketCount;
}
so the script just uses the portion Normal, is there anyway to change it from saying Normal to a value that displays all portiona, or can i just add my different portions as a comma separated list after Normal?
function checkPrice(inputBarcode) {
qry = "SELECT s.[Name], p.[Price] FROM [MenuItemPrices] p LEFT JOIN [MenuItemPortions] s ON s.[Id] = p.[MenuItemPortionId] LEFT JOIN [MenuItems] m ON m.[Id] = s.[MenuItemId] WHERE m.[Barcode]="+inputBarcode;
var priceList = sql.Query(qry).Delimit(' ').All;
var priceCount = priceList.Length;
var responce = '';
for (t = 0; t < priceCount ; t++) {
responce += priceList[t]+'<linebreak/>';
}
return responce
}
Scripts are awesome, well worth learning. Plus as its JScript which is pretty much the same as JavaScript its a good code to understand the basics of.
I often end up doing things in scripts which could be done with reports or other ‘easier ways’ as especially with the helper functions from samba there isnt much you cant do.
You can even trigger some automation actions like messages/dialoges etc.
SQL to is a good language to have basic understanding of. SELECT for sure and basic JOIN understanding will get youmore ways to get data out of samba where report expressions miss bits.
This is the PMS Intergration topic, which at the begining of I had minimal knolage of SQL or JScript but Q and Kendash thankfully offered me directions and as with many things, once you get the basics google becomes so much more usefull for expanding your skills.
I have 2 questions for you Jtrtech:
1- Is there any possibility that we can show name of the item as well with price? Do I have to add [MenuItemName] in the script with [Price]?
2- The price its showing is it the price for the items which we have in the menu only or all the products we have in the product list?
One more thing is there a possibility to add this item in the ticket which we scanned for the price check?
Take a scenario if a customer comes to cashier with a item and ask for the price, so when cashier press price check button scan item tell the customer price and then customer say that he want this item.
Could we add two buttons like ok and cancel if customer say that he want it so cashier press ok and the item would be added to order, if customer say no so cashier will press cancel and the item would not be added to order.
You would add [Name] in the script to show the name and also update the response accordingly.
All products in your Product List. It is not related to Menus
Possibly. You could amend the buttons on the Ask Question and set the OK button to execute an Automation Command that in turn triggers the Add Order action to add the item to a new / existing ticket, however it won’t be that straightforward as you need to pass the product name to the Add Order action and you currently don’t have that from the barcode.
I would suggest just to scan the item again if someone wants to buy it, it is probably easier and I have seen in many shops when I ask a price for something then buy, they have to scan the item again to sell it, so I think any staff you have wouldn’t find it too much of a hassle.
Why go thru the problem? just add item to ticket as usual, he don’t want it just click cancel dont need to do all this. Why we always want to make thing more complicate than it should be?