| Linux in-mum-web1499.main-hosting.eu 5.14.0-503.40.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Mon May 5 06:06:04 EDT 2025 x86_64 Path : /home/u901718425/domains/task.urbanpillar.in/public_html/dashboard/ |
| Current File : /home/u901718425/domains/task.urbanpillar.in/public_html/dashboard/get_attendance_dates.php |
<?php
require_once "../db.php";
if (!isset($_GET['user_id']) || !isset($_GET['month']) || !isset($_GET['year'])) {
echo json_encode([]);
exit;
}
$userId = intval($_GET['user_id']);
$month = intval($_GET['month']); // 1-12
$year = intval($_GET['year']); // 4-digit year
$startDate = "$year-$month-01";
$endDate = date("Y-m-t", strtotime($startDate));
$query = "SELECT DATE(login_time) AS login_date
FROM user_attendance
WHERE user_id = ?
AND DATE(login_time) BETWEEN ? AND ?";
$stmt = $conn->prepare($query);
$stmt->bind_param("iss", $userId, $startDate, $endDate);
$stmt->execute();
$result = $stmt->get_result();
$dates = [];
while ($row = $result->fetch_assoc()) {
$dates[] = date('j', strtotime($row['login_date'])); // extract day number only
}
echo json_encode($dates);
?>