<?php
header('Content-Type: text/html; charset=utf-8');

try {
    $pdo = new PDO(
        'mysql:host=localhost;dbname=munimor9_bdmoralestramite;charset=utf8mb4',
        'root',
        '',
        [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
    );

    echo "<h2>SP_REGISTRAR_TRAMITE_DERIVAR</h2>";
    echo "<style>
        body { font-family: monospace; background: #f5f5f5; padding: 20px; }
        pre { background: white; padding: 15px; border-left: 4px solid #4CAF50; overflow-x: auto; }
    </style>";

    $stmt = $pdo->prepare("SHOW CREATE PROCEDURE SP_REGISTRAR_TRAMITE_DERIVAR");
    $stmt->execute();
    $result = $stmt->fetch(PDO::FETCH_ASSOC);

    if ($result) {
        echo "<pre>" . htmlspecialchars($result['Create Procedure']) . "</pre>";
    }

} catch (PDOException $e) {
    echo "<pre style='background:#ffebee;'>❌ ERROR: " . $e->getMessage() . "</pre>";
}
?>
