<?php
require 'vendor/autoload.php';

$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();

$pdo = new PDO(
    'mysql:host='.$_ENV['DB_HOST'].';dbname='.$_ENV['DB_DATABASE'],
    $_ENV['DB_USERNAME'],
    $_ENV['DB_PASSWORD']
);

echo "=== Subscription 37 Details ===\n";
$stmt = $pdo->query('SELECT id, user_id, status, current_period_start, current_period_end, expires_at, activated_at FROM subscriptions WHERE id = 37');
$sub = $stmt->fetch();
echo "ID: {$sub['id']}\n";
echo "User: {$sub['user_id']}\n";
echo "Status: {$sub['status']}\n";
echo "Current Period Start: {$sub['current_period_start']}\n";
echo "Current Period End: {$sub['current_period_end']}\n";
echo "Expires At: {$sub['expires_at']}\n";
echo "Activated: {$sub['activated_at']}\n\n";

echo "=== Invoices for Subscription 37 ===\n";
$stmt = $pdo->query('SELECT id, invoice_number, amount, status, paid_at, created_at FROM invoices WHERE subscription_id = 37 ORDER BY id DESC');
while ($inv = $stmt->fetch()) {
    echo "Invoice #{$inv['id']}: {$inv['invoice_number']} - \${$inv['amount']} - {$inv['status']} - Paid: {$inv['paid_at']} - Created: {$inv['created_at']}\n";
}
