<div class="card">
    <div class="card-header">
        <div class="subheading1">Ung&uuml;ltige Rufnummern &ndash; Audit-Report</div>
        <hr class="mb-n3">
    </div>
    <div class="card-body">
        <div class="row mb-4">
            <div class="col-sm-3">
                <div class="card text-center">
                    <div class="card-body">
                        <h2 class="mb-0">{$tntIpCounts.total}</h2>
                        <small class="text-muted">insgesamt</small>
                    </div>
                </div>
            </div>
            <div class="col-sm-3">
                <div class="card text-center">
                    <div class="card-body">
                        <h2 class="mb-0">{$tntIpCounts.last7}</h2>
                        <small class="text-muted">letzte 7 Tage</small>
                    </div>
                </div>
            </div>
            <div class="col-sm-3">
                <div class="card">
                    <div class="card-body py-2">
                        <small class="text-muted d-block mb-1">nach Formular</small>
                        {foreach $tntIpCounts.byForm as $row}
                            <div class="d-flex justify-content-between">
                                <span>{$row->form}</span><strong>{$row->cnt}</strong>
                            </div>
                        {foreachelse}
                            <span class="text-muted">&ndash;</span>
                        {/foreach}
                    </div>
                </div>
            </div>
            <div class="col-sm-3">
                <div class="card">
                    <div class="card-body py-2">
                        <small class="text-muted d-block mb-1">nach Grund</small>
                        {foreach $tntIpCounts.byReason as $row}
                            <div class="d-flex justify-content-between">
                                <span>{$row->reason}</span><strong>{$row->cnt}</strong>
                            </div>
                        {foreachelse}
                            <span class="text-muted">&ndash;</span>
                        {/foreach}
                    </div>
                </div>
            </div>
        </div>
        <div class="d-flex justify-content-between align-items-center mb-2">
            <span class="text-muted">Letzte {$tntIpLimit} Eintr&auml;ge</span>
            <a class="btn btn-primary btn-sm" href="{$tntIpCsvURL}">
                <span class="fas fa-download"></span> CSV-Export (alle)
            </a>
        </div>
        <div class="table-responsive">
            <table class="table table-striped table-sm">
                <thead>
                <tr>
                    <th>#</th>
                    <th>Zeitpunkt</th>
                    <th>Formular</th>
                    <th>Feld</th>
                    <th>Eingabe</th>
                    <th>Land</th>
                    <th>Grund</th>
                </tr>
                </thead>
                <tbody>
                {foreach $tntIpRecent as $row}
                    <tr>
                        <td>{$row->id}</td>
                        <td>{$row->created_at}</td>
                        <td>{$row->form}</td>
                        <td>{$row->field}</td>
                        <td><code>{$row->raw_value|escape:'html'}</code></td>
                        <td>{$row->country_hint|escape:'html'}</td>
                        <td>{$row->reason}</td>
                    </tr>
                {foreachelse}
                    <tr>
                        <td colspan="7" class="text-center text-muted">Keine ung&uuml;ltigen Rufnummern protokolliert.</td>
                    </tr>
                {/foreach}
                </tbody>
            </table>
        </div>
    </div>
</div>

<div class="card mt-4">
    <div class="card-header">
        <div class="subheading1">Automatisch korrigierte Rufnummern &ndash; Normalisierung</div>
        <hr class="mb-n3">
    </div>
    <div class="card-body">
        <div class="row mb-4">
            <div class="col-sm-3">
                <div class="card text-center">
                    <div class="card-body">
                        <h2 class="mb-0">{$tntIpModifiedCounts.total}</h2>
                        <small class="text-muted">insgesamt</small>
                    </div>
                </div>
            </div>
            <div class="col-sm-3">
                <div class="card text-center">
                    <div class="card-body">
                        <h2 class="mb-0">{$tntIpModifiedCounts.last7}</h2>
                        <small class="text-muted">letzte 7 Tage</small>
                    </div>
                </div>
            </div>
            <div class="col-sm-3">
                <div class="card">
                    <div class="card-body py-2">
                        <small class="text-muted d-block mb-1">nach Formular</small>
                        {foreach $tntIpModifiedCounts.byForm as $row}
                            <div class="d-flex justify-content-between">
                                <span>{$row->form}</span><strong>{$row->cnt}</strong>
                            </div>
                        {foreachelse}
                            <span class="text-muted">&ndash;</span>
                        {/foreach}
                    </div>
                </div>
            </div>
        </div>
        <div class="d-flex justify-content-between align-items-center mb-2">
            <span class="text-muted">Letzte {$tntIpLimit} Eintr&auml;ge (Eingabe &rarr; gespeichert)</span>
            <a class="btn btn-primary btn-sm" href="{$tntIpModifiedCsvURL}">
                <span class="fas fa-download"></span> CSV-Export (alle)
            </a>
        </div>
        <div class="table-responsive">
            <table class="table table-striped table-sm">
                <thead>
                <tr>
                    <th>#</th>
                    <th>Zeitpunkt</th>
                    <th>Formular</th>
                    <th>Feld</th>
                    <th>Eingabe (vorher)</th>
                    <th></th>
                    <th>Gespeichert (nachher)</th>
                    <th>Land</th>
                </tr>
                </thead>
                <tbody>
                {foreach $tntIpModified as $row}
                    <tr>
                        <td>{$row->id}</td>
                        <td>{$row->created_at}</td>
                        <td>{$row->form}</td>
                        <td>{$row->field}</td>
                        <td><code>{$row->before_value|escape:'html'}</code></td>
                        <td class="text-muted">&rarr;</td>
                        <td><code>{$row->after_value|escape:'html'}</code></td>
                        <td>{$row->country_hint|escape:'html'}</td>
                    </tr>
                {foreachelse}
                    <tr>
                        <td colspan="8" class="text-center text-muted">Keine automatisch korrigierten Rufnummern protokolliert.</td>
                    </tr>
                {/foreach}
                </tbody>
            </table>
        </div>
    </div>
</div>
