"""
Dashboard Admin Configuration

Admin interface for employee evaluation models.
"""

from django.contrib import admin

from .models import EvaluationNote, ComplaintRequest, ReportCompletion, EscalatedComplaintLog, InquiryDetail


@admin.register(EvaluationNote)
class EvaluationNoteAdmin(admin.ModelAdmin):
    """Admin interface for EvaluationNote model"""

    list_display = ["staff", "category", "sub_category", "count", "note_date", "created_by"]
    list_filter = ["category", "note_date", "created_at"]
    search_fields = ["staff__first_name", "staff__last_name", "description"]
    date_hierarchy = "note_date"
    raw_id_fields = ["staff", "created_by"]


@admin.register(ComplaintRequest)
class ComplaintRequestAdmin(admin.ModelAdmin):
    """Admin interface for ComplaintRequest model"""

    list_display = [
        "staff",
        "patient_name",
        "filled",
        "on_hold",
        "from_barcode",
        "request_date",
        "filling_time_category",
        "reason_non_activation",
        "hospital",
    ]
    list_filter = [
        "filled",
        "on_hold",
        "from_barcode",
        "filling_time_category",
        "reason_non_activation",
        "request_date",
        "hospital",
    ]
    search_fields = ["staff__first_name", "staff__last_name", "patient_name", "file_number", "notes"]
    date_hierarchy = "request_date"
    raw_id_fields = ["staff", "complaint", "hospital", "complained_department"]
    fieldsets = (
        (None, {"fields": ("staff", "complaint", "hospital", "request_date", "request_time")}),
        (
            "Patient Information",
            {"fields": ("patient_name", "file_number", "complained_department", "incident_date", "phone_number")},
        ),
        ("Status", {"fields": ("filled", "on_hold", "not_filled", "from_barcode", "filling_time_category")}),
        ("Timeline", {"fields": ("form_sent_at", "form_sent_time", "filled_at", "filled_time")}),
        ("Non-Activation", {"fields": ("reason_non_activation", "reason_non_activation_other", "pr_observations")}),
        ("Notes", {"fields": ("notes",)}),
    )


@admin.register(ReportCompletion)
class ReportCompletionAdmin(admin.ModelAdmin):
    """Admin interface for ReportCompletion model"""

    list_display = ["staff", "report_type", "is_completed", "week_start_date", "completed_at"]
    list_filter = ["report_type", "is_completed", "week_start_date"]
    search_fields = ["staff__first_name", "staff__last_name"]
    date_hierarchy = "week_start_date"
    raw_id_fields = ["staff"]


@admin.register(EscalatedComplaintLog)
class EscalatedComplaintLogAdmin(admin.ModelAdmin):
    """Admin interface for EscalatedComplaintLog model"""

    list_display = ["staff", "complaint", "escalation_timing", "is_resolved", "escalated_at"]
    list_filter = ["escalation_timing", "is_resolved", "week_start_date"]
    search_fields = ["staff__first_name", "staff__last_name", "resolution_notes"]
    date_hierarchy = "escalated_at"
    raw_id_fields = ["staff", "complaint"]


@admin.register(InquiryDetail)
class InquiryDetailAdmin(admin.ModelAdmin):
    """Admin interface for InquiryDetail model"""

    list_display = ["staff", "inquiry_type", "is_outgoing", "inquiry_date", "response_time_category"]
    list_filter = ["inquiry_type", "is_outgoing", "response_time_category", "inquiry_status", "inquiry_date"]
    search_fields = ["staff__first_name", "staff__last_name", "notes"]
    date_hierarchy = "inquiry_date"
    raw_id_fields = ["staff", "inquiry"]
