from django import forms
from .models import Contrat, Departement, Employe,Affectation,Formation

class EmployeForm(forms.ModelForm):
    """Formulaire pour modifier les informations de profil d'un employé"""
    class Meta:
        model = Employe
        fields = (
            'adresse',
            'telephone',
            'CV', 
            'diplome', 
            'rib', 
            'photo', 
            'casier_judiciaire'
        )  

class AffectationForm(forms.ModelForm):
    class Meta:
        model = Affectation
        fields = (
            'projet', 
            'date_affectation', 
            'date_fin_daffectation', 
            'role', 
            'pourcentage_temps_affectation'
        )

        widgets = {
            'projet': forms.Select(attrs={'class': 'form-select'}),
            'date_affectation': forms.DateInput(attrs={'class': 'form-control', 'type': 'date'}),
            'date_fin_daffectation': forms.DateInput(attrs={'class': 'form-control', 'type': 'date'}),
            'role': forms.Select(attrs={'class': 'form-select'}),
            'pourcentage_temps_affectation': forms.NumberInput(attrs={'class': 'form-control'}),
        }

class ContratForm(forms.ModelForm):
    class Meta:
        model = Contrat
        fields = [
            "numero_contrat", 
            "type_contrat", 
            "date_debut", 
            "date_fin", 
            "salaire_mensuel", 
            "statut", 
            "fichier_contrat"
        ]

        widgets = {
            'numero_contrat': forms.TextInput(attrs={'class': 'form-control'}),
            'type_contrat': forms.Select(attrs={'class': 'form-select'}),
            'date_debut': forms.DateInput(attrs={'class': 'form-control', 'type': 'date'}),
            'date_fin': forms.DateInput(attrs={'class': 'form-control', 'type': 'date'}),
            'salaire_mensuel': forms.TextInput(attrs={'class': 'form-control'}),
            'statut': forms.Select(attrs={'class': 'form-select'}),
            'fichier_contrat': forms.FileInput(attrs={'class': 'form-control'}),
        }
        
class DepartementForm(forms.ModelForm):
    class Meta:
        model = Departement 
        fields = ['nom']

class FormationForm(forms.ModelForm):
    class Meta:
        model = Formation
        fields = [
            'titre', 
            'organisme',
            'date_obtention', 
            'date_fin', 
            'description', 
            'certificat' 
        ]

        widgets = {
            'titre': forms.TextInput(attrs={"class": "form-control"}),
            'organisme': forms.TextInput(attrs={"class": "form-control"}),
            'date_obtention': forms.DateInput(attrs={"class": "form-control", "type": "date"}),
            'date_fin': forms.DateInput(attrs={"class": "form-control", "type": "date"}),
            'description': forms.Textarea(attrs={"class": "form-control"}),
            'certificat': forms.FileInput(attrs={"class": "form-control"}),
        }