<?php
/**
 * BookiFlex Core
 *
 * @package    BookiFlex
 * @subpackage Core
 * @author     BookiFlex
 * @copyright  Copyright (c) 2025 BookiFlex
 * @license    GPL-2.0-or-later
 *
 * @link       https://bookiflex.com
 */

declare(strict_types=1);

namespace BookiFlex\Core\Model\Reservation;

use BookiFlex\Core\Model\AbstractStatus;

defined( 'ABSPATH' ) || exit;

/**
 * Overdue:
 * When all reservations in the group have Overdue status.
 * The most critical group status.
 *
 * Partially overdue:
 * When at least one reservation has Overdue status, but not all.
 * This status signals a problem that requires attention.
 *
 * Split:
 * Applied when the group has been split into multiple groups.
 * This status is usually temporary and used to record the split event.
 *
 * Partially confirmed:
 * When at least one reservation is Confirmed, but others are in process or cancelled.
 * This status is higher than Active, but lower than critical ones (Overdue).
 *
 * Cancelled:
 * When all reservations in the group are cancelled.
 * Indicates completion of work with the group.
 *
 * Confirmed:
 * When all reservations are Confirmed.
 * Reflects successful completion of the booking process.
 *
 * Active:
 * Initial group status when all reservations are in process and there are no problems.
 */
class GroupReservationStatus extends AbstractStatus
{
    public const STATUS_ACTIVE              = 'ACTIVE';
    public const STATUS_CONFIRMED           = 'CONFIRMED';
    public const STATUS_CANCELLED           = 'CANCELLED';
    public const STATUS_PARTIALLY_CONFIRMED = 'PARTIALLY_CONFIRMED';
    public const STATUS_SPLIT               = 'SPLIT';
    public const STATUS_PARTIALLY_OVERDUE   = 'PARTIALLY_OVERDUE';
    public const STATUS_OVERDUE             = 'OVERDUE';

    protected static array $validTransitions = [
        self::STATUS_ACTIVE              => [self::STATUS_CONFIRMED, self::STATUS_PARTIALLY_CONFIRMED, self::STATUS_SPLIT, self::STATUS_PARTIALLY_OVERDUE, self::STATUS_OVERDUE, self::STATUS_CANCELLED],
        self::STATUS_CONFIRMED           => [self::STATUS_CANCELLED, self::STATUS_SPLIT],
        self::STATUS_CANCELLED           => [],
        self::STATUS_PARTIALLY_CONFIRMED => [self::STATUS_CONFIRMED, self::STATUS_PARTIALLY_OVERDUE, self::STATUS_OVERDUE, self::STATUS_CANCELLED],
        self::STATUS_SPLIT               => [self::STATUS_ACTIVE, self::STATUS_CONFIRMED, self::STATUS_PARTIALLY_CONFIRMED, self::STATUS_PARTIALLY_OVERDUE, self::STATUS_OVERDUE, self::STATUS_CANCELLED],
        self::STATUS_PARTIALLY_OVERDUE   => [self::STATUS_OVERDUE, self::STATUS_SPLIT, self::STATUS_PARTIALLY_CONFIRMED, self::STATUS_CONFIRMED, self::STATUS_CANCELLED],
        self::STATUS_OVERDUE             => [self::STATUS_SPLIT, self::STATUS_PARTIALLY_CONFIRMED, self::STATUS_CONFIRMED, self::STATUS_CANCELLED],
    ];
}
