Update verification review detail with correct info

This commit is contained in:
2025-12-27 10:43:18 -05:00
parent b916907937
commit c32cb40333
2 changed files with 288 additions and 262 deletions
+22 -4
View File
@@ -5552,6 +5552,22 @@ def verification_review_detail(record_id):
# Get the QR code information for additional context # Get the QR code information for additional context
qr_code = QRCode.query.get(record.qr_code_id) if record.qr_code_id else None qr_code = QRCode.query.get(record.qr_code_id) if record.qr_code_id else None
# Get employee name from Employee table
employee_name = None
try:
if record.employee_id:
employee = Employee.query.filter_by(id=int(record.employee_id)).first()
if employee:
employee_name = f"{employee.lastName}, {employee.firstName}"
else:
employee_name = f"Unknown (ID: {record.employee_id})"
except (ValueError, TypeError) as e:
logger_handler.logger.warning(f"Could not lookup employee name for ID {record.employee_id}: {e}")
employee_name = f"Unknown (ID: {record.employee_id})"
# Get event type from QR code (Check In/Check Out)
location_event = qr_code.location_event if qr_code and qr_code.location_event else 'N/A'
# Log the access for audit trail # Log the access for audit trail
logger_handler.logger.info( logger_handler.logger.info(
f"User {session.get('username')} ({session.get('role')}) " f"User {session.get('username')} ({session.get('role')}) "
@@ -5570,10 +5586,12 @@ def verification_review_detail(record_id):
check_in_time = str(record.check_in_time) if record.check_in_time else 'N/A' check_in_time = str(record.check_in_time) if record.check_in_time else 'N/A'
return render_template('verification_review_detail.html', return render_template('verification_review_detail.html',
record=record, record=record,
qr_code=qr_code, qr_code=qr_code,
check_in_date=check_in_date, check_in_date=check_in_date,
check_in_time=check_in_time) check_in_time=check_in_time,
employee_name=employee_name,
location_event=location_event)
except Exception as e: except Exception as e:
logger_handler.logger.error(f"Error loading verification review detail: {e}") logger_handler.logger.error(f"Error loading verification review detail: {e}")
+266 -258
View File
@@ -1,53 +1,50 @@
{% extends "base_authenticated.html" %} {% extends "base_authenticated.html" %} {% block title %}Verification Review -
QR Code Management{% endblock %} {% block extra_head %}
{% block title %}Verification Review - QR Code Management{% endblock %}
{% block extra_head %}
<style> <style>
.verification-review-page { .verification-review-page {
max-width: 1200px; max-width: 1200px;
margin: 0 auto; margin: 0 auto;
padding: 30px 20px; padding: 30px 20px;
} }
.review-header { .review-header {
background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%); background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
color: white; color: white;
padding: 30px; padding: 30px;
border-radius: 12px; border-radius: 12px;
margin-bottom: 30px; margin-bottom: 30px;
box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2); box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
} }
.review-header h1 { .review-header h1 {
margin: 0 0 10px 0; margin: 0 0 10px 0;
font-size: 2rem; font-size: 2rem;
display: flex; display: flex;
align-items: center; align-items: center;
gap: 15px; gap: 15px;
} }
.review-header p { .review-header p {
margin: 0; margin: 0;
opacity: 0.9; opacity: 0.9;
font-size: 1.1rem; font-size: 1.1rem;
} }
.review-content { .review-content {
display: grid; display: grid;
grid-template-columns: 1fr 1fr; grid-template-columns: 1fr 1fr;
gap: 30px; gap: 30px;
margin-bottom: 30px; margin-bottom: 30px;
} }
.review-section { .review-section {
background: white; background: white;
border-radius: 12px; border-radius: 12px;
padding: 25px; padding: 25px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
} }
.review-section h2 { .review-section h2 {
margin: 0 0 20px 0; margin: 0 0 20px 0;
font-size: 1.3rem; font-size: 1.3rem;
color: #1f2937; color: #1f2937;
@@ -56,107 +53,107 @@
gap: 10px; gap: 10px;
padding-bottom: 15px; padding-bottom: 15px;
border-bottom: 2px solid #e5e7eb; border-bottom: 2px solid #e5e7eb;
} }
.info-row { .info-row {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
padding: 12px 0; padding: 12px 0;
border-bottom: 1px solid #f3f4f6; border-bottom: 1px solid #f3f4f6;
} }
.info-row:last-child { .info-row:last-child {
border-bottom: none; border-bottom: none;
} }
.info-label { .info-label {
color: #6b7280; color: #6b7280;
font-weight: 500; font-weight: 500;
text-transform: uppercase; text-transform: uppercase;
font-size: 0.85rem; font-size: 0.85rem;
letter-spacing: 0.5px; letter-spacing: 0.5px;
} }
.info-value { .info-value {
color: #1f2937; color: #1f2937;
font-weight: 600; font-weight: 600;
text-align: right; text-align: right;
} }
.distance-badge { .distance-badge {
display: inline-block; display: inline-block;
padding: 6px 12px; padding: 6px 12px;
border-radius: 6px; border-radius: 6px;
font-weight: 600; font-weight: 600;
font-size: 0.9rem; font-size: 0.9rem;
} }
.distance-high { .distance-high {
background: #fee2e2; background: #fee2e2;
color: #991b1b; color: #991b1b;
} }
.distance-medium { .distance-medium {
background: #fef3c7; background: #fef3c7;
color: #92400e; color: #92400e;
} }
.distance-low { .distance-low {
background: #d1fae5; background: #d1fae5;
color: #065f46; color: #065f46;
} }
.status-badge { .status-badge {
display: inline-block; display: inline-block;
padding: 8px 16px; padding: 8px 16px;
border-radius: 20px; border-radius: 20px;
font-weight: 600; font-weight: 600;
font-size: 0.95rem; font-size: 0.95rem;
} }
.status-pending { .status-pending {
background: #fef3c7; background: #fef3c7;
color: #92400e; color: #92400e;
} }
.status-approved { .status-approved {
background: #d1fae5; background: #d1fae5;
color: #065f46; color: #065f46;
} }
.status-rejected { .status-rejected {
background: #fee2e2; background: #fee2e2;
color: #991b1b; color: #991b1b;
} }
.photo-section { .photo-section {
grid-column: 1 / -1; grid-column: 1 / -1;
} }
.verification-photo { .verification-photo {
max-width: 100%; max-width: 100%;
height: auto; height: auto;
border-radius: 12px; border-radius: 12px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
display: block; display: block;
margin: 20px auto; margin: 20px auto;
} }
.no-photo { .no-photo {
text-align: center; text-align: center;
padding: 60px 20px; padding: 60px 20px;
background: #f9fafb; background: #f9fafb;
border-radius: 12px; border-radius: 12px;
color: #6b7280; color: #6b7280;
} }
.no-photo i { .no-photo i {
font-size: 4rem; font-size: 4rem;
margin-bottom: 20px; margin-bottom: 20px;
color: #d1d5db; color: #d1d5db;
} }
.action-buttons { .action-buttons {
display: flex; display: flex;
gap: 15px; gap: 15px;
justify-content: center; justify-content: center;
@@ -164,9 +161,9 @@
background: white; background: white;
border-radius: 12px; border-radius: 12px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
} }
.action-buttons .btn { .action-buttons .btn {
padding: 14px 40px; padding: 14px 40px;
font-size: 1.1rem; font-size: 1.1rem;
font-weight: 600; font-weight: 600;
@@ -178,263 +175,274 @@
gap: 10px; gap: 10px;
transition: all 0.2s; transition: all 0.2s;
text-decoration: none; text-decoration: none;
} }
.btn-approve { .btn-approve {
background: #10b981; background: #10b981;
color: white; color: white;
} }
.btn-approve:hover { .btn-approve:hover {
background: #059669; background: #059669;
transform: translateY(-2px); transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3); box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3);
} }
.btn-reject { .btn-reject {
background: #ef4444; background: #ef4444;
color: white; color: white;
} }
.btn-reject:hover { .btn-reject:hover {
background: #dc2626; background: #dc2626;
transform: translateY(-2px); transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(239, 68, 68, 0.3); box-shadow: 0 6px 16px rgba(239, 68, 68, 0.3);
} }
.btn-back { .btn-back {
background: #6b7280; background: #6b7280;
color: white; color: white;
} }
.btn-back:hover { .btn-back:hover {
background: #4b5563; background: #4b5563;
transform: translateY(-2px); transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(107, 114, 128, 0.3); box-shadow: 0 6px 16px rgba(107, 114, 128, 0.3);
} }
.alert { .alert {
padding: 15px 20px; padding: 15px 20px;
border-radius: 8px; border-radius: 8px;
margin-bottom: 20px; margin-bottom: 20px;
display: flex; display: flex;
align-items: center; align-items: center;
gap: 10px; gap: 10px;
} }
.alert-warning { .alert-warning {
background: #fef3c7; background: #fef3c7;
color: #92400e; color: #92400e;
border-left: 4px solid #f59e0b; border-left: 4px solid #f59e0b;
} }
.alert-info { .alert-info {
background: #dbeafe; background: #dbeafe;
color: #1e40af; color: #1e40af;
border-left: 4px solid #3b82f6; border-left: 4px solid #3b82f6;
} }
@media (max-width: 768px) { @media (max-width: 768px) {
.review-content { .review-content {
grid-template-columns: 1fr; grid-template-columns: 1fr;
} }
.action-buttons { .action-buttons {
flex-direction: column; flex-direction: column;
} }
.action-buttons .btn { .action-buttons .btn {
width: 100%; width: 100%;
justify-content: center; justify-content: center;
} }
.review-header h1 { .review-header h1 {
font-size: 1.5rem; font-size: 1.5rem;
} }
} }
</style> </style>
{% endblock %} {% endblock %} {% block content %}
{% block content %}
<div class="verification-review-page"> <div class="verification-review-page">
<!-- Header --> <!-- Header -->
<div class="review-header"> <div class="review-header">
<h1> <h1>
<i class="fas fa-camera-retro"></i> <i class="fas fa-camera-retro"></i>
Verification Photo Review Verification Photo Review
</h1> </h1>
<p>Review and approve/reject employee verification photo for off-site check-in</p> <p>
Review and approve/reject employee verification photo for off-site
check-in
</p>
</div>
<!-- Alert for already reviewed records -->
{% if record.verification_status != 'pending' %}
<div class="alert alert-info">
<i class="fas fa-info-circle"></i>
<span
>This verification has already been {{ record.verification_status
}}.</span
>
</div>
{% endif %}
<!-- Review Content -->
<div class="review-content">
<!-- Employee Information -->
<div class="review-section">
<h2>
<i class="fas fa-user"></i>
Employee Information
</h2>
<div class="info-row">
<span class="info-label">Employee ID</span>
<span class="info-value">{{ record.employee_id }}</span>
</div>
<div class="info-row">
<span class="info-label">Employee Name</span>
<span class="info-value">{{ employee_name or 'Unknown' }}</span>
</div>
<div class="info-row">
<span class="info-label">Check-in Date</span>
<span class="info-value">{{ check_in_date }}</span>
</div>
<div class="info-row">
<span class="info-label">Check-in Time</span>
<span class="info-value">{{ check_in_time }}</span>
</div>
<div class="info-row">
<span class="info-label">Status</span>
<span class="info-value">
<span class="status-badge status-{{ record.verification_status }}">
{{ record.verification_status.upper() }}
</span>
</span>
</div>
</div> </div>
<!-- Alert for already reviewed records --> <!-- Location Information -->
{% if record.verification_status != 'pending' %} <div class="review-section">
<div class="alert alert-info"> <h2>
<i class="fas fa-info-circle"></i> <i class="fas fa-map-marker-alt"></i>
<span>This verification has already been {{ record.verification_status }}.</span> Location Information
</div> </h2>
{% endif %} <div class="info-row">
<span class="info-label">Location Name</span>
<!-- Review Content --> <span class="info-value">{{ record.location_name or 'Unknown' }}</span>
<div class="review-content"> </div>
<!-- Employee Information --> <div class="info-row">
<div class="review-section"> <span class="info-label">Event</span>
<h2> <span class="info-value">{{ location_event or 'N/A' }}</span>
<i class="fas fa-user"></i> </div>
Employee Information <div class="info-row">
</h2> <span class="info-label">Distance from QR</span>
<div class="info-row"> <span class="info-value">
<span class="info-label">Employee ID</span> {% if record.location_accuracy %} {% if record.location_accuracy > 0.5
<span class="info-value">{{ record.employee_id }}</span> %}
</div> <span class="distance-badge distance-high"
<div class="info-row"> >{{ "%.3f"|format(record.location_accuracy) }} miles</span
<span class="info-label">Employee Name</span> >
<span class="info-value">{{ record.employee_name or 'Unknown' }}</span> {% elif record.location_accuracy > 0.2 %}
</div> <span class="distance-badge distance-medium"
<div class="info-row"> >{{ "%.3f"|format(record.location_accuracy) }} miles</span
<span class="info-label">Check-in Date</span> >
<span class="info-value">{{ check_in_date }}</span> {% else %}
</div> <span class="distance-badge distance-low"
<div class="info-row"> >{{ "%.3f"|format(record.location_accuracy) }} miles</span
<span class="info-label">Check-in Time</span> >
<span class="info-value">{{ check_in_time }}</span> {% endif %} {% else %} N/A {% endif %}
</div> </span>
<div class="info-row"> </div>
<span class="info-label">Status</span> <div class="info-row">
<span class="info-value"> <span class="info-label">QR Address</span>
<span class="status-badge status-{{ record.verification_status }}"> <span class="info-value"
{{ record.verification_status.upper() }} >{{ qr_code.address if qr_code else 'N/A' }}</span
</span> >
</span> </div>
</div> <div class="info-row">
</div> <span class="info-label">Check-in Address</span>
<span class="info-value">{{ record.address or 'N/A' }}</span>
<!-- Location Information --> </div>
<div class="review-section"> <div class="info-row">
<h2> <span class="info-label">Device</span>
<i class="fas fa-map-marker-alt"></i> <span class="info-value">{{ record.device_info or 'Unknown' }}</span>
Location Information </div>
</h2>
<div class="info-row">
<span class="info-label">Location Name</span>
<span class="info-value">{{ record.location_name or 'Unknown' }}</span>
</div>
<div class="info-row">
<span class="info-label">Event</span>
<span class="info-value">{{ record.location_event or 'N/A' }}</span>
</div>
<div class="info-row">
<span class="info-label">Distance from QR</span>
<span class="info-value">
{% if record.location_accuracy %}
{% if record.location_accuracy > 0.5 %}
<span class="distance-badge distance-high">{{ "%.3f"|format(record.location_accuracy) }} miles</span>
{% elif record.location_accuracy > 0.2 %}
<span class="distance-badge distance-medium">{{ "%.3f"|format(record.location_accuracy) }} miles</span>
{% else %}
<span class="distance-badge distance-low">{{ "%.3f"|format(record.location_accuracy) }} miles</span>
{% endif %}
{% else %}
N/A
{% endif %}
</span>
</div>
<div class="info-row">
<span class="info-label">QR Address</span>
<span class="info-value">{{ qr_code.address if qr_code else 'N/A' }}</span>
</div>
<div class="info-row">
<span class="info-label">Check-in Address</span>
<span class="info-value">{{ record.address or 'N/A' }}</span>
</div>
<div class="info-row">
<span class="info-label">Device</span>
<span class="info-value">{{ record.device_info or 'Unknown' }}</span>
</div>
</div>
<!-- Verification Photo -->
<div class="review-section photo-section">
<h2>
<i class="fas fa-camera"></i>
Verification Photo
</h2>
{% if record.verification_photo %}
<img src="{{ record.verification_photo }}"
alt="Verification Photo for {{ record.employee_id }}"
class="verification-photo">
{% else %}
<div class="no-photo">
<i class="fas fa-image"></i>
<h3>No Photo Available</h3>
<p>This record does not have a verification photo.</p>
</div>
{% endif %}
</div>
</div> </div>
<!-- Action Buttons --> <!-- Verification Photo -->
{% if record.verification_status == 'pending' %} <div class="review-section photo-section">
<div class="action-buttons"> <h2>
<button onclick="updateStatus('approved')" class="btn btn-approve"> <i class="fas fa-camera"></i>
<i class="fas fa-check"></i> Verification Photo
Approve Verification </h2>
</button> {% if record.verification_photo %}
<button onclick="updateStatus('rejected')" class="btn btn-reject"> <img
<i class="fas fa-times"></i> src="{{ record.verification_photo }}"
Reject Verification alt="Verification Photo for {{ record.employee_id }}"
</button> class="verification-photo"
<a href="{{ url_for('attendance_report') }}" class="btn btn-back"> />
<i class="fas fa-arrow-left"></i> {% else %}
Back to Attendance <div class="no-photo">
</a> <i class="fas fa-image"></i>
<h3>No Photo Available</h3>
<p>This record does not have a verification photo.</p>
</div>
{% endif %}
</div> </div>
{% else %} </div>
<div class="action-buttons">
<a href="{{ url_for('attendance_report') }}" class="btn btn-back"> <!-- Action Buttons -->
<i class="fas fa-arrow-left"></i> {% if record.verification_status == 'pending' %}
Back to Attendance <div class="action-buttons">
</a> <button onclick="updateStatus('approved')" class="btn btn-approve">
</div> <i class="fas fa-check"></i>
{% endif %} Approve Verification
</button>
<button onclick="updateStatus('rejected')" class="btn btn-reject">
<i class="fas fa-times"></i>
Reject Verification
</button>
<a href="{{ url_for('attendance_report') }}" class="btn btn-back">
<i class="fas fa-arrow-left"></i>
Back to Attendance
</a>
</div>
{% else %}
<div class="action-buttons">
<a href="{{ url_for('attendance_report') }}" class="btn btn-back">
<i class="fas fa-arrow-left"></i>
Back to Attendance
</a>
</div>
{% endif %}
</div> </div>
<script> <script>
function updateStatus(status) { function updateStatus(status) {
const confirmMessage = status === 'approved' const confirmMessage = status === 'approved'
? 'Are you sure you want to APPROVE this verification?' ? 'Are you sure you want to APPROVE this verification?'
: 'Are you sure you want to REJECT this verification?'; : 'Are you sure you want to REJECT this verification?';
if (!confirm(confirmMessage)) { if (!confirm(confirmMessage)) {
return; return;
} }
console.log(`[LOG] Updating verification status to ${status} for record {{ record.id }}`); console.log(`[LOG] Updating verification status to ${status} for record {{ record.id }}`);
// Send update request // Send update request
fetch('/verification-review/{{ record.id }}/update', { fetch('/verification-review/{{ record.id }}/update', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
body: JSON.stringify({ body: JSON.stringify({
status: status status: status
}) })
}) })
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
if (data.success) { if (data.success) {
console.log(`[LOG] Successfully updated verification status to ${status}`); console.log(`[LOG] Successfully updated verification status to ${status}`);
alert(`Verification ${status} successfully!`); alert(`Verification ${status} successfully!`);
// Redirect back to attendance report // Redirect back to attendance report
window.location.href = '{{ url_for('attendance_report') }}'; window.location.href = '{{ url_for('attendance_report') }}';
} else { } else {
throw new Error(data.message || 'Failed to update verification status'); throw new Error(data.message || 'Failed to update verification status');
} }
}) })
.catch(error => { .catch(error => {
console.error('[ERROR] Failed to update verification status:', error); console.error('[ERROR] Failed to update verification status:', error);
alert(`Error: ${error.message}`); alert(`Error: ${error.message}`);
}); });
} }
</script> </script>
{% endblock %} {% endblock %}