from django import forms
from .models import Prospect, Event
import datetime

class SmallTextArea(forms.Textarea):
    def __init__(self, *args, **kwargs):
        kwargs.setdefault('attrs', {})
        kwargs['attrs'].update({
            'rows': 2,
            'cols': 100,
            'style': 'height: 80px; width: 800px;'
        })
        super().__init__(*args, **kwargs)

class ProspectForm(forms.ModelForm):
    class Meta:
        model = Prospect
        fields = ['entity_name', 'first_name', 'last_name', 'email',
                 'phone', 'address', 'zip_code', 'city']

class BulkEmailForm(forms.Form):
    prospects = forms.ModelMultipleChoiceField(
        queryset=Prospect.objects.all(),
        widget=forms.CheckboxSelectMultiple
    )
    subject = forms.CharField(max_length=200)
    content = forms.CharField(widget=forms.Textarea)

class EventForm(forms.ModelForm):
    prospects = forms.ModelMultipleChoiceField(
        queryset=Prospect.objects.all(),
        widget=forms.SelectMultiple(attrs={'class': 'select2'}),
        required=False
    )
    description = forms.CharField(widget=SmallTextArea)
    attachment_text = forms.CharField(widget=SmallTextArea)

    class Meta:
        model = Event
        fields = ['date', 'type', 'description', 'attachment_text', 'prospects', 'status']
        widgets = {
            'date': forms.DateTimeInput(attrs={'type': 'datetime-local'}),
        }

class CSVImportForm(forms.Form):
    csv_file = forms.FileField()
