<?php
require_once 'config.php';
require_once 'includes/Database.php';

$db = new Database();

echo "=== Test Kayıt Ekleme ===\n\n";

// gelen_arama_suresi için kayıt ekle
$criteriaCode = 'gelen_arama_suresi';
$pointValue = 0.35;
$startDate = '2025-03-01';
$endDate = '2025-04-30';
$notes = 'Test kaydı - Mart-Nisan 2025';

try {
    $db->query("
        INSERT INTO criteria_history (criteria_code, point_value, start_date, end_date, notes, created_by)
        VALUES (?, ?, ?, ?, ?, ?)
    ", [$criteriaCode, $pointValue, $startDate, $endDate, $notes, null]);

    echo "✓ Kayıt başarıyla eklendi\n\n";

    // Kontrol
    $check = $db->fetchAll("SELECT * FROM criteria_history WHERE criteria_code = ?", [$criteriaCode]);
    echo "Toplam kayıt: " . count($check) . "\n";
    foreach ($check as $r) {
        echo json_encode($r, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n";
    }
} catch (Exception $e) {
    echo "✗ Hata: " . $e->getMessage() . "\n";
}
