<?php
include 'includes/auth.php';
include 'db.php';

if(!isset($_GET['id']) || !is_numeric($_GET['id'])){
    die("Invalid request ID.");
}

$request_id = intval($_GET['id']);
$completed_at = date('Y-m-d H:i:s');

// Update status to Completed
$stmt = $conn->prepare("UPDATE maintenance_requests SET status='Completed', completed_at=? WHERE id=?");
$stmt->bind_param("si", $completed_at, $request_id);
$stmt->execute();
$stmt->close();

header("Location: maintenance_requests.php");
exit;
?>