
from django.db import models


class Staff(models.Model):
    name = models.CharField(max_length=200)
    phone = models.CharField(max_length=15)
    gender = models.CharField(max_length=20, blank=True, null=True)
    date_of_birth = models.DateField(blank=True, null=True)
    address = models.TextField(blank=True, null=True)
    employee_id = models.CharField(max_length=50, unique=True)
    joining_date = models.DateField()
    salary = models.DecimalField(
        max_digits=10, decimal_places=2, blank=True, null=True
    )
    email = models.CharField(max_length=150, unique=True)
    password = models.CharField(max_length=255)
    status = models.CharField(max_length=20, default='Active')
    # Locations (places) this collection agent works in. The staff panel only
    # shows loans, customers and collections of these places.
    places = models.ManyToManyField(
        'NexusApp.Place',
        related_name='staff_members',
        blank=True,
    )
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return f"{self.employee_id} - {self.name}"
