<?php
require_once 'auth.php';
requireAdminLogin();

require_once '../config/database.php';
$pdo = getDBConnection();

try {
    // Update tatkal_price in settings table
    $stmt = $pdo->prepare("INSERT INTO settings (setting_key, setting_value) VALUES (?, ?) ON DUPLICATE KEY UPDATE setting_value = ?");
    $stmt->execute(['tatkal_price', '1500', '1500']);
    
    // Update tatkal_booking consultation type price
    $stmt = $pdo->prepare("UPDATE consultation_types SET base_price = 1500.00, is_active = 1 WHERE type_code = 'tatkal_booking'");
    $stmt->execute();
    
    echo "✅ Tatkal price updated to ₹1500 in both settings and consultation_types tables!";
    
    // Verify the changes
    $stmt = $pdo->prepare("SELECT setting_value FROM settings WHERE setting_key = 'tatkal_price'");
    $stmt->execute();
    $settingsPrice = $stmt->fetchColumn();
    
    $stmt = $pdo->prepare("SELECT base_price FROM consultation_types WHERE type_code = 'tatkal_booking'");
    $stmt->execute();
    $consultationPrice = $stmt->fetchColumn();
    
    echo "<br><br>✅ Verification:";
    echo "<br>Settings table tatkal_price: ₹" . $settingsPrice;
    echo "<br>Consultation types tatkal_booking price: ₹" . $consultationPrice;
    
} catch (Exception $e) {
    echo "❌ Error: " . $e->getMessage();
}

echo "<br><br><a href='tatkal_management_panel.php'>← Back to Tatkal Management</a>";
?>
