{% extends (course_count(course.courseSetId) > 1 ? 'course' : 'courseset') ~ '-manage/layout.html.twig' %}

{% block title %}{{'计划设置'|trans}} - {{ course.title }} - {{ parent() }}{% endblock %}
{% set side_nav = 'info' %}
{% do script(['libs/es-ckeditor/ckeditor.js','libs/jquery-validation.js','libs/bootstrap-datetimepicker.js','app/js/course-manage/info/index.js']) %}

{% block main %}
  <div class="panel panel-default" role="course-manage-info">
    {% include 'course-manage/panel-header/course-publish-header.html.twig' with {code: side_nav} %}
    <div class="panel-body">
      {{ web_macro.flash_messages() }}
      <form class="form-horizontal" role="form" id="course-info-form" action="{{path('course_set_manage_course_info', {courseSetId: courseSet.id, courseId: course.id})}}" method="post">
        <div class="form-group">
          <div class="col-sm-2 control-label">
          <label for="title" class="control-label-required">{{'计划名称'|trans}}</label>
          </div>
          <div class="col-sm-8">
            <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
            <input type="hidden" name="courseSetId" value="{{courseSet.id}}">
            <input type="hidden" name="id" value="{{course.id|default(0)}}">
            <input class="form-control" type="text" id="title" name="title" value="{{course.title|default('')}}">
          </div>
        </div>
        <div class="form-group">
          <label for="" class="col-sm-2 control-label">{{'学习模式'|trans}}</label>
          <div class="col-sm-8 form-control-static"> 
             {% if course.learnMode|default('freeMode') == 'freeMode' %}
               {{'自由式学习'|trans}}<a class="es-icon es-icon-help ml5 link-gray" data-trigger="hover" data-toggle="popover" data-container="body" data-placement="top" data-content="{{'学习过程自由安排'|trans}}"></a>
             {% else %}
               {{'解锁式学习'|trans}}<a class="es-icon es-icon-help ml5 link-gray" data-trigger="hover" data-toggle="popover" data-container="body" data-placement="top" data-content="{{'根据既定顺序逐个解锁学习'|trans}}"></a>
               <p class="help-block" id="learnLockModeHelp" data-role="tab-content" >{{''|trans}}</p>
             {% endif %}
          </div>
        </div>
        <div class="form-group">
          <label for="" class="col-sm-2 control-label">{{'任务完成规则'|trans}}</label>
          <div class="col-sm-8 radios"> 
            <label>
              <input type="radio" name="enableFinish" value="0" {% if course.enableFinish|default('0') == 0 %}checked{% endif %}> 由任务完成条件决定
              <a class="es-icon es-icon-help ml5 link-gray" data-trigger="hover" data-toggle="popover" data-container="body" data-placement="top" data-content="{{'必须达到完成条件，任务才算完成'|trans}}"></a>
            </label>
            <label>
              <input type="radio" name="enableFinish" value="1" {% if course.enableFinish|default('0') == 1 %}checked{% endif %}> 无限制
            </label>
          </div>
        </div>
        {#移动到营销设置#}
        {#<div class="form-group">
          <label class="col-sm-2 control-label">{{'学习有效期模式'|trans}}</label>
          {% if course.status|default('draft') == 'draft' %}
            <div class="col-sm-8 radios">
                {{ radios('expiryMode', { 'days': '随到随学'|trans, 'date': '指定日期学习'|trans }, course.expiryMode|default('days'), course.status|default('draft') == 'published'? 'disabled': '') }}
                <div class="mbm mtm {% if course.expiryMode|default('days') == 'date' %}hidden{% endif %}" id="expiry-days">
                  {{'学习有效期'|trans}}
                  <input class="form-control mhs" type="text" id="expiryDays" name="expiryDays" style="display:inline-block;width:150px" value="{{course.expiryDays|default('0')}}">
                  {{'天'|trans}}
                  <a class="es-icon es-icon-help ml5 link-gray" data-trigger="hover" data-toggle="popover" data-container="body" data-placement="top" data-content="{{'设置为0天则无限制'|trans}}"></a>
                </div>
                <div class="mbm mtm {% if course.expiryMode|default('days') == 'days' %}hidden{% endif %}" id="expiry-date">
                  {{'开始日期'|trans}}
                  <input class="form-control mls mrl" id="expiryStartDate" type="text" name="expiryStartDate" value="{{course.expiryStartDate|default('now'|date('Y-m-d'))}}" style="display:inline-block;width:150px">
                  {{'结束日期'|trans}}
                  <input class="form-control mls" type="text" id="expiryEndDate" name="expiryEndDate" value="{{course.expiryEndDate|default('')}}" style="display:inline-block;width:150px">
                </div>
                <p class="help-block mtm mbm">{{'过期后将无法观看内容，系统默认会在到期前10天提醒学员。'|trans}}</p>
                <div class="color-warning">{{'课程首次发布后“学习有效期方式”将不能再修改'|trans}}</div>
            </div>
          {% else %}
            <div class="col-sm-8 form-control-static">
              {% if course.expiryMode|default('days') != 'date' %}
                随到随学
                <div class="mbm mtm" id="expiry-days">
                  {{'学习有效期'|trans}}<input class="form-control mhs" type="text" id="expiryDays" name="expiryDays" style="display:inline-block;width:150px" value="{{course.expiryDays|default('0')}}" >{{'天'|trans}}
                  <a class="es-icon es-icon-info ml5 link-gray" data-trigger="hover" data-toggle="popover" data-container="body" data-placement="top" data-content="{{'设置为0天则无限制'|trans}}"></a>
                </div>
              {% else %}
                指定日期学习
                <a class="es-icon es-icon-help ml5 link-gray" data-trigger="hover" data-toggle="popover" data-container="body" data-placement="top" data-content="{{'过期后将无法观看内容，系统默认会在到期前10天提醒学员。'|trans}}"></a>
                <div class="mbm mtm" id="expiry-date">
                {{'开始日期'|trans}}
                <input class="form-control mls mrl" disabled id="expiryStartDate" type="text" name="expiryStartDate" value="{{course.expiryStartDate|default('now'|date('Y-m-d'))}}" style="display:inline-block;width:150px" >
                {{'结束日期'|trans}}
                <input class="form-control mls" disabled type="text" id="expiryEndDate" name="expiryEndDate" value="{{course.expiryEndDate|default('')}}" style="display:inline-block;width:150px">
                </div>
              {% endif %}
              <p class="help-block mtm">{{'过期后将无法观看内容，系统默认会在到期前10天提醒学员。'|trans}}</p>
            </div>
          {% endif %}
        </div>#}
        {% if courseSet.type == 'live' %}
          <div class="form-group">
            <label class="col-md-2 control-label" for="maxStudentNum-field">课程人数</label>
            <div class="col-md-10 controls">
              <input type="text" id="maxStudentNum-field" name="maxStudentNum" class="form-control width-input width-input-large"
                value="{{ course.maxStudentNum|default('') }}" data-live-capacity-url="{{ path('course_set_live_capacity', {courseSetId: courseSet.id, courseId: course.id}) }}" data-explain=""> 人
              <div class="help-block" style="display:none;"></div></div>
            <div class="col-md-offset-2 col-md-10 js-course-rule">
              <p class="alert-warning"></p>
              <a href="{{ path('content_course_rule') }}" target="_blank">【查看直播课程细则】</a>
            </div>
          </div>
        {% endif %}

        <div class="form-group">
          <div class="col-md-2 control-label">
            <label>{{'计划简介'|trans}}</label>
          </div>
          <div class="col-md-8 controls">
            <textarea class="form-control invisible" name="summary" rows="10" id="summary" data-image-upload-url="{{ path('editor_upload', {token:upload_token('course')}) }}">{{ field_value(course, 'summary') }}</textarea>
          </div>
        </div>
        <div class="form-group dynamic-collection" id="course-goals-form-group">
          <div class="col-md-2 control-label">
            <label>{{'课程目标'|trans}}</label>
          </div>
          <div class="col-md-8 controls">
            <div id="course-goals" data-field-name="goals" data-init-value="{{course.goals|default([])|json_encode_utf8()}}"></div>
          </div>
        </div>
        <div class="form-group" id="course-audiences-form-group">
          <div class="col-md-2 control-label">
            <label>{{'适应人群'|trans}}</label>
          </div>
          <div class="col-md-8 controls">
            <div id="intended-students" data-field-name="audiences" data-init-value="{{course.audiences|default([])|json_encode_utf8()}}"></div>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-offset-2 col-sm-8">
            <button id="course-submit" type="button" class="btn btn-primary" data-loading-text="{{ '正在保存...'|trans }}">{{ '保存'|trans }}</button>
            <div id="test"></div>
          </div>
        </div>
      </form>
    </div>
  </div>
{% endblock %}