<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
chdir('/home/dimark93/public_html/supercerebro');
require_once 'config.php';

// Check dm_clients columns
$cols = $pdo->query("DESCRIBE dm_clients")->fetchAll(PDO::FETCH_COLUMN);
echo "dm_clients columns: " . implode(", ", $cols) . "\n";

// Count clients
$cnt = $pdo->query("SELECT COUNT(*) FROM dm_clients")->fetchColumn();
echo "Total clients: $cnt\n";

// Check users with subscriptions
$rows = $pdo->query("SELECT u.id, u.email, s.plan, s.status, s.modules_chosen, s.max_clients FROM dm_users u LEFT JOIN dm_subscriptions s ON s.user_id=u.id WHERE u.role!='admin' LIMIT 5")->fetchAll();
foreach ($rows as $r) {
    echo "User {$r['id']}: {$r['email']} | plan={$r['plan']} status={$r['status']} mods={$r['modules_chosen']} max_cl={$r['max_clients']}\n";
}

// Check dm_user_clients
$links = $pdo->query("SELECT * FROM dm_user_clients LIMIT 10")->fetchAll();
echo "user_clients rows: " . count($links) . "\n";
