<?php
session_start();
require_once '../includes/config.php';

if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
    header("Location: ../auth/login.php");
    exit;
}

$id = $_POST['id'];
$time_out = $_POST['time_out'];

$stmt = $pdo->prepare("UPDATE attendance SET time_out = ? WHERE id = ?");
$stmt->execute([$time_out, $id]);

header("Location: edit_attendance.php?updated=1");
exit;
