<?php

namespace Modules\HR\Database\Seeders;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Modules\Core\Database\Seeders\Traits\DisableForeignKeys;
use Modules\Core\Enums\StatusEnum;
use Modules\HR\Models\AttendancePolicy;

class AttendancePolicySeeder extends Seeder
{
    use DisableForeignKeys, WithoutModelEvents;

    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $this->disableForeignKeys();

        AttendancePolicy::truncate();

        AttendancePolicy::insert(
            [
                'name'                   => 'Regular Corporate Policy',
                'late_grace_minutes'     => 15,  // 15 minutes grace time for late check-in
                'max_late_count'         => 3,   // Maximum 3 days allowed in a month
                'half_day_after_minutes' => 240, // 4 hours minimum work required
                'absent_after_minutes'   => 60,  // Absent after 1 hour of shift start
                'auto_absent'            => true,
                'allow_overtime'         => false,
                'status'                 => StatusEnum::ACTIVE,
            ],
            [
                'name'                   => 'Medical Staff Shift Policy',
                'late_grace_minutes'     => 10,  // Strict 10 minutes grace time
                'max_late_count'         => 4,   // Maximum 4 days allowed
                'half_day_after_minutes' => 180, // 3 hours minimum work required
                'absent_after_minutes'   => 45,  // Absent after 45 minutes of shift start
                'auto_absent'            => true,
                'allow_overtime'         => true, // Overtime allowed for extra duty hours
                'status'                 => StatusEnum::ACTIVE,
            ]
        );

        $this->enableForeignKeys();
    }
}
