I wanted a friendlier interface into making Inventory Purchase Documents and Transactions, and making Payouts to my Suppliers, so I spent some time putting together a PHP-based system.
The PHP code for SambaPOS v4.1.73 or later : (
Additional Units support)
inv1.5.zip (99.9 KB)
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)
PHP 5.6 NTS (non-thread safe) x86 on IIS 7.0 on Windows 7 x64
MS SQLExpress 2014 x64, 2012 x64 and 2008R2 x64
SambaPOS 4.1.73 or later (inv1.5)
SambaPOS 4.1.70 to 4.1.72 (inv1.4)
SambaPOS 4.1.58 to 4.1.69 (inv1.3)
I’m releasing this code to illustrate what can be done using PHP when attached to the SambaPOS Database (SQLExpress). I have done my best to make it as generic as possible for those who want to use it, but inevitably, there are some specific functions within it that apply to the way I have SambaPOS configured, and the way I think Inventory should operate.
You should also read the file !readme.txt for more information.
Ensure you modify the configuration file to set your DB username and password, located here:
You can also look at
config.php which contains simple things like Site Name.
- PHP installation on some type of Webserver… There are many methods to setting this up - here is a Tutorial that I recommend: PHP setup on IIS
- the PHP uses an extension called
sqlsrvto perform operations on MSSQL Databases. This extension needs to be downloaded and used on later PHP versions since built-in support for MS databases was dropped in PHP as of version 5.3. There is an official MS version of this extension that has support for PHP 5.3.6 thru 5.4, but I use an unofficial version which supports PHP 5.3 thru 5.6. There is a link in the
requiredfolder where you can download the unofficial version.
- other support files mentioned in
!readme.txt, namely SQL Native Client and VC++ Redistributables are required for all of this to work.
- SQL Express 2008, 2012, or 2014
- SambaPOS 4.1.70 or greater
- Have a look at the 2nd post in this thread to see how I have SambaPOS configured, since a good deal of the PHP code is based on it.
Use it at your own risk on a non-production system until you understand how it works. It will insert, update, delete records in the database.
The code is fairly clean, but poorly documented, and there may be portions of it that are unused or deprecated… I’ll work on cleaning it up over time. It’s pretty “old school” and linear. I make no claims of being a good coder, and I admit I’m exposing myself and my bad habits in this regard - laugh if you want, complain you must, offer suggestions if you please - it’s a work-in-progress, even though I am actively using it in Production. Play around with it yourself and make it work for you, scoff at it, change it, improve it, share it, delete it, light it on fire…
I probably won’t provide much support for this (especially how to get PHP working), but feel free to ask questions anyway.
My SambaPOS configuration uses a Warehouse for every Supplier that I have. Each Supplier Entity has it’s own Warehouse mapped to it, and for simplicity, the Supplier Entity Name and its associated Warehouse have the same name. These are all categorized as
Warehouse Type Supplier Warehouses.
I also have 2 Warehouses of Type Local Warehouses. One is On-site where I receive my deliveries called SHOP. The other is off-site where I store extra stock called BODEGA. These 2 Warehouses are the foundation of the way this system operates.
Purchases are made from the PURCHASE screen, and Inventory is inserted into the SHOP Warehouse. An Account Transaction is also made when Payment is made. I then transfer extra stock from SHOP to the BODEGA using the STOCK screen. Later, requests are made from the Shop using the REQUEST screen to have Inventory brought from the BODEGA. When I Fulfill a Request, inventory is transferred from BODEGA to SHOP.
Buttons in SambaPOS to open the PHP in a HTML Widget (you need to make these yourself):
The REQUEST screen:
The PURCHASE (Payout) screen:
The STOCK screen: (for moving and updating stock in Warehouses)
II screen: (for Adding and Updating Inventory Items)