Submit Leave Request
Fill out the form to request time off.
prepare($sql)) {
$stmt->bindParam(':employee_id', $_SESSION['id'], PDO::PARAM_INT);
$stmt->bindParam(':start_date', $start_date, PDO::PARAM_STR);
$stmt->bindParam(':end_date', $end_date, PDO::PARAM_STR);
$stmt->bindParam(':reason', $reason, PDO::PARAM_STR);
if ($stmt->execute()) {
$success_msg = 'Leave request submitted successfully!';
// Send email notification to Admins and HR
require_once 'mail/MailService.php';
$sql_users = "SELECT username FROM users WHERE role = 'Admin' OR role = 'HR'";
$stmt_users = db()->query($sql_users);
$recipients = $stmt_users->fetchAll(PDO::FETCH_COLUMN);
if (!empty($recipients)) {
$subject = "New Leave Request Submitted";
$body = "A new leave request has been submitted by {$_SESSION['username']}.
"
. "Start Date: {$start_date}
"
. "End Date: {$end_date}
"
. "Reason: {$reason}
"
. "Please log in to the system to approve or reject this request.";
MailService::sendMail($recipients, $subject, $body, strip_tags($body));
}
$start_date = $end_date = $reason = '';
} else {
echo 'Oops! Something went wrong. Please try again later.';
}
unset($stmt);
}
}
}
?>
Fill out the form to request time off.