OpenNIT

Quelltext des aktuellen Standes

Fassung 1.1.1

confirmations.php

9 KB
<?php $this->layout('layouts/admin', [
    'page_title'         => 'Geräte-Bestätigungen',
    'current_admin_page' => 'portal',
    'extra_css'          => ['/assets/css/portal-admin.css'],
]);
$filterTabs = [
    'all'       => 'Alle',
    'open'      => 'Offen',
    'confirmed' => 'Bestätigt',
    'missing'   => 'Nicht mehr vorhanden',
];
?>

<div class="settings-page pa-page">

    <nav class="settings-tabs">
        <a class="settings-tab" href="/admin/portal">
            <span class="settings-tab-icon"><i class="fas fa-sliders-h"></i></span> <?= $this->te('Einstellungen') ?>
        </a>
        <a class="settings-tab" href="/admin/portal/kennzahlen">
            <span class="settings-tab-icon"><i class="fas fa-chart-line"></i></span> <?= $this->te('Kennzahlen') ?>
        </a>
        <a class="settings-tab active" href="/admin/portal/confirmations">
            <span class="settings-tab-icon"><i class="fas fa-clipboard-check"></i></span> <?= $this->te('Geräte-Bestätigungen') ?>
        </a>
    </nav>

    <section class="settings-card">
        <div class="settings-card-header">
            <span class="settings-card-icon">&#128203;</span>
            <div>
                <h2><?= $this->te('Rückläufer der laufenden Runde') ?></h2>
                <p class="settings-card-desc"><?= $this->t('Stand der Geräte-Selbstbestätigung im Self-Service-Portal. Als aktuell gilt jede Rückmeldung seit dem {datum}.', ['datum' => date('d.m.Y', strtotime((string)$due_since))]) ?></p>
            </div>
        </div>
        <div class="settings-card-body">
            <?php if (empty($enabled)): ?>
            <p class="pa-note pa-note--warn">
                <i class="fas fa-exclamation-triangle"></i>
                <?= $this->te('Die Geräte-Selbstbestätigung ist derzeit deaktiviert – im Portal erscheint keine Rückfrage.') ?>
                <a href="/admin/portal"><?= $this->te('Zu den Portal-Einstellungen') ?></a>
            </p>
            <?php endif; ?>

            <div class="kpi-row">
                <div class="kpi-col">
                    <div class="small-box bg-info">
                        <div class="inner">
                            <h3><?= (int)($stats['total'] ?? 0) ?></h3>
                            <p><?= $this->te('Zugewiesene Geräte') ?></p>
                        </div>
                        <div class="icon"><i class="fas fa-laptop"></i></div>
                    </div>
                </div>
                <div class="kpi-col">
                    <div class="small-box bg-success">
                        <div class="inner">
                            <h3><?= (int)($stats['confirmed'] ?? 0) ?></h3>
                            <p><?= $this->te('Bestätigt') ?></p>
                        </div>
                        <div class="icon"><i class="fas fa-clipboard-check"></i></div>
                    </div>
                </div>
                <div class="kpi-col">
                    <div class="small-box bg-warning">
                        <div class="inner">
                            <h3><?= (int)($stats['open'] ?? 0) ?></h3>
                            <p><?= $this->te('Offen') ?></p>
                        </div>
                        <div class="icon"><i class="fas fa-hourglass-half"></i></div>
                    </div>
                </div>
                <div class="kpi-col">
                    <div class="small-box bg-danger">
                        <div class="inner">
                            <h3><?= (int)($stats['missing'] ?? 0) ?></h3>
                            <p><?= $this->te('Nicht mehr vorhanden') ?></p>
                        </div>
                        <div class="icon"><i class="fas fa-flag"></i></div>
                    </div>
                </div>
            </div>

            <div class="pa-stats">
                <span class="pa-stat"><?= $this->te('Intervall') ?> <strong><?= $this->te('{anzahl} Monate', ['anzahl' => (int)$interval]) ?></strong></span>
                <?php if (!empty($round_start)): ?>
                <span class="pa-stat"><?= $this->te('Runde gestartet am') ?> <strong><?= $this->e(date('d.m.Y', strtotime((string)$round_start))) ?></strong></span>
                <?php endif; ?>
            </div>

            <div class="pa-form-actions pa-round-actions">
                <form method="post" action="/admin/portal/confirmations/remind">
                    <input type="hidden" name="_csrf" value="<?= $this->e($this->csrf()) ?>">
                    <button type="submit" class="btn btn-default btn-sm"><i class="fas fa-envelope"></i> <?= $this->te('Erinnerung jetzt senden') ?></button>
                </form>
                <form method="post" action="/admin/portal/confirmations/round"
                      onsubmit="return confirm('Neue Bestätigungsrunde starten? Alle zugewiesenen Geräte gelten danach wieder als offen.');">
                    <input type="hidden" name="_csrf" value="<?= $this->e($this->csrf()) ?>">
                    <button type="submit" class="btn btn-primary btn-sm"><i class="fas fa-redo"></i> <?= $this->te('Neue Runde starten') ?></button>
                </form>
            </div>
        </div>
    </section>

    <section class="settings-card">
        <div class="settings-card-header">
            <span class="settings-card-icon">&#128209;</span>
            <div>
                <h2><?= $this->te('Geräte und Rückmeldungen') ?></h2>
                <p class="settings-card-desc"><?= $this->te('Alle zugewiesenen Geräte mit ihrem Stand in der laufenden Runde.') ?></p>
            </div>
        </div>
        <div class="settings-card-body">
            <div class="subnav pa-filter-tabs">
                <?php foreach ($filterTabs as $key => $label): ?>
                <a class="subnav-tab <?= $filter === $key ? 'active' : '' ?>"
                   href="/admin/portal/confirmations?filter=<?= $this->e($key) ?>"><?= $this->e($label) ?></a>
                <?php endforeach; ?>
            </div>

            <?php if (empty($rows)): ?>
            <div class="empty-state">
                <i class="fas fa-clipboard-check"></i>
                <p><?= $this->te('Keine Einträge für diese Auswahl.') ?></p>
            </div>
            <?php else: ?>
            <div class="table-wrapper">
                <table class="data-table">
                    <thead>
                        <tr>
                            <th scope="col"><?= $this->te('Person') ?></th>
                            <th scope="col"><?= $this->te('Gerät') ?></th>
                            <th scope="col"><?= $this->te('Stand') ?></th>
                            <th scope="col"><?= $this->te('Rückmeldung') ?></th>
                            <th scope="col"><?= $this->te('Anmerkung') ?></th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php foreach ($rows as $r): ?>
                        <tr>
                            <td>
                                <strong><?= $this->e($r['display_name']) ?></strong>
                                <?php if (!empty($r['email'])): ?><br><span class="text-muted"><?= $this->e($r['email']) ?></span><?php endif; ?>
                            </td>
                            <td>
                                <a class="table-link" href="/assets/<?= (int)$r['asset_id'] ?>"><?= $this->e($r['inventory_number']) ?></a>
                                <?php if (!empty($r['asset_name'])): ?><br><span class="text-muted"><?= $this->e($r['asset_name']) ?></span><?php endif; ?>
                            </td>
                            <td>
                                <?php if ($r['result'] === 'confirmed'): ?>
                                    <span class="status-pill status-pill--success"><?= $this->te('Bestätigt') ?></span>
                                <?php elseif ($r['result'] === 'missing'): ?>
                                    <span class="status-pill status-pill--danger"><?= $this->te('Nicht mehr vorhanden') ?></span>
                                <?php else: ?>
                                    <span class="status-pill status-pill--neutral"><?= $this->te('Offen') ?></span>
                                <?php endif; ?>
                            </td>
                            <td>
                                <?php if (!empty($r['confirmed_at'])): ?>
                                    <?= $this->e(date('d.m.Y H:i', strtotime((string)$r['confirmed_at']))) ?>
                                    <?php if (!empty($r['ticket_id'])): ?>
                                        <br><a class="table-link" href="/tickets/<?= (int)$r['ticket_id'] ?>"><?= $this->te('Ticket #{nummer}', ['nummer' => (int)$r['ticket_id']]) ?></a>
                                    <?php endif; ?>
                                <?php else: ?>
                                    <span class="text-muted">–</span>
                                <?php endif; ?>
                            </td>
                            <td><?= !empty($r['note']) ? $this->e($r['note']) : '<span class="text-muted">–</span>' ?></td>
                        </tr>
                    <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
            <?php endif; ?>
        </div>
    </section>
</div>