How To Make An Awesome Inventory Management Application in PHP and MySQL
How To Make An Awesome Inventory Management Application in PHP and MySQL
Menu
by Richard
System Requirements
Our Inventory System requires the standard commercial phpGrid and
phpChart license. It needs a few advanced features from both
components.
MySQL / MariaDB
Incoming shipments
Outgoing orders
Inventory
Suppliers
https://www.freecodecamp.org/news/making-an-awesome-inventory-management-application-in-php-and-mysql-from-start-to-finish-90bc5996680a/ 2/21
11/9/2019 How to Make an Awesome Inventory Management Application in PHP and MySQL
Menu
Inventory System Database Design
Typically, an inventory system has four basic elements: products,
purchases, orders, and suppliers. Each element must be tracked based
on its location, SKU, and quantity. Current inventory, or products on
hand, is updated by tracking incoming shipments and outgoing orders.
Order alerts can be set to trigger when inventory levels fall below
custom-defined minimum levels.
https://www.freecodecamp.org/news/making-an-awesome-inventory-management-application-in-php-and-mysql-from-start-to-finish-90bc5996680a/ 3/21
11/9/2019 How to Make an Awesome Inventory Management Application in PHP and MySQL
Set up phpGrid
Let’s move on.
Current Inventory
Incoming Purchases
Orders to Ship
Reports
https://www.freecodecamp.org/news/making-an-awesome-inventory-management-application-in-php-and-mysql-from-start-to-finish-90bc5996680a/ 4/21
11/9/2019 How to Make an Awesome Inventory Management Application in PHP and MySQL
Menu
Menus
The include file for the menu is stored in an inc folder named menu.p
hp . The code for the menu is straightforward. For the sake of focus,
we will not go into great detail. Feel free to look at the code inside the
inc folder.
Pages
https://www.freecodecamp.org/news/making-an-awesome-inventory-management-application-in-php-and-mysql-from-start-to-finish-90bc5996680a/ 5/21
11/9/2019 How to Make an Awesome Inventory Management Application in PHP and MySQL
We will use the same page template we used for the CRM and Project Menu
Management tutorials.
Current Inventory
https://www.freecodecamp.org/news/making-an-awesome-inventory-management-application-in-php-and-mysql-from-start-to-finish-90bc5996680a/ 6/21
11/9/2019 How to Make an Awesome Inventory Management Application in PHP and MySQL
If you have read the last tutorial Building a Donation Manager from
Scratch, you will have no problem following the code below.
That’s it for the Current Inventory datagrid. Here’s what it looks like
so far:
The above code adds a display condition so that whenever the Invent
https://www.freecodecamp.org/news/making-an-awesome-inventory-management-application-in-php-and-mysql-from-start-to-finish-90bc5996680a/ 7/21
11/9/2019 How to Make an Awesome Inventory Management Application in PHP and MySQL
oryOnHand field has a value that is less than ( lt ) one, the text color Menu
changes to red and the background color to dark gray ( #DCDCDC ).
The code below uses a for loop to iterate through each row in the
Products datagrid. It compares the inventoryOnHand with the minimu
mRequired and, when the condition is met, it will use the setCell
function to change the background color.
You can learn more about comparing multiple cell values on the
phpGrid support website.
Finally, our complete code to manage the Current Inventory page is:
https://www.freecodecamp.org/news/making-an-awesome-inventory-management-application-in-php-and-mysql-from-start-to-finish-90bc5996680a/ 8/21
11/9/2019 How to Make an Awesome Inventory Management Application in PHP and MySQL
Menu
Incoming Purchases
https://www.freecodecamp.org/news/making-an-awesome-inventory-management-application-in-php-and-mysql-from-start-to-finish-90bc5996680a/ 9/21
11/9/2019 How to Make an Awesome Inventory Management Application in PHP and MySQL
Outgoing Orders
https://www.freecodecamp.org/news/making-an-awesome-inventory-management-application-in-php-and-mysql-from-start-to-finish-90bc5996680a/ 10/21
11/9/2019 How to Make an Awesome Inventory Management Application in PHP and MySQL
Menu
The next page is the Outgoing Orders page. It is similar to the Orders
Detail Grid from the Current Inventory page. Here, we will introduce
an advanced function called set_grid_method().
Summary
This tutorial builds a simple and extendable inventory system in less
than 50 lines of code. The progressive style of these tutorials also
helps the reader to ultimately become more familar and comfortable
with phpGrid by introducing a limited number of new phpGrid
features in each one.
What’s Coming Up
This marks the end of the code needed to create the datagrids
required for this tutorial. However, we are not done yet. There is still
one more page we need to create — Reports. We will cover that after
the jump.
Here’s what our page will look like when it’s done:
https://www.freecodecamp.org/news/making-an-awesome-inventory-management-application-in-php-and-mysql-from-start-to-finish-90bc5996680a/ 11/21
11/9/2019 How to Make an Awesome Inventory Management Application in PHP and MySQL
Menu
Setup phpChart
It’s important that we keep phpGrid and phpChart in separate folders.
Below is the recommended folder hierarchy.
Report Design
We will place a pie chart next to an inventory summary grid. The
datagrid provides the series data to plot the pie chart.
https://www.freecodecamp.org/news/making-an-awesome-inventory-management-application-in-php-and-mysql-from-start-to-finish-90bc5996680a/ 12/21
11/9/2019 How to Make an Awesome Inventory Management Application in PHP and MySQL
Menu
require_once("phpGrid/conf.php"); require_once("phpChart/conf.php")
Pie Chart
Below is the complete code to create our pie chart:
https://www.freecodecamp.org/news/making-an-awesome-inventory-management-application-in-php-and-mysql-from-start-to-finish-90bc5996680a/ 13/21
11/9/2019 How to Make an Awesome Inventory Management Application in PHP and MySQL
when it is first initialized. The data is fed from the datagrid later in Menu
JSON.
We also give our chart a unique name, PieChart .
Once we have the title, we call the series default function to set the re
nderer to PieRenderer . Unlike a bar chart, a pie chart does not have a
Y axis.
However, if you execute the code now, you will not see the chart
because the data used to render it isn’t available yet.
Since we must wait for the datagrid to finish loading before it can send
the data to plot the chart, we use the event jqGridLoadComplete .
Now there you have it. Your just built your very first inventory
management system from scratch using PHP and MySQL!
Thank you for reading! If you enjoyed this post, please give me some
claps so more people see it.
https://www.freecodecamp.org/news/making-an-awesome-inventory-management-application-in-php-and-mysql-from-start-to-finish-90bc5996680a/ 15/21
11/9/2019 How to Make an Awesome Inventory Management Application in PHP and MySQL
Incoming Purchases
Outgoing orders
https://www.freecodecamp.org/news/making-an-awesome-inventory-management-application-in-php-and-mysql-from-start-to-finish-90bc5996680a/ 16/21
11/9/2019 How to Make an Awesome Inventory Management Application in PHP and MySQL
How to fix:
If you are using the free Lite version, you can either comment out the
first line
// use phpGrid\C_DataGrid;
— OR —
Web Development
The Future of the freeCodeCamp Forum
https://www.freecodecamp.org/news/making-an-awesome-inventory-management-application-in-php-and-mysql-from-start-to-finish-90bc5996680a/ 18/21
11/9/2019 How to Make an Awesome Inventory Management Application in PHP and MySQL
Menu
See all 1552 posts →
#JAVASCRIPT
#TECH
How ACG brought an award-winning tech podcast to life on Alexa, and what
we learned along the way
https://www.freecodecamp.org/news/making-an-awesome-inventory-management-application-in-php-and-mysql-from-start-to-finish-90bc5996680a/ 19/21
11/9/2019 How to Make an Awesome Inventory Management Application in PHP and MySQL
DREW FIRMENT 2 YEARS AGO
Menu
Our mission: to help people learn to code for free. We accomplish this by creating thousands of videos,
articles, and interactive coding lessons - all freely available to the public. We also have thousands of
Donations to freeCodeCamp go toward our education initiatives, and help pay for servers, services, and
staff.
https://www.freecodecamp.org/news/making-an-awesome-inventory-management-application-in-php-and-mysql-from-start-to-finish-90bc5996680a/ 21/21