# Generated by Django 6.0 on 2026-03-04 23:59

import django.core.validators
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('academics', '0001_initial'),
        ('core', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Staff',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('employee_id', models.CharField(help_text='Unique staff identifier', max_length=20, unique=True, verbose_name='Employee ID')),
                ('date_of_birth', models.DateField(blank=True, null=True, verbose_name='Date of Birth')),
                ('gender', models.CharField(choices=[('M', 'Male'), ('F', 'Female'), ('O', 'Other')], default='M', max_length=1, verbose_name='Gender')),
                ('nationality', models.CharField(blank=True, default='Cameroonian', max_length=50, verbose_name='Nationality')),
                ('marital_status', models.CharField(blank=True, choices=[('single', 'Single'), ('married', 'Married'), ('divorced', 'Divorced'), ('widowed', 'Widowed')], default='single', max_length=20, verbose_name='Marital Status')),
                ('phone_number', models.CharField(blank=True, max_length=17, validators=[django.core.validators.RegexValidator(message="Phone number must be entered in format: '+237XXXXXXXXX'", regex='^\\+?[1-9]\\d{1,14}$')], verbose_name='Phone Number')),
                ('alternate_phone', models.CharField(blank=True, max_length=17, validators=[django.core.validators.RegexValidator(message="Phone number must be entered in format: '+237XXXXXXXXX'", regex='^\\+?[1-9]\\d{1,14}$')], verbose_name='Alternate Phone Number')),
                ('email', models.EmailField(blank=True, max_length=254, verbose_name='Email Address')),
                ('address', models.TextField(blank=True, verbose_name='Residential Address')),
                ('quarter', models.CharField(blank=True, help_text='e.g., Bonapriso, Akwa, Bonanjo', max_length=100, verbose_name='Quarter/Neighborhood')),
                ('city', models.CharField(blank=True, default='Douala', max_length=100, verbose_name='City')),
                ('emergency_contact_name', models.CharField(blank=True, max_length=100, verbose_name='Emergency Contact Name')),
                ('emergency_contact_phone', models.CharField(blank=True, max_length=17, validators=[django.core.validators.RegexValidator(message="Phone number must be entered in format: '+237XXXXXXXXX'", regex='^\\+?[1-9]\\d{1,14}$')], verbose_name='Emergency Contact Phone')),
                ('emergency_contact_relationship', models.CharField(blank=True, max_length=50, verbose_name='Relationship')),
                ('role', models.CharField(choices=[('proprietor', 'Proprietor'), ('head_master', 'Head Master'), ('head_mistress', 'Head Mistress'), ('bursar', 'Bursar'), ('admin', 'Administrator'), ('teacher', 'Teacher'), ('class_teacher', 'Class Teacher'), ('subject_teacher', 'Subject Teacher'), ('assistant_teacher', 'Assistant Teacher'), ('secretary', 'Secretary'), ('driver', 'Driver'), ('cleaner', 'Cleaner'), ('canteen', 'Canteen Staff'), ('security', 'Security'), ('support', 'Support Staff'), ('other', 'Other')], default='teacher', max_length=20, verbose_name='Role/Position')),
                ('department', models.CharField(choices=[('admin', 'Administration'), ('english', 'English Section'), ('french', 'French Section'), ('bilingual', 'Bilingual Section'), ('nursery', 'Nursery Section'), ('finance', 'Finance'), ('support', 'Support Staff'), ('transport', 'Transport')], default='english', max_length=20, verbose_name='Department')),
                ('employment_status', models.CharField(choices=[('permanent', 'Permanent'), ('contract', 'Contract'), ('probation', 'Probation'), ('intern', 'Intern'), ('volunteer', 'Volunteer'), ('part_time', 'Part Time'), ('casual', 'Casual')], default='contract', max_length=20, verbose_name='Employment Status')),
                ('hire_date', models.DateField(blank=True, null=True, verbose_name='Hire Date')),
                ('contract_end_date', models.DateField(blank=True, null=True, verbose_name='Contract End Date')),
                ('qualifications', models.TextField(blank=True, help_text='Degrees, certifications, training', verbose_name='Qualifications')),
                ('specialization', models.CharField(blank=True, help_text='Subject area specialization', max_length=200, verbose_name='Specialization')),
                ('years_of_experience', models.PositiveIntegerField(default=0, verbose_name='Years of Experience')),
                ('is_class_teacher', models.BooleanField(default=False, verbose_name='Is Class Teacher?')),
                ('salary', models.DecimalField(blank=True, decimal_places=0, max_digits=10, null=True, verbose_name='Monthly Salary (XAF)')),
                ('bank_name', models.CharField(blank=True, max_length=100, verbose_name='Bank Name')),
                ('bank_account', models.CharField(blank=True, max_length=50, verbose_name='Bank Account Number')),
                ('bank_branch', models.CharField(blank=True, max_length=100, verbose_name='Bank Branch')),
                ('tax_id', models.CharField(blank=True, max_length=50, verbose_name='Tax ID / NIU')),
                ('social_security', models.CharField(blank=True, max_length=50, verbose_name='Social Security Number')),
                ('photo', models.ImageField(blank=True, null=True, upload_to='staff/photos/', verbose_name='Profile Photo')),
                ('cv_file', models.FileField(blank=True, null=True, upload_to='staff/documents/cv/', verbose_name='CV/Resume')),
                ('contract_file', models.FileField(blank=True, null=True, upload_to='staff/documents/contracts/', verbose_name='Employment Contract')),
                ('id_document', models.FileField(blank=True, null=True, upload_to='staff/documents/id/', verbose_name='ID Document')),
                ('diplomas', models.FileField(blank=True, null=True, upload_to='staff/documents/diplomas/', verbose_name='Diplomas/Certificates')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
                ('is_active', models.BooleanField(default=True, verbose_name='Active')),
                ('notes', models.TextField(blank=True, verbose_name='Additional Notes')),
                ('imported_from', models.CharField(blank=True, help_text="Source of import (e.g., 'Staff Excel')", max_length=100)),
                ('original_data', models.JSONField(blank=True, help_text='Original imported data', null=True)),
                ('homeroom_class', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='homeroom_teachers', to='academics.schoolclass', verbose_name='Homeroom Class')),
                ('school', models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='staff_members', to='core.school', verbose_name='School')),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='staff_profile', to=settings.AUTH_USER_MODEL, verbose_name='User Account')),
            ],
            options={
                'verbose_name': 'Staff Member',
                'verbose_name_plural': 'Staff Members',
                'ordering': ['role', 'user__first_name', 'user__last_name'],
            },
        ),
        migrations.CreateModel(
            name='StaffDocument',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('document_type', models.CharField(choices=[('contract', 'Employment Contract'), ('diploma', 'Diploma/Certificate'), ('id', 'ID Card'), ('cv', 'CV/Resume'), ('medical', 'Medical Certificate'), ('other', 'Other')], max_length=20)),
                ('title', models.CharField(max_length=200)),
                ('file', models.FileField(upload_to='staff/documents/')),
                ('uploaded_at', models.DateTimeField(auto_now_add=True)),
                ('notes', models.TextField(blank=True)),
                ('staff', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='documents', to='staff.staff')),
            ],
            options={
                'ordering': ['-uploaded_at'],
            },
        ),
        migrations.CreateModel(
            name='StaffLeave',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('leave_type', models.CharField(choices=[('annual', 'Annual Leave'), ('sick', 'Sick Leave'), ('maternity', 'Maternity Leave'), ('paternity', 'Paternity Leave'), ('bereavement', 'Bereavement'), ('unpaid', 'Unpaid Leave'), ('training', 'Training Leave')], max_length=20)),
                ('start_date', models.DateField()),
                ('end_date', models.DateField()),
                ('days_requested', models.PositiveIntegerField()),
                ('reason', models.TextField()),
                ('status', models.CharField(choices=[('pending', 'Pending'), ('approved', 'Approved'), ('rejected', 'Rejected'), ('cancelled', 'Cancelled')], default='pending', max_length=20)),
                ('approved_date', models.DateField(blank=True, null=True)),
                ('remarks', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('approved_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='approved_leaves', to='staff.staff')),
                ('staff', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='leave_requests', to='staff.staff')),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='TeacherSubject',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('hours_per_week', models.PositiveIntegerField(default=2)),
                ('class_assigned', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='academics.schoolclass')),
                ('subject', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subject_teachers', to='academics.subject')),
                ('teacher', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='teacher_subjects', to='staff.staff')),
            ],
            options={
                'verbose_name': 'Teacher Subject Assignment',
                'verbose_name_plural': 'Teacher Subject Assignments',
                'unique_together': {('teacher', 'subject', 'class_assigned')},
            },
        ),
        migrations.AddField(
            model_name='staff',
            name='subjects_taught',
            field=models.ManyToManyField(blank=True, related_name='teachers', through='staff.TeacherSubject', to='academics.subject', verbose_name='Subjects Taught'),
        ),
        migrations.CreateModel(
            name='StaffAttendance',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('date', models.DateField()),
                ('check_in_time', models.TimeField(blank=True, null=True)),
                ('check_out_time', models.TimeField(blank=True, null=True)),
                ('status', models.CharField(choices=[('present', 'Present'), ('absent', 'Absent'), ('late', 'Late'), ('leave', 'On Leave'), ('sick', 'Sick Leave'), ('training', 'Training')], default='present', max_length=20)),
                ('remarks', models.CharField(blank=True, max_length=200)),
                ('staff', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attendances', to='staff.staff')),
            ],
            options={
                'ordering': ['-date'],
                'unique_together': {('staff', 'date')},
            },
        ),
        migrations.AddIndex(
            model_name='staff',
            index=models.Index(fields=['employee_id'], name='staff_staff_employe_f8cd0b_idx'),
        ),
        migrations.AddIndex(
            model_name='staff',
            index=models.Index(fields=['role'], name='staff_staff_role_423c94_idx'),
        ),
        migrations.AddIndex(
            model_name='staff',
            index=models.Index(fields=['department'], name='staff_staff_departm_eea1cc_idx'),
        ),
        migrations.AddIndex(
            model_name='staff',
            index=models.Index(fields=['is_active'], name='staff_staff_is_acti_0db61a_idx'),
        ),
    ]
