<?php
/**
 * Installation Script - Phase 4
 * Creates contact_inquiries table for quotation/contact form submissions
 * Path: install-four.php
 */
require_once 'config.php';
header('Content-Type: text/html; charset=utf-8');

if (!$conn) {
    die("<div style='color:red;font-family:sans-serif;padding:20px;'><strong>ত্রুটি:</strong> ডাটাবেজ সংযোগ হয়নি।</div>");
}

$prefix = DB_PREFIX;
$messages = [];
$success = true;

$sql = "CREATE TABLE IF NOT EXISTS `{$prefix}contact_inquiries` (
    `id` INT AUTO_INCREMENT PRIMARY KEY,
    `name` VARCHAR(150) NOT NULL,
    `phone` VARCHAR(50) NOT NULL,
    `email` VARCHAR(150) NOT NULL,
    `service` VARCHAR(200) NULL,
    `message` TEXT NULL,
    `ip_address` VARCHAR(45) NULL,
    `is_read` TINYINT(1) NOT NULL DEFAULT 0,
    `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;";

if ($conn->query($sql) === TRUE) {
    $messages[] = "✓ টেবিল তৈরি: `{$prefix}contact_inquiries`";
} else {
    $messages[] = "✗ ত্রুটি: " . $conn->error;
    $success = false;
}
?>
<!DOCTYPE html>
<html lang="bn">
<head><meta charset="UTF-8"><title>Install Four</title>
<style>body{font-family:sans-serif;background:#0f172a;padding:40px;color:#cbd5e1}.box{max-width:500px;margin:0 auto;background:#1e293b;padding:30px;border-radius:12px;border:1px solid #334155}h2{color:#38bdf8}li{padding:8px;font-size:13px}.ok{color:#4ade80;font-weight:bold}</style>
</head>
<body><div class="box"><h2>Phase 4 — Contact Inquiries</h2><ul><?php foreach($messages as $m) echo "<li>".htmlspecialchars($m)."</li>"; ?></ul>
<?php if($success): ?><p class="ok">সফল! এখন admin/inquiries.php থেকে কোটেশন দেখতে পারবেন।</p><?php endif; ?>
</div></body></html>
