<?php
define('ROOT_PATH', 'C:/xampp/htdocs/inveetaire');
require_once ROOT_PATH . '/app/core/Autoloader.php';
\App\Core\Autoloader::register();
require_once ROOT_PATH . '/app/helpers/env.php';
require_once ROOT_PATH . '/app/helpers/config.php';
$db = \App\Core\Database::getConnection();

echo "=== CREW USER CHECK ===\n";
$stmt = $db->prepare("SELECT id, username, email, role, workspace_id, status FROM users WHERE username='crew' OR role='crew' LIMIT 5");
$stmt->execute();
$rows = $stmt->fetchAll();
foreach ($rows as $r) {
    echo "  ID={$r['id']} user={$r['username']} role={$r['role']} ws_id={$r['workspace_id']} status={$r['status']}\n";
}
echo "Count: " . count($rows) . "\n";

echo "\n=== GUEST COUNT WS83 ===\n";
$stmt2 = $db->prepare("SELECT COUNT(*) as cnt FROM guests WHERE workspace_id=83");
$stmt2->execute();
echo "Guests: " . $stmt2->fetch()['cnt'] . "\n";

echo "\n=== SAMPLE GUEST CODES ===\n";
$stmt3 = $db->prepare("SELECT guest_code, guest_name, invited_pax FROM guests WHERE workspace_id=83 LIMIT 3");
$stmt3->execute();
foreach ($stmt3->fetchAll() as $g) {
    echo "  code={$g['guest_code']} name={$g['guest_name']} pax={$g['invited_pax']}\n";
}

echo "\n=== INVITATION STATUS ===\n";
$stmt4 = $db->prepare("SELECT id, invitation_status, groom_display_name, bride_display_name, theme_version_id FROM invitations WHERE workspace_id=83");
$stmt4->execute();
foreach ($stmt4->fetchAll() as $inv) {
    echo "  ID={$inv['id']} status={$inv['invitation_status']} groom={$inv['groom_display_name']} bride={$inv['bride_display_name']} theme={$inv['theme_version_id']}\n";
}
