Storage Boxx is a simple PHP Inventory Management System. This is not the “super professional crazy bloated with a lot of features” kind of system. But it does cover the basics and has a built-in HTML webcam QR code scanner. This should help the small businesses get started with their inventory stock keeping.
TABLE OF CONTENTS
DOWNLOAD & NOTES
First, here are the download links and a quick “setup guide” for the impatient folks who don’t have the patience to read through everything.
REQUIREMENTS
- Apache Mod Rewrite
- PHP MYSQL PDO Extension
- Best to have at least PHP 7.4
- “Grade A” browser
Storage Boxx has not been extensively tested, but it is developed and works on a WAMP8 (Windows Apache MySQL PHP 8) server.
INSTALLATION
Just access index.php
in your browser and walk through the installer.
LICENSE & DOWNLOAD
Storage Boxx is released under the MIT License. You are free to use it for your own personal and commercial projects, modify it as you see fit. On the condition that there 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.
Download Storage Boxx | GitHub | SourceForge
HOW TO USE
So far so good? Let us now go through a quick crash course on how to use Storage Boxx.
STEP 1) REGISTER INVENTORY ITEMS
- Go to the “Manage Inventory” section.
- Click on “Add”.
- Register the item.
- Print out the QR code if you want – It does speed things up and makes things easier to manage. Get yourself a USB barcode scanner if you do not already have one. A simple one only costs like… 30 bucks these days.
- Rinse and repeat, register all your items (or do some mass import from CSV magic into the database on your own).
STEP 2) UPDATE STOCK LEVELS
- Next, go to the “Stock Movement” section.
- This should be self-explanatory. Fill in and update the stock levels whenever required.
STEP 3) CHECKING STOCK LEVELS
To check the stock levels, simply type in the SKU or scan the QR code.
QUICK REFERENCE
This section is for the developers, a quick walkthrough of the general system structures.
FOLDER STRUCTURE
api/
The API endpoint.assets/
Public images, Javascript, CSS, etc…lib/
Core engine and library files.pages/
HTML pages.
Yes, there are only 4 folders in the entire system.
THE DATABASE
Field | Description |
stock_sku |
The SKU of the item, primary key. |
stock_name |
Name of the item. |
stock_desc |
Description of the item. |
stock_unit |
Unit of measurement. |
stock_qty |
Current quantity in stock. |
Field | Description |
stock_sku |
The SKU of the item. Primary key. |
mvt_date |
Date of movement entry. Primary key. |
mvt_direction |
The direction of the movement.
|
user_id |
The user who made this movement entry. |
mvt_qty |
Quantity moved. |
mvt_notes |
Notes, if any. |
Field | Description |
user_id |
The user ID, primary key. |
user_name |
The user name. |
user_email |
The user’s email address. |
user_password |
The password. Encrypted. |
THE FRAMEWORKS & CREDITS
Storage Boxx is built using:
- Bootstrap
- QR Code Scanner
- QR Code Generator
- Core Boxx. Believe it or not, the initial version is built within 48 man-hours using:
Go ahead and check those out if you want… The other “pre-developed” modules of Core Boxx should also snap right in.
DEVELOPING STORAGE BOXX
As simple as it may be, going through the entire system is still going to take some time. So instead of “explaining line-by-line”, here is a condensed version of “how to quickly customize and upgrade”.
STEP 1) CREATE/MODIFY DATABASE TABLES
Add your new tables or views, modify the existing ones.
STEP 2) ADD/UPDATE SYSTEM MODULE
class Report extends Core {
function getMoveByUser ($id) {
return $this->DB->fetchAll(
"SELECT * FROM `stock_mvt` WHERE `user_id`=? ORDER BY `mvt_date` DESC",
[$id]
);
}
}
To add a new module, create lib/LIB-Module.php
. Define class Module extends Core
, and add functions inside. In this example, we add a new report module – lib/LIB-Report.php
and class Report extends Core
.
That’s all. This new module can now be loaded via $_CORE->load("Report")
and the function can be accessed via $_CORE->Report->getMoveByUser()
.
STEP 3) ADD/UPDATE API ENDPOINT (OPTIONAL)
// (A) REGISTERED USERS ONLY
if (!isset($_SESS["user"])) {
$_CORE->respond(0, "Please sign in first", null, null, 403);
}
switch ($_REQ) {
// (B) INVALID REQUEST
default:
$_CORE->respond(0, "Invalid request", null, null, 400);
break;
// (C) MOVE BY USER REPORT
case "getMoveByUser":
$_CORE->autoGETAPI("Report", "getMoveByUser");
break;
}
Create api/API-Module.php
. For this example, send $_POST["id"]=123
to http://site.com/Report/getMoveByUser/
to get the movement report – The API will reply with a JSON encoded string.
STEP 4) ADD/UPDATE HTML CSS JAVASCRIPT
- Add your new pages in
pages/
.- For example,
pages/PAGE-report.php
can be accessed fromhttp://site.com/report
. - Take note –
PAGE-report.php
can only be accessed by users who are signed in.
- For example,
That’s about it. Just reverse engineer and copy from the existing libraries, API, and pages… You will see the development pattern here.
COMMON PROBLEMS & FIXING THEM
Storage Boxx is “not working”? Here are a few of the common problems and how to “fix” them.
I FORGOT THE PASSWORD OR DELETED ALL ADMIN ACCOUNTS
require "lib/CORE-go.php";
$_CORE->load("Users");
$_CORE->Users->save("NAME", "EMAIL", "PASSWORD", OPTIONAL-USER-ID);
Just create an “account recovery” script to create a new account (or update an existing one). Run and delete this afterward.
MIGRATING TO A NEW DOMAIN OR CHANGING THE URL PATH
- Simply update
HOST_BASE
inlib/CORE-config.php
. - Run
$_CORE->Route->init()
to update the.htaccess
andapi/.htaccess
files. - Clear the browser cache to prevent irritating cache redirects.
UPGRADING
- If your existing copy has an
options
table – Just override all the files and accessindex.php
. The installer will take care of database updates (if any). - If not – Manually import the
options
table fromSQL-storage-boxx.sql
, create aSTOREBOXX_VER
entry with a value of0
and group0
. Thereafter, just copy the new files and let the installer do the magic.
MANUAL INSTALLATION
- Create a database and import
lib/SQL-storage-boxx.sql
. - Open
lib/CORE-config.php
, update the settings to your own.- The host settings.
- Database settings.
- If you want to develop mobile apps, consider enabling CORS.
- Generate your own JWT secret key, set the issuer to your domain or company name.
- Run
$_CORE->Route->init()
to generate the.htaccess
andapi/.htaccess
files. - Create your own admin user, see “forgot password” above.
- Rename
lib/INSTALL-index.foo
toindex.php
.
NOT WORKING. DON’T KNOW WHY.
Open the developer’s console, reload the page and see the error message.
Hi there,
I have checked and debugged as best i can but i am not seeing what the problem is.
I have also made sure that PHP 7.4 is installed. I am getting the following error when installing:
Fatal error: Uncaught Error: Call to undefined function apache_get_version() in /home/ccmuhahx/public_html/ua/lib/CORE-install.php:72 Stack trace: #0 /home/ccmuhahx/public_html/ua/index.php(2): require() #1 {main} thrown in /home/ccmuhahx/public_html/ua/lib/CORE-install.php on line 72
any assistance would be greatly appreciated
Garth
undefined function apache_get_version() > PHP is not installed as a module of Apache
Installer updated. Nothing is wrong if you are running Apache. It’s just running in another manner. Follow up with an “apache cgi vs module” search on the Internet if you wish to learn more.
Thank you, however the new installer is throwing the following error:
Fatal error: Uncaught Error: Call to undefined function str_contains() in E:\Software\wamp\www\php\Storage-Boxx-2022-05-05-a\lib\CORE-install.php on line 72
Error: Call to undefined function str_contains() in E:\Software\wamp\www\php\Storage-Boxx-2022-05-05-a\lib\CORE-install.php on line 72
Regards
Garth
Of course.
str_contains()
only exists in PHP 8+.1) Updated installer to use
strpos
instead.2) Required PHP version has been updated to 8.0. Reason – PHP 7.4 will come to its end of life in Nov 2022. A gentle reminder to update your server soon. https://www.php.net/supported-versions.php
3) If you still want to continue with 7.4, edit lib/CORE-install.php C1 – change I_MIN_PHP back to 7.4.0
Hi there, works perfectly. Only problem is, it does not scan any barcode or QR code.
Error always says: Invalid SKU
Any ideas?
Thanks
Garth
Please do your own basic troubleshooting first (has SKU been registered, open developer’s console), and provide more details.
https://code-boxx.com/faq/#help “Unclear question and request”
https://code-boxx.com/faq/#notwork
Hi W.S. TOH,
I succeeded.
Thank you for your patience and please allow me to continue learning with your help.
projects seem to me the best way to really learn!
all good,
Hi W.S.TOH,
I almost managed, that is, after “installation”, at the primary login with user: “admin@sb.com” and the password “123456”, click on “Sign in” and the “AJAX ERROR” window appears.
“AJAX call error!”
What should I investigate?
Probably API path issues, re-download the latest version. Just import the SQL, and access your site – This thing now has a simple installer… and a webcam QR code scanner.
ok, i tried and got stuck in the “installer” where I got the “Fetch error – See console” error, but I noticed two things:
1. This error occurs regardless of what user and password you entered to access the database
2. The file “lib / storage-boxx.sql” is empty, ie it has only a command line “ctrl – C – exit!” and nothing about the tables on which the database is built
…help me please !
1) Exactly. What is the error message? Just open the developer’s console.
https://code-boxx.com/how-to-debug-javascript/
2) The SQL file reads 1.25KB. No idea what you are talking about – https://github.com/code-boxx/Storage-Boxx/blob/main/lib/storage-boxx.sql
3) Delete your current Storage Boxx database and folder – Redownload an entirely fresh copy. The installer is now fully automated, don’t even need to manually import the database.
‘Failed to create .htaccess’ – followed installation; thoughts?
PHP does not have permission to create or write files on your server.
BINGO; thought had worked that out; thank you!!
Appreciate your responsiveness and this app!!
Helpful for others:
https://stackoverflow.com/a/49566838/3882558
Thank you so much for creating this!
Is there anyway to make this responsive for mobile devices?
Already is.
Hi, I installed in base path and can’t get past login screen. It seems to be dropping me at “(B4) USERS NOT LOGGED IN + INVALID PATH”
What do you think is the problem?
You have already guessed it. Probably invalid path. Just do some simple troubleshooting? See what the server is complaining.
public/common.js section C3
https://code-boxx.com/simple-javascript-debugging-troubleshooting/
how to change (section D2) to my own .htaccess .
thank you
No changes are required if you are deploying in the base path. If not, see “requirements & installation” above (did a small update).