<?php
require_once __DIR__ . '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->safeLoad();

$pdo = new PDO(
    'mysql:host=' . getenv('DB_HOST') . ';dbname=' . getenv('DB_NAME'),
    getenv('DB_USER'),
    getenv('DB_PASS')
);

// Paket 4 ve 5 testlerini kontrol et
$stmt = $pdo->prepare('
  SELECT p.id, p.name, 
         GROUP_CONCAT(CONCAT(i.test_code, " - ", i.test_name) ORDER BY i.sort_order SEPARATOR ", ") as tests
  FROM test_packages p
  LEFT JOIN test_package_items i ON i.package_id = p.id
  WHERE p.id IN (4, 5)
  GROUP BY p.id
');
$stmt->execute();

echo "=== PAKETLERİN İÇERİĞİ ===\n\n";
foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $pkg) {
    echo "Paket ID: " . $pkg['id'] . "\n";
    echo "Paket Adı: " . $pkg['name'] . "\n";
    echo "Testler: " . $pkg['tests'] . "\n\n";
}

// Manuel testleri kontrol et
echo "\n=== MANUEL TESTLER ===\n\n";
$stmt = $pdo->prepare('
  SELECT DISTINCT code, name, category 
  FROM local_test_definitions 
  ORDER BY category, name
');
$stmt->execute();

foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $test) {
    echo $test['code'] . " - " . $test['name'] . " (" . $test['category'] . ")\n";
}
