<?php
require_once 'config/database.php';

header('Content-Type: text/plain; charset=UTF-8');

echo "SMS Settings in Database:\n";
echo "========================\n";

$stmt = $pdo->query("SELECT setting_key, setting_value FROM settings WHERE setting_key LIKE '%sms%' OR setting_key LIKE '%non_musking%' ORDER BY setting_key");
while($row = $stmt->fetch()) {
    echo $row['setting_key'] . ': ' . $row['setting_value'] . "\n";
}

echo "\nCurrent SMS Configuration:\n";
echo "=========================\n";
require_once 'includes/sms_helper.php';
$config = sms_config();
echo "Enabled: " . ($config['enabled'] ? 'Yes' : 'No') . "\n";
echo "Test Mode: " . ($config['test_mode'] ? 'Yes' : 'No') . "\n";
echo "Send to Guardian: " . ($config['send_to_guardian_also'] ? 'Yes' : 'No') . "\n";
echo "API URL: " . ($config['api_url'] ?? 'Not Set') . "\n";
echo "API Key: " . (!empty($config['api_key']) ? 'Set' : 'Not Set') . "\n";
echo "Sender ID: " . ($config['sender_id'] ?? 'Not Set') . "\n";

echo "\nNon-Musking Configuration:\n";
echo "==========================\n";
$non_musking_config = non_musking_config();
echo "Enabled: " . ($non_musking_config['enabled'] ? 'Yes' : 'No') . "\n";
echo "API URL: " . ($non_musking_config['api_url'] ?? 'Not Set') . "\n";
echo "API Key: " . (!empty($non_musking_config['api_key']) ? 'Set' : 'Not Set') . "\n";
echo "Sender ID: " . ($non_musking_config['sender_id'] ?? 'Not Set') . "\n";
echo "Method: " . ($non_musking_config['method'] ?? 'Not Set') . "\n";

echo "\nFee Payment Template Check:\n";
echo "===========================\n";
$fee_template = $config['templates']['fee_payment'] ?? 'Not Found';
echo "Fee Payment Template: " . $fee_template . "\n";

echo "\nFee Notification Setting:\n";
echo "=========================\n";
$stmt = $pdo->prepare("SELECT setting_value FROM settings WHERE setting_key = 'sms_send_fee_notifications'");
$stmt->execute();
$result = $stmt->fetch();
echo "Fee Notifications Enabled: " . ($result ? ($result['setting_value'] === '1' ? 'Yes' : 'No') : 'Not Set') . "\n";

?>