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

error_reporting(E_ALL);
ini_set('display_errors', 1);

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

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

?>
<!DOCTYPE html>
<html>
<head>
    <title>Check Products Table - TellerPro</title>
    <style>
        body { font-family: Arial, sans-serif; max-width: 800px; margin: 50px auto; padding: 20px; background: #f5f5f5; }
        .container { background: white; padding: 30px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
        h1 { color: #333; margin-top: 0; }
        .success { color: #16a34a; font-weight: bold; }
        .error { color: #dc2626; font-weight: bold; }
        .info { color: #2563eb; }
        pre { background: #f3f4f6; padding: 15px; border-radius: 4px; overflow-x: auto; margin: 10px 0; }
        .section { margin: 20px 0; padding: 15px; background: #f9fafb; border-radius: 4px; }
    </style>
</head>
<body>
    <div class="container">
        <h1>Check Products Table Structure</h1>
        
        <div class="section">
            <h3>Products Table Columns</h3>
            <?php
            try {
                $stmt = db()->prepare("DESCRIBE products");
                $stmt->execute();
                $columns = $stmt->fetchAll();
                
                echo '<p class="success">✓ Query successful</p>';
                echo '<p>Found ' . count($columns) . ' columns</p>';
                echo '<pre>';
                foreach ($columns as $col) {
                    echo htmlspecialchars($col['Field'] . ' - ' . $col['Type'] . ' - ' . $col['Null'] . ' - ' . $col['Default']) . "\n";
                }
                echo '</pre>';
            } catch (Exception $e) {
                echo '<p class="error">✗ Error: ' . htmlspecialchars($e->getMessage()) . '</p>';
                echo '<pre>' . htmlspecialchars($e->getTraceAsString()) . '</pre>';
            }
            ?>
        </div>
    </div>
</body>
</html>
