39348-vm/leave_requests.php
Flatlogic Bot c135e4db89 123
2026-03-27 16:57:36 +00:00

71 lines
3.2 KiB
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/includes/app.php';
$statusFilter = isset($_GET['status']) ? (string)$_GET['status'] : null;
$requests = filteredLeaveRequests($statusFilter);
renderPageStart(
'Leave Request Queue',
'Review all leave requests for the active tenant with status filters and quick access to detail.',
'requests'
);
?>
<section class="panel-card">
<div class="panel-head flex-column flex-lg-row gap-3 align-items-lg-center">
<div>
<span class="section-kicker">Approval queue</span>
<h2 class="panel-title mb-1">All leave requests</h2>
<p class="text-secondary mb-0">Filtered by active company context: <?= htmlspecialchars(currentCompanyName()) ?>.</p>
</div>
<div class="d-flex flex-wrap gap-2">
<?php foreach (['all' => 'All', 'pending' => 'Pending', 'approved' => 'Approved', 'rejected' => 'Rejected'] as $value => $label): ?>
<?php $isActive = (($statusFilter ?? 'all') === $value) || ($value === 'all' && !$statusFilter); ?>
<a href="<?= htmlspecialchars(currentCompanyFilterQuery('/leave_requests.php', $value === 'all' ? [] : ['status' => $value])) ?>" class="btn btn-sm <?= $isActive ? 'btn-dark' : 'btn-outline-secondary' ?>"><?= htmlspecialchars($label) ?></a>
<?php endforeach; ?>
</div>
</div>
<?php if (!$requests): ?>
<div class="empty-state">
<h4>No matching requests</h4>
<p>Try another filter or add the first leave request for this company.</p>
<a href="<?= htmlspecialchars(currentCompanyFilterQuery('/request_leave.php')) ?>" class="btn btn-dark btn-sm">Create request</a>
</div>
<?php else: ?>
<div class="table-responsive">
<table class="table align-middle hr-table mb-0">
<thead>
<tr>
<th>Employee</th>
<th>Department</th>
<th>Window</th>
<th>Days</th>
<th>Status</th>
<th class="text-end">Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($requests as $request): ?>
<tr>
<td>
<div class="fw-semibold"><?= htmlspecialchars($request['employee_name']) ?></div>
<div class="small text-secondary"><?= htmlspecialchars($request['employee_email']) ?></div>
</td>
<td><?= htmlspecialchars($request['department']) ?></td>
<td>
<div><?= htmlspecialchars(formatDateLabel($request['start_date'])) ?></div>
<div class="small text-secondary">to <?= htmlspecialchars(formatDateLabel($request['end_date'])) ?></div>
</td>
<td><?= (int)$request['days_requested'] ?></td>
<td><span class="badge <?= htmlspecialchars(requestStatusBadgeClass($request['status'])) ?>"><?= htmlspecialchars(ucfirst($request['status'])) ?></span></td>
<td class="text-end"><a class="btn btn-sm btn-outline-dark" href="<?= htmlspecialchars(currentCompanyFilterQuery('/leave_request.php', ['id' => (int)$request['id']])) ?>">View detail</a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</section>
<?php renderPageEnd(); ?>