from django.contrib import admin
from .models import Department, JobPosition, Employee, Attendance, LeaveRequest, BiometricDevice

@admin.register(Department)
class DepartmentAdmin(admin.ModelAdmin):
    list_display = ('name_en', 'name_ar')

@admin.register(JobPosition)
class JobPositionAdmin(admin.ModelAdmin):
    list_display = ('title_en', 'title_ar', 'department')
    list_filter = ('department',)

@admin.register(Employee)
class EmployeeAdmin(admin.ModelAdmin):
    list_display = ('first_name', 'last_name', 'biometric_id', 'email', 'department', 'job_position', 'status')
    list_filter = ('status', 'department', 'gender')
    search_fields = ('first_name', 'last_name', 'email', 'phone', 'biometric_id')
    ordering = ('first_name', 'last_name')

@admin.register(Attendance)
class AttendanceAdmin(admin.ModelAdmin):
    list_display = ('employee', 'date', 'check_in', 'check_out', 'device')
    list_filter = ('date', 'employee', 'device')

@admin.register(LeaveRequest)
class LeaveRequestAdmin(admin.ModelAdmin):
    list_display = ('employee', 'leave_type', 'start_date', 'end_date', 'status')
    list_filter = ('status', 'leave_type')
    list_editable = ('status',)

@admin.register(BiometricDevice)
class BiometricDeviceAdmin(admin.ModelAdmin):
    list_display = ('name', 'ip_address', 'port', 'device_type', 'status', 'last_sync')
    list_filter = ('status', 'device_type')
    search_fields = ('name', 'ip_address')
