diff --git a/assets/css/custom.css b/assets/css/custom.css new file mode 100644 index 0000000..be27d0e --- /dev/null +++ b/assets/css/custom.css @@ -0,0 +1,69 @@ + +body { + font-family: 'Poppins', sans-serif; + background-color: #ecf0f1; + color: #2c3e50; +} + +.sidebar { + position: fixed; + top: 0; + left: 0; + height: 100%; + width: 250px; + background-color: #ffffff; + padding: 20px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); +} + +.sidebar .logo { + text-align: center; + margin-bottom: 30px; +} + +.sidebar .nav-link { + color: #2c3e50; + padding: 10px 15px; + margin: 5px 0; + border-radius: 8px; + transition: all 0.3s ease; +} + +.sidebar .nav-link:hover, +.sidebar .nav-link.active { + background-color: #3498db; + color: #ffffff; +} + +.main-content { + margin-left: 250px; + padding: 20px; +} + +.header { + display: flex; + justify-content: flex-end; + align-items: center; + background-color: #ffffff; + padding: 10px 20px; + border-radius: 8px; + margin-bottom: 20px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); +} + +.header .user-profile { + display: flex; + align-items: center; +} + +.header .user-profile img { + border-radius: 50%; + margin-right: 10px; +} + +.card { + background-color: #ffffff; + border: none; + border-radius: 8px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.05); +} diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..e69de29 diff --git a/db/migrate.php b/db/migrate.php new file mode 100644 index 0000000..be44dd1 --- /dev/null +++ b/db/migrate.php @@ -0,0 +1,44 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $migrationsDir = __DIR__ . '/migrations'; + + if (!is_dir($migrationsDir)) { + mkdir($migrationsDir, 0775, true); + echo "Created migrations directory.\n"; + } + + $files = glob($migrationsDir . '/*.sql'); + + if (empty($files)) { + echo "No migration files found.\n"; + exit; + } + + sort($files); + + foreach ($files as $file) { + $sql = file_get_contents($file); + if ($sql) { + $pdo->exec($sql); + echo "Executed migration: " . basename($file) . "\n"; + } + } + + echo "All migrations executed successfully.\n"; + +} catch (PDOException $e) { + // Use error_log for server-side logging instead of exposing details to the browser + error_log("Migration failed: " . $e->getMessage()); + // Provide a generic error to the user + http_response_code(500); + die("Database migration failed. Check server logs for details."); +} + diff --git a/db/migrations/001_create_vehicles_table.sql b/db/migrations/001_create_vehicles_table.sql new file mode 100644 index 0000000..f32139a --- /dev/null +++ b/db/migrations/001_create_vehicles_table.sql @@ -0,0 +1,12 @@ +CREATE TABLE IF NOT EXISTS `vehicles` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `make` VARCHAR(255) NOT NULL, + `model` VARCHAR(255) NOT NULL, + `year` INT NOT NULL, + `license_plate` VARCHAR(50) NOT NULL UNIQUE, + `vin` VARCHAR(100) NOT NULL UNIQUE, + `status` VARCHAR(50) DEFAULT 'active', + `driver_id` INT NULL, + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/db/migrations/002_create_drivers_table.sql b/db/migrations/002_create_drivers_table.sql new file mode 100644 index 0000000..ca45227 --- /dev/null +++ b/db/migrations/002_create_drivers_table.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS drivers ( + id INT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(255) NOT NULL, + license_number VARCHAR(255) NOT NULL, + phone_number VARCHAR(50), + email VARCHAR(255), + status VARCHAR(50) DEFAULT 'active', + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); diff --git a/db/migrations/003_create_expenses_table.sql b/db/migrations/003_create_expenses_table.sql new file mode 100644 index 0000000..0cc092a --- /dev/null +++ b/db/migrations/003_create_expenses_table.sql @@ -0,0 +1,12 @@ +CREATE TABLE IF NOT EXISTS expenses ( + id INT AUTO_INCREMENT PRIMARY KEY, + driver_id INT, + vehicle_id INT, + expense_date DATE NOT NULL, + category VARCHAR(255) NOT NULL, + amount DECIMAL(10, 2) NOT NULL, + description TEXT, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (driver_id) REFERENCES drivers(id) ON DELETE SET NULL, + FOREIGN KEY (vehicle_id) REFERENCES vehicles(id) ON DELETE SET NULL +); diff --git a/db/migrations/004_create_routes_table.sql b/db/migrations/004_create_routes_table.sql new file mode 100644 index 0000000..bc5680b --- /dev/null +++ b/db/migrations/004_create_routes_table.sql @@ -0,0 +1,14 @@ +CREATE TABLE IF NOT EXISTS routes ( + id INT AUTO_INCREMENT PRIMARY KEY, + origin VARCHAR(255) NOT NULL, + destination VARCHAR(255) NOT NULL, + distance DECIMAL(10, 2), + status VARCHAR(50) DEFAULT 'planned', + departure_time TIMESTAMP NULL, + arrival_time TIMESTAMP NULL, + driver_id INT, + vehicle_id INT, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (driver_id) REFERENCES drivers(id) ON DELETE SET NULL, + FOREIGN KEY (vehicle_id) REFERENCES vehicles(id) ON DELETE SET NULL +); diff --git a/db/setup.php b/db/setup.php new file mode 100644 index 0000000..c582b1a --- /dev/null +++ b/db/setup.php @@ -0,0 +1,21 @@ + PDO::ERRMODE_EXCEPTION, + ]); + + // Create the database if it doesn't exist + $pdo->exec("CREATE DATABASE IF NOT EXISTS `".DB_NAME."`"); + echo "Database '".DB_NAME."' created or already exists.\n"; + +} catch (PDOException $e) { + die("Database setup failed: " . $e->getMessage()); +} + diff --git a/drivers.php b/drivers.php new file mode 100644 index 0000000..7e38f59 --- /dev/null +++ b/drivers.php @@ -0,0 +1,132 @@ +prepare( + 'INSERT INTO drivers (name, license_number, phone_number, email, status) VALUES (?, ?, ?, ?, ?)' + ); + $stmt->execute([$name, $license_number, $phone_number, $email, $status]); + $message = '