from django.db import models

# Create your models here.
class DigitalSignatureApplication(models.Model):
    full_name=models.CharField(max_length=250)
    legal_status=models.CharField(max_length=250,blank=True)
    citizenship_no=models.CharField(max_length=250,blank=True)
    issuing_office=models.CharField(max_length=250,blank=True)
    issue_date=models.DateTimeField(null=True,blank=True)
    duration_validity=models.CharField(max_length=250,null=True,blank=True)
    registration_certificate = models.CharField(max_length=255, blank=True)
    company_issue_date = models.DateField(null=True, blank=True)
    company_issuing_office = models.CharField(max_length=255, blank=True)
    objectives = models.TextField(blank=True)
    puropse_all=models.BooleanField(default=False)
    purpose_banking = models.BooleanField(default=False)
    purpose_purchase = models.BooleanField(default=False)
    purpose_certification = models.BooleanField(default=False)
    transaction_threshold = models.CharField(max_length=100, blank=True)
    declaration = models.BooleanField(default=False)
    applicant_name = models.CharField(max_length=255, blank=True)
    final_name = models.CharField(max_length=255, blank=True)
    signature = models.CharField(max_length=255, blank=True)
    # =================================================================
    # Additional information
    # ================================================================
    image=models.ImageField(upload_to='profile_image/')
    address=models.TextField(blank=True)
    district=models.CharField(max_length=250,blank=True,null=True)
    municipality = models.CharField(max_length=100, blank=True)
    city = models.CharField(max_length=100, blank=True)
    ward = models.CharField(max_length=20, blank=True)
    post_box = models.CharField(max_length=50, blank=True)
    contact_number = models.CharField(max_length=20, blank=True)
    email=models.EmailField(blank=True)
    alternate_email=models.EmailField(blank=True)
    cell_number=models.CharField(max_length=250,)
    telephon_no=models.CharField(max_length=250,blank=True)
    organization_name = models.CharField(max_length=255, blank=True)

    ORG_TYPES = (
        ("Proprietorship", "Proprietorship"),
        ("Partnership", "Partnership"),
        ("Public", "Public"),
        ("NGO/INGO", "NGO/INGO"),
        ("Government", "Government"),
        ("Others", "Others"),
    )
    organization_type = models.CharField(
        max_length=50,
        choices=ORG_TYPES,
        blank=True
    )
    organization_address = models.TextField(blank=True)
    organization_city = models.CharField(max_length=100, blank=True)
    organization_province = models.CharField(max_length=100, blank=True)
    organization_district = models.CharField(max_length=100, blank=True)
    organization_municipality = models.CharField(max_length=100, blank=True)
    organization_ward = models.CharField(max_length=20, blank=True)
    pan_vat = models.CharField(max_length=100, blank=True)
    tax_clearance = models.CharField(max_length=100, blank=True)
    organization_email = models.EmailField(blank=True)
    organization_alternate_email = models.EmailField(blank=True)
    fax = models.CharField(max_length=50, blank=True)
    website = models.URLField(blank=True)
    CERTIFICATE_CLASS = (
        ("1", "Class 1"),
        ("2", "Class 2"),
        ("3", "Class 3"),
        ("GIOMS", "GIOMS"),
    )
    certificate_class = models.CharField(
        max_length=20,
        choices=CERTIFICATE_CLASS,
        blank=True
    )
    use_signature = models.BooleanField(default=False)
    use_encryption = models.BooleanField(default=False)
    use_both = models.BooleanField(default=False)

    VALIDITY = (
        ("1", "1 Year"),
        ("2", "2 Years"),
    )

    validity_year = models.CharField(
        max_length=10,
        choices=VALIDITY,
        blank=True
    )
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        ordering = ["-created_at"]
        verbose_name = "Digital Signature Application"
        verbose_name_plural = "Digital Signature Applications"

    def __str__(self):
        return self.full_name






