79 lines
4.1 KiB
PHP
79 lines
4.1 KiB
PHP
<?php
|
|
require_once __DIR__ . '/config.php';
|
|
|
|
try {
|
|
$pdo = db();
|
|
echo "Connected to the database successfully.\n";
|
|
|
|
// Create tour_packages table
|
|
$pdo->exec("
|
|
CREATE TABLE IF NOT EXISTS `tour_packages` (
|
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
|
`name` VARCHAR(255) NOT NULL,
|
|
`description` TEXT,
|
|
`price` DECIMAL(10, 2),
|
|
`image_url` VARCHAR(255),
|
|
`category` ENUM('domestic', 'international') NOT NULL,
|
|
`location` VARCHAR(255),
|
|
`duration_days` INT
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
");
|
|
echo "Table 'tour_packages' created or already exists.\n";
|
|
|
|
// Create leads table
|
|
$pdo->exec("
|
|
CREATE TABLE IF NOT EXISTS `leads` (
|
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
|
`name` VARCHAR(255) NOT NULL,
|
|
`email` VARCHAR(255) NOT NULL,
|
|
`phone` VARCHAR(50),
|
|
`message` TEXT,
|
|
`tour_package_id` INT,
|
|
`status` ENUM('new', 'contacted', 'closed') DEFAULT 'new',
|
|
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (`tour_package_id`) REFERENCES `tour_packages`(`id`) ON DELETE SET NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
");
|
|
echo "Table 'leads' created or already exists.\n";
|
|
|
|
// Check if tour_packages is empty before inserting data
|
|
$stmt = $pdo->query("SELECT COUNT(*) FROM `tour_packages`");
|
|
if ($stmt->fetchColumn() == 0) {
|
|
echo "Table 'tour_packages' is empty. Inserting sample data...\n";
|
|
// Sample Data for Tour Packages
|
|
$packages = [
|
|
// Domestic
|
|
['Kashmir Paradise', 'Experience the heaven on earth.', 25000.00, 'assets/images/kashmir.jpg', 'domestic', 'Kashmir', 7],
|
|
['Uttarakhand Adventures', 'Explore the mountains and rivers.', 18000.00, 'assets/images/uttarakhand.jpg', 'domestic', 'Uttarakhand', 5],
|
|
['Kerala Backwaters', 'Relax in the serene backwaters.', 22000.00, 'assets/images/kerala.jpg', 'domestic', 'Kerala', 6],
|
|
['Goa Beach Fun', 'Enjoy the sun, sand, and sea.', 15000.00, 'assets/images/goa.jpg', 'domestic', 'Goa', 4],
|
|
['Manali Winter Magic', 'A snowy escape in the Himalayas.', 17000.00, 'assets/images/manali.jpg', 'domestic', 'Manali', 5],
|
|
['Spiritual Varanasi', 'A journey through ancient traditions.', 12000.00, 'assets/images/varanasi.jpg', 'domestic', 'Varanasi', 3],
|
|
['Ayodhya Ram Mandir Tour', 'Visit the historic city of Ayodhya.', 10000.00, 'assets/images/ayodhya.jpg', 'domestic', 'Ayodhya', 2],
|
|
// International
|
|
['Dubai Extravaganza', 'Experience the luxury of Dubai.', 55000.00, 'assets/images/dubai.jpg', 'international', 'Dubai', 5],
|
|
['Thailand Temples & Beaches', 'A mix of culture and relaxation.', 45000.00, 'assets/images/thailand.jpg', 'international', 'Thailand', 7],
|
|
['Classic United Kingdom', 'Explore London, Edinburgh and more.', 85000.00, 'assets/images/uk.jpg', 'international', 'United Kingdom', 10],
|
|
['Vietnam\'s Natural Wonders', 'From Halong Bay to Ho Chi Minh City.', 60000.00, 'assets/images/vietnam.jpg', 'international', 'Vietnam', 8],
|
|
['Bali Island Escape', 'Volcanoes, beaches, and temples.', 50000.00, 'assets/images/bali.jpg', 'international', 'Bali', 7],
|
|
['Maldives Overwater Bungalow', 'The ultimate romantic getaway.', 95000.00, 'assets/images/maldives.jpg', 'international', 'Maldives', 5],
|
|
];
|
|
|
|
$stmt = $pdo->prepare("
|
|
INSERT INTO `tour_packages` (name, description, price, image_url, category, location, duration_days)
|
|
VALUES (?, ?, ?, ?, ?, ?, ?)");
|
|
|
|
foreach ($packages as $package) {
|
|
$stmt->execute($package);
|
|
}
|
|
echo "Sample data inserted successfully.\n";
|
|
} else {
|
|
echo "Table 'tour_packages' already contains data. Skipping sample data insertion.\n";
|
|
}
|
|
|
|
echo "Database setup completed successfully!\n";
|
|
|
|
} catch (PDOException $e) {
|
|
die("Database setup failed: " . $e->getMessage() . "\n");
|
|
}
|
|
?>
|