Truck Checks is a web application designed to manage and monitor the inventory of truck lockers. It provides tools for administrators to maintain records, generate reports, and ensure compliance with inventory checks.
- Locker Item Management: Maintain and update the items stored in each truck locker.
- Inventory Checks: Perform and record checks of locker items to ensure inventory accuracy.
- User Management: Secure login and logout functionalities for administrators.
- Login Logging & Security: Comprehensive login attempt logging with IP geolocation, browser detection, and security monitoring.
- Reports: Generate and email reports on inventory checks.
- Demo Mode: A special mode that allows users to explore the system without affecting real data.
- QR Code Generation: Generate QR codes for easy identification of lockers.
- Database Management: Includes tools for maintaining database backups and cleaning tables.
- Interactive Quiz: Users can participate in a quiz where they guess the location of an item. The quiz tracks the number of attempts and calculates a total score based on the number of correct guesses.
- Changeover Management: Facilitate the transfer of equipment between trucks during shift changes or crew rotations, ensuring accountability and proper documentation of all transferred items.
- Audit Trail: Complete audit logging for data deletions with automatic triggers.
- PHP 7.x or higher
- MySQL or MariaDB
- Docker (optional, for containerized deployment)
-
Clone the repository:
git clone https://github.com/jtbnz/TruckChecks.git cd TruckChecks -
Set up the database:
- Import the provided SQL file to set up your database schema.
- Update
config.phpwith your database connection details.
-
Install dependencies: If you're using Docker, you can skip this step since dependencies will be handled by Docker. The main one you will need is qr-code to generate the qrcode image
composer2 require endroid/qr-code composer2 require tecnickcom/tcpdf composer2 require phpmailer/phpmailer
-
Configure local files:
-
db.php: update with your username,password,database name - This also has the demo toggle field
-
config.php: Configure Database Credentials Copy the config_sample.php file to config.php.
cp config_sample.php config.phpOpen config.php and set your database credentials, admin password, email settings and demo mode (unlikely!)
if (!defined('DB_HOST')) define('DB_HOST' , 'localhost'); if (!defined('DB_NAME')) define('DB_NAME' , 'your_database_name'); if (!defined('DB_USER')) define('DB_USER' , 'your_username'); if (!defined('DB_PASS')) define('DB_PASS' , 'your_password'); if (!defined('PASSWORD')) define('PASSWORD' , 'YourSecurePassword'); //Used for access to the Admin pages if (!defined('EMAIL_HOST')) define("EMAIL_HOST" ,"smtp host"); if (!defined('EMAIL_USER')) define('EMAIL_USER', 'email addess'); if (!defined('EMAIL_PASS')) define('EMAIL_PASS', 'email password'); if (!defined('EMAIL_PORT')) define('EMAIL_PORT' , 'SMTP outgoing port'); if (!defined('TZ_OFFSET')) define('TZ_OFFSET','+12:00'); //If you need to change timezones if (!defined('IS_DEMO')) define('IS_DEMO' , false); if (!defined('REFRESH')) define('REFRESH' , 30000); // 30000 = 30 seconds this is how often the main page will auto refresh if (!defined('RANDORDER')) define('RANDORDER', true); // Randomize the order of the locker items on the check page if (!defined('DEBUG')) define('DEBUG' , false); // Set to true to enable debugging // IP Geolocation API Key for ipgeolocation.io // Get your free API key from https://ipgeolocation.io/ // Leave empty to disable IP geolocation lookups if (!defined('IP_API_KEY')) define('IP_API_KEY', ''); // Your ipgeolocation.io API key define('IS_DEMO' , false);
-
Set up IP Geolocation (Optional): The application includes IP geolocation functionality to track login locations. This is optional but recommended for security monitoring.
-
Get a free API key:
- Visit ipgeolocation.io
- Sign up for a free account
- Navigate to your dashboard to get your API key
- Free accounts include 1,000 requests per month
-
Configure the API key: Add your API key to the
config.phpfile:if (!defined('IP_API_KEY')) define('IP_API_KEY', 'your_api_key_here');
-
Features when enabled:
- Login logs will include country and city information
- Enhanced security monitoring capabilities
- Geographic tracking of admin access
-
If not configured:
- Login logging will still work but without location data
- Local network IPs will be identified as "Local Network"
- External IPs will show empty location fields
-
-
Run the application:
- Point your web server to the
index.phpfile or use Docker to run the application.
- Point your web server to the
-
Login:
- Navigate to
login.phpto access the administrator panel.
- Navigate to
-
View Login Logs:
- Access
login_logs.phpfrom the admin panel to monitor login attempts. - Filter by success status, IP address, or date range.
- View detailed information including browser, OS, location, and timing.
- Access
-
Perform Checks:
- Use the
check_locker_items.phpto perform and log inventory checks.
- Use the
-
Generate Reports:
- Access
reports.phpto generate and email inventory reports.
- Access
-
Manage Changeovers:
- Use the changeover functionality to track and document equipment transfers between trucks.
- Record who performed the changeover, when it occurred, and which items were transferred.
- Generate changeover reports to maintain accountability.
-
Manage Data:
- Use various maintenance scripts (
maintain_lockers.php,maintain_trucks.php, etc.) to manage lockers, trucks, and items.
- Use various maintenance scripts (
- Login Logging: All login attempts (successful and failed) are logged with detailed information
- IP Geolocation: Track login locations using ipgeolocation.io API
- Browser Detection: Identify browser, operating system, and device type
- Audit Trail: Complete audit logging for data deletions with automatic database triggers
- Session Management: Secure session handling with configurable timeouts
- Access Control: Password-protected admin areas with proper authentication
This project supports Docker for easy deployment.
-
Build the Docker image:
docker-compose build
-
Run the container:
docker-compose up -d
-
Access the application:
- The application will be accessible at
http://localhost:8000by default.
- The application will be accessible at
- index.php: The main entry point of the application.
- login.php/logout.php: Handles user authentication with comprehensive logging.
- login_logs.php: Admin interface for viewing and filtering login attempts.
- admin.php: Admin panel for managing the application.
- db.php: Database connection settings.
- check_locker_items.php: Interface for performing locker checks.
- changeover.php: Manages the transfer of equipment between trucks.
- reports.php: Generate and email reports.
- qr-codes.php: Generate QR codes for lockers.
- Docker/: Contains Docker-related files for containerizing the application.
- styles/: CSS files for styling the application.
- templates/: HTML templates used throughout the application.
- scripts/: Local scripts used to email the checks automatically with timezone handling
- Config Sample File: Copy and configure the
config.phpfile fromconfig_sample.php. - quiz/: Quiz to locate the correct locker for an item
The application includes several key tables:
- login_log: Stores all login attempts with IP, browser, location, and timing data
- audit_log: Tracks all data deletions with complete row data in JSON format
- trucks, lockers, items, checks: Core inventory management tables
- swap tables: Handle equipment changeovers between trucks
waiting on next ideas!
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Make your changes.
- Commit your changes (
git commit -m 'Add feature'). - Push to the branch (
git push origin feature-branch). - Open a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Open Source Projects
- PHP Documentation
- Docker Documentation
- ipgeolocation.io - IP Geolocation API service