Simple Stock Management Website made using pure PHP, HTML, CSS, and JS. Here are the key features:
- Login and Register account,
- User can buy chocolate,
- Superuser/Admin can create new chocolate and restock chocolate,
- Some functions updated using AJAX,
- Data are saved on MySQL databases,
- no framework library used, but I made my own, worked around MVC concept
Update Oct 19, 2020:
- deployed on http://jonathan.elseproperty.com/
Update Nov 17, 2020:
- Integrated with factory website.
- Add stock only sends deliver request to factory (wait factory approval).
- Add new chocolate need to submit recipe (ingredient list).
Use branch webonly to use older version.
- PHP (tested on 5.6+)
- Mysql (tested on 5.5.8)
- Python 3 (tested on 3.6+) - for populating sample image
- Your favorite browser
- Install Requirements (I used XAMPP to install all requirements)
- Clean (delete all files) inside PHP root document folder (i.e:
htdocson XAMPP) - Clone repo inside PHP root document folder (i.e:
htdocson XAMPP) - Open folder
application/config - Duplicate
config.example.ini, rename toconfig.ini - Adjust
config.iniif needed - Run PHP and MySQL (more info see next section)
- Restore database schema (more info see next section)
- Restore chocolate images (more info see next section)
- Run PHP and MySQL (again, I used XAMPP)
- If using XAMPP: press
Starton Apache(PHP) and MySQL
- If using XAMPP: press
- Open localhost:$PORT on browser (default url is http://localhost:80/)
- Open mysql on repo's root folder
mysql -u root -p
-
Enter mysql password (default is empty)
-
Create new database
CREATE DATABASE chocofac;
- Use database
USE chocofac;
- Execute queries
source chocofac20201009.sql
This will create:
- 200 users + 1 superuser
- 100 chocolates
- 2211 transactions
sample images is not all saved on repo, you can populate them by running this script:
python populate_uploads.py
htdocs
├───application
│ ├───config
│ ├───controllers
│ ├───models
│ └───views
├───framework
│ ├───core
│ └───database
├───mockup
├───public
│ ├───css
│ ├───html
│ │ ├───chocolate
│ │ ├───error
│ │ ├───home
│ │ ├───templates
│ │ └───user
│ ├───images
│ ├───js
│ └───uploads
├───screenshot
└───wwwroot
- application: contains MVC(models, views, controllers) and config folder
- framework: custom framework, based on MVC
- public/html: divided as per model
- public/images: sample images
- public/uploads: uploaded images goes here
- wwwroot: first redirect, sanitize url, runs framework
To register a new account
Valid example
Invalid example
Not unique example (username-email pair already taken)
Must login before entering website
Showing top 10 chocolates by amount sold
as viewed by normal user (difference on navbar)
as viewed by super user (difference on navbar)
using search bar on top
with pagination:
Click on a chocolate card to see detail
viewed as normal user (user can buy)
viewed as super user (user can add stock)
Click
Buy Nowon Chocolate Detail page (as normal user)
Click
Buyto buy, orCancelto cancel
prompt after succesful transaction
Click
Add Stockon Chocolate Detail page (as superuser)
Click
Addto add stock, orCancelto cancel
prompt after succesful add stock
Click
Historyon navigation bar (on top of the page) (as user)
with pagination
Click
Add New Chocoon navigation bar (on top of the page) (as superuser)
Click
Addto add new chocolate, orCancelto cancel
will redirect to that chocolate details page after succesful adding new choco
Cookie is not plain username-password pair anymore
using SHA-1 of salted username+password+secret
will check again on database, not only on frontend
before
after
utilising CSS Grid, mimicking Bootstrap Grid Layout (
rowclass)
already shown above
So the user know if it is successful
- Login: 13518084
- Register: 13518084
- Dashboard: 13518084
- Search Result: 13518084
- Chocolate Detail: 13518084
- Buy Chocolate: 13518084
- Add Stock Chocolate: 13518084
- Transaction History: 13518084
- Add New Chocolate: 13518084
- Bonus: 13518084
- Login: 13518084
- Register: 13518084
- Dashboard: 13518084
- Search Result: 13518084
- Chocolate Detail: 13518084
- Buy Chocolate: 13518084
- Add Stock Chocolate: 13518084
- Transaction History: 13518084
- Add New Chocolate: 13518084
- Bonus: 13518084
Basic PHP Knowledge
Creating Custom Framework
- MVC: https://www.codeproject.com/Articles/1080626/Code-Your-Own-PHP-MVC-Framework-in-Hour
- Templating: https://softwareengineering.stackexchange.com/questions/159529/how-to-structure-template-system-using-plain-php
Other PHP Knowledge
- Pagination: https://www.malasngoding.com/membuat-paging-dengan-php-dan-mysql/
- AJAX: https://www.w3schools.com/php/php_ajax_php.asp
Frontend Design
- Responsive Table: https://codepen.io/andornagy/pen/EVXpbR
- CSS Grid: https://speckyboy.com/replicate-bootstrap-grid-using-css-grid/
Jonathan Yudi Gunawan - 13518084
- superuser notified when stock empty




















