Removed CSV export functionality

This commit is contained in:
2025-12-03 14:39:36 -05:00
parent 78cbe4839f
commit 7ae7baba10
2 changed files with 6 additions and 95 deletions
+2 -66
View File
@@ -7970,8 +7970,7 @@ def download_import_template():
def export_time_attendance(): def export_time_attendance():
"""Export time attendance records to CSV or Excel""" """Export time attendance records to CSV or Excel"""
try: try:
# Get export format (default to CSV) export_format = request.args.get('format', 'excel').lower()
export_format = request.args.get('format', 'csv').lower()
# Get filter parameters (same as records page) # Get filter parameters (same as records page)
employee_filter = request.args.get('employee_id') employee_filter = request.args.get('employee_id')
@@ -8079,11 +8078,7 @@ def export_time_attendance():
filter_str = "_".join(filter_desc) if filter_desc else "all" filter_str = "_".join(filter_desc) if filter_desc else "all"
# Export based on format return export_time_attendance_excel(records, project_name_for_filename, date_range_str, filter_str, start_date, end_date)
if export_format == 'excel' or export_format == 'xlsx':
return export_time_attendance_excel(records, project_name_for_filename, date_range_str, filter_str, start_date, end_date)
else:
return export_time_attendance_csv(records, project_name_for_filename, date_range_str, filter_str)
except Exception as e: except Exception as e:
logger_handler.logger.error(f"Error exporting time attendance records: {e}") logger_handler.logger.error(f"Error exporting time attendance records: {e}")
@@ -8091,57 +8086,6 @@ def export_time_attendance():
return redirect(url_for('time_attendance_records')) return redirect(url_for('time_attendance_records'))
def export_time_attendance_csv(records, project_name_for_filename, date_range_str, filter_str):
"""Generate CSV export of time attendance records"""
import csv
import io
# Create CSV in memory
output = io.StringIO()
writer = csv.writer(output)
# Write header
writer.writerow([
'Employee ID',
'Employee Name',
'Platform',
'Date',
'Time',
'Location Name',
'Action Description',
'Event Description',
'Recorded Address'
])
# Write data rows
for record in records:
writer.writerow([
record.employee_id,
record.employee_name,
record.platform or '',
record.attendance_date.strftime('%Y-%m-%d') if record.attendance_date else '',
record.attendance_time.strftime('%H:%M:%S') if record.attendance_time else '',
record.location_name,
record.action_description,
record.event_description or '',
record.recorded_address or ''
])
# Prepare response with new filename format
output.seek(0)
if date_range_str:
filename = f'{project_name_for_filename}time_attendance_{date_range_str}.csv'
else:
filename = f'{project_name_for_filename}time_attendance.csv'
return Response(
output.getvalue(),
mimetype='text/csv',
headers={
'Content-Disposition': f'attachment; filename={filename}'
}
)
def calculate_possible_violation(distance_value): def calculate_possible_violation(distance_value):
""" """
Calculate possible violation status based on distance Calculate possible violation status based on distance
@@ -8802,14 +8746,6 @@ def export_time_attendance_excel(records, project_name_for_filename, date_range_
download_name=filename download_name=filename
) )
@app.route('/time-attendance/export/quick-csv')
@login_required
@log_user_activity('time_attendance_quick_csv_export')
def quick_csv_export_time_attendance():
"""Quick CSV export with current page filters"""
# Redirect to main export with CSV format
return redirect(url_for('export_time_attendance', format='csv', **request.args))
@app.route('/time-attendance/export/excel') @app.route('/time-attendance/export/excel')
@login_required @login_required
@log_user_activity('time_attendance_excel_export') @log_user_activity('time_attendance_excel_export')
+4 -29
View File
@@ -33,23 +33,10 @@
Import Data Import Data
</a> </a>
{% endif %} {% endif %}
<div class="export-dropdown-wrapper"> <button class="btn btn-secondary" onclick="exportRecords('excel')">
<button class="btn btn-secondary" onclick="toggleExportMenu(event)"> <i class="fas fa-file-excel"></i>
<i class="fas fa-download"></i> Export to Excel
Export </button>
<i class="fas fa-chevron-down" style="margin-left: 0.5rem; font-size: 0.75rem;"></i>
</button>
<div class="export-dropdown-menu" id="exportMenu" style="display: none;">
<button type="button" onclick="exportRecords('excel')" class="export-option">
<i class="fas fa-file-excel" style="color: #10b981;"></i>
<span>Export to Excel</span>
</button>
<button type="button" onclick="exportRecords('csv')" class="export-option">
<i class="fas fa-file-csv" style="color: #3b82f6;"></i>
<span>Export to CSV</span>
</button>
</div>
</div>
</div> </div>
</div> </div>
@@ -379,19 +366,7 @@ function confirmDelete(recordId, employeeName, date) {
} }
} }
function toggleExportMenu(event) {
event.stopPropagation();
const menu = document.getElementById('exportMenu');
const isVisible = menu.style.display === 'block';
// Close menu if open, open if closed
menu.style.display = isVisible ? 'none' : 'block';
}
function exportRecords(format) { function exportRecords(format) {
// Close the dropdown menu
document.getElementById('exportMenu').style.display = 'none';
// Get current filter values // Get current filter values
const employeeId = document.querySelector('select[name="employee_id"]')?.value || ''; const employeeId = document.querySelector('select[name="employee_id"]')?.value || '';
const locationName = document.querySelector('select[name="location_name"]')?.value || ''; const locationName = document.querySelector('select[name="location_name"]')?.value || '';