<?php

error_reporting(E_ALL);
ini_set('display_errors',1);

require '../config.php';
session_start();

$userId = intval($_SESSION['user_id']);

if($_SERVER['REQUEST_METHOD']=='POST'){

    $date = $_POST['overtime_date'];

    $hours =
    floatval($_POST['overtime_hours']);

    $reason =
    trim($_POST['reason']);

    $stmt = $conn->prepare("
        INSERT INTO overtime_requests
        (
            employee_id,
            overtime_date,
            overtime_hours,
            reason
        )
        VALUES
        (?,?,?,?)
    ");

    $stmt->bind_param(
        "isds",
        $userId,
        $date,
        $hours,
        $reason
    );

    $stmt->execute();

    header(
        "Location:overtime_request.php?saved=1"
    );

    exit;
}