<?php
/**
 * Agregar plantilla hello_world que funciona
 */

require_once 'config/config.php';

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

try {
    $db = Database::getInstance();
    
    echo "=== AGREGAR PLANTILLA QUE FUNCIONA ===\n\n";
    
    // Agregar plantilla hello_world que sabemos que funciona
    $db->query(
        "INSERT INTO message_templates (template_name, language_code, status, body_text, created_at, updated_at) VALUES (?, ?, ?, ?, NOW(), NOW())",
        ['hello_world', 'en_US', 'approved', 'Hello World! This is a test message from WhatsApp Business API.']
    );
    
    echo "✅ Agregada plantilla 'hello_world' (en_US) - FUNCIONA CORRECTAMENTE\n\n";
    
    // Mostrar plantillas finales
    echo "📋 Plantillas en la base de datos:\n";
    $stmt = $db->query("SELECT id, template_name, language_code, status, body_text FROM message_templates ORDER BY template_name");
    $templates = $stmt->fetchAll();
    
    foreach ($templates as $template) {
        echo "• ID: {$template['id']}\n";
        echo "  Nombre: {$template['template_name']}\n";
        echo "  Idioma: {$template['language_code']}\n";
        echo "  Estado: {$template['status']}\n";
        echo "  Texto: {$template['body_text']}\n";
        echo "  -----\n";
    }
    
    echo "\n🎉 Ahora puedes enviar mensajes usando la plantilla 'hello_world'\n";
    
} catch (Exception $e) {
    echo "❌ Error: " . $e->getMessage() . "\n";
}
?>