Creating Drivers Table..."; include 'config/config.php'; $query = "CREATE TABLE `tbl_driver` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `mobile_no` varchar(15) NOT NULL, `aadhar_card` varchar(500) DEFAULT NULL COMMENT 'Path to Aadhar card file', `licence` varchar(500) DEFAULT NULL COMMENT 'Path to driving licence file', `profile_photo` varchar(500) DEFAULT NULL COMMENT 'Path to profile photo file', `driver_experience` varchar(100) DEFAULT NULL COMMENT 'Years of driving experience', `vehicle_type` json DEFAULT NULL COMMENT 'Vehicle types as JSON array: [\"Automatic\", \"Manual\", \"Load Vehicle\"]', `status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0=active, 1=inactive', `created_at` timestamp NOT NULL DEFAULT current_timestamp(), `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `created_by` int(11) DEFAULT NULL, `updated_by` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `mobile_no` (`mobile_no`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;"; echo "

Executing CREATE TABLE query...

"; echo "" . htmlspecialchars($query) . ""; try { $stmt = $pdo->prepare($query); $stmt->execute(); echo "
✅ Table created successfully
"; // Add indexes $indexQueries = [ "ALTER TABLE `tbl_driver` ADD INDEX `idx_status` (`status`)", "ALTER TABLE `tbl_driver` ADD INDEX `idx_created_by` (`created_by`)" ]; echo "

Adding Indexes...

"; foreach ($indexQueries as $index => $indexQuery) { echo "

Executing index query " . ($index + 1) . "...

"; echo "" . htmlspecialchars($indexQuery) . ""; try { $stmt = $pdo->prepare($indexQuery); $stmt->execute(); echo "
✅ Index added successfully
"; } catch (PDOException $e) { $error = $e->getMessage(); echo "
⚠️ Index creation failed (might already exist): " . htmlspecialchars($error) . "
"; } echo "
"; } } catch (PDOException $e) { $error = $e->getMessage(); echo "
❌ Table creation failed: " . htmlspecialchars($error) . "
"; // Check if table already exists if (strpos($error, 'already exists') !== false) { echo "
The table might already exist. Checking current structure...
"; } } // Show final table structure echo "

Table Structure:

"; try { $stmt = $pdo->query("DESCRIBE `tbl_driver`"); $columns = $stmt->fetchAll(PDO::FETCH_ASSOC); echo ""; echo ""; foreach ($columns as $column) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
FieldTypeNullKeyDefaultExtra
" . $column['Field'] . "" . $column['Type'] . "" . $column['Null'] . "" . $column['Key'] . "" . ($column['Default'] ?? 'NULL') . "" . $column['Extra'] . "
"; } catch (PDOException $e) { echo "
Error getting table structure: " . $e->getMessage() . "
"; } echo "
"; echo "
"; echo "

✅ Drivers Table Setup Complete!

"; echo "

The tbl_driver table has been created with the following columns:

"; echo ""; echo "

You can now create driver management pages similar to the customer management system.

"; echo "
"; ?>