|
Server : LiteSpeed System : Linux terra.hostitbro.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64 User : outerorb ( 1091) PHP Version : 8.1.34 Disable Function : mail Directory : /home2/outerorb/emp.outerorbittech.in/admin/ | |
|
Path: /home2/outerorb/emp.outerorbittech.in/admin/report-leave.php
Size: 9.25 KB
Permissions: 0666
<?php
require __DIR__ . '/../includes/helpers.php';
require_admin();
ensure_employees_table();
ensure_notifications_table();
$admin = current_admin();
$departmentFilter = isset($_GET['department']) ? sanitize_text($_GET['department']) : '';
$export = isset($_GET['export']) && $_GET['export'] === '1';
$departments = list_departments();
$leaveData = get_leave_report($departmentFilter ?: null);
if ($export) {
$csvHeaders = ['Employee Name', 'Email', 'Department', 'Leaves Taken', 'Total Balance', 'Remaining Balance', 'Total Approvals', 'Pending Approvals'];
$csvRows = [];
foreach ($leaveData as $row) {
$csvRows[] = [
'employee_name' => $row['employee_name'],
'email' => $row['email'],
'department' => $row['department'],
'leaves_taken' => $row['leaves_taken'],
'total_leave_balance' => $row['total_leave_balance'],
'remaining_balance' => $row['remaining_balance'],
'total_approvals' => $row['total_approvals'],
'pending_approvals' => $row['pending_approvals']
];
}
export_to_csv($csvHeaders, $csvRows, 'leave_report');
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Leave Report - HRMS</title>
<link rel="stylesheet" href="../assets/css/style.css" />
<link rel="stylesheet" href="../assets/css/polish.css">
<script src="../assets/js/app.js"></script>
</head>
<body class="dashboard-layout">
<div class="app-wrapper">
<!-- SIDEBAR -->
<aside class="sidebar-wrapper" id="sidebar">
<div class="sidebar-header">
<div class="sidebar-logo">HR</div>
<div class="sidebar-company">
<div class="sidebar-company-name">Leave<br/>Report</div>
<div class="sidebar-company-role">Admin</div>
</div>
</div>
<nav class="sidebar-menu">
<div class="sidebar-section">
<div class="sidebar-section-title">๐ Reports</div>
<div class="sidebar-item">
<a href="reports.php" class="sidebar-link">๐ Overview</a>
</div>
<div class="sidebar-item">
<a href="report-leave.php" class="sidebar-link active">๐ด Leave</a>
</div>
<div class="sidebar-item">
<a href="report-recruitment.php" class="sidebar-link">๐ค Recruitment</a>
</div>
</div>
</nav>
</aside>
<!-- MAIN CONTENT -->
<div class="main-content">
<!-- Top Bar -->
<div class="top-bar">
<div class="top-bar-left">
<button class="sidebar-toggle" id="sidebarToggle" aria-label="Toggle sidebar">รขหยฐ</button>
<div>
<h1 class="page-title">Leave Report</h1>
<div class="breadcrumb-nav">
<span>Reports</span> / <span>Leave</span>
</div>
</div>
</div>
<div class="top-bar-right">
<button class="notification-bell" title="Notifications">
<i class="fas fa-bell"></i>
<?php
$unreadCount = get_unread_notification_count($admin['id']);
if ($unreadCount > 0):
?>
<span class="notification-badge"><?php echo $unreadCount; ?></span>
<?php endif; ?>
</button>
<a href="logout.php" style="color: #cbd5e1; text-decoration: none; padding: 8px 12px; border-radius: 6px; font-size: 13px; font-weight: 600;">รขโ ย Logout</a>
</div>
</div>
<!-- Main Content -->
<div class="dashboard-container">
<!-- Filters -->
<div class="chart-card" style="margin-bottom: 20px;">
<form method="get" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px;">
<div>
<label style="font-size: 12px; color: #9ca3af; display: block; margin-bottom: 4px;">Department</label>
<select name="department" style="width: 100%; padding: 8px; border: 1px solid rgba(255,255,255,0.2); border-radius: 6px; background: rgba(255,255,255,0.05); color: #e5e7eb;">
<option value="">All Departments</option>
<?php foreach ($departments as $dept): ?>
<option value="<?php echo htmlspecialchars($dept, ENT_QUOTES, 'UTF-8'); ?>" <?php echo $departmentFilter === $dept ? 'selected' : ''; ?>><?php echo htmlspecialchars($dept, ENT_QUOTES, 'UTF-8'); ?></option>
<?php endforeach; ?>
</select>
</div>
<div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; align-items: flex-end;">
<button type="submit" style="background: #2563eb; color: white; padding: 8px 12px; border: none; border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 13px;">Apply Filters</button>
<a href="report-export.php?report=leave&type=excel" target="_blank" style="background: #059669; color: white; padding: 8px 12px; border-radius: 6px; text-decoration: none; text-align: center; font-weight: 600; font-size: 13px; display: block;">๐ Excel</a>
<a href="report-export.php?report=leave&type=pdf" target="_blank" style="background: #dc2626; color: white; padding: 8px 12px; border-radius: 6px; text-decoration: none; text-align: center; font-weight: 600; font-size: 13px; display: block;">๐ PDF</a>
<a href="report-export.php?report=leave&type=csv" target="_blank" style="background: #7c3aed; color: white; padding: 8px 12px; border-radius: 6px; text-decoration: none; text-align: center; font-weight: 600; font-size: 13px; display: block;">๐ CSV</a>
</div>
</form>
</div>
<!-- Report Table -->
<div class="chart-card">
<div class="chart-header">Leave Balances & Usage</div>
<div class="table-wrapper" style="overflow-x: auto;">
<table class="table">
<thead>
<tr>
<th>Employee Name</th>
<th>Email</th>
<th>Department</th>
<th class="cell-nowrap">Leaves Taken</th>
<th class="cell-nowrap">Total Balance</th>
<th class="cell-nowrap">Remaining</th>
<th class="cell-nowrap">Approved Reqs</th>
<th class="cell-nowrap">Pending Reqs</th>
</tr>
</thead>
<tbody>
<?php if (empty($leaveData)): ?>
<tr><td colspan="8" style="text-align: center; color: #9ca3af; padding: 32px;">No records found.</td></tr>
<?php else: foreach ($leaveData as $emp):
$remainingColor = $emp['remaining_balance'] >= 5 ? '#10b981' : ($emp['remaining_balance'] >= 2 ? '#f59e0b' : '#ef4444');
?>
<tr>
<td><?php echo htmlspecialchars($emp['employee_name'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($emp['email'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($emp['department'] ?? 'N/A', ENT_QUOTES, 'UTF-8'); ?></td>
<td class="cell-nowrap"><?php echo (int)$emp['leaves_taken']; ?></td>
<td class="cell-nowrap"><?php echo (int)$emp['total_leave_balance']; ?></td>
<td class="cell-nowrap" style="color: <?php echo $remainingColor; ?>; font-weight: 600;"><?php echo (int)$emp['remaining_balance']; ?></td>
<td class="cell-nowrap"><?php echo (int)$emp['total_approvals']; ?></td>
<td class="cell-nowrap" style="color: #f59e0b;"><?php echo (int)$emp['pending_approvals']; ?></td>
</tr>
<?php endforeach; endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<script>
const sidebar = document.getElementById('sidebar');
const sidebarToggle = document.getElementById('sidebarToggle');
sidebarToggle?.addEventListener('click', () => {
sidebar.classList.toggle('open');
});
document.addEventListener('click', (e) => {
if (!sidebar.contains(e.target) && !sidebarToggle.contains(e.target)) {
sidebar.classList.remove('open');
}
});
</script>
</body>
</html>