<?php

namespace App\Modules\Attendance\Entities;

use CodeIgniter\Entity\Entity;

/**
 * Attendance Session Entity
 * 
 * Represents an attendance check-in session.
 */
class AttendanceSession extends Entity
{
    /**
     * Attributes that can be mass assigned
     * 
     * @var array<string>
     */
    protected $allowedFields = [
        'student_id',
        'schedule_id',
        'checkin_type',
        'attendance_date',
        'device_id',
        'checkin_at',
        'latitude',
        'longitude',
        'confidence',
        'status',
    ];

    /**
     * Attributes that should be cast to specific types
     * 
     * @var array<string, string>
     */
    protected $casts = [
        'id'          => 'integer',
        'student_id'  => 'integer',
        'schedule_id'     => 'integer',
        'checkin_type'    => 'string',
        'attendance_date' => 'date',
        'device_id'       => 'integer',
        'checkin_at'  => 'datetime',
        'latitude'    => 'float',
        'longitude'   => 'float',
        'confidence'  => 'float',
        'created_at'  => 'datetime',
        'updated_at'  => 'datetime',
    ];

    /**
     * Status constants
     */
    public const STATUS_PRESENT = 'PRESENT';
    public const STATUS_LATE = 'LATE';
    public const STATUS_OUTSIDE_ZONE = 'OUTSIDE_ZONE';
    public const STATUS_NO_SCHEDULE = 'NO_SCHEDULE';
    public const STATUS_INVALID_DEVICE = 'INVALID_DEVICE';
    public const STATUS_ALREADY_CHECKED_IN = 'ALREADY_CHECKED_IN';
    public const STATUS_ABSENCE_WINDOW_CLOSED = 'ABSENCE_WINDOW_CLOSED';
    public const STATUS_SESSION_CLOSED = 'SESSION_CLOSED';
}
