Storage Boxx is an open-source PHP Inventory Management System. With a built-in webcam QR scanner, NFC scanner, passwordless login, and an optional experimental AI assistant.
TABLE OF CONTENTS
DOWNLOAD & INSTALLATION
First, here are the download links and a quick “setup guide” for the impatient folks who don’t want to read through everything.
LICENSE & DOWNLOAD
Storage Boxx is released under the MIT License. You are free to use it for personal and commercial projects, and modify it as you see fit. On the condition that the software is provided “as-is”. There are no warranties provided and “no strings attached”. Code Boxx and the authors are not liable for any claims, damages, or liabilities.
SORRY FOR THE ADS...
But someone has to pay the bills, and sponsors are paying for it. I insist on not turning Code Boxx into a "paid scripts" business, and I don't "block people with Adblock". Every little bit of support helps.
Buy Me A Coffee Code Boxx eBooks
SYSTEM REQUIREMENTS
- LAMP/WAMP/MAMP/XAMPP
- Apache Mod Rewrite
- PHP MYSQL PDO Extension
- PHP OpenSSL Extension
- At least PHP 8.0
INSTALLATION
Just copy/unzip into your HTTP folder. Access http://your-site.com
in the browser and walk through the installer.
HOW TO USE
So far so good? Let us now go through a quick crash course on how to use Storage Boxx.
EQUIPMENT RECOMMENDATIONS
- Webcam – If you are using a desktop without a webcam, a simple one only costs about $20~30.
- USB QR Code scanner – Alternatively, a “dedicated barcode scanner” will cost about $30~40 bucks.
- NFC tags – 10 pieces of Ntag213 only cost 2-3 bucks. Buy them in bulk, and one piece will only cost a few cents.
- Fingerprint sensors – These are kind of expensive… But I got lucky with a $25 “Made in China” that works just fine.
- Label printer – Print your QR codes. There are Bluetooth ones that can pair with smartphones.
PART 1) REGISTER ITEMS
First step, register all your items. You can do it one by one, or the smarter way is to upload a CSV file if you have a lot of products.
PART 2) REGISTER BATCHES
Now that the items are in place, create the batches for every item.
- Batches are particularly good for managing items with expiry dates, or if you want to track how slow/fast a batch moves.
- For the people who don’t care about “batches” – Just create a dummy batch and use it for a lifetime.
- Print the QR code for the batches, and/or create the NFC tags.
PART 3) ITEM MOVEMENT
Record the item/batch movement accordingly over time. Pretty self-explanatory.
- Set the direction (in, out, discard, stock take).
- Set the quantity.
- Add notes, if any.
- Enter the SKU and batch – Or just scan.
PART 4) CHECK
You can access the “check” section at any time, check the stock movement history.
EXTRA) PASSWORDLESS SIGN IN
The days of stinky passwords are over.
- You can create NFC login tags (staff card) for users. So long as they have a compatible device/browser, they can use it to login without entering the user/password.
- Alternatively, open the user menu after you have signed in (top-right corner) – Passwordless Login. Register to sign in with your fingerprint, face recognition, or pin number.
STORAGE BOXX FAQ
Storage Boxx is “not working”? Here are a few of the common problems and how to “fix” them.
I DELETED ALL ADMIN ACCOUNTS
require "lib/CORE-Go.php";
$_CORE->load("Users");
$_CORE->Users->save("NAME", "EMAIL", "PASSWORD", "A");
Just create an “account recovery” script to create a new account. Run and delete this afterward.
CHANGED DOMAIN OR PATH
- Update
SITE_NAME
andHOST_BASE
inlib/CORE-Config.php
. Include the path (with a trailing slash) if not deployed at the base URL. E.G.http://site.com/storageboxx/
- Delete the existing
.htaccess
file. - Create
init.php
.require "lib/CORE-Go.php";
$_CORE->Route->init();
- Access
http://site.com/init.php
, this will automatically regenerate.htaccess
and updateCB-manifest.json
. - Delete
init.php
. - Clear the service worker, flush the browser cache, and do a hard reload if you want to be “totally safe”.
PAGES ARE NOT RESOLVING OR SHOWING PROPERLY
- Make sure that
MOD_REWRITE
is enabled in Apache. - Make sure that
AllowOverride
is set properly in Apache. - If using
https://
, make sure that your SSL cert and virtual host are properly set. - In Mac/Linux, make sure that Apache/PHP has permission to read the files and folders.
Here is a quick “working example” of a test site on my WAMP server:
<VirtualHost site.com:443>
DocumentRoot "D:\http"
ServerName site.com:443
SSLEngine On
SSLCertificateFile "C:/xampp/apache/conf/ssl.crt/server.crt"
SSLCertificateKeyFile "C:/xampp/apache/conf/ssl.key/server.key"
<Directory "D:\http">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
NOT WORKING. DON’T KNOW WHY.
Open the developer’s console, reload the page, and see the error message.
NFC FEATURES ARE “NOT WORKING”!
At the time of writing, Web NFC only works on Android Chrome and Baidu Browser – CanIUse
UNABLE TO GENERATE JSON WEB TOKEN KEYS
Make sure that the OpenSSL extension is properly installed.
- Linux
- It is as simple as
sudo apt-get install openssl
. - Or
yum install openssl
for the CentOS users. - Then,
php -i | grep -i openssl
.
- It is as simple as
- Windows – I am using XAMPP and OpenSSL is already included. But a hiccup got me stumped for a while.
- Start > Search for “system environment” > “Edit the system environment variables” > “Environment variables”.
- Add a new system variable called
OPENSSL_CONF
and point it to theopenssl.cnf
file. By default, it is located atxampp\php\extras\openssl\openssl.cnf
.
FOR THE DEVELOPERS
This section is for the developers, with a couple of development notes for customization.
BUILT ON CORE BOXX
- At least go through the very short tutorial.
- Thereafter, go into the deeper concepts:
- Storage Boxx has also adopted the following modules:
SUPPORTING MULTIPLE HOST/DOMAIN NAMES
- In
CORE-Config.php
, detect the origin and setHOST_BASE
accordingly. - If you have different paths, you are going to face problems with the manifest. E.G.
https://sitea.com
andhttps://siteb.com/storageboxx
.- You can create multiple
CB-manifest.json
, each with a differentstart_url
andscope
. InTEMPLATE-top.php
, point to the “correct manifest” accordingly. - Alternatively, generate the manifest dynamically using PHP.
- You can create multiple
SETTING TIMEZONES
- You can change the default timezone in
CORE-Config.php
,SYS_TZ
andSYS_TZ_OFFSET
. Beware though, this can mess up the timestamps in the database if you already have entries. - If you have to support multiple timezones, it will be wise to keep the system default to
UTC
. Calculate the offset in PHP or MYSQL queries instead.
I WANT TO CHANGE THE DATE FORMAT
- Login > System Settings > There are 4 “MYSQL date/time format” settings, change them accordingly. These are simply formats for the MYSQL
DATE_FORMAT()
function. - Use the respective date/time format in your SQL –
"SELECT DATE_FORMAT(`col`, '".DT_LONG."') FROM `table`"
.
EXPIRING ITEMS NOTIFICATION
Tricky.
- Create a
expire-notify.php
script, set it to run every 24 hours in Windows Task Scheduler orCRON
. - Add a
EXPIRE_WARN_DAYS
setting. - Modify
$_CORE->Report->getExpiry()
to get expiring items withEXPIRE DAYS > 0 && EXPIRE DAYS <= EXPIRE_WARN_DAYS
. - If there are expiring items, send the notification.
- It will be wise to add another
EXPIRE_NOTIFIED
table to keep theitem_id
andbatch_name
… Or the system will nag every 24 hours until the item expires.
EXPERIMENTAL AI ASSISTANT
So, you may have noticed that the experimental AI is “missing” or “not working” out of the box. It’s a long story.
REQUIREMENTS
- Python – Yes, Python. Not PHP. Version 3.9 to 3.10 seems to work fine at the time of writing.
- Microsoft C++ Build Tools
- Plenty of “processing juice”. AI does consume quite a lot of system resources, depending on the model size.
INSTALLATION
- Move the
ai
folder out of your HTTP folder. Yes, keep it outside of your project folder. - Access the GPT4All website, and scroll down to the “Model Explorer”. Pick your poison, download your chosen model into
ai/models
. - Alternatively, here is the list of available models in JSON.
- Edit
settings.json
, change the model to your own. - Run
1-install.bat
(Windows)1-install.sh
(Linux/Mac). This will automatically:- Create a virtual environment and activate it.
- Download the necessary modules.
CREATE A “CONTEXT DATABASE”
- Put the documents that you want the AI to “learn” in
ai/docs
– This can be CSV, TXT, PDF, HTML, MD, or DOCX. - Run
2-create.bat
(Windows)2-create.sh
(Linux/Mac). - This will read all the documents in
ai/docs
and create a databaseai.db
. - Try not to overwhelm by putting in too many documents… There’s a limit to how much things can be processed.
LAUNCH
- Finally, just run
3-launch.bat
(Windows)3-launch.sh
(Linux/Mac). - This will deploy the bot at
ws://localhost:5678
. - Change
settings.json
andassets/PAGE-ai.js
if you want to deploy it at a different port.
NOTES ON THE PERFORMANCE
- GPT4ALL does not support GPU acceleration at the time of writing. It’s slow, but at least it works across multiple different platforms.
- If you want a free GPU-accelerated model, check out LLAMA.
- This module is based on LangChain – It also supports many other models, ChatGPT included. Do your own tweaks to
create.py
andbot.py
if you want to use other models than GPT4All. - On my potato server, the Falcon model seems to understand text content well enough… But generates erroneous results when it comes to numbers.
- The results pretty much depend on the model and
prompt.txt
template – Tweak and do your own experiments. It’s an EXPERIMENTAL module after all. - You can also directly chain the AI to an SQL database. Maybe in a future update when I have dug deeper into LangChain.
- You may want to find some way to verify the user. Not a good idea to open the AI assistant to the entire world.
- Also, limit the total number of users at once if you have limited system resources.
Hi, when ever i am trying to install it on localhost with xampp i get below error.
“Fatal error: Uncaught RuntimeException: Unable to create the key in C:\xampp\htdocs\inventory\lib\webpush\web-token\jwt-core\Util\ECKey.php:98 Stack trace: #0 C:\xampp\htdocs\inventory\lib\webpush\web-token\jwt-core\Util\ECKey.php(72): Jose\Component\Core\Util\ECKey::createECKeyUsingOpenSSL(‘P-256’) #1 C:\xampp\htdocs\inventory\lib\webpush\web-token\jwt-key-mgmt\JWKFactory.php(69): Jose\Component\Core\Util\ECKey::createECKey(‘P-256’, Array) #2 C:\xampp\htdocs\inventory\lib\webpush\minishlink\web-push\src\VAPID.php(165): Jose\Component\KeyManagement\JWKFactory::createECKey(‘P-256’) #3 C:\xampp\htdocs\inventory\lib\CORE-Install.php(135): Minishlink\WebPush\VAPID::createVapidKeys() #4 C:\xampp\htdocs\inventory\index.php(2): require(‘C:\\xampp\\htdocs…’) #5 {main} thrown in C:\xampp\htdocs\inventory\lib\webpush\web-token\jwt-core\Util\ECKey.php on line 98″
And when i am trying to install it on server without apache [Hostinger domain Shared] edited .htaccess file I get error ” AJAX ERROR | Bad server response”
I have got older version too ie. 2022 it’s working fine on localhost but it could not be installed on server, it shows error while creating data base, and when I first create database then try to install, it shows error that ” Could not create database with name, as it is already available” same old version is working fine on localhost.
Help !
See “UNABLE TO GENERATE JSON WEB TOKEN KEYS” and “PAGES ARE NOT RESOLVING OR SHOWING PROPERLY” above. Sorry, I cannot give free troubleshooting for personal projects and hosting…
https://code-boxx.com/faq/#help “Help and requests on a deeper level.”
HI, i just installed it and after login it shows ” Service worker not supported. “
As it is – You are either using an outdated browser or your domain is not using https.
https://caniuse.com/serviceworkers
I am using it on localhost , so it must be reason for showing it. Will it work without any problem if it shows that error ?
Thanks.
Service workers are installed in the browser. Still works without service workers, but no advanced caching and push notifications.
P.S. So long as the url is not http://localhost, it NEEDS to be https://. Even if it is an IP address.
P.P.S. If it is a half-eaten rotten Apple – They don’t quite follow the international standards. I don’t have a Mac to verify the workers and push. Too lazy to create a Hackintosh VM…
AJAX ERROR
Bad server response
Any tips how to fix please? Thank you
https://code-boxx.com/faq/#notwork
Hi, can you help me with this problem?
It says “The installer cannot verify if you are running Apache Web Server, or if MOD_REWRITE is enabled. You can still try to proceed if you want. If you are not running Apache, you need to create your own “translated” .htaccess file. See lib/LIB-Route.php > function htaccess().”
And I followed your instruction to create init.php, and it keep showign this error message, {“status”:0,”message”:”Call to a member function init() on null”,”data”:{“code”:0,”file”:”/public_html\/init.php”,”line”:3,”trace”:”#0 {main}”},”more”:null,”page”:null}
As it is.
1) If you are using Apache – Enable MOD_REWRITE
2) If you are not using Apache – Create your own translated .htaccess equivalent as in $_CORE->Route->init()
But after I have successfully installed, when I login, it says AJAX ERROR, Failed to parse JSON data.
Did some small updates to the Javascript and installer – API calls will show more details other than “JSON error” now.
Chances are, mod_rewrite is not properly configured on your server – See “PAGES ARE NOT RESOLVING OR SHOWING PROPERLY” above.
Hi did you manage to resolve the AJAX Error and if how? Im using a litespeed server which is proving difficult
Don’t quite remember, but there are some mod_rewrite differences for Litespeed – You have to do some research on your own.
Hello, I am hosting it on localhost using xampp, and got this error
Notifications denied – Manually enable permissions to allow low stock warning.
How do I fix this problem? Thank you
As it is, you have previously denied push notifications or a security plugin did it automatically. If the URL is not http://localhost, make sure that you use https.
https://support.google.com/chrome/answer/114662?hl=en&co=GENIE.Platform%3DAndroid
https://support.mozilla.org/en-US/kb/site-permissions-panel
https://www.windowscentral.com/how-manage-site-permissions-new-microsoft-edge