<?php
/**
 * Check subscriptions table structure
 */

require_once __DIR__ . '/config/config.php';
require_once __DIR__ . '/config/database.php';

header('Content-Type: text/html; charset=utf-8');

echo '<!DOCTYPE html>
<html>
<head>
    <title>Table Structure Check</title>
    <style>
        body { font-family: Arial, sans-serif; padding: 20px; max-width: 800px; margin: 0 auto; }
        table { border-collapse: collapse; width: 100%; }
        th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
        th { background-color: #f2f2f2; }
    </style>
</head>
<body>
    <h1>Subscriptions Table Structure</h1>';

try {
    $stmt = db()->query("DESCRIBE subscriptions");
    $columns = $stmt->fetchAll();
    
    echo '<table>';
    echo '<tr><th>Field</th><th>Type</th><th>Null</th><th>Key</th><th>Default</th><th>Extra</th></tr>';
    
    foreach ($columns as $column) {
        echo '<tr>';
        echo '<td>' . htmlspecialchars($column['Field']) . '</td>';
        echo '<td>' . htmlspecialchars($column['Type']) . '</td>';
        echo '<td>' . htmlspecialchars($column['Null']) . '</td>';
        echo '<td>' . htmlspecialchars($column['Key']) . '</td>';
        echo '<td>' . htmlspecialchars($column['Default']) . '</td>';
        echo '<td>' . htmlspecialchars($column['Extra']) . '</td>';
        echo '</tr>';
    }
    
    echo '</table>';
    
    echo '<h2>Total Columns: ' . count($columns) . '</h2>';
    
} catch (Exception $e) {
    echo '<h2>Error</h2>';
    echo '<pre>' . htmlspecialchars($e->getMessage()) . '</pre>';
}

echo '</body>
</html>';
