setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { die("Database Connection Failed: " . $e->getMessage()); } // Distance Calculation using Haversine Formula function isInsideGeofence($lat1, $lon1, $lat2, $lon2, $radius) { if(empty($lat1) || empty($lon1) || empty($lat2) || empty($lon2)) return false; $earthRadius = 6371000; $latFrom = deg2rad((float)$lat1); $lonFrom = deg2rad((float)$lon1); $latTo = deg2rad((float)$lat2); $lonTo = deg2rad((float)$lon2); $latDelta = $latTo - $latFrom; $lonDelta = $lonTo - $lonFrom; $angle = 2 * asin(sqrt(pow(sin($latDelta / 2), 2) + cos($latFrom) * cos($latTo) * pow(sin($lonDelta / 2), 2))); $distance = $angle * $earthRadius; return $distance <= $radius; } // Automatic OT Hours Calculation (OUT - IN) function calculateOT($user_id, $pdo) { $stmt = $pdo->prepare("SELECT id, created_at FROM attendance WHERE user_id = ? AND action = 'OUT' ORDER BY id DESC LIMIT 1"); $stmt->execute([$user_id]); $latestOut = $stmt->fetch(PDO::FETCH_ASSOC); if($latestOut) { $stmt2 = $pdo->prepare("SELECT id, created_at FROM attendance WHERE user_id = ? AND action = 'IN' AND id < ? ORDER BY id DESC LIMIT 1"); $stmt2->execute([$user_id, $latestOut['id']]); $latestIn = $stmt2->fetch(PDO::FETCH_ASSOC); if($latestIn) { $inTime = strtotime($latestIn['created_at']); $outTime = strtotime($latestOut['created_at']); $hours = round(($outTime - $inTime) / 3600, 2); if($hours < 0) $hours = 0; $update = $pdo->prepare("UPDATE attendance SET ot_hours = ? WHERE id = ?"); $update->execute([$hours, $latestOut['id']]); } } } ?> OT System | Access Control Portal

OT Attendance
Tracking System.

Geofence-verified attendance & automatic overtime computation engine with live administrative approval protocols.

Lead Architect & Founder
Engineered by Suman Sutradhar

Employee Access

Enter system credentials to proceed