<?php

namespace common\modules\support\models\redmine;

use Yii;

class Issue extends yii\base\Model
{
    public $subject;
    public $project_id;
    public $priority_id = self::PRIORITY_FIRE;
    public $description;
    public $author_id;
    public $tracker_id = self::TRACKER_NONE;
    public $status_id = self::STATUS_NEW;
    public $notes; 

    public $files = null;

    const PRIORITY_SIMPLE = 2;
    const PRIORITY_FIRE = 3;

    const TRACKER_NONE = 14; // Не определено

    const STATUS_NEW = 7;
    const STATUS_APPROVE = 16;
    const STATUS_ACCEPTED = 14;

    const SCENARIO_CREATE = 'create';
    const SCENARIO_UPDATE = 'update';

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['notes'], 'required', 'on' => self::SCENARIO_UPDATE],

            [['tracker_id', 'status_id', 'priority_id'], 'required', 'on' => self::SCENARIO_CREATE],
            [['project_id'], 'required', 'message' => 'Выберите проект, к которому относится новая задача', 'on' => self::SCENARIO_CREATE],
            [['subject'], 'required', 'message' => 'Введите наименование задачи', 'on' => self::SCENARIO_CREATE],
            [['description'], 'required', 'message' => 'Укажите описание задачи', 'on' => self::SCENARIO_CREATE],
            [['tracker_id', 'project_id', 'status_id', 'priority_id'], 'integer', 'on' => self::SCENARIO_CREATE],
            [['description'], 'string', 'on' => self::SCENARIO_CREATE],
            [['subject'], 'string', 'max' => 255, 'on' => self::SCENARIO_CREATE],

            [['files', 'notes'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'project_id' => 'Проект',
            'subject' => 'Заголовок задачи',
            'tracker_id' => 'Tracker ID',
            'description' => 'Текст задачи',
            'priority_id' => 'Важность',
            'status_id' => 'Статус',
            'notes' => 'Комментарий',
        ];
    }

   
}