<?php
/**
 * Setup script to add bank transaction notification settings to the database
 */

require_once 'config/database.php';

try {
    // Enable non-musking SMS service
    $stmt = $pdo->prepare("INSERT INTO settings (setting_key, setting_value) VALUES (?, ?) ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value)");
    $stmt->execute(['non_musking_enabled', '1']);
    
    // Enable bank transaction notifications
    $stmt = $pdo->prepare("INSERT INTO settings (setting_key, setting_value) VALUES (?, ?) ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value)");
    $stmt->execute(['sms_send_bank_transaction_notifications', '1']);
    
    // Add default bank transaction template if it doesn't exist
    $stmt = $pdo->prepare("INSERT INTO settings (setting_key, setting_value) VALUES (?, ?) ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value)");
    $stmt->execute(['non_musking_tpl_bank_transaction', 'Dear {name}, your bank transaction of ৳{paid_amount} has been successfully verified. Your current due is ৳{due_amount}. Thank you.']);
    
    // Add default bank transaction rejection template
    $stmt = $pdo->prepare("INSERT INTO settings (setting_key, setting_value) VALUES (?, ?) ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value)");
    $stmt->execute(['non_musking_tpl_bank_transaction_rejection', 'Dear {name}, your bank transaction of ৳{amount} with ID {transaction_id} has been rejected. Reason: {notes}. Please contact administration.']);

    echo "Bank transaction SMS notification settings have been added/updated successfully!\n";
    echo "Features enabled:\n";
    echo "- Bank transaction verification notifications\n";
    echo "- Bank transaction rejection notifications\n";
    echo "\nYou can now verify bank transactions from https://zashof.com/fees/verify_bank_transactions.php\n";
    echo "and SMS notifications will be sent to students' phones.\n";

} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}