<?php
session_start();
require_once 'config/database.php';
require_once 'includes/site_settings.php';

// Get system name for branding
$system_name = get_system_name($pdo);
$system_name_en = get_system_name_en($pdo);

// Test setting a new system name
if (isset($_POST['test_branding'])) {
    set_setting($pdo, 'system_name', $_POST['system_name']);
    set_setting($pdo, 'system_name_en', $_POST['system_name_en']);
    
    // Refresh the values
    $system_name = get_system_name($pdo);
    $system_name_en = get_system_name_en($pdo);
    
    $message = "Branding updated successfully!";
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Branding Test - <?php echo htmlspecialchars($system_name); ?></title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
    <div class="container mt-5">
        <h1>Branding System Test</h1>
        
        <?php if (isset($message)): ?>
            <div class="alert alert-success"><?php echo $message; ?></div>
        <?php endif; ?>
        
        <div class="card">
            <div class="card-header">
                <h3>Current Branding Settings</h3>
            </div>
            <div class="card-body">
                <p><strong>System Name (BN):</strong> <?php echo htmlspecialchars($system_name); ?></p>
                <p><strong>System Name (EN):</strong> <?php echo htmlspecialchars($system_name_en); ?></p>
            </div>
        </div>
        
        <div class="card mt-4">
            <div class="card-header">
                <h3>Update Branding</h3>
            </div>
            <div class="card-body">
                <form method="POST">
                    <div class="mb-3">
                        <label for="system_name" class="form-label">System Name (Bangla)</label>
                        <input type="text" class="form-control" id="system_name" name="system_name" 
                               value="<?php echo htmlspecialchars($system_name); ?>">
                    </div>
                    <div class="mb-3">
                        <label for="system_name_en" class="form-label">System Name (English)</label>
                        <input type="text" class="form-control" id="system_name_en" name="system_name_en" 
                               value="<?php echo htmlspecialchars($system_name_en); ?>">
                    </div>
                    <button type="submit" name="test_branding" class="btn btn-primary">Update Branding</button>
                </form>
            </div>
        </div>
    </div>
</body>
</html>