Storage Boxx – Simple PHP Inventory Management System

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 How To Use Quick Reference
How To Develop Common Problems

 

 

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 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 your website 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

stock – The list of inventory items.
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.
stock_mvt – Stock movement history.
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.

  • I – Stock In (receive)
  • O – Stock Out (release)
  • T – Stock Take (audit)
user_id The user who made this movement entry.
mvt_qty Quantity moved.
mvt_notes Notes, if any.
users – The users.
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:

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

lib/LIB-Report.php
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)

api/API-report.php
// (A) MUST BE SIGNED IN
if ($_USER===false) {
  $_CORE->respond("E", "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 from http://site.com/report.
    • Take note – PAGE-report.php can only be accessed by users who are signed in.

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

recover.php
require "lib/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 URL_BASE in lib/GO.php.
  • Update the path in /.htaccess and /api/.htaccess if necessary.
  • Clear the browser cache to prevent irritating cache redirects.

 

MANUAL INSTALLATION

  • Create a database and import lib/storage-boxx.sql.
  • Rename lib/GO.foo to lib/GO.php.
  • Open lib/GO.php, update the settings to your own.
    • (A2) The host settings.
    • (A3) Database settings.
    • (A4) If you want to develop mobile apps, consider enabling CORS.
    • (A6) Generate your own secret key, set the issuer to your domain or company name.
  • You will need to manually create /.htaccess and /api/.htaccess. Open index.php – Check out (D7) and (D8).
  • Delete the installer script index.php… Or just move it somewhere else.
  • Rename index.foo to index.php.
  • Create your own admin user, see “forgot password” above.

 

NOT WORKING. DON’T KNOW WHY.

Open the developer’s console, reload the page and see the error message.

How To Debug Javascript – A Very Simple Guide

How to Debug PHP Code – A Very Simple Guide

 

14 thoughts on “Storage Boxx – Simple PHP Inventory Management System”

  1. 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,

  2. 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?

    1. 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.

      1. 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 !

  3. 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?

Leave a Comment

Your email address will not be published. Required fields are marked *