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

echo "Checking current SMS settings in the database...\n";

$settings_to_check = [
    'non_musking_enabled',
    'non_musking_username', 
    'non_musking_password',
    'sms_send_bank_transaction_notifications',
    'non_musking_templates_bank_transaction',
    'non_musking_templates_bank_transaction_rejection'
];

foreach ($settings_to_check as $setting_key) {
    $stmt = $pdo->prepare("SELECT setting_value FROM general_settings WHERE setting_key = ?");
    $stmt->execute([$setting_key]);
    $result = $stmt->fetch(PDO::FETCH_ASSOC);
    
    if ($result) {
        echo "$setting_key: " . substr($result['setting_value'], 0, 100) . (strlen($result['setting_value']) > 100 ? '...' : '') . "\n";
    } else {
        echo "$setting_key: NOT FOUND\n";
    }
}

echo "\nChecking if bank transaction notification function exists in verify_bank_transactions.php...\n";

$filePath = '../fees/verify_bank_transactions.php';
if (file_exists($filePath)) {
    $content = file_get_contents($filePath);
    
    // Look for SMS function calls
    if (strpos($content, 'non_musking_send_template') !== false) {
        echo "Found SMS function calls in verify_bank_transactions.php\n";
        
        // Show the relevant code sections
        $lines = explode("\n", $content);
        foreach ($lines as $index => $line) {
            if (strpos($line, 'non_musking_send_template') !== false) {
                echo "Line " . ($index + 1) . ": " . trim($line) . "\n";
                
                // Show surrounding context
                $start = max(0, $index - 3);
                $end = min(count($lines) - 1, $index + 3);
                for ($i = $start; $i <= $end; $i++) {
                    if ($i != $index) {
                        echo "  " . ($i + 1) . ": " . trim($lines[$i]) . "\n";
                    }
                }
                echo "\n";
            }
        }
    } else {
        echo "No SMS function calls found in verify_bank_transactions.php\n";
    }
} else {
    echo "File not found: $filePath\n";
}
?>