{% extends 'classroom-manage/layout.html.twig' %}
{% block title %}{{ '基本信息'|trans }} - {{ parent() }}{% endblock %}

{% set script_arguments = {
tagMatchUrl: path('tag_match'),
classroomStatus: classroom.status
} %}

{% set side_nav = 'base' %}

{% do script(['libs/jquery-validation.js', 'libs/es-ckeditor/ckeditor.js', 'libs/bootstrap-datetimepicker.js', 'libs/select2.js', 'app/js/classroom-manage/set-info/index.js']) %}

{% block main %}
  <div class="panel panel-default" role="classroom-manage-base">
    <div class="panel-heading">{{ '基本信息'|trans }}</div>
    <div class="panel-body">
      {{ web_macro.flash_messages() }}
      <form class="form-horizontal" method="post" id="classroom-set-form" novalidate>
        <div class="row form-group">
          <div class="col-md-2 control-label">
            <label class="control-label-required" for="title" >{{ '名称'|trans }}</label>
          </div>
          <div class="controls col-md-8">
            <input name="title" type="text" id="title" class="form-control" value="{{ classroom.title }}"/>
          </div>
        </div>
        <div class="row form-group">
          <div class="col-md-2 control-label">
            <label>{{ '简介'|trans }}</label>
          </div>
          <div class="controls col-md-8">
            <textarea name="about" class="form-control" rows="6"
            data-image-upload-url="{{ path('editor_upload', {token:upload_token('default')}) }}"
            data-flash-upload-url="{{ path('editor_upload', {token:upload_token('default', 'flash')}) }}"
            id="about">{{ classroom.about|raw }}</textarea>
            <div class="help-block">{{ '为正常使用IFrame，请在【管理后台】-【系统】-【站点设置】-【安全】-【IFrame白名单】中进行设置'|trans }}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="col-md-2 control-label">{{ '标签'|trans }}</label>
          <div class="col-md-8 controls">
            <input type="text" id="classroom_tags" name="tags"  class="width-full select2-offscreen"
              tabindex="-1" value="{{ tags|join(',') }}"
              data-explain="{{ '用于按标签检索班级等，由网校管理员后台统一管理'|trans }}">
            <div class="help-block">{{ '用于按标签检索班级等，由网校管理员后台统一管理'|trans }}</div>
          </div>
        </div>
        <div class="row form-group">
          <div class="col-md-2 control-label">
            <label>{{ '%name%展示'|trans({'%name%':setting('classroom.name')|default('班级'|trans)}) }}</label>
          </div>
          <div class="col-md-8 controls radios">
            <label>
              <input id="showable-open" type="radio" name="showable" value="1" data-showable="{{ classroom.showable }}"> {{ '开启'|trans }}
            </label>
            <label>
              <input id="showable-close" type="radio" name="showable" value="0"> {{ '关闭'|trans }}
            </label>
            <div class="help-block">{{ '关闭后，%name%将彻底隐藏，无法在前台查看到。'|trans({'%name%':setting('classroom.name')|default('班级'|trans)}) }}</div>
          </div>

        </div>
        <div class="row form-group" id='buyable'>
          <div class="col-md-2 control-label">
            <label>{{ setting("classroom.name")|default("班级") }}{{ '购买'|trans }}</label>
          </div>
          <div class="col-md-8 controls radios">
            <label>
              <input id="buyable-open" type="radio" name="buyable" value="1" data-buyable="{{ classroom.buyable }}"> {{ '开启'|trans }}
            </label>
            <label>
              <input id="buyable-close" type="radio" name="buyable" value="0"> {{ '关闭'|trans }}
            </label>
            <div class="help-block">{{ '关闭后%name%将无法在线购买加入。'|trans({'%name%':setting('classroom.name')|default('班级'|trans)}) }}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="col-md-2 control-label">班级有效期</label>
          <div class="col-md-8 controls radios">
            {% if classroom.status == 'draft' %}
              <input type="hidden" name="expiryMode" value="{{ classroom.expiryMode }}">
              {{ radios('expiryMode', {'date':'截止日期'|trans, 'days':'有效期天数'|trans,'forever':'永久有效'|trans}, classroom.expiryMode|default('forever')) }}
            {% else %}
              {{ radios('expiryMode', {'date':'截止日期'|trans, 'days':'有效期天数'|trans,'forever':'永久有效'|trans}, classroom.expiryMode|default('forever'), 'disabled') }}
              <input type="hidden" name="expiryMode" value="{{ classroom.expiryMode|default('forever') }}">
            {% endif %}
          </div>
        </div>
        <div class="form-group expiry-value-js {% if classroom.expiryMode|default('forever') == 'forever' %} hidden {% endif %}">
          <div class="col-md-offset-2 col-md-4 controls">
            <input type="text" id="classroom_expiryValue" name="expiryValue" 
              value="{% if classroom.expiryMode|default('forever') == 'date' %}{{ classroom.expiryValue|date('Y-m-d') }}{% else %}{{ classroom.expiryValue }}{% endif %}"
              class="form-control width-input width-input-large"> 
              <span {% if classroom.expiryMode|default('forever') != 'days' %}class="hidden" {% endif %}>
                {{ '天'|trans }}
              </span>
            {% set date_help = '设置该值后，%user_name%只能在截止日期前进行课程的学习，系统默认会在截止时间前10天提醒学员。'|trans({'%user_name%': setting('default.user_name')|default('学员'|trans)}) %}
            {% set days_help = '设置该值后，%user_name%只能在有效天数内进行课程的学习，系统默认会在有效期前10天提醒学员。'|trans({'%user_name%': setting('default.user_name')|default('学员'|trans)}) %}

            <div class="help-block" data-date="{{ date_help }}" data-days="{{ days_help }}">
              {% if classroom.expiryMode|default('forever') == 'date' %}  {{ date_help }}{% elseif  classroom.expiryMode|default('forever') == 'days' %}{{ days_help }} {% endif %}
            </div>
          </div>
          <div class="col-md-6 js-course-rule">
            <p class="alert-warning"></p>
            <a href="{{ path('classroom_expiry_date_rule') }}" target="_blank">查看有效期规则</a>
          </div>
        </div>
        <div class="form-group">
          <label class="col-md-2 control-label">{{ '分类'|trans }}</label>
          <div class="col-md-8 controls">
            <select id="course_categoryId" name="categoryId" required="required" class="form-control width-input width-input-large">
              {{ select_options(category_choices('classroom'), classroom.categoryId, {0:'分类'|trans}) }}

            </select>
            <div class="help-block" style="display:none;"></div>
          </div>
        </div>
        {% include 'org/org-tree-select.html.twig' with {orgCode: classroom.orgCode, inputClass: 'width-input width-input-large'} %}
        <div class="row form-group">
          <div class="col-md-2 control-label"></div>
          <div class="controls col-md-8">
            <button class="btn btn-primary" id="classroom-save">{{ '提交'|trans }}</button>
          </div>
        </div>

        <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
      </form>
    </div>
  </div>
{% endblock %}
