@extends('layouts.user_type.auth') @section('content')

Employee Attendance - {{ \Carbon\Carbon::parse($startDate)->format('d M Y') }} to {{ \Carbon\Carbon::parse($endDate)->format('d M Y') }}

📥 Export Attendance
@php $hasData = false; $officeLocations = [ ['lat' => 19.88872063745518, 'lng' => 75.36867925450616, 'name' => 'Aurangabad Office'], ['lat' => 19.065966468569965, 'lng' => 72.99926801031167, 'name' => 'Mumbai Office'], ['lat' => 18.59007007542511, 'lng' => 73.74808194495957, 'name' => 'Pune Office'], ]; function getDistanceAndStatus($latLng, $offices, $radius = 300) { if (!$latLng || !str_contains($latLng, ',')) return ['status' => 'N/A', 'distance' => null]; [$lat1, $lon1] = explode(',', $latLng); $lat1 = floatval($lat1); $lon1 = floatval($lon1); $earthRadius = 6371000; $closestDistance = null; foreach ($offices as $office) { $lat2 = $office['lat']; $lon2 = $office['lng']; $dLat = deg2rad($lat2 - $lat1); $dLon = deg2rad($lon2 - $lon1); $a = sin($dLat/2) ** 2 + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * sin($dLon/2) ** 2; $c = 2 * atan2(sqrt($a), sqrt(1 - $a)); $distance = $earthRadius * $c; if (is_null($closestDistance) || $distance < $closestDistance) { $closestDistance = $distance; } } $status = ($closestDistance <= $radius) ? 'Inside Office' : 'Outside Office'; return ['status' => $status, 'distance' => round($closestDistance)]; } @endphp @foreach ($employees as $employee) @foreach ($employee->attendances as $attendance) @php $hasData = true; @endphp @php $checkin = getDistanceAndStatus($attendance->check_in_location, $officeLocations); @endphp @php $checkout = getDistanceAndStatus($attendance->check_out_location, $officeLocations); @endphp @endforeach @endforeach @if (!$hasData) @endif
Employee Date Check-in Time Check-out Time Check-in Status Check-out Status Check-in Address Check-out Address
{{ $employee->name ?? ($employee->first_name . ($employee->middle_name ? ' ' . $employee->middle_name : '') . ' ' . $employee->last_name) }} {{ \Carbon\Carbon::parse($attendance->check_in)->format('d M Y') }} {{ \Carbon\Carbon::parse($attendance->check_in)->setTimezone('Asia/Kolkata')->format('h:i A') }} {{ $attendance->check_out ? \Carbon\Carbon::parse($attendance->check_out)->setTimezone('Asia/Kolkata')->format('h:i A') : '-' }} {{ $checkin['status'] }} @if ($checkin['distance'])
({{ $checkin['distance'] }} m)
@endif
{{ $checkout['status'] }} @if ($checkout['distance'])
({{ $checkout['distance'] }} m)
@endif
{{ $attendance->check_in_address ?? '-' }} {{ $attendance->check_out_address ?? '-' }}
No attendance data found for the selected date range.
@endsection