diff --git a/app.py b/app.py index f289501..6ff9b36 100644 --- a/app.py +++ b/app.py @@ -6197,6 +6197,12 @@ def create_excel_export_ordered(selected_columns, column_names, filters): header_fill = PatternFill(start_color="366092", end_color="366092", fill_type="solid") header_alignment = Alignment(horizontal="center", vertical="center") + # Verification status color fills for location_accuracy column + # Yellow for pending, Green for approved, Red for rejected + verification_fill_pending = PatternFill(start_color="FFFF00", end_color="FFFF00", fill_type="solid") # Yellow + verification_fill_approved = PatternFill(start_color="90EE90", end_color="90EE90", fill_type="solid") # Light Green + verification_fill_rejected = PatternFill(start_color="FF6B6B", end_color="FF6B6B", fill_type="solid") # Light Red + # Set headers based on selected columns in the specified order headers = [] for column_key in selected_columns: @@ -6305,6 +6311,15 @@ def create_excel_export_ordered(selected_columns, column_names, filters): cell.value = attendance_record.accuracy or '' elif column_key == 'location_accuracy': cell.value = attendance_record.location_accuracy or '' + # Apply color fill based on verification_status + # Only apply color if verification_status is not NULL + if hasattr(attendance_record, 'verification_status') and attendance_record.verification_status: + if attendance_record.verification_status == 'pending': + cell.fill = verification_fill_pending # Yellow + elif attendance_record.verification_status == 'approved': + cell.fill = verification_fill_approved # Green + elif attendance_record.verification_status == 'rejected': + cell.fill = verification_fill_rejected # Red else: cell.value = '' except Exception as cell_error: @@ -6329,11 +6344,11 @@ def create_excel_export_ordered(selected_columns, column_names, filters): wb.save(excel_buffer) excel_buffer.seek(0) - print("📊 Excel file created successfully with employee names") + print("📊 Excel file created successfully with employee names and verification status coloring") - # Log export action with employee name column + # Log export action with employee name column and verification status coloring try: - logger_handler.logger.info(f"Excel export with employee names generated by user {session.get('username', 'unknown')}") + logger_handler.logger.info(f"Excel export with employee names and verification status coloring generated by user {session.get('username', 'unknown')}") except Exception as log_error: print(f"⚠️ Logging error (non-critical): {log_error}")