{% extends 'old-bootstrap-modal-layout.html.twig' %}

{% set modalSize = 'large' %}

{% block title %}{% if announcement|default(null) %}{{ '编辑'|trans }}{% else %}{{ '新增'|trans }}{% endif %}{{ '公告'|trans }}{% endblock %}
{% block body %}

  <form id="announcement-create-form" class="form-horizontal" method="post"
    action="{% if announcement|default(null) %}{{ path('admin_announcement_edit',{id:announcement.id}) }}{% else %}{{ path('admin_announcement_create') }}{% endif %}">
    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="title">{{ '公告内容'|trans }}</label>
      </div>
      <div class="col-md-8 controls">
        <textarea class="form-control" id="content-filed" name="content"
          data-display="{{ '公告内容'|trans }}">{% if announcement|default(null) %}{{ announcement.content }}{% endif %}</textarea>
      </div>
    </div>
    {% if announcement.url | default('') %}
      <div class="row form-group">
        <div class="col-md-2 control-label">
          <label for="url">{{ '内容链接'|trans }}</label>
        </div>
        <div class="col-md-8 controls">
          <input type="text" id="url" name="url" class="form-control" value="{{ announcement.url|default('') }}">
          <p class="help-block">{{ '以"http://"或"https://"开头'|trans }}</p>
        </div>
      </div>
    {% else %}
      <input type="hidden" id="url" name="url" class="form-control" value="">
    {% endif %}
    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="startTime">{{ '发布时间'|trans }}</label>
      </div>
      <div class="col-md-8 controls" style="z-index:2000;">
        <input type="text" id="startTime" name="startTime" class="form-control"
          value="{% if announcement|default(null) %}{{ announcement.startTime|date("Y-m-d H:i") }}{% endif %}">
      </div>
    </div>

    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="endTime">{{ '结束时间'|trans }}</label>
      </div>
      <div class="col-md-8 controls" style="z-index:2000;">
        <input type="text" id="endTime" name="endTime" class="form-control"
          value="{% if announcement|default(null) %}{{ announcement.endTime|date("Y-m-d H:i") }}{% endif %}">
      </div>
    </div>
    <div class="alert alert-info">
      <strong>1.公告将显示在网站首页顶部导航上方</strong><br><strong>2.最多可显示3条最新的进行中的通告</strong>
    </div>
    {% include 'org/org-tree-select.html.twig' with {orgCode:announcement.orgCode|default(null), modal: 'modal'} %}

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

{% block footer %}
  <button id="announcement-create-btn" data-submiting-text="{{ '正在提交'|trans }}" type="submit" class="btn btn-primary pull-right"
    data-toggle="form-submit" data-target="#announcement-create-form">{{ '提交'|trans }}</button>
  <button type="button" class="btn btn-link pull-right" data-dismiss="modal">{{ '取消'|trans }}</button>
  <script>app.load('announcement/create-modal')</script>
{% endblock %}