- PHP 88.4%
- CSS 9.6%
- HTML 2%
|
All checks were successful
Deploy to Raspberry Pi / deploy (push) Successful in 1s
Signed-off-by: VitBojanovsky <vit.bojanovsky@outlook.cz> |
||
|---|---|---|
| .github/workflows | ||
| deploy | ||
| screenshots | ||
| web | ||
| .gitignore | ||
| DOKUMENTACE.md | ||
| ER-Diagram.png | ||
| README.md | ||
Dochazka pro firmu - Company Attendance System
The commits are broken because I was dealing with an ownership issue (they were committed with a different email and Git didn’t like it), so I reset the HEAD.
Project Structure
├── web/ # Web-accessible files
│ ├── scripts/ # PHP utility scripts
│ │ ├── config.php # Centralized database & config
│ │ ├── csrf.php # CSRF token handling
│ │ └── migrate_db.php # Database migration script
│ │
│ ├── styles.css # Unified stylesheet
│ ├── index.html # Home page
│ ├── zaznamenat.html # Redirect to zaznamenat.php
│ ├── login.html # Legacy login page
│ ├── admin-login.html # Redirect to login form
│ │
│ ├── zaznamenat.php # Attendance entry processing
│ ├── zobrazit.php # Attendance view with pagination
│ ├── admin-login-form.php # Admin login form (secure)
│ ├── admin-dashboard.php # Admin dashboard with tabs
│ ├── admin-login.php # Legacy redirect (backward compatibility)
│ ├── execute.php # Whitelisted SQL execution
│ └── logout.php # Secure logout
│
├── deploy/ # Deployment configuration
│ └── apache.conf # Apache web server configuration
│
├── .github/ # GitHub configuration
│ └── workflows/
│ └── deploy.yaml # CI/CD deployment pipeline (Raspberry Pi)
│
├── .env # Database configuration (copy of .env.example)
├── .gitignore # Git ignore rules
└── README.md # This file
Setup Instructions
1. Create .env File
Create a .env file in the project root (same level as the web/ folder):
DB_SERVERNAME=localhost
DB_USERNAME=root
DB_PASSWORD=yourpassword
DB_NAME=company_attendance
2. Web Server Configuration
- For this step you will need to have PHP installed
- Apache2 recommended
- Also MySQL needs to be installed as well
Point your web server's document root to the web/ directory.
PHP Development Server:
cd web
php -S localhost:8000
Then visit http://localhost:8000
Apache:
Create .htaccess in project root to rewrite to web folder, or point DocumentRoot directly to web folder.
3. Database Setup
Run the database migration script to create the required tables:
cd web/scripts
php migrate_db.php
This will create three tables:
employees- Employee managementattendance_logs- Attendance recordsadmin_accounts- Admin authentication
Note: The migration script will automatically migrate any existing data from the old testovaqi_table to the new attendance_logs table.
Database Migration
If upgrading from a previous version, run the migration script to restructure the database:
cd web/scripts
php migrate_db.php
This will:
- Create the new
employees,attendance_logs, andadmin_accountstables - Migrate existing attendance data to
attendance_logs - Create a default admin account (admin/admin123)
- Preserve all existing functionality
4. Web Server Configuration
Apache:
See deploy/apache.conf for the recommended Apache configuration. Point your DocumentRoot to the web/ directory.
Example .env
DB_SERVERNAME=localhost
DB_USERNAME=root
DB_PASSWORD=yourpassword
DB_NAME=company_attendance
Admin Access
- Click "Administrace" on home page
- Login with default credentials:
- Username:
admin - Password:
admin123
- Username:
- The admin dashboard provides three tabs:
- Employees: Manage employee records and hours worked
- Attendance Logs: View and edit attendance records
- Admin Accounts: Create and manage admin users
Note: Additional admin accounts can be created through the Admin Accounts tab in the dashboard.
Database Schema
employees
CREATE TABLE employees (
employee_id VARCHAR(50) PRIMARY KEY,
name VARCHAR(255) NOT NULL,
hours_worked DECIMAL(10,2) DEFAULT 0.00,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
attendance_logs
CREATE TABLE attendance_logs (
id INT AUTO_INCREMENT PRIMARY KEY,
employee_id VARCHAR(50) NOT NULL,
name VARCHAR(255) NOT NULL,
date DATE NOT NULL,
time_in TIME NOT NULL,
time_out TIME NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
INDEX idx_employee_date (employee_id, date),
INDEX idx_date (date)
);
admin_accounts
CREATE TABLE admin_accounts (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(100) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
last_login TIMESTAMP NULL
);
