Popup Browser action.
First of all we need to enable web server on message server service application. That explained under SambaPOS 5.1.60 Release topic.
After enabling web server you can place your application files under SambaPOS installation folder. If you didn’t do it before create an
apps folder under SambaPOS installation folder and place
deliverydate application under that folder.
Please remember you’ll copy application under SambaPOS installation folder where message server service is actually runs. If it runs on same server with SQL server you should copy application to server machine.
This is the application I’ve created. I used pikaday.js datepicker. ( https://github.com/dbushell/Pikaday) Pikaday does all stuff we need so to create my date selector application I downloaded content of their demo and played with CSS a little bit to match it to SambaPOS look.
deliverydate.zip (21.1 KB)
When you unzip deliveydate folder under apps folder you can use your browser to test if it works fine or not.
- When you click Delivery Date button on Ticket it reads Delivery Date tag and copies it as an URL parameter. So navigating to
http://localhost:9000/apps/deliverydate/?1 1 2010URL (you’ll normally see %20’s instead of spaces) the selected date becomes 1 January 2010.
- When you select a date app saves selected data as a local program setting. Specifically this line does it.
window.external.SetLocalSettingValue('Delivery Date',this.getMoment().format('DD MM YYYY'))
- Clicking OK button updates Ticket Tag with
Delivery Datelocal setting.
So we can pass parameters to app by using URL parameters and app can update Local settings by using
window.external.SetLocalSettingValue() function. We can read that setting in SambaPOS automation to read selected values.
Here are the Rules and Actions I added.
I created an action to update Ticket’s
Delivery Date tag.
Another action to Display Popup browser. Please note how I added [:param] variable to pass selected date to JS Application. When OK button clicked it executes
Update Delivery Date automation command.
This automation command displays
Delivery Date button. Don’t forget to map it to Ticket Screen.
This rule works when Delivery Date button clicked and it Displays Date Selector. Current delivery date passed to
Finally this action works when OK button clicked on Date Selection screen.
I hope you liked it. I know this sample make you think about new automation possibilities so please feel free to share your ideas.