<?php
include 'config.php'; // Database connection

// Fetch performance data with employee names
$performance = mysqli_query($conn, "SELECT performance.*, users.username FROM performance JOIN users ON performance.employee_id = users.id");
?>

<!DOCTYPE html>
<html>
<head>
    <title>Performance Records</title>
    <style>
        body {
            display: flex;
            margin: 0;
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
        }
        .sidebar {
            width: 250px;
            height: 100vh;
            background-color: rgb(234, 242, 250);
            padding: 20px;
            position: fixed;
            top: 0;
            left: 0;
            overflow-y: auto;
            box-shadow: 2px 0 5px rgba(23, 135, 226, 0.89);
        }
        .content {
            margin-left: 270px;
            padding: 20px;
            width: calc(100% - 290px);
        }
        .container {
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0px 0px 10px 0px #aaa;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
            background: white;
            border-radius: 8px;
            overflow: hidden;
        }
        th, td {
            padding: 10px;
            border: 1px solid #ddd;
            text-align: center;
        }
        th {
            background: #007bff;
            color: white;
        }
    </style>
</head>
<body>
    <!-- Sidebar -->
    <div class="sidebar" id="sidebar">
        <h2>Mypeopleconnect</h2>
        <a class="dropdown-toggle active" href="dashboard_admin.php" aria-expanded="false">
            <i class="fas fa-home"></i> Organisation Chart
        </a>
        <div class="dropdown">
            <a class="dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                <i class="fas fa-home"></i> DAP
            </a>
            <ul class="dropdown-menu">
                <li><a class="dropdown-item" href="manage_users.php">Employee Details</a></li>
                <li><a class="dropdown-item" href="manage_documents.php">Policies Rolled Out</a></li>
                <li><a class="dropdown-item" href="digital.php">Acceptance Confirmed</a></li>
            </ul>
        </div>
        <div class="dropdown">
            <a class="dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                <i class="fas fa-users"></i> CAB
            </a>
            <ul class="dropdown-menu">
                <li><a class="dropdown-item" href="attendanceexcel.php">Attendance Excel</a></li>
                <li><a class="dropdown-item" href="attendance.php">Attendance</a></li>
                <li><a class="dropdown-item" href="manage_mappings.php">managemappings</a></li>
                <li><a class="dropdown-item" href="attendance_sync.php">manageatt</a></li>
                <li><a class="dropdown-item" href="payroll_excel.php">Payroll Excel</a></li>
                <li><a class="dropdown-item" href="payroll_dashboard.php">Payroll</a></li>
                <li><a class="dropdown-item" href="leave_dashboard.php">Leave</a></li>
                <li><a class="dropdown-item" href="grievance_dashboard.php">Grievance Portal</a></li>
            </ul>
        </div>
        <div class="dropdown">
            <a class="dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                <i class="fas fa-user"></i> PEP
            </a>
            <ul class="dropdown-menu">
                <li><a class="dropdown-item" href="individual_rr.php">Individual R & R</a></li>
                <li><a class="dropdown-item" href="individual_kpi.php">Individual KPI</a></li>
                <li><a class="dropdown-item" href="login_credentials.php">Login Credentials</a></li>
            </ul>
        </div>
        <div class="dropdown">
            <a class="dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                <i class="fas fa-book"></i> L&D
            </a>
            <ul class="dropdown-menu">
                <li><a class="dropdown-item" href="incident_employee.php">Incident Portal</a></li>
                <li><a class="dropdown-item" href="training_dashboard.php">Training Portal</a></li>
                <li><a class="dropdown-item" href="rr.php">Rewards and Recognition</a></li>
            </ul>
        </div>
        <div class="dropdown">
            <a class="dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                <i class="fas fa-star"></i> AAA
            </a>
            <ul class="dropdown-menu">
                <li><a class="dropdown-item" href="employee_tiy.php">Employee TIY</a></li>
                <li><a class="dropdown-item" href="login_credentials.php">Login Credentials</a></li>
            </ul>
        </div>
        <a href="logout.php" class="text-danger"><i class="fas fa-sign-out-alt"></i> Logout</a>
    </div>

    <div class="content">
        <div class="container">
            <h2>Performance Records</h2>
            <table>
                <tr>
                    <th>Employee</th>
                    <th>OKR Target</th>
                    <th>OKR Actual</th>
                    <th>KPI Target</th>
                    <th>KPI Actual</th>
                    <th>KRA Target</th>
                    <th>KRA Actual</th>
                    <th>Evaluation Period</th>
                    <th>Marks</th>
                </tr>
                <?php while ($row = mysqli_fetch_assoc($performance)) { ?>
                <tr>
                    <td><?php echo $row['username']; ?></td>
                    <td><?php echo $row['okr_target']; ?></td>
                    <td><?php echo $row['okr_actual']; ?></td>
                    <td><?php echo $row['kpi_target']; ?></td>
                    <td><?php echo $row['kpi_actual']; ?></td>
                    <td><?php echo $row['kra_target']; ?></td>
                    <td><?php echo $row['kra_actual']; ?></td>
                    <td><?php echo $row['evaluation_period']; ?></td>
                    <td><?php echo $row['marks']; ?></td>
                </tr>
                <?php } ?>
            </table>
        </div>
    </div>
</body>
</html>
