<?php
session_start();
include 'config.php';

// Check user role
if (!isset($_SESSION['role'])) {
    header('Location: login.php');
    exit();
}

$role = $_SESSION['role'];
$user_id = $_SESSION['user_id'];

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Training Portal</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <div class="container">
        <h1>Welcome to Training Portal</h1>
        
        <?php if ($role === 'HR') { ?>
            <h2>HR Dashboard</h2>
            <a href="create_training.php">Create Training</a>
            <a href="track_progress.php">Track Employee Progress</a>
            <a href="approve_requests.php">Approve Requests</a>
            <a href="manage_expenses.php">Manage Expenses</a>
            <a href="view_trainings.php">View Trainings</a>
            <a href="assign_trainers.php">Assign Trainers</a>
        <?php } else { ?>
            <h2>Employee Dashboard</h2>
            <a href="view_training.php">View Assigned Training</a>
            <a href="track_my_progress.php">Track My Progress</a>
            <a href="request_training.php">Request Training</a>
            <a href="apply_training.php">Apply for Training</a>
            <a href="submit_expenses.php">Submit Expenses</a>
            <a href="view_trainers.php">View Trainers</a>
        <?php } ?>
        
        <a href="logout.php">Logout</a>
    </div>
</body>
</html>
