[inv 1.5] Inventory Purchase and Control via PHP

This is how I have SambaPOS set up, so some of the code is based on (naming) conventions found here:

Warehouses:

Inventory Transaction Types:

Inventory Document Types:

Supplier Entities: (mapped to an associated Warehouse and Account)

Account Transaction Types:

Account Document Types: (these appear as buttons on the PURCHASE screen)

Department Warehouse:

1 Like

Authentication was added in v1.2. The authentication is mapped to Users and Roles in SambaPOS, and can be used to control the Buttons that are shown at the top of the screen in the PHP system, via this config file:

/inv/html/zconfigs/configbuttons.php


There is an optional Auto-Login feature which requires the following Action and Rules to store a Program Setting value for the current logged-in User. If you don’t need/want the Auto-login feature, there is no need to follow the setup shown below.

Action - Update Program Setting InvUser:

Rules - fire the Action to update the Program Setting for InvUser:

Custom Entity Screen HTML Viewer Widget showing the URL setting:

Set the directives in /inv/html/zconfigs/configdb.php for Auto-login:

$autologinSambaUser=true;
$autologinDomain='localhost'; // should match the HTML Viewer Widget URL
$autologinDBsetting='InvUser'; // should match Program Setting name

I’ve reviewed it and seems readme file contains all required information. I’ll try setting it up in few days and let you know if I notice something.

2 Likes

@emre, where in the DB is the current logged-in user stored?

EDIT: found it here, but the value is NULL

[ProgramSettingValues].[UserName]

I want to put login/authorization on this system (which I have working already), but it would be nice if I could automate the login based on the current SambaPOS user.

If it’s not in the DB, can I pass it in the URL of the HTML Widget like this?

http://localhost/?currentuser={:CURRENTUSER}

EDIT: hmm… can’t seem to get that to work… is there other syntax I can use?
@Jesse, is there something that works for TimeTrex?

Yes, I am on mobile atm though so I cannot pull it up. I have timetrex authenticate using !#username= ill look it up when I get home.

Set a widget name from Properties > Name and set URL with Set Widget Value action. You can use such tags inside rule.

1 Like

Thanks for that @emre, I might try that. In the interim, I got around it by storing [:Username] in a Program Setting called InvUser after login, and clearing the setting on logout.

It brings to mind another question though: is {:CURRENTUSER} Terminal-specific? What about [:Username] ?

If you store it in database all terminals will see same last logged in user. Maybe you can configure a setting name that includes a terminal suffix ?

{:Username} is something else that relates with my latest staff notification :slight_smile:

Ok, I’ll bite. @emre, how do I access the value for Terminal?

EDIT: deleted post and moved to post 3

@QMcKay sorry I think I meant something different. I meant you can create a rule that mapped to the terminal and works when a user logged in. That terminal specific rule will save {:CURRENTUSER} value to a terminal specific setting so you can query which user logged to a terminal through database.

However you’ll need to know which terminal accesses to server right? Maybe using Set Widget Value is easier to implement.

Correct, I need to know which Terminal, and I don’t know how to access that value. I haven’t seen any Terminal-specific parameters that can be used in Rules…

The way I have it working now is that only the Server Terminal will perform Auto-login, based on the HTML Widget having an URL setting of http://localhost. The PHP checks the URL and will only auto-login if the host is localhost, because we should assume that the code is running on the Server Terminal anyway.

It’s not that we can’t access the PHP remotely, but the remote-URL won’t match localhost, so the Auto-login will fail. I’m fine with that; I like it that way.

P.S. localhost could be set to 127.0.0.1 or 192.168.1.100 or whatever (it’s parameterized in the code), so long as it’s the IP of the Server with the DB and the PHP, and the Widget URL matches the directive in the PHP code ($autologinDomain).

I moved 18 posts to a new topic: HTML Widget URL: setting URL value with Set Widget Value Action

Ok, so after all of that discussion on setting the URL value, I’m of the opinion that it’s not going to work very well in my PHP implementation without some rethinking on the Authorization and Auto-Login. I already store the User as a Session variable so we can move within the HTML from REQUEST to PURCHASE without having to GET the URL currentuser. But it complicates things a bit. I prefer it the way I have it now, by storing the Username in the DB upon Login, and letting the PHP look up the user. This saves having to Set Widget Value at all.

However, there is still the point of the Terminal. If I could access the Terminal value upon Login, I could store it along with the User and it would make things much simpler.

I find it hard to believe there is no setting for {:TERMINAL} or [:Terminal]. @emre, is there a reason for this missing setting?

On next version you’ll be able to use {:CURRENTUSER} and {:CURRENTTERMINAL} tags in your widget’s URL setting.

Seems nobody needed it until now :slight_smile:

2 Likes

Newest addition to the system: now you can Add & Update Inventory Items using this interface. Populated pick-lists for GroupCode, Base Unit, Transaction Unit so you can select from existing choices. Available in v1.3.


The II screen: (for Adding and Updating Inventory Items)

(2014-12-01) New version 1.5 updated to work with SambaPOS v4.1.73 or later, with support for Additional Units. Config Files have been relocated to their own folder:

/inv/html/zconfigs/configdb.php
/inv/html/zconfigs/configbuttons.php

The PHP code for SambaPOS v4.1.73 or later :
inv1.5.zip (99.9 KB)

(2014-10-20) New version 1.4 updated to work with SambaPOS v4.1.70 thru 4.1.72. Earlier versions (4.1.69 or less) will not work with this release. For earlier versions of SambaPOS, you need to use inv1.3.zip

The PHP code for SambaPOS v4.1.70 or later :
inv1.4.zip (83.2 KB)

The PHP code for SambaPOS v4.1.69 or earlier:
inv1.3.zip (83.1 KB)

4 Likes

how can I import these files and DB for PhP My Admin on Xampp?

You should know this will not let you update previous WP purchases either. What he built was a front end for purchases but it is still bound by the same rules.

phpMyAdmin is a tool for managing MySQL using PHP. This does not use MySQL .

my bad luck, I want to also update the previous WP purchases Either
how can I configure update previous WP purchases Either?