OpenNIT

Quelltext des aktuellen Standes

Fassung 1.1.1

delegation.php

5 KB
<?php
$this->layout('layouts/main', [
    'page_title'    => $page_title ?? 'Meine Vertretung',
    'current_route' => 'workflows',
    'full_width'    => true,
    'extra_css'     => ['/assets/css/workflows.css'],
]);
$delegations = $delegations ?? [];
$users       = $users ?? [];
$workflows   = $workflows ?? [];
$active = 'delegation';
include __DIR__ . '/_nav.php';
?>
<div class="page-body">
    <?php include __DIR__ . '/_subnav.php'; ?>
    <div class="wf-detail-grid">
    <div class="detail-card">
        <div class="detail-card-header"><span class="detail-card-title"><?= $this->te('Aktive &amp; geplante Vertretungen') ?></span></div>
        <div class="detail-card-body">
            <?php if (empty($delegations)): ?>
                <div class="empty-state"><i class="fas fa-user-clock"></i><p><?= $this->te('Keine Vertretung hinterlegt.') ?></p></div>
            <?php else: ?>
            <div class="table-wrapper">
                <table class="data-table">
                    <thead><tr><th scope="col"><?= $this->te('Vertreter') ?></th><th scope="col"><?= $this->te('Vorlage') ?></th><th scope="col"><?= $this->te('Von') ?></th><th scope="col"><?= $this->te('Bis') ?></th><th scope="col"></th></tr></thead>
                    <tbody>
                    <?php foreach ($delegations as $d): ?>
                        <tr>
                            <td><?= $this->e($d['deputy_name']) ?></td>
                            <td><?= $d['workflow_name'] ? $this->e($d['workflow_name']) : '<span class="text-muted">Alle</span>' ?></td>
                            <td><?= $this->date($d['valid_from'], 'd.m.Y') ?></td>
                            <td><?= $this->date($d['valid_until'], 'd.m.Y') ?></td>
                            <td>
                                <form method="post" action="/antraege/vertretung/<?= (int)$d['id'] ?>/delete" onsubmit="return confirm('Vertretung entfernen?');">
                                    <input type="hidden" name="_csrf" value="<?= $this->csrf() ?>">
                                    <button aria-label="<?= $this->te('Löschen') ?>" class="btn btn-sm btn-danger" type="submit"><i class="fas fa-trash"></i></button>
                                </form>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
            <?php endif; ?>
        </div>
    </div>

    <div class="detail-card">
        <div class="detail-card-header"><span class="detail-card-title"><?= $this->te('Neue Vertretung') ?></span></div>
        <div class="detail-card-body">
            <form method="post" action="/antraege/vertretung">
                <input type="hidden" name="_csrf" value="<?= $this->csrf() ?>">
                <div class="form-group">
                    <label for="f-062a-deputy_id"><?= $this->te('Vertreter') ?> <span class="text-danger">*</span></label>
                    <select id="f-062a-deputy_id" class="form-control form-control-sm" name="deputy_id" required>
                        <option value=""><?= $this->te('– bitte wählen –') ?></option>
                        <?php foreach ($users as $u): ?><option value="<?= (int)$u['id'] ?>"><?= $this->e($u['display_name']) ?></option><?php endforeach; ?>
                    </select>
                </div>
                <div class="form-group">
                    <label for="f-062a-workflow_id"><?= $this->te('Nur für Vorlage (optional)') ?></label>
                    <select id="f-062a-workflow_id" class="form-control form-control-sm" name="workflow_id">
                        <option value="0"><?= $this->te('Alle Vorlagen') ?></option>
                        <?php foreach ($workflows as $w): ?><option value="<?= (int)$w['id'] ?>"><?= $this->e($w['name']) ?></option><?php endforeach; ?>
                    </select>
                </div>
                <div class="form-group">
                    <label for="f-062a-valid_from"><?= $this->te('Von') ?> <span class="text-danger">*</span></label>
                    <input id="f-062a-valid_from" class="form-control form-control-sm" type="date" name="valid_from" required>
                </div>
                <div class="form-group">
                    <label for="f-062a-valid_until"><?= $this->te('Bis') ?> <span class="text-danger">*</span></label>
                    <input id="f-062a-valid_until" class="form-control form-control-sm" type="date" name="valid_until" required>
                </div>
                <button class="btn btn-primary" type="submit"><i class="fas fa-plus"></i> <?= $this->te('Vertretung anlegen') ?></button>
            </form>
        </div>
    </div>
    </div>
</div>