from django.db import models

from .services import Service, ServiceOffering, Plan


class Lead(models.Model):
    name = models.CharField(max_length=200)
    email = models.EmailField()
    company = models.CharField(max_length=200, null=True, blank=True)
    phone = models.CharField(max_length=50, null=True, blank=True)
    message = models.TextField(blank=True, null=True, max_length=1000)
    odoo_lead_id = models.IntegerField(null=True, blank=True)

    service = models.ForeignKey(
        Service, on_delete=models.SET_NULL, null=True, blank=True
    )
    offering = models.ForeignKey(
        ServiceOffering, on_delete=models.SET_NULL, null=True, blank=True
    )
    plan = models.ForeignKey(Plan, on_delete=models.SET_NULL, null=True, blank=True)

    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return f"{self.name} - {self.company} ({self.service})"
