@php $record = $getRecord(); $user = auth()->user(); $company = $user->company; // Check permissions $isSuperAdmin = $user->hasRole('super_admin'); $isOwnAttendance = $record->user_id == $user->id; $backdateEnabled = $company->backdate_enabled ?? false; $editableEnabled = $company->allow_editable_location ?? false; // Can edit if: (super admin OR own attendance) AND backdate enabled AND editable enabled // Note: Tidak ada batasan periode cutoff untuk edit koordinat map $canEdit = ($isSuperAdmin || $isOwnAttendance) && $backdateEnabled && $editableEnabled; $markers = []; $offices = []; // Helper function to sanitize strings for JSON $sanitizeForJson = function($value) { if ($value === null) return null; if (is_numeric($value)) return $value; // Remove any control characters and normalize line breaks $value = preg_replace('/[\x00-\x1F\x7F]/u', '', (string)$value); return $value; }; // Add check-in marker (draggable if can edit) if ($record->check_in_latitude && $record->check_in_longitude) { $markers[] = [ 'lat' => (float) $record->check_in_latitude, 'lng' => (float) $record->check_in_longitude, 'type' => 'check_in', 'name' => $sanitizeForJson($record->user?->name ?? 'User'), 'time' => $record->check_in_time ? \Carbon\Carbon::parse($record->check_in_time)->format('H:i') : null, 'address' => $sanitizeForJson($record->check_in_address), 'distance' => $record->check_in_distance, 'draggable' => $canEdit, ]; } // Add check-out marker (draggable if can edit) if ($record->check_out_latitude && $record->check_out_longitude) { $markers[] = [ 'lat' => (float) $record->check_out_latitude, 'lng' => (float) $record->check_out_longitude, 'type' => 'check_out', 'name' => $sanitizeForJson($record->user?->name ?? 'User'), 'time' => $record->check_out_time ? \Carbon\Carbon::parse($record->check_out_time)->format('H:i') : null, 'address' => $sanitizeForJson($record->check_out_address), 'distance' => $record->check_out_distance, 'draggable' => $canEdit, ]; } // Add office marker if available if ($record->office && $record->office->latitude && $record->office->longitude) { $offices[] = [ 'lat' => (float) $record->office->latitude, 'lng' => (float) $record->office->longitude, 'name' => $sanitizeForJson($record->office->name), 'address' => $sanitizeForJson($record->office->address), 'radius' => $record->office->radius ?? 100, ]; } $hasLocation = count($markers) > 0; $mapId = 'attendance-map-' . $record->id; $mapIdJs = str_replace('-', '_', $mapId); $initMapFunctionName = 'initMap_' . $mapIdJs; $initSearchFunctionName = 'initSearch_' . $mapIdJs; $saveCoordinatesFunctionName = 'saveCoordinates_' . $mapIdJs; @endphp @if($hasLocation)
Mode Edit: Drag marker atau cari lokasi untuk mengubah koordinat
Tidak ada data lokasi