from django.contrib import admin
from controle_app.models import ProcesVerbal, Participant, ElementOuvrage, PointControle, ControleResultat,Ouvrage,Client,Projets,TypePV

@admin.register(ProcesVerbal)
class ProcesVerbalAdmin(admin.ModelAdmin):
    list_display = ['numero', 'type_pv', 'client', 'date_visite', 'objet_controle', 'lieu', 'observations_generales', 'date_creation', 'date_modification', 'createur']
    list_filter = ['numero', 'date_creation']
    search_fields = ['numero', 'objet_controle', 'lieu']

@admin.register(Participant)
class ParticipantAdmin(admin.ModelAdmin):
    list_display = ['pv', 'nom', 'signature','date_signature']
    list_filter = ['date_signature']
    search_fields = ['nom']

@admin.register(Ouvrage) 
class OuvrageAdmin(admin.ModelAdmin):
    list_display = ['code','nom']
    search_fields = ['nom']  
@admin.register(ElementOuvrage)
class ElementOuvrageAdmin(admin.ModelAdmin):
    list_display = ['code', 'nom', 'ouvrage']
    list_filter = ['ouvrage']
    search_fields = ['code', 'nom']

@admin.register(PointControle)
class PointControleAdmin(admin.ModelAdmin):
    list_display = ['code', 'element', 'point_de_controle']
    list_filter = ['element__ouvrage']
    search_fields = ['code', 'element']

@admin.register(ControleResultat)
class ControleResultatAdmin(admin.ModelAdmin):
    list_display = ['pv', 'point_controle', 'statut', 'date_controle']
    list_filter = ['statut', 'date_controle']
    search_fields = ['pv__numero', 'point_controle__code']

@admin.register(Client)
class ClientAdmin(admin.ModelAdmin):
    list_display = ['nom', 'adresse', 'telephone', 'email']
    search_fields = ['nom', 'email']

@admin.register(Projets)
class ProjetsAdmin(admin.ModelAdmin):
    list_display = ['nom_projet', 'client', 'adresse', 'etat']
    search_fields = ['nom_projet', 'client']

@admin.register(TypePV)
class TypePVAdmin(admin.ModelAdmin):
    list_display = ['code','type_pv']
    search_fields = ['type_pv']
    