<?php
define('SKIP_B24_CONFIG_CHECK', true);
require_once __DIR__ . '/settings.php';
require_once __DIR__ . '/tmobile_config.php';

// Small status page shown inside Bitrix24 as the app's default placement.
header('Content-Type: text/html; charset=utf-8');
?>
<!doctype html>
<html lang="pl">
<head>
    <meta charset="utf-8">
    <title>T-Mobile SMS</title>
    <style>
        body { font-family: -apple-system, sans-serif; padding: 24px; color: #333; }
        h1 { margin-top: 0; }
        code { background: #f3f3f3; padding: 2px 6px; border-radius: 4px; }
        .ok { color: #207f2a; }
        .warn { color: #b08000; }
    </style>
</head>
<body>
<h1>T-Mobile SMS — provider Bitrix24</h1>
<p>Aplikacja jest aktywna. SMS-y wysyłane z CRM/BPM trafiają do
   <b>T-Mobile Platforma Głosowa</b> (Messaging API v1.1).</p>

<h2>Status konfiguracji</h2>
<ul>
    <li>Provider code: <code><?= htmlspecialchars(B24_SENDER_CODE) ?></code></li>
    <li>Nadawca (CCN): <code><?= htmlspecialchars(TMOBILE_SENDER_CCN) ?></code></li>
    <li>Endpoint: <code><?= htmlspecialchars(TMOBILE_ENDPOINT) ?></code></li>
    <li>Polskie znaki: <code><?= TMOBILE_POLISH_CHARS ? 'tak' : 'nie' ?></code></li>
    <li>Validity period: <code><?= htmlspecialchars(TMOBILE_VALIDITY_PERIOD) ?></code></li>
    <li>Bitrix24 klient OAuth:
        <?php if (C_REST_CLIENT_ID !== ''): ?>
            <span class="ok">skonfigurowany</span>
        <?php else: ?>
            <span class="warn">BRAK — uzupełnij settings.php</span>
        <?php endif; ?>
    </li>
    <li>settings.json:
        <?= is_file(__DIR__ . '/settings.json') ? '<span class="ok">istnieje (aplikacja zainstalowana)</span>' : '<span class="warn">brak (wymaga instalacji)</span>' ?>
    </li>
</ul>

<p style="margin-top:32px; color:#888; font-size:12px;">
    Logi wysyłek: <code>logs/</code> · Baza mapowań: <code>storage/messages.db</code>
</p>
</body>
</html>
