Sep 11 - Reupload the code
This commit is contained in:
@@ -0,0 +1,644 @@
|
||||
{% extends "base_authenticated.html" %}
|
||||
{% block title %}Review Duplicate Records - {{ COMPANY_NAME }}{% endblock %}
|
||||
|
||||
{% block extra_head %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/time_attendance.css') }}">
|
||||
<style>
|
||||
.duplicate-review-page {
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.review-summary {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
padding: 2rem;
|
||||
border-radius: 12px;
|
||||
margin-bottom: 2rem;
|
||||
box-shadow: 0 8px 24px rgba(0,0,0,0.15);
|
||||
}
|
||||
|
||||
.summary-stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 1.5rem;
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.stat-box {
|
||||
background: rgba(255,255,255,0.2);
|
||||
padding: 1.5rem;
|
||||
border-radius: 8px;
|
||||
text-align: center;
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.stat-box .number {
|
||||
font-size: 2.5rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.stat-box .label {
|
||||
font-size: 0.875rem;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.duplicates-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.duplicate-item {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
||||
overflow: hidden;
|
||||
border: 2px solid #e2e8f0;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.duplicate-item.selected {
|
||||
border-color: #667eea;
|
||||
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
|
||||
}
|
||||
|
||||
.duplicate-header {
|
||||
background: #f7fafc;
|
||||
padding: 1rem 1.5rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.duplicate-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.duplicate-title h3 {
|
||||
margin: 0;
|
||||
color: #2d3748;
|
||||
font-size: 1.125rem;
|
||||
}
|
||||
|
||||
.row-badge {
|
||||
background: #ed8936;
|
||||
color: white;
|
||||
padding: 0.25rem 0.75rem;
|
||||
border-radius: 20px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.duplicate-actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.duplicate-body {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.comparison-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
.record-card {
|
||||
background: #f8fafc;
|
||||
padding: 1.5rem;
|
||||
border-radius: 8px;
|
||||
border: 2px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.record-card h4 {
|
||||
margin: 0 0 1rem 0;
|
||||
color: #2d3748;
|
||||
font-size: 1rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.record-card.new-record h4 {
|
||||
color: #3182ce;
|
||||
}
|
||||
|
||||
.record-card.existing-record h4 {
|
||||
color: #805ad5;
|
||||
}
|
||||
|
||||
.record-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.detail-row {
|
||||
display: grid;
|
||||
grid-template-columns: 140px 1fr;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.detail-label {
|
||||
color: #718096;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.detail-value {
|
||||
color: #2d3748;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.detail-value.highlight {
|
||||
background: #fef5e7;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 4px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.checkbox-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 1rem;
|
||||
background: #ebf8ff;
|
||||
border-radius: 8px;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.checkbox-container input[type="checkbox"] {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.checkbox-container label {
|
||||
font-weight: 600;
|
||||
color: #2c5282;
|
||||
cursor: pointer;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
margin-top: 2rem;
|
||||
padding: 1.5rem;
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
||||
position: sticky;
|
||||
bottom: 1rem;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.action-buttons .left-actions,
|
||||
.action-buttons .right-actions {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.75rem 1.5rem;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
text-decoration: none;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: linear-gradient(135deg, #667eea, #764ba2);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: #e2e8f0;
|
||||
color: #2d3748;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: #cbd5e0;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: #fc8181;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-danger:hover {
|
||||
background: #f56565;
|
||||
}
|
||||
|
||||
.selection-summary {
|
||||
background: #f0fff4;
|
||||
border: 2px solid #9ae6b4;
|
||||
padding: 1rem;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 1rem;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.selection-summary.visible {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.selection-summary .count {
|
||||
font-weight: 700;
|
||||
color: #22543d;
|
||||
font-size: 1.125rem;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 4rem 2rem;
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.empty-state i {
|
||||
font-size: 4rem;
|
||||
color: #48bb78;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.empty-state h3 {
|
||||
color: #2d3748;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.empty-state p {
|
||||
color: #718096;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.comparison-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.action-buttons .left-actions,
|
||||
.action-buttons .right-actions {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block page_title %}Review Duplicate Records{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="duplicate-review-page">
|
||||
<!-- Page Header -->
|
||||
<div class="time-attendance-header">
|
||||
<div class="header-navigation">
|
||||
<a href="{{ url_for('time_attendance.import_time_attendance') }}" class="back-button">
|
||||
<i class="fas fa-arrow-left"></i>
|
||||
Back to Import
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="header-content">
|
||||
<h1>
|
||||
<i class="fas fa-exclamation-triangle"></i>
|
||||
Review Duplicate Records
|
||||
</h1>
|
||||
<p class="header-description">
|
||||
The following records already exist in the system. Please review and select which ones you want to import anyway.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Summary Section -->
|
||||
<div class="review-summary">
|
||||
<h2 style="margin: 0 0 0.5rem 0;">
|
||||
<i class="fas fa-file-excel"></i>
|
||||
File: {{ filename }}
|
||||
</h2>
|
||||
<p style="margin: 0; opacity: 0.9;">Review duplicate records before importing</p>
|
||||
|
||||
<div class="summary-stats">
|
||||
<div class="stat-box">
|
||||
<div class="number">{{ analysis.total_records }}</div>
|
||||
<div class="label">Total Records in File</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-box">
|
||||
<div class="number">{{ analysis.new_records }}</div>
|
||||
<div class="label">New Records</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-box">
|
||||
<div class="number">{{ analysis.duplicate_records }}</div>
|
||||
<div class="label">Duplicate Records</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Selection Summary -->
|
||||
<div id="selectionSummary" class="selection-summary">
|
||||
<i class="fas fa-check-circle"></i>
|
||||
<span class="count">0</span> duplicate record(s) selected to import
|
||||
</div>
|
||||
|
||||
<!-- Duplicates List -->
|
||||
{% if analysis.duplicate_records > 0 %}
|
||||
<form id="duplicateReviewForm" method="POST" action="{{ url_for('time_attendance.import_time_attendance') }}">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<input type="hidden" name="analyze_duplicates" value="false">
|
||||
<input type="hidden" name="skip_duplicates" value="true">
|
||||
<input type="hidden" name="import_source" value="Import with Duplicates - {{ filename }}">
|
||||
<input type="hidden" name="project_id" value="{{ project_id }}">
|
||||
<input type="hidden" name="from_duplicate_review" value="true">
|
||||
|
||||
<div class="duplicates-container">
|
||||
{% for duplicate in analysis.duplicates %}
|
||||
<div class="duplicate-item" data-hash="{{ duplicate.hash }}">
|
||||
<div class="duplicate-header">
|
||||
<div class="duplicate-title">
|
||||
<span class="row-badge">Row {{ duplicate.row_number }}</span>
|
||||
<h3>{{ duplicate.new_record.employee_name }} (ID: {{ duplicate.new_record.employee_id }})</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="duplicate-body">
|
||||
<div class="comparison-grid">
|
||||
<!-- New Record (from file) -->
|
||||
<div class="record-card new-record">
|
||||
<h4>
|
||||
<i class="fas fa-file-import"></i>
|
||||
New Record (From File)
|
||||
</h4>
|
||||
<div class="record-details">
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Employee ID:</span>
|
||||
<span class="detail-value highlight">{{ duplicate.new_record.employee_id }}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Name:</span>
|
||||
<span class="detail-value">{{ duplicate.new_record.employee_name }}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Date:</span>
|
||||
<span class="detail-value highlight">{{ duplicate.new_record.attendance_date }}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Time:</span>
|
||||
<span class="detail-value highlight">{{ duplicate.new_record.attendance_time }}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Location:</span>
|
||||
<span class="detail-value highlight">{{ duplicate.new_record.location_name }}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Action:</span>
|
||||
<span class="detail-value highlight">{{ duplicate.new_record.action_description }}</span>
|
||||
</div>
|
||||
{% if duplicate.new_record.platform %}
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Platform:</span>
|
||||
<span class="detail-value">{{ duplicate.new_record.platform }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if duplicate.new_record.event_description %}
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Event:</span>
|
||||
<span class="detail-value">{{ duplicate.new_record.event_description }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if duplicate.new_record.recorded_address %}
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Address:</span>
|
||||
<span class="detail-value">{{ duplicate.new_record.recorded_address }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Existing Record (in database) -->
|
||||
<div class="record-card existing-record">
|
||||
<h4>
|
||||
<i class="fas fa-database"></i>
|
||||
Existing Record (In System)
|
||||
</h4>
|
||||
<div class="record-details">
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Employee ID:</span>
|
||||
<span class="detail-value highlight">{{ duplicate.existing_record.employee_id }}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Name:</span>
|
||||
<span class="detail-value">{{ duplicate.existing_record.employee_name }}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Date:</span>
|
||||
<span class="detail-value highlight">{{ duplicate.existing_record.attendance_date }}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Time:</span>
|
||||
<span class="detail-value highlight">{{ duplicate.existing_record.attendance_time }}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Location:</span>
|
||||
<span class="detail-value highlight">{{ duplicate.existing_record.location_name }}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Action:</span>
|
||||
<span class="detail-value highlight">{{ duplicate.existing_record.action_description }}</span>
|
||||
</div>
|
||||
{% if duplicate.existing_record.platform %}
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Platform:</span>
|
||||
<span class="detail-value">{{ duplicate.existing_record.platform }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if duplicate.existing_record.event_description %}
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Event:</span>
|
||||
<span class="detail-value">{{ duplicate.existing_record.event_description }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if duplicate.existing_record.recorded_address %}
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Address:</span>
|
||||
<span class="detail-value">{{ duplicate.existing_record.recorded_address }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Import Date:</span>
|
||||
<span class="detail-value">
|
||||
<i class="fas fa-clock"></i>
|
||||
{{ duplicate.existing_record.import_date.strftime('%Y-%m-%d %H:%M') if duplicate.existing_record.import_date else 'Unknown' }}
|
||||
</span>
|
||||
</div>
|
||||
{% if duplicate.existing_record.import_source %}
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Import Source:</span>
|
||||
<span class="detail-value">{{ duplicate.existing_record.import_source }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Selection Checkbox -->
|
||||
<div class="checkbox-container">
|
||||
<input type="checkbox"
|
||||
id="duplicate_{{ loop.index }}"
|
||||
name="force_import_hashes[]"
|
||||
value="{{ duplicate.hash }}"
|
||||
class="duplicate-checkbox">
|
||||
<label for="duplicate_{{ loop.index }}">
|
||||
Import this duplicate record anyway
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<div class="action-buttons">
|
||||
<div class="left-actions">
|
||||
<a href="{{ url_for('time_attendance.cancel_pending_import') }}" class="btn btn-secondary">
|
||||
<i class="fas fa-times"></i>
|
||||
Cancel Import
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="right-actions">
|
||||
<button type="button" id="selectAllBtn" class="btn btn-secondary">
|
||||
<i class="fas fa-check-square"></i>
|
||||
Select All
|
||||
</button>
|
||||
<button type="button" id="skipAllBtn" class="btn btn-secondary">
|
||||
<i class="fas fa-forward"></i>
|
||||
Skip All Duplicates
|
||||
</button>
|
||||
<button type="submit" class="btn btn-primary" id="proceedBtn">
|
||||
<i class="fas fa-upload"></i>
|
||||
Proceed with Import
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% else %}
|
||||
<div class="empty-state">
|
||||
<i class="fas fa-check-circle"></i>
|
||||
<h3>No Duplicates Found</h3>
|
||||
<p>All records in the file are unique. You can proceed with the import.</p>
|
||||
<a href="{{ url_for('time_attendance.import_time_attendance') }}" class="btn btn-primary" style="margin-top: 1rem;">
|
||||
<i class="fas fa-arrow-left"></i>
|
||||
Back to Import
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Track selected duplicates
|
||||
const checkboxes = document.querySelectorAll('.duplicate-checkbox');
|
||||
const selectionSummary = document.getElementById('selectionSummary');
|
||||
const selectAllBtn = document.getElementById('selectAllBtn');
|
||||
const skipAllBtn = document.getElementById('skipAllBtn');
|
||||
const proceedBtn = document.getElementById('proceedBtn');
|
||||
|
||||
function updateSelectionSummary() {
|
||||
const selectedCount = document.querySelectorAll('.duplicate-checkbox:checked').length;
|
||||
const countSpan = selectionSummary.querySelector('.count');
|
||||
countSpan.textContent = selectedCount;
|
||||
|
||||
if (selectedCount > 0) {
|
||||
selectionSummary.classList.add('visible');
|
||||
} else {
|
||||
selectionSummary.classList.remove('visible');
|
||||
}
|
||||
|
||||
// Update duplicate items visual state
|
||||
document.querySelectorAll('.duplicate-item').forEach(item => {
|
||||
const checkbox = item.querySelector('.duplicate-checkbox');
|
||||
if (checkbox && checkbox.checked) {
|
||||
item.classList.add('selected');
|
||||
} else {
|
||||
item.classList.remove('selected');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Listen to checkbox changes
|
||||
checkboxes.forEach(checkbox => {
|
||||
checkbox.addEventListener('change', updateSelectionSummary);
|
||||
});
|
||||
|
||||
// Select all button
|
||||
if (selectAllBtn) {
|
||||
selectAllBtn.addEventListener('click', () => {
|
||||
checkboxes.forEach(cb => cb.checked = true);
|
||||
updateSelectionSummary();
|
||||
});
|
||||
}
|
||||
|
||||
// Skip all button (uncheck all and submit)
|
||||
if (skipAllBtn) {
|
||||
skipAllBtn.addEventListener('click', () => {
|
||||
if (confirm('This will skip all duplicate records and import only new records. Continue?')) {
|
||||
checkboxes.forEach(cb => cb.checked = false);
|
||||
document.getElementById('duplicateReviewForm').submit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Form submission confirmation
|
||||
if (proceedBtn) {
|
||||
proceedBtn.addEventListener('click', (e) => {
|
||||
const selectedCount = document.querySelectorAll('.duplicate-checkbox:checked').length;
|
||||
const totalDuplicates = checkboxes.length;
|
||||
const newRecordsCount = {{ analysis.new_records }};
|
||||
|
||||
let message = '';
|
||||
if (selectedCount > 0) {
|
||||
message = `You are about to import:\n\n`;
|
||||
message += `- ${newRecordsCount} new record(s)\n`;
|
||||
message += `- ${selectedCount} duplicate record(s)\n`;
|
||||
message += `- Skipping ${totalDuplicates - selectedCount} duplicate(s)\n\n`;
|
||||
message += `Total: ${newRecordsCount + selectedCount} records will be imported.\n\n`;
|
||||
message += `Continue with import?`;
|
||||
} else {
|
||||
message = `You are about to import ${newRecordsCount} new record(s) only.\n\n`;
|
||||
message += `All ${totalDuplicates} duplicate record(s) will be skipped.\n\n`;
|
||||
message += `Continue with import?`;
|
||||
}
|
||||
|
||||
if (!confirm(message)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Initial update
|
||||
updateSelectionSummary();
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user