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/

📁 Create New:
⬆️ Upload File:
Current Dir [ Writable ] Root [ Writable ]


OR Upload from URL:
URL: Save as:

📄 File: report-payroll.php

Path: /home2/outerorb/emp.outerorbittech.in/admin/report-payroll.php

Size: 12.6 KB

Permissions: 0666

<?php
require __DIR__ . '/../includes/helpers.php';
require_admin();
ensure_payroll_tables();
ensure_notifications_table();

$admin = current_admin();

$month = isset($_GET['month']) ? (int)$_GET['month'] : (int)date('m');
$year = isset($_GET['year']) ? (int)$_GET['year'] : (int)date('Y');
$departmentFilter = isset($_GET['department']) ? sanitize_text($_GET['department']) : '';
$export = isset($_GET['export']) && $_GET['export'] === '1';

$departments = list_departments();
$payrollData = get_payroll_report($month, $year, $departmentFilter ?: null);

if ($export) {
    $csvHeaders = ['Employee Name', 'Email', 'Department', 'Basic', 'HRA', 'DA', 'Gross', 'PF', 'ESI', 'PT', 'Deductions', 'Net'];
    $csvRows = [];
    foreach ($payrollData as $row) {
        $csvRows[] = [
            'employee_name' => $row['employee_name'],
            'email' => $row['email'],
            'department' => $row['department'],
            'basic' => $row['basic'],
            'hra' => $row['hra'],
            'da' => $row['da'],
            'gross' => $row['gross'],
            'pf' => $row['pf'],
            'esi' => $row['esi'],
            'pt' => $row['pt'],
            'deductions' => $row['total_deduction'],
            'net' => $row['net']
        ];
    }
    export_to_csv($csvHeaders, $csvRows, 'payroll_report');
    exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Payroll 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">Payroll<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-payroll.php" class="sidebar-link active">💰 Payroll</a>
                </div>
                <div class="sidebar-item">
                    <a href="report-leave.php" class="sidebar-link">🌴 Leave</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">Payroll Report</h1>
                    <div class="breadcrumb-nav">
                        <span>Reports</span> / <span>Payroll</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;">Month</label>
                        <select name="month" 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;">
                            <?php for ($m = 1; $m <= 12; $m++): ?>
                                <option value="<?php echo $m; ?>" <?php echo $m === $month ? 'selected' : ''; ?>><?php echo date('F', mktime(0, 0, 0, $m, 1)); ?></option>
                            <?php endfor; ?>
                        </select>
                    </div>
                    <div>
                        <label style="font-size: 12px; color: #9ca3af; display: block; margin-bottom: 4px;">Year</label>
                        <select name="year" 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;">
                            <?php for ($y = date('Y'); $y >= date('Y') - 5; $y--): ?>
                                <option value="<?php echo $y; ?>" <?php echo $y === $year ? 'selected' : ''; ?>><?php echo $y; ?></option>
                            <?php endfor; ?>
                        </select>
                    </div>
                    <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=payroll&type=excel&from_date=<?php echo $year . '-' . str_pad($month, 2, '0', STR_PAD_LEFT) . '-01'; ?>" 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=payroll&type=pdf&from_date=<?php echo $year . '-' . str_pad($month, 2, '0', STR_PAD_LEFT) . '-01'; ?>" 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=payroll&type=csv&from_date=<?php echo $year . '-' . str_pad($month, 2, '0', STR_PAD_LEFT) . '-01'; ?>" 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">Payroll Data (<?php echo date('F Y', mktime(0, 0, 0, $month, 1, $year)); ?>)</div>
                <div class="table-wrapper" style="overflow-x: auto;">
                    <table class="table">
                        <thead>
                            <tr>
                                <th>Employee Name</th>
                                <th>Email</th>
                                <th class="cell-nowrap">Basic</th>
                                <th class="cell-nowrap">HRA</th>
                                <th class="cell-nowrap">DA</th>
                                <th class="cell-nowrap">Gross</th>
                                <th class="cell-nowrap">PF</th>
                                <th class="cell-nowrap">ESI</th>
                                <th class="cell-nowrap">Deductions</th>
                                <th class="cell-nowrap">Net</th>
                            </tr>
                        </thead>
                        <tbody>
                        <?php if (empty($payrollData)): ?>
                            <tr><td colspan="10" style="text-align: center; color: #9ca3af; padding: 32px;">No records found.</td></tr>
                        <?php else: 
                            $totalBasic = $totalGross = $totalDeductions = $totalNet = 0;
                            foreach ($payrollData as $emp):
                                $totalBasic += $emp['basic'];
                                $totalGross += $emp['gross'];
                                $totalDeductions += $emp['total_deduction'];
                                $totalNet += $emp['net'];
                        ?>
                            <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 class="cell-nowrap">₹<?php echo number_format($emp['basic'], 2); ?></td>
                                <td class="cell-nowrap">₹<?php echo number_format($emp['hra'], 2); ?></td>
                                <td class="cell-nowrap">₹<?php echo number_format($emp['da'], 2); ?></td>
                                <td class="cell-nowrap"><strong>₹<?php echo number_format($emp['gross'], 2); ?></strong></td>
                                <td class="cell-nowrap">₹<?php echo number_format($emp['pf'], 2); ?></td>
                                <td class="cell-nowrap">₹<?php echo number_format($emp['esi'], 2); ?></td>
                                <td class="cell-nowrap">₹<?php echo number_format($emp['total_deduction'], 2); ?></td>
                                <td class="cell-nowrap" style="font-weight: 600; color: #10b981;">₹<?php echo number_format($emp['net'], 2); ?></td>
                            </tr>
                        <?php endforeach; ?>
                            <tr style="border-top: 2px solid rgba(255,255,255,0.2); font-weight: 600; background: rgba(255,255,255,0.05);">
                                <td colspan="2">TOTAL</td>
                                <td class="cell-nowrap">₹<?php echo number_format($totalBasic, 2); ?></td>
                                <td class="cell-nowrap">-</td>
                                <td class="cell-nowrap">-</td>
                                <td class="cell-nowrap">₹<?php echo number_format($totalGross, 2); ?></td>
                                <td class="cell-nowrap">-</td>
                                <td class="cell-nowrap">-</td>
                                <td class="cell-nowrap">₹<?php echo number_format($totalDeductions, 2); ?></td>
                                <td class="cell-nowrap">₹<?php echo number_format($totalNet, 2); ?></td>
                            </tr>
                        <?php 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>



← Back to Directory Edit File 🔒 Chmod

WP File Manager