Update location coordinates precision
This commit is contained in:
@@ -90,7 +90,7 @@ class QRCode(db.Model):
|
|||||||
def coordinates_display(self):
|
def coordinates_display(self):
|
||||||
"""Get formatted coordinates for display"""
|
"""Get formatted coordinates for display"""
|
||||||
if self.has_coordinates:
|
if self.has_coordinates:
|
||||||
return f"{self.address_latitude:.6f}, {self.address_longitude:.6f}"
|
return f"{self.address_latitude:.8f}, {self.address_longitude:.8f}"
|
||||||
return "Coordinates not available"
|
return "Coordinates not available"
|
||||||
|
|
||||||
def update_coordinates(self, latitude, longitude, accuracy='geocoded'):
|
def update_coordinates(self, latitude, longitude, accuracy='geocoded'):
|
||||||
@@ -155,7 +155,7 @@ class AttendanceData(db.Model):
|
|||||||
def coordinates_display(self):
|
def coordinates_display(self):
|
||||||
"""Get formatted coordinates for display"""
|
"""Get formatted coordinates for display"""
|
||||||
if self.has_location_data:
|
if self.has_location_data:
|
||||||
return f"{self.latitude:.6f}, {self.longitude:.6f}"
|
return f"{self.latitude:.8f}, {self.longitude:.8f}"
|
||||||
return "No GPS data"
|
return "No GPS data"
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
@@ -268,7 +268,7 @@ def get_coordinates_from_address_enhanced(address):
|
|||||||
accuracy = 'poor'
|
accuracy = 'poor'
|
||||||
|
|
||||||
print(f"✅ Enhanced geocoding successful:")
|
print(f"✅ Enhanced geocoding successful:")
|
||||||
print(f" Coordinates: {lat:.6f}, {lng:.6f}")
|
print(f" Coordinates: {lat:.8f}, {lng:.8f}")
|
||||||
print(f" Accuracy: {accuracy}")
|
print(f" Accuracy: {accuracy}")
|
||||||
|
|
||||||
return lat, lng, accuracy
|
return lat, lng, accuracy
|
||||||
@@ -324,7 +324,7 @@ def geocode_address_enhanced(address):
|
|||||||
accuracy = 'low'
|
accuracy = 'low'
|
||||||
|
|
||||||
print(f"✅ Geocoded address: {address}")
|
print(f"✅ Geocoded address: {address}")
|
||||||
print(f" Coordinates: {lat:.6f}, {lng:.6f}")
|
print(f" Coordinates: {lat:.8f}, {lng:.8f}")
|
||||||
print(f" Accuracy: {accuracy} ({place_type})")
|
print(f" Accuracy: {accuracy} ({place_type})")
|
||||||
|
|
||||||
return lat, lng, accuracy
|
return lat, lng, accuracy
|
||||||
@@ -376,8 +376,8 @@ def calculate_distance_miles(lat1, lng1, lat2, lng2):
|
|||||||
distance = round(distance, 4)
|
distance = round(distance, 4)
|
||||||
|
|
||||||
print(f"📏 Enhanced distance calculation:")
|
print(f"📏 Enhanced distance calculation:")
|
||||||
print(f" Point 1: {lat1*180/3.14159:.6f}, {lng1*180/3.14159:.6f}")
|
print(f" Point 1: {lat1*180/3.14159:.8f}, {lng1*180/3.14159:.8f}")
|
||||||
print(f" Point 2: {lat2*180/3.14159:.6f}, {lng2*180/3.14159:.6f}")
|
print(f" Point 2: {lat2*180/3.14159:.8f}, {lng2*180/3.14159:.8f}")
|
||||||
print(f" Distance: {distance:.4f} miles")
|
print(f" Distance: {distance:.4f} miles")
|
||||||
|
|
||||||
return distance
|
return distance
|
||||||
@@ -455,7 +455,7 @@ def calculate_location_accuracy_enhanced(qr_address, checkin_address, checkin_la
|
|||||||
print(f"❌ Could not geocode QR address: {qr_address}")
|
print(f"❌ Could not geocode QR address: {qr_address}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
print(f"✅ QR location coordinates: {qr_lat:.6f}, {qr_lng:.6f} (accuracy: {qr_accuracy})")
|
print(f"✅ QR location coordinates: {qr_lat:.8f}, {qr_lng:.8f} (accuracy: {qr_accuracy})")
|
||||||
|
|
||||||
# Step 2: Determine check-in coordinates
|
# Step 2: Determine check-in coordinates
|
||||||
print(f"\n📱 Step 2: Determining check-in coordinates...")
|
print(f"\n📱 Step 2: Determining check-in coordinates...")
|
||||||
@@ -475,7 +475,7 @@ def calculate_location_accuracy_enhanced(qr_address, checkin_address, checkin_la
|
|||||||
checkin_coords_lat = lat_val
|
checkin_coords_lat = lat_val
|
||||||
checkin_coords_lng = lng_val
|
checkin_coords_lng = lng_val
|
||||||
checkin_source = "gps"
|
checkin_source = "gps"
|
||||||
print(f"✅ Using GPS coordinates: {lat_val:.6f}, {lng_val:.6f}")
|
print(f"✅ Using GPS coordinates: {lat_val:.8f}, {lng_val:.8f}")
|
||||||
else:
|
else:
|
||||||
print(f"⚠️ Invalid GPS coordinates: {lat_val}, {lng_val}")
|
print(f"⚠️ Invalid GPS coordinates: {lat_val}, {lng_val}")
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
@@ -487,7 +487,7 @@ def calculate_location_accuracy_enhanced(qr_address, checkin_address, checkin_la
|
|||||||
checkin_coords_lat, checkin_coords_lng, checkin_accuracy = get_coordinates_from_address_enhanced(checkin_address)
|
checkin_coords_lat, checkin_coords_lng, checkin_accuracy = get_coordinates_from_address_enhanced(checkin_address)
|
||||||
if checkin_coords_lat is not None:
|
if checkin_coords_lat is not None:
|
||||||
checkin_source = "address"
|
checkin_source = "address"
|
||||||
print(f"✅ Using geocoded coordinates: {checkin_coords_lat:.6f}, {checkin_coords_lng:.6f} (accuracy: {checkin_accuracy})")
|
print(f"✅ Using geocoded coordinates: {checkin_coords_lat:.8f}, {checkin_coords_lng:.8f} (accuracy: {checkin_accuracy})")
|
||||||
|
|
||||||
# Check if we have valid coordinates for both locations
|
# Check if we have valid coordinates for both locations
|
||||||
if checkin_coords_lat is None or checkin_coords_lng is None:
|
if checkin_coords_lat is None or checkin_coords_lng is None:
|
||||||
@@ -502,8 +502,8 @@ def calculate_location_accuracy_enhanced(qr_address, checkin_address, checkin_la
|
|||||||
|
|
||||||
if distance is not None:
|
if distance is not None:
|
||||||
print(f"✅ Enhanced location accuracy calculated successfully!")
|
print(f"✅ Enhanced location accuracy calculated successfully!")
|
||||||
print(f" QR Location: {qr_lat:.6f}, {qr_lng:.6f}")
|
print(f" QR Location: {qr_lat:.8f}, {qr_lng:.8f}")
|
||||||
print(f" Check-in Location: {checkin_coords_lat:.6f}, {checkin_coords_lng:.6f}")
|
print(f" Check-in Location: {checkin_coords_lat:.8f}, {checkin_coords_lng:.8f}")
|
||||||
print(f" Source: {checkin_source}")
|
print(f" Source: {checkin_source}")
|
||||||
print(f" Distance: {distance:.4f} miles")
|
print(f" Distance: {distance:.4f} miles")
|
||||||
print(f" Accuracy Level: {get_location_accuracy_level_enhanced(distance)}")
|
print(f" Accuracy Level: {get_location_accuracy_level_enhanced(distance)}")
|
||||||
@@ -1322,7 +1322,7 @@ def geocode_address():
|
|||||||
'latitude': lat,
|
'latitude': lat,
|
||||||
'longitude': lng,
|
'longitude': lng,
|
||||||
'accuracy': accuracy,
|
'accuracy': accuracy,
|
||||||
'coordinates_display': f"{lat:.6f}, {lng:.6f}"
|
'coordinates_display': f"{lat:.8f}, {lng:.8f}"
|
||||||
},
|
},
|
||||||
'message': f'Address geocoded successfully with {accuracy} accuracy'
|
'message': f'Address geocoded successfully with {accuracy} accuracy'
|
||||||
})
|
})
|
||||||
@@ -1680,7 +1680,7 @@ def create_qr_code():
|
|||||||
new_qr_code.address_longitude = lng
|
new_qr_code.address_longitude = lng
|
||||||
new_qr_code.coordinate_accuracy = coordinate_accuracy
|
new_qr_code.coordinate_accuracy = coordinate_accuracy
|
||||||
new_qr_code.coordinates_updated_date = datetime.utcnow()
|
new_qr_code.coordinates_updated_date = datetime.utcnow()
|
||||||
print(f"✅ Added coordinates to QR code: {lat:.6f}, {lng:.6f}")
|
print(f"✅ Added coordinates to QR code: {lat:.8f}, {lng:.8f}")
|
||||||
except (ValueError, TypeError) as e:
|
except (ValueError, TypeError) as e:
|
||||||
print(f"⚠️ Invalid coordinates provided: {e}")
|
print(f"⚠️ Invalid coordinates provided: {e}")
|
||||||
|
|
||||||
@@ -1745,7 +1745,7 @@ def edit_qr_code(qr_id):
|
|||||||
qr_code.address_longitude = lng
|
qr_code.address_longitude = lng
|
||||||
qr_code.coordinate_accuracy = coordinate_accuracy
|
qr_code.coordinate_accuracy = coordinate_accuracy
|
||||||
qr_code.coordinates_updated_date = datetime.utcnow()
|
qr_code.coordinates_updated_date = datetime.utcnow()
|
||||||
print(f"✅ Updated coordinates for QR code: {lat:.6f}, {lng:.6f}")
|
print(f"✅ Updated coordinates for QR code: {lat:.8f}, {lng:.8f}")
|
||||||
except (ValueError, TypeError) as e:
|
except (ValueError, TypeError) as e:
|
||||||
print(f"⚠️ Invalid coordinates provided during edit: {e}")
|
print(f"⚠️ Invalid coordinates provided during edit: {e}")
|
||||||
|
|
||||||
@@ -2242,7 +2242,7 @@ def attendance_report():
|
|||||||
'gps_accuracy': gps_accuracy,
|
'gps_accuracy': gps_accuracy,
|
||||||
'accuracy_level': get_location_accuracy_level(location_accuracy) if location_accuracy else 'unknown',
|
'accuracy_level': get_location_accuracy_level(location_accuracy) if location_accuracy else 'unknown',
|
||||||
'has_location_data': record.latitude is not None and record.longitude is not None,
|
'has_location_data': record.latitude is not None and record.longitude is not None,
|
||||||
'coordinates': f"{record.latitude:.6f}, {record.longitude:.6f}" if record.latitude and record.longitude else "No GPS data",
|
'coordinates': f"{record.latitude:.8f}, {record.longitude:.8f}" if record.latitude and record.longitude else "No GPS data",
|
||||||
'has_location_accuracy_feature': has_location_accuracy
|
'has_location_accuracy_feature': has_location_accuracy
|
||||||
}
|
}
|
||||||
processed_records.append(record_dict)
|
processed_records.append(record_dict)
|
||||||
|
|||||||
@@ -268,6 +268,13 @@ body {
|
|||||||
margin-top: 0.25rem;
|
margin-top: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form-actions {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
/* Button Styles - Light Theme */
|
/* Button Styles - Light Theme */
|
||||||
.btn {
|
.btn {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
|
|||||||
@@ -459,8 +459,8 @@ function ensureLocationFormFields() {
|
|||||||
|
|
||||||
function updateLocationFormFields() {
|
function updateLocationFormFields() {
|
||||||
const fields = {
|
const fields = {
|
||||||
latitude: userLocation.latitude ? userLocation.latitude.toFixed(6) : "",
|
latitude: userLocation.latitude ? userLocation.latitude.toFixed(8) : "",
|
||||||
longitude: userLocation.longitude ? userLocation.longitude.toFixed(6) : "",
|
longitude: userLocation.longitude ? userLocation.longitude.toFixed(8) : "",
|
||||||
accuracy: userLocation.accuracy || "",
|
accuracy: userLocation.accuracy || "",
|
||||||
altitude: userLocation.altitude || "",
|
altitude: userLocation.altitude || "",
|
||||||
locationSource: userLocation.source || "manual",
|
locationSource: userLocation.source || "manual",
|
||||||
@@ -493,8 +493,8 @@ function submitCheckin(employeeId) {
|
|||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("employee_id", employeeId);
|
formData.append("employee_id", employeeId);
|
||||||
formData.append("latitude", userLocation.latitude ? userLocation.latitude.toFixed(6) : "");
|
formData.append("latitude", userLocation.latitude ? userLocation.latitude.toFixed(8) : "");
|
||||||
formData.append("longitude", userLocation.longitude ? userLocation.longitude.toFixed(6) : "");
|
formData.append("longitude", userLocation.longitude ? userLocation.longitude.toFixed(8) : "");
|
||||||
formData.append("accuracy", userLocation.accuracy || "");
|
formData.append("accuracy", userLocation.accuracy || "");
|
||||||
formData.append("altitude", userLocation.altitude || "");
|
formData.append("altitude", userLocation.altitude || "");
|
||||||
formData.append("location_source", userLocation.source || "manual");
|
formData.append("location_source", userLocation.source || "manual");
|
||||||
|
|||||||
@@ -719,8 +719,8 @@
|
|||||||
const clearBtn = document.getElementById("clearCoordinatesBtn");
|
const clearBtn = document.getElementById("clearCoordinatesBtn");
|
||||||
|
|
||||||
if (coordinatesData.latitude && coordinatesData.longitude) {
|
if (coordinatesData.latitude && coordinatesData.longitude) {
|
||||||
latDisplay.textContent = coordinatesData.latitude.toFixed(6);
|
latDisplay.textContent = coordinatesData.latitude.toFixed(8);
|
||||||
lngDisplay.textContent = coordinatesData.longitude.toFixed(6);
|
lngDisplay.textContent = coordinatesData.longitude.toFixed(8);
|
||||||
clearBtn.style.display = "inline-flex";
|
clearBtn.style.display = "inline-flex";
|
||||||
} else {
|
} else {
|
||||||
latDisplay.textContent = "---.------";
|
latDisplay.textContent = "---.------";
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
||||||
<meta name="robots" content="noindex, nofollow">
|
<meta name="robots" content="noindex, nofollow">
|
||||||
<style>
|
<style>
|
||||||
/* Additional styles for location tracking - PRESERVED FROM ORIGINAL */
|
/* Additional styles for location tracking */
|
||||||
.location-status {
|
.location-status {
|
||||||
background: #f8f9fa;
|
background: #f8f9fa;
|
||||||
border: 1px solid #dee2e6;
|
border: 1px solid #dee2e6;
|
||||||
@@ -216,7 +216,7 @@
|
|||||||
background: #545b62;
|
background: #545b62;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Language Selector Styles - ENHANCED */
|
/* Language Selector Styles */
|
||||||
.language-selector {
|
.language-selector {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 1rem;
|
top: 1rem;
|
||||||
@@ -260,7 +260,7 @@
|
|||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Smooth transitions - SIMPLIFIED */
|
/* Smooth transitions */
|
||||||
.fade-transition {
|
.fade-transition {
|
||||||
transition: opacity 0.15s ease;
|
transition: opacity 0.15s ease;
|
||||||
}
|
}
|
||||||
@@ -283,7 +283,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="destination-container">
|
<div class="destination-container">
|
||||||
<!-- Language Selector - ENHANCED -->
|
<!-- Language Selector -->
|
||||||
<div class="language-selector">
|
<div class="language-selector">
|
||||||
<button id="languageToggle" class="language-toggle" type="button" aria-label="Switch Language">
|
<button id="languageToggle" class="language-toggle" type="button" aria-label="Switch Language">
|
||||||
<i class="fas fa-globe"></i>
|
<i class="fas fa-globe"></i>
|
||||||
@@ -308,13 +308,13 @@
|
|||||||
<div class="checkin-header">
|
<div class="checkin-header">
|
||||||
<h2>
|
<h2>
|
||||||
<i class="fas fa-user-check"></i>
|
<i class="fas fa-user-check"></i>
|
||||||
<span data-en="Staff Check-In" data-es="Registro de Personal">Staff Check-In</span>
|
<span data-en="Attendance Tracking" data-es="Seguimiento de asistencia">Attendance Tracking</span>
|
||||||
</h2>
|
</h2>
|
||||||
<p data-en="Please enter your Employee ID to check in" data-es="Por favor ingrese su ID de Empleado para registrarse">Please enter your Employee ID to check in</p>
|
<p data-en="Please enter your Employee ID to check in" data-es="Por favor ingrese su ID de Empleado para registrarse">Please enter your Employee ID to check in</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form id="checkinForm" class="checkin-form">
|
<form id="checkinForm" class="checkin-form">
|
||||||
<!-- HIDDEN LOCATION FIELDS - PRESERVED FROM ORIGINAL -->
|
<!-- HIDDEN LOCATION FIELDS -->
|
||||||
<input type="hidden" id="latitude" name="latitude">
|
<input type="hidden" id="latitude" name="latitude">
|
||||||
<input type="hidden" id="longitude" name="longitude">
|
<input type="hidden" id="longitude" name="longitude">
|
||||||
<input type="hidden" id="accuracy" name="accuracy">
|
<input type="hidden" id="accuracy" name="accuracy">
|
||||||
@@ -347,7 +347,7 @@
|
|||||||
<button type="submit" class="btn btn-primary">
|
<button type="submit" class="btn btn-primary">
|
||||||
<span class="btn-content">
|
<span class="btn-content">
|
||||||
<i class="fas fa-check"></i>
|
<i class="fas fa-check"></i>
|
||||||
<span data-en="Check In Now" data-es="Registrarse Ahora">Check In Now</span>
|
<span data-en="Submit" data-es="Someter">Submit</span>
|
||||||
</span>
|
</span>
|
||||||
<div class="btn-loader" style="display: none;">
|
<div class="btn-loader" style="display: none;">
|
||||||
<i class="fas fa-spinner fa-spin"></i>
|
<i class="fas fa-spinner fa-spin"></i>
|
||||||
@@ -368,14 +368,14 @@
|
|||||||
<div class="success-icon">
|
<div class="success-icon">
|
||||||
<i class="fas fa-check-circle"></i>
|
<i class="fas fa-check-circle"></i>
|
||||||
</div>
|
</div>
|
||||||
<h2 data-en="Check-In Successful!" data-es="¡Registro Exitoso!">Check-In Successful!</h2>
|
<h2 data-en="Submitted Successful!" data-es="Enviado exitosamente!">Submitted Successful!</h2>
|
||||||
<div class="success-details">
|
<div class="success-details">
|
||||||
<div class="success-item">
|
<div class="success-item">
|
||||||
<strong data-en="Employee ID:" data-es="ID de Empleado:">Employee ID:</strong>
|
<strong data-en="Employee ID:" data-es="ID de Empleado:">Employee ID:</strong>
|
||||||
<span id="successEmployeeId">-</span>
|
<span id="successEmployeeId">-</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="success-item">
|
<div class="success-item">
|
||||||
<strong data-en="Location:" data-es="Ubicación:">Location:</strong>
|
<strong data-en="Location/Building:" data-es="Ubicación/Edificio:">Location/Building:</strong>
|
||||||
<span id="successLocation">-</span>
|
<span id="successLocation">-</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="success-item">
|
<div class="success-item">
|
||||||
@@ -390,7 +390,7 @@
|
|||||||
<strong data-en="Date:" data-es="Fecha:">Date:</strong>
|
<strong data-en="Date:" data-es="Fecha:">Date:</strong>
|
||||||
<span id="successDate">-</span>
|
<span id="successDate">-</span>
|
||||||
</div>
|
</div>
|
||||||
<!-- LOCATION SUCCESS INFO - PRESERVED FROM ORIGINAL -->
|
<!-- LOCATION SUCCESS INFO -->
|
||||||
<div class="success-item" id="successLocationInfo" style="display: none;">
|
<div class="success-item" id="successLocationInfo" style="display: none;">
|
||||||
<strong data-en="GPS Location:" data-es="Ubicación GPS:">GPS Location:</strong>
|
<strong data-en="GPS Location:" data-es="Ubicación GPS:">GPS Location:</strong>
|
||||||
<span id="successGpsInfo">-</span>
|
<span id="successGpsInfo">-</span>
|
||||||
@@ -426,7 +426,7 @@
|
|||||||
<!-- Load the JavaScript -->
|
<!-- Load the JavaScript -->
|
||||||
<script src="{{ url_for('static', filename='js/qr_destination.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/qr_destination.js') }}"></script>
|
||||||
<script>
|
<script>
|
||||||
// Initialize page with QR code URL (PRESERVED FROM ORIGINAL)
|
// Initialize page with QR code URL
|
||||||
window.qrUrl = '{{ qr_code.qr_url }}';
|
window.qrUrl = '{{ qr_code.qr_url }}';
|
||||||
window.locationName = '{{ qr_code.location }}';
|
window.locationName = '{{ qr_code.location }}';
|
||||||
window.eventName = '{{ qr_code.location_event }}';
|
window.eventName = '{{ qr_code.location_event }}';
|
||||||
|
|||||||
Reference in New Issue
Block a user