<?php
// Simple tatkal status API without complex data
ob_start();
ob_clean();

header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET');
header('Access-Control-Allow-Headers: Content-Type');

try {
    $pdo = new PDO("mysql:host=localhost;dbname=astro_db;charset=utf8", 'root', '');
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    
    // Get tatkal enabled status
    $stmt = $pdo->prepare("SELECT setting_value FROM settings WHERE setting_key = 'tatkal_enabled'");
    $stmt->execute();
    $enabled = $stmt->fetchColumn();
    
    // Get tatkal price
    $stmt = $pdo->prepare("SELECT setting_value FROM settings WHERE setting_key = 'tatkal_price'");
    $stmt->execute();
    $price = $stmt->fetchColumn();
    
    $response = [
        'success' => true,
        'tatkal_enabled' => $enabled ?: '0',
        'tatkal_price' => $price ?: '1500'
    ];
    
    echo json_encode($response);
    
} catch (Exception $e) {
    echo json_encode([
        'success' => false,
        'message' => $e->getMessage()
    ]);
}
?>
