Using a Raspberry Pi for your own inventory management system.
An open-source, inventory management system written in PHP with a MySQL database has no problem operating on a Raspberry Pi. Initially, you’ll only have local network access, but if you want to allow remote web access, you can.
In order to setup a web interface to access, view, and manage the content of your inventory management system you’ll need to set up a LAMP (Linux, Apache, MySQL, PHP) stack on your Raspberry Pi and configure it to work as a web server and set up a basic website which you can access on any device on the same network as your Pi. This is a link to a nice tutorial for setting-up a L.A.M.P. server on your Pi, the WordPress portion is optional, you can stop after installing PHP.
If you plan on having access to your Raspberry Pi through the Internet, you’ll need to configure your router and DDNS settings, or use a service such as dataplicity.io to wormhole to your pi through the web.
Install the Basic Inventory Management System Web Application
Included Features:
- User Management: Groups, Basic Profile, and Change Password
- Categories: For organizing products
- Products: Basic product information, title, quantity, pricing.
- Sales: Sales transactions are individual by product.
- Reports: Daily, Monthly, and Ranged Dates Sales/Profit Report
After updating the Raspberry Pi and setting up the LAMP stack, installation of the inventory application is relatively painless.
If you haven’t done so, use apt-get
to acquire and install the database software:
sudo apt-get install mariadb-server sudo apt-get install php-mysql
When the installation is complete, run a simple security script that comes pre-installed with MariaDB which will remove some insecure default settings and lock down access to your database system. Start the interactive script by running:
sudo mysql_secure_installation
Download the source-code package and then you’ll need to extract the contents to the folder. Either rename the folder to the base name now or after you move it to the web root for Apache Web Server found at /var/www/html/
example: sudo cp -R ~/Downloads/inventory-master /var/www/html/inventory
Use the MySQL/MariaDB command line to import the database schema.
Create a database named inventory and import the schema included in the project directory inventory.sql If you haven’t done so, installation is as easy as:
sudo mysql -uroot mysql> CREATE DATABASE inventory; mysql> USE inventory; mysql> source /var/www/html/inventory/inventory.sql mysql>CREATE USER 'webuser'@localhost IDENTIFIED BY 'p1r4sp';
mysql>GRANT ALL PRIVILEGES ON inventory.* TO 'webuser'@localhost; mysql> FLUSH PRIVILEGES;
Edit the /includes/config.php to match the username and password used to access your database.
The directory containing the project, especially, the uploads directory, must have write permissions on the system and let the web application be run using the www-data account by executing the following commands from the project directory:
sudo chmod -R 775 uploads/ sudo chown -R www-data:www-data *
Edit the header.php file lines #19 – #22 to suit the needs of your organization. e.g. change to logo
[project folder on server]/layouts/header.php
Same folder also contains the various menus used by the system.
Edit the CSS at line #85 and #102 to reflect the needs of your organization. e.g. background color
[project folder on server]/libs/css/main.css
Using the Inventory Management System
- Secure the default accounts with a change password.
- Create a user account for each person using the system, including yourself.
Optionally upload a photo for the user. - Add Categories – you’ll need to add at least one category before you can add products.
- Add Media before you Add Product if you want to associate a photo when you Add Product. Otherwise, you can elect to have no image and updated later.
- Add Order – before you try to Add Sales.
Improvements
These are the improvements I’ve added for my own system
- Delete confirmation popup before delete actions
- Description column for products
- Location column for products
- View products by category
- Add sales from list of products – remove selected from list.
- Add/Edit/Delete Sales also updates product’s quantity available
- Order Management for all sales – All sales must be associated with an order number
- View Sales by Order calculate total
- Delete Order: deletes all sales associated with order AND restores quantity/stock
- Add/Edit/Delete Order also updates product’s quantity available
- Stock: Inventory Management for all products – Log of increase/decrease stock
- Add/Edit/Delete Inventory also updates product’s quantity available
More Improvements
- Stock Report containing current status of inventory by category
- Currency Format Support allows for international currencies
- Add/Edit/Delete Customer Details for relationship management
- Search by Customer when adding new order
- Sales Invoice by order
- Inventory Stock Picklist by order
- Add Sales by Product SKU number
Hi there,
thanks to your post I found this little gem of inventory mangement. I see you have done a lot improovements. Are you willing to share your edits? Best Chris
LikeLike
https://github.com/bitsandbots/inventory
LikeLike
yes man! thank you very much
LikeLiked by 1 person
I verified the code this morning and updated a few minor bits.
LikeLike
I like this project a lot. I’m following it, as I’m looking for a good use for my RPi3.
Question – will this accept input from a barcode scanner? UPC/QR/ISBN/whatever?
LikeLiked by 2 people
Good feature request! If you have implementation suggestions please send me an email.
LikeLike
Good afternoon,
I am very interested in getting this up and running, however I am stuck at a WordPress landing page after I have completed all the steps. Is there a checklist of where to start in my trouble shooting and audit of my work?
It seems like I dont have any temlpates, but as I read through your guide it should have been included and defaulted in the files I downloaded.
Thanks for reading!
LikeLike
Hi Florian,
Thank you for taking the time to share the issue you are having, it’s likely other people have had the same experience. The WordPress installation has over written the default settings of the web server installation. If you try the URL to your inventory management system directory, for example: http://localhost/inventory/index.php and you are redirected to WordPress then you will want to check your apache web server settings found in the /etc/apache2/apache.conf
Let me know how it goes!
LikeLike
Thank you for taking your time to respond .
This is my first time but looking at the apache web server settings nothing seems to out of order . When try log in the site with localhost i get wordpress, if i try with ip adress//inventory/index.php i get a not found page .
If i go on http://localhost/inventory/index.php i get 404
Thank you !
LikeLike
Where did you install, and by install, I mean, to which directory did you extract the contents of the inventory management system source-code?
LikeLike
Mine is setup like this /var/www/html/warehouse-inventory-system , i kept the files in warehouse-inventory-system where they are .
Thank you
LikeLike
Hi Florian,
I’m happy to help as much as I can 🙂 Your URL should be http://localhost/warehouse-inventory-system/index.php
Double-check that the directory and file permissions are set correctly.
LikeLike
If i try to log in i get Database connection failed:Access denied for user ‘admin’@’localhost’ (using password: YES) where do i choose the default log in ? Should i just go and grand all permission to admin user ?
Thank you
LikeLike
Check your MySql databases configuration. The access is denied because the default password is set to yes for user admin. Does user admin exist, if so is the password in the conf file inside the inventory management system directory set to that password.
LikeLike
Ive got the same issure but cant find config file…
LikeLike
/inventory/includes/config.php
LikeLike
Great thanks, done that so i dont get the error anymore but get to a login screen and cant login
LikeLike
The default is “admin” for username and password. Or “user”, “special”
LikeLike
Hi, is the Add Sale page working or is it my config has some issues.
LikeLike
Hi Adrian, what error are you receiving?
LikeLike
Okay, check the GitHub
LikeLike
Hi, couple of things i need help with/ask about?:
– Is there a way to change currency to £?
– Is there anyway of changing it so prices could be say £1.30 as at the moment it only allows me to input whole numbers?
– When adding products to a sale is there a way as adding multiple items at once, as if i put in qty’s for severasl items then click add item on one of the items it only adds that one item even though ive put in quantities for several?
Either way this is a very nice inventory management tool 🙂
LikeLike
Thank you for your feedback. I’ve updated the cents for sales, but need to upload. I’ll see what I can do about changing the monetary system.
LikeLike
Saw you updated some of the files… went to re-downloaded and deleted current folder contents and replaced with new download. Changed config file to my database password and now getting “Error on this Query :
INSERT INTO log (user_id,remote_ip,action,date) VALUES (”,’::1′,’/’,’2019-11-21 21:51:03′)”… any ideas?
LikeLike
The log is optional. Make sure that you have a table “log” and permission to insert; or you can comment-out the source-code if you don’t want to log.
LikeLike
Stupid question but what source code? 😂
LikeLike
Fixed it but now can’t login… using admin admin?
LikeLike
Fixed that but now cant login.. using u-admin and p-admin
LikeLike
If you’ve changed the login password, it should still be the same. Otherwise, you’ll need to reload the credentials in the database.
LikeLike
I am very new to linux. I was able to install lamp & wordpress.
But, at the time of integrating database, I guess I made some kind of mistake.
LikeLike
Error – “Failed to Select Database”
LikeLike
Were you able to “Edit the /includes/config.php to match the username and password used to access your database.”?
LikeLike
Hi I am getting the same error. I was able to edit the coinfigs.php file with the username and password.
LikeLike
Thank you for letting me know! I think it might be this missing library:
sudo apt-get install php-mysql
LikeLike
So I was able to install that missing library. but I am still getting the same error “Failed to select database”.
https//:localhost takes me to the word press page but localhost/inventory/index.php produces the error.
Again, Any help is appreciated. And thanks for the tutorial!
LikeLike
“Failed to select database”
This error message means that the database being referenced DOES NOT exist.
Either it has not been created or the one being referenced is named differently than the one expected.
LikeLike
Hello thanks for a great database application. I am having some problems with the side bar menu not loading the appropriate menu items such as the admin menu. when logging in as admin the admin.php file loads up as it should but the header.php file is not loading the admin side bar.
LikeLike
Hey Jeff,
Thank you for posting your issue!
Maybe permissions?
sudo chmod -R 775 .
sudo chown -R www-data:www-data *
LikeLike
Thanks for the reply! I tried both commands and still no luck.
LikeLike
I have solved the issue. I had a logo image file that was sized “100 x 200” that caused an overlap of the header over the menus frame. Duh…. Thanks for the help really like the application.
LikeLike
Thanks for sharing the issue you had!
LikeLike
after login below error :
Error on this Query :
SHOW TABLES FROM projects_inventory_inventory-master LIKE “users”
LikeLike
The error message is telling you that the database: “projects_inventory_inventory-master” is invalid or doesn’t exist. Your database should be named “inventory”
LikeLike
Hi I tried installing the application locally & I ran into this error. Is there a way around it? I am able to login to the backend just fine.
“Notice: Undefined index: user_id in C:\xampp\htdocs\inventory-master\includes\load.php on line 24”
LikeLike
I commented-out the lines for you.
https://github.com/bitsandbots/inventory/blob/master/includes/load.php
LikeLike
The error still pops up sadly. However I’ve found that when I comment out this line. It no longer is there.
$user_id = $_SESSION[‘user_id’];
LikeLike
I’m glad you found a solution.
LikeLike
I followed all the steps but I am getting a blank page at http://localhost/inventory/index.php
Not sure what I did wrong?
LikeLike
check the log file: cat /var/log/apache2/error.log
LikeLike
It says…
PHP Fatal error: Call to undefined function mysqli_connect( ) in /var/www/html/inventory/includes/database.php on line 18
LikeLike
Make sure that you have installed the database connector:
sudo apt-get install php-mysql
and then make sure that you have setup the database:
Create a database named inventory and import the schema included in the project directory inventory.sql If you haven’t done so, installation is as easy as:
sudo mysql -uroot
mysql> CREATE DATABASE inventory;
mysql> USE inventory;
mysql> source /var/www/html/inventory/inventory.sql
mysql> CREATE USER ‘webuser’@localhost IDENTIFIED BY ‘p1r4sp’;
mysql> GRANT ALL PRIVILEGES ON inventory.* TO ‘webuser’@localhost;
mysql> FLUSH PRIVILEGES;
Edit the /includes/config.php to match the username and password used to access your database.
LikeLike
i’ve just made an arabic version of this system. and fixed some bugs.
LikeLike
Please share!
LikeLike
Really enjoyed doing this project works treat ! Thank you !
LikeLike
I cannot log in, because the view for login doesn’t display.
LikeLike
Are you not able to load the login page?
What happens when you try?
LikeLike
Hi, before I ask you one question I want to congrat you with the fabulous well done job.
I don´t know if this management system can be used in Windows, but I installed in Xampp and have changed the login and is working, but I am having a problem when add products in the section name it gives me this error, and also in the description and the SKU and location.
The error is Warning: Undefined variable $product in C:\xampp\htdocs\inventory-main\products\add_product.php on line 111Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\inventory-main\products\add_product.php on line 111
Can you say if this works in Xampp ?
Awaiting answer.
LikeLike
thanks for letting me know. I’ll remove that variable from the form for now.
LikeLike
Hi again, I have seen that you update a few minutes ago repairing my problem 😀 but if you try to add some product in the end it will give you this error
Fatal error: Uncaught ArgumentCountError: Too few arguments to function logAction(), 1 passed in C:\xampp\htdocs\inventory-main\products\add_product.php on line 62 and exactly 3 expected in C:\xampp\htdocs\inventory-main\includes\sql.php:307 Stack trace: #0 C:\xampp\htdocs\inventory-main\products\add_product.php(62): logAction(‘success’) #1 {main} thrown in C:\xampp\htdocs\inventory-main\includes\sql.php on line 307
But even with this error the product will be added successfully. Can you see what could it be causing the problem?
Awaiting answer .
Best regards 😉
LikeLike
thanks for letting me know, looks like I mixed up source from the newer version. probably why I shouldn’t be running more than one version 😉
LikeLike
You are awesome, fast response, thank you very very much 😉 I have been search a good management system for years and finally found it thanks to you 😉
The system is really awesome , very simple and intuitive.
Just for asking, will you do more improving on the management system?
Best regards.
LikeLiked by 1 person
Mostly security related upgrades:
https://github.com/bitsandbots/inventory/issues
LikeLike
Hello there!
I recently followed your guide here and set up a inventory system on a Raspberry Pi 3B for my company (despite being a beginner with Linux and servers), but there’s a couple things I was wondering:
1. How would I add barcode scanning capabilities to the system? What about using a phone camera to add pictures of products or scan codes?
2. Would it be possible to make the system order things when stock gets too low? For example, the company I work for does a lot of wiring and wifi access point installation, so we are constantly having to remember to buy more wire, APs, switches, etc. Could the ordering be automated?
Any reply is greatly appreciated,
Ollie
LikeLike
Hi. This is an awesome work that I’d like to try on a live hosting, but after editing “config.php” I just get this error: Database connection failed:Can’t connect to MySQL server on ‘mywebaddress.xx’. I’d appreciate any help or input about it.
LikeLike
Hello! I love everything about this inventory system. I have a question, though. I am running this database off a raspberry pi, wondering if there was a way to turn on an LED on a component shelf when the component is selected within the inventory management GUI using a conditional statement, and if so, how would this be possible? I really appreciate any help you can provide.
LikeLike