# Custom Can Confirm Admin Pin Prompt

**URL:** <https://forum.sambapos.com/t/custom-can-confirm-admin-pin-prompt/19459>\
**Category:** V5 Tutorial\
**Created:** [March 1, 2019, 2:07am UTC](https://forum.sambapos.com/t/custom-can-confirm-admin-pin-prompt/19459 "2019-03-01T02:07:42Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![JTRTech](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jtrtech/32/21270_2.png) [@JTRTech](https://forum.sambapos.com/u/JTRTech)\
**Post date:** [March 1, 2019, 2:07am UTC](https://forum.sambapos.com/t/custom-can-confirm-admin-pin-prompt/19459/1 "2019-03-01T02:07:42Z")

</div>

So working on better logs and alternate login options.  
Seen it asked a couple of times but not seen a documented solution.  
I plan to use this to log and set state value for void and the likes.  
I like having void available for all rolls as this allows a passing manager to void mistakes without having to switch to their user.  
This however will show as a void for the current user not the manager than ‘swiped’ to confirm admin pin.  
So rather than use confirm admin pin I have used a script and a multi set command flow with [?prompt] for pin entry then script to check can confirm admin pin option for the user with the ‘swipped’ pin.

Since I would prefer to use less rules for easier managment I will pass all the automation command through my own can confirm admin pin rule before triggering the actual command for say void.

My example is for Void but will extend this to refund and gift etc.

Fisrt step is to change the VOID automation command button.  
Rather than going straight to the void command rule it will now go to my new processing rule;

 ![image](https://forum.sambapos.com/uploads/default/original/3X/0/7/07923c40e37c327755c2daa6e85f8d294f3898fb.png)

You will see I have added - ConfirmAdminPin to the command name and set Void as the only value in the values field. I will use this command value to separate the end command back to the original void rule once pin is and can confirm roll checked.

Next I make a ‘Custom Confirm Admin Pin’ rule;

 ![image](https://forum.sambapos.com/uploads/default/original/3X/1/3/131774c2cf6451be390c30cd11019debedec12f3.png)

So the automation command name is constrained to the ‘Void - ConfirmAdminPin’ command now triggered by the Void button.  
I then use an execute automation command action to trigger the original void rule.  
Using [:CommandValue] passed from the button the triggered rule after this will now be the origional Void rule.  
Now for the command value I use a {CALL:xx} function with a [?Prompt]. The prompt will ask for user to enter a pin like confirm admin pin. The entered value is passed to the acript to validate and will pass the value returned as the command value into the void rule.

I have used this script;

 ![image](https://forum.sambapos.com/uploads/default/original/3X/8/a/8a01e0711d415486c795c57f7f05cb2ccea4a6bd.png)

```
 function canConfirmAdminPin(inputPin){
	qry = "SELECT u.Name as UserName ,max(case when p.[Name] = 'CanConfirmAdminPin' then p.value end) as CanConfirmAdminPin	";
	qry +=	"FROM [Users] u JOIN [UserRoles] r on r.Id = u.UserRole_Id JOIN [Permissions] p on r.id = p.UserRoleId ";
	qry +=	"WHERE u.PinCode = '"+inputPin+"'";
	qry +=	"GROUP BY u.Name";
	var userQry = sql.Query(qry).Delimit('~').First;
	if(!userQry){
		return false
	}
	var userQryArray = userQry.split('~');
	var userName = userQryArray[0];
	var canConfirmAdminPin = userQryArray[1];
	if (canConfirmAdminPin==0){
		return userName
	} else {
		return false
	}
}

```

This script will lookup the entered pin and return false if pin is not valid or if correct but user does not have a role set which allows can confirm admin pin.  
If the pin is correct and has permission to confirm admin pin it will return the user name for the pin.

Then all that is left is to add an extra constraint to the original void rule for command value not equals False.  
This way if the script cannot find pin or doesn’t have permission and returns/passes False as command value the rule will not fire.  
Anything else - ie the user name the rule triggers.  
Then if not already set, adding command value to the gift state void value the user who swiped will be named as the state value;

![image](https://forum.sambapos.com/uploads/default/original/3X/d/1/d15e926ea4fabe743cd6275593296466a51d6442.png)

Now even with default work period report Voids will be listed per user;

![image](https://forum.sambapos.com/uploads/default/original/3X/a/8/a8dd8e8366e225369bb60094295c69ef47ed5de4.png)

---

<div class="post-metadata">

**Author:** ![Shivan](https://forum.sambapos.com/user_avatar/forum.sambapos.com/shivan/32/27314_2.png) [@Shivan](https://forum.sambapos.com/u/Shivan)\
**Post date:** [March 1, 2019, 2:23am UTC](https://forum.sambapos.com/t/custom-can-confirm-admin-pin-prompt/19459/2 "2019-03-01T02:23:47Z")

</div>

I really envy your Scripting skills \>.\<

This is great!

---

<div class="post-metadata">

**Author:** ![JTRTech](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jtrtech/32/21270_2.png) [@JTRTech](https://forum.sambapos.com/u/JTRTech)\
**Post date:** [March 1, 2019, 2:27am UTC](https://forum.sambapos.com/t/custom-can-confirm-admin-pin-prompt/19459/3 "2019-03-01T02:27:23Z")

</div>

JScript part is simple, but am chuffed with the SQl as after half an hour tring to find the permissions table LOL I managd to JOIN which was a worry at first as it is stored wordpress meta style with permission name 'key and 1/0 value. As usual google showed the way.

---

<div class="post-metadata">

**Author:** ![Shivan](https://forum.sambapos.com/user_avatar/forum.sambapos.com/shivan/32/27314_2.png) [@Shivan](https://forum.sambapos.com/u/Shivan)\
**Post date:** [March 1, 2019, 2:42am UTC](https://forum.sambapos.com/t/custom-can-confirm-admin-pin-prompt/19459/4 "2019-03-01T02:42:48Z")

</div>

Ive followed many of the tutorials regarding Jscript within SambaPOS and honestly I still have a hard time getting grips with it.

SQL is really fun but also can be a bit of a pain to deal with. I only understood SQL because I studied it a lot at Uni(And yet I still suck at putting something together haha)

---

<div class="post-metadata">

**Author:** ![JTRTech](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jtrtech/32/21270_2.png) [@JTRTech](https://forum.sambapos.com/u/JTRTech)\
**Post date:** [March 1, 2019, 2:48am UTC](https://forum.sambapos.com/t/custom-can-confirm-admin-pin-prompt/19459/5 "2019-03-01T02:48:09Z")

</div>

JScript is 95% the same as JavaScript which in all honesty is more valuable to understand but luckily they are very similar.  
Its synchronous like PHP which makes like simpler, line by line in order, very logical. Its all just about handling variables. Google shows and explains functions and there parameters and being so similar to java there is huge amounts of info on web.

---

<div class="post-metadata">

**Author:** ![JTRTech](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jtrtech/32/21270_2.png) [@JTRTech](https://forum.sambapos.com/u/JTRTech)\
**Post date:** [March 1, 2019, 2:50am UTC](https://forum.sambapos.com/t/custom-can-confirm-admin-pin-prompt/19459/6 "2019-03-01T02:50:03Z")

</div>

Before doing that PMS integration I have never touched JScript, Java or SQL beyond very simple tweeks to existing scripts. Luckily q and kendash helped allot and took interest in my project and offered allot of guidance in early days.

---

<div class="post-metadata">

**Author:** ![Shivan](https://forum.sambapos.com/user_avatar/forum.sambapos.com/shivan/32/27314_2.png) [@Shivan](https://forum.sambapos.com/u/Shivan)\
**Post date:** [March 1, 2019, 2:50am UTC](https://forum.sambapos.com/t/custom-can-confirm-admin-pin-prompt/19459/7 "2019-03-01T02:50:17Z")

</div>

I need to go back to like a coding bootcamp lol

---

<div class="post-metadata">

**Author:** ![JTRTech](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jtrtech/32/21270_2.png) [@JTRTech](https://forum.sambapos.com/u/JTRTech)\
**Post date:** [March 1, 2019, 2:52am UTC](https://forum.sambapos.com/t/custom-can-confirm-admin-pin-prompt/19459/8 "2019-03-01T02:52:34Z")

</div>

Only took me a few months to get the basics and build that integration from 0 experience other than light HTML and CSS. No pro but think I can hold my weight.  
A logic mindset helps which I am fortunate to have.

---

<div class="post-metadata">

**Author:** ![JTRTech](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jtrtech/32/21270_2.png) [@JTRTech](https://forum.sambapos.com/u/JTRTech)\
**Post date:** [March 1, 2019, 2:56am UTC](https://forum.sambapos.com/t/custom-can-confirm-admin-pin-prompt/19459/9 "2019-03-01T02:56:47Z")

</div>

A change to contains ConfirmAdminPin simplifies the process, already propagated out to void, change price, gift and refund;

 ![image](https://forum.sambapos.com/uploads/default/original/3X/9/0/905f7a4fce80f6fb6b042240cc74b6f564a1f0b6.png)

![image](https://forum.sambapos.com/uploads/default/original/3X/a/e/aef7a299d768465449fcf4619afe6b526c8fb3df.png)

---

<div class="post-metadata">

**Author:** ![anvartmc](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/a/35a633/32.png) [@anvartmc](https://forum.sambapos.com/u/anvartmc)\
**Post date:** [March 27, 2019, 7:40pm UTC](https://forum.sambapos.com/t/custom-can-confirm-admin-pin-prompt/19459/10 "2019-03-27T19:40:12Z")

</div>

Can I do it in Samba POS 3 ?

---

<div class="post-metadata">

**Author:** ![JTRTech](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jtrtech/32/21270_2.png) [@JTRTech](https://forum.sambapos.com/u/JTRTech)\
**Post date:** [March 27, 2019, 7:40pm UTC](https://forum.sambapos.com/t/custom-can-confirm-admin-pin-prompt/19459/11 "2019-03-27T19:40:47Z")

</div>

No, you need scripting for SQL and scripts. Not available before v5

---

<div class="post-metadata">

**Author:** ![anvartmc](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/a/35a633/32.png) [@anvartmc](https://forum.sambapos.com/u/anvartmc)\
**Post date:** [March 27, 2019, 7:42pm UTC](https://forum.sambapos.com/t/custom-can-confirm-admin-pin-prompt/19459/12 "2019-03-27T19:42:01Z")

</div>

how can I do ADMIN cinfirmation for Void items in Version 3

---

<div class="post-metadata">

**Author:** ![JTRTech](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jtrtech/32/21270_2.png) [@JTRTech](https://forum.sambapos.com/u/JTRTech)\
**Post date:** [March 27, 2019, 7:43pm UTC](https://forum.sambapos.com/t/custom-can-confirm-admin-pin-prompt/19459/13 "2019-03-27T19:43:37Z")

</div>

Oh thought you meant custom method of tutorial, normal confirm admin pin is an automation command button option, that is available in V4 but not sure about v3. Most on forum have not used V4 yet alone v3, I haven’t looked at v3 for at least 5 years.

---

<div class="post-metadata">

**Author:** ![markjw](https://forum.sambapos.com/user_avatar/forum.sambapos.com/markjw/32/9942_2.png) [@markjw](https://forum.sambapos.com/u/markjw)\
**Post date:** [March 27, 2019, 8:32pm UTC](https://forum.sambapos.com/t/custom-can-confirm-admin-pin-prompt/19459/14 "2019-03-27T20:32:29Z")

</div>

> [@anvartmc](#):
>
> ADMIN cinfirmation for Void items in Version 3

It is not possible in V3. There is no support for Confirmation of Automation Commands

 ![image](https://forum.sambapos.com/uploads/default/original/3X/3/d/3df84ca3fb37d71f65e8f5e125be2336ffb8e6d4.png)

It is however available in V4

 ![image](https://forum.sambapos.com/uploads/default/original/3X/f/d/fdd266fa307cdb354dcab0f252586ff9e32cc2aa.png)

---

<div class="post-metadata">

**Author:** ![Castech](https://forum.sambapos.com/user_avatar/forum.sambapos.com/castech/32/38503_2.png) [@Castech](https://forum.sambapos.com/u/Castech)\
**Post date:** [April 1, 2019, 7:58am UTC](https://forum.sambapos.com/t/custom-can-confirm-admin-pin-prompt/19459/15 "2019-04-01T07:58:16Z")

</div>

Wow! Fantastic! Just in time!

---

<div class="post-metadata">

**Author:** ![jerryfin](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/j/d78d45/32.png) [@jerryfin](https://forum.sambapos.com/u/jerryfin)\
**Post date:** [January 23, 2023, 6:32am UTC](https://forum.sambapos.com/t/custom-can-confirm-admin-pin-prompt/19459/16 "2023-01-23T06:32:32Z")

</div>

Great code, I tweaked it to add the reason for voiding.
