<?php
require_once __DIR__ . '/../config/db.php';
require_once __DIR__ . '/../config/auth.php';
$user = requireAuth();
$db   = getDB();
$empStmt = $db->prepare("SELECT e.* FROM employees e WHERE e.user_id=?");
$empStmt->execute([$user['id']]);
$emp = $empStmt->fetch();
if (!$emp) apiError('No employee profile linked.', 404);

$lb = $db->prepare("SELECT * FROM employee_leave_balance WHERE employee_id=? AND year=YEAR(CURDATE())");
$lb->execute([$emp['id']]); $emp['leave_balances'] = $lb->fetchAll();

apiSuccess(['employee' => $emp]);
