Quelltext des aktuellen Standes
<?php $this->layout('layouts/portal', [
'page_title' => 'Genehmigung',
'ssp_active' => 'approvals',
]);
$du = ($portal_address ?? 'du') !== 'sie';
$req = $wf_request;
$step = $wf_step;
$fields = $fields ?? [];
$notes = $notes ?? [];
?>
<a href="/portal/approvals" class="ssp-back"><i class="fas fa-arrow-left" aria-hidden="true"></i> <?= $this->te('Meine Genehmigungen') ?></a>
<div class="ssp-ticket-head">
<h1><i class="fas fa-clipboard-check" aria-hidden="true"></i> <?= $this->e($req['title']) ?></h1>
<p class="ssp-ticket-info">
<span class="status-pill status-pill--warning"><?= $this->te('Entscheidung offen') ?></span>
<span><i class="fas fa-code-branch" aria-hidden="true"></i>Station „<?= $this->e($step['name']) ?>“</span>
<span><i class="fas fa-clock" aria-hidden="true"></i>eingereicht <?= $this->te('{zeitpunkt} Uhr', ['zeitpunkt' => date('d.m.Y H:i', strtotime((string)$req['created_at']))]) ?></span>
</p>
</div>
<div class="ssp-card" style="margin-bottom:1rem;">
<h2><span class="ssp-card-icon"><i class="fas fa-list" aria-hidden="true"></i></span> <?= $this->te('Angaben') ?></h2>
<table class="ssp-kv">
<?php foreach ($fields as $f): $v = (string)($f['field_value'] ?? ''); ?>
<tr>
<th scope="col"><?= $this->e($f['field_label']) ?></th>
<td><?= $v !== '' && !str_starts_with($v, '/uploads/') ? nl2br($this->e($v)) : ($v !== '' ? 'Datei-Anhang' : '–') ?></td>
</tr>
<?php endforeach; ?>
</table>
</div>
<?php if (!empty($notes)): ?>
<div class="ssp-card" style="margin-bottom:1rem;">
<h2><span class="ssp-card-icon"><i class="fas fa-history" aria-hidden="true"></i></span> <?= $this->te('Bisherige Anmerkungen') ?></h2>
<div class="ssp-wf-thread">
<?php foreach ($notes as $n): ?>
<div class="ssp-wf-item">
<div class="ssp-wf-meta"><strong><?= $this->e($n['approver_name'] ?: 'Beteiligte:r') ?></strong> · <?= $this->te('{zeitpunkt} Uhr', ['zeitpunkt' => date('d.m.Y H:i', strtotime((string)$n['created_at']))]) ?></div>
<?php if (!empty($n['reason'])): ?><div class="ssp-wf-note"><?= nl2br($this->e($n['reason'])) ?></div><?php endif; ?>
<?php if (!empty($n['note'])): ?><div class="ssp-wf-note"><em><?= nl2br($this->e($n['note'])) ?></em></div><?php endif; ?>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<div class="ssp-card ssp-form">
<h2><span class="ssp-card-icon"><i class="fas fa-clipboard-check" aria-hidden="true"></i></span> <?= $du ? $this->te('Deine Entscheidung') : $this->te('Ihre Entscheidung') ?></h2>
<form method="post" action="/portal/approvals/<?= (int)$approver_id ?>/decide" id="ssp-approval-form">
<input type="hidden" name="_csrf" value="<?= $this->e($this->csrf()) ?>">
<div class="form-group">
<label for="ssp-app-note"><?= $this->te('Notiz für nachfolgende Stationen (bei Zustimmung, optional)') ?></label>
<textarea class="form-control form-control-sm" id="ssp-app-note" name="note" rows="2"></textarea>
</div>
<div class="form-group">
<label for="ssp-app-reason"><?= $this->te('Begründung (bei Ablehnung erforderlich)') ?></label>
<textarea class="form-control form-control-sm" id="ssp-app-reason" name="reason" rows="2"></textarea>
</div>
<div class="ssp-approval-actions">
<button class="btn btn-success" type="submit" name="decision" value="approve"><i class="fas fa-check" aria-hidden="true"></i> <?= $this->te('Genehmigen') ?></button>
<button class="btn btn-danger" type="submit" name="decision" value="reject" id="ssp-app-reject"><i class="fas fa-times" aria-hidden="true"></i> <?= $this->te('Ablehnen') ?></button>
</div>
</form>
</div>
<script>
// Ablehnung nur mit Begründung zulassen (serverseitig ebenfalls erzwungen).
document.getElementById('ssp-app-reject').addEventListener('click', function (e) {
var reason = document.getElementById('ssp-app-reason');
if (!reason.value.trim()) {
e.preventDefault();
alert(<?= $du ? "'Bitte gib eine Begründung für die Ablehnung an.'" : "'Bitte geben Sie eine Begründung für die Ablehnung an.'" ?>);
reason.focus();
}
});
</script>