# ADDITIVE: Django admin for Timesheet models
from django.contrib import admin

from . import models as m


@admin.register(m.TimesheetProject)
class TimesheetProjectAdmin(admin.ModelAdmin):
    list_display = ("id", "company", "code", "title", "client_department", "status", "budget_hours", "is_billable", "is_active")
    list_filter = ("company", "status", "is_billable", "is_active")
    search_fields = ("code", "title", "client_department")


@admin.register(m.ProjectAllocation)
class ProjectAllocationAdmin(admin.ModelAdmin):
    list_display = ("id", "company", "project", "employee", "role", "allocation_percent", "start_date", "end_date", "is_active")
    list_filter = ("company", "project", "is_active")
    search_fields = ("employee__name", "employee__employee_code", "project__title")


@admin.register(m.TimesheetEntry)
class TimesheetEntryAdmin(admin.ModelAdmin):
    list_display = ("id", "company", "work_date", "employee", "project", "hours", "overtime_hours", "status", "approver_code", "is_active")
    list_filter = ("company", "status", "project", "is_billable", "is_active")
    search_fields = ("employee__name", "employee__employee_code", "task_summary")
    date_hierarchy = "work_date"


@admin.register(m.OvertimeClaim)
class OvertimeClaimAdmin(admin.ModelAdmin):
    list_display = ("id", "company", "employee", "month", "year", "approved_hours", "hourly_rate", "calculated_pay", "status", "approver_code")
    list_filter = ("company", "status", "year", "month")
    search_fields = ("employee__name", "employee__employee_code")


@admin.register(m.TimesheetSetting)
class TimesheetSettingAdmin(admin.ModelAdmin):
    list_display = ("id", "company", "standard_daily_hours", "max_daily_hours", "auto_overtime", "overtime_multiplier", "enforce_allocation")
