"
+ . "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);
+ }
+ }
+}
+
+?>
+
+
+
+
+
+ Submit Leave Request - Employee Attendance System
+
+
+
+
+
+
+
+
+
Submit Leave Request
+
Fill out the form to request time off.
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/update_leave_status.php b/update_leave_status.php
new file mode 100644
index 0000000..6576cde
--- /dev/null
+++ b/update_leave_status.php
@@ -0,0 +1,42 @@
+prepare($sql)) {
+ $stmt->bindParam(':status', $status, PDO::PARAM_STR);
+ $stmt->bindParam(':id', $id, PDO::PARAM_INT);
+ if ($stmt->execute()) {
+ // Send email notification to the employee
+ require_once 'mail/MailService.php';
+ $sql_request = "SELECT lr.start_date, lr.end_date, u.username FROM leave_requests lr JOIN users u ON lr.employee_id = u.id WHERE lr.id = :id";
+ $stmt_request = db()->prepare($sql_request);
+ $stmt_request->bindParam(':id', $id, PDO::PARAM_INT);
+ $stmt_request->execute();
+ $request_data = $stmt_request->fetch(PDO::FETCH_ASSOC);
+
+ if ($request_data) {
+ $to = $request_data['username'];
+ $subject = "Your Leave Request has been " . ucfirst($status);
+ $body = "Your leave request from {$request_data['start_date']} to {$request_data['end_date']} has been {$status}.
"
+ . "Log in to the system for more details.";
+ MailService::sendMail($to, $subject, $body, strip_tags($body));
+ }
+ }
+ }
+ }
+}
+
+header('location: leave_requests.php');
+exit;
+?>
\ No newline at end of file
diff --git a/view_employees.php b/view_employees.php
new file mode 100644
index 0000000..6b185fa
--- /dev/null
+++ b/view_employees.php
@@ -0,0 +1,103 @@
+query("SELECT id, username, role FROM users ORDER BY id DESC");
+ $users = $stmt->fetchAll(PDO::FETCH_ASSOC);
+} catch (PDOException $e) {
+ // For a real app, you'd want to log this error
+ die("Could not connect to the database or fetch users.");
+}
+
+?>
+
+
+
+
+
+ View Employees - Employee Attendance System
+
+
+
+
+
+
+
+
+
+