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

// Check if timesheetID is provided in the URL
if (isset($_GET['timesheetID'])) {
    $timesheetID = $_GET['timesheetID'];

    // Construct the DELETE query
    $deleteQuery = "DELETE FROM timesheet WHERE timesheetID = $timesheetID";

    // Execute the DELETE query
    if (mysqli_query($conn, $deleteQuery)) {
        // Timesheet entry deleted successfully
        $_SESSION['success_message'] = 'Timesheet entry deleted successfully.';
    } else {
        // Error occurred while deleting
        $_SESSION['error_message'] = 'Error: ' . mysqli_error($conn);
    }

    // Close the database connection
    mysqli_close($conn);
}

// Redirect back to timesheet.php
header('Location: timesheet.php');
?>