{% extends 'checkIn/layout.html' %}
{% load staticfiles %}

{% block script %}
<script src="{% static 'JS/newItems.js' %}"></script>
{% endblock %}

{% block body %}
<div id="input" class="container">
    <form id="newItem" method="post">
        {% csrf_token %}
        <div class="form-group">
            <label>标题</label>
            <input type="text" name="description" required="required" value="{{item.description}}" class="form-control"/>
        </div>
        <div class="form-group">
            <label>类型</label>
            <select id="type" name="type" class="form-control" onchange="selectionShow()">
                    <option value="0" {% if item.type == 0 %} selected="selected" {% endif %}>文本</option>
                    <option value="1" {% if item.type == 1 %} selected="selected" {% endif %}>数字</option>
                    <option value="2" {% if item.type == 2 %} selected="selected" {% endif %}>邮件</option>
                    <option value="3" {% if item.type == 3 %} selected="selected" {% endif %}>日期</option>
                    <option value="4" {% if item.type == 4 %} selected="selected" {% endif %}>单项选择</option>
                    <option value="5" {% if item.type == 5 %} selected="selected" {% endif %}>多项选择</option>
                    <option value="6" {% if item.type == 6 %} selected="selected" {% endif %}>文件上传</option>
                    <option value="7" {% if item.type == 7 %} selected="selected" {% endif %}>图片上传</option>
                    </select>
        </div>
        <div id="itemSelection" name="itemSeletion" hidden="hidden" class="form-group">
            <label id="labelForItemSelection">输入所有的选项，每个选项一行<br /></label>
            <textarea id="selectOptions" name="itemSelection" rows="10" cols="50" class="form-control">{{item.itemSelection}}</textarea>
        </div>
        <div id="onlyDIV" class="form-group">
            <label>是否要求唯一？</label>
            <input id="onlyCheck" type="checkbox" name="uniqueItem" {% if item.unique %} checked="checked" {% endif %} data-toggle="tooltip" title="系统将拒绝同样的签到内容二次签到。" />
        </div>
        <div id="reservedDIV" class="form-group">
            <label>是否预设签到内容？</label>
            <input type="checkbox" id="reservedCheck" name="reservedFlag" onchange="reservedChange()" {% if item.reservedContent %} checked="checked" {% endif %} data-toggle="tooltip" title="系统将只会接受签到者输入的信息在预制信息之内。"/>
        </div>
        <div id="reservedArea" hidden="hidden" class="form-group">
            <label>如果需要设定预设内容，请输入所有选项，用分号（；）分割，或者每个选项一行。并且勾选是否预设签到内容。<br /></label>
            <textarea name="reservedContent" rows="10" cols="50" class="form-control"> {{item.reservedContent }}</textarea>
        </div>
        <input type="submit" value="修改" class="btn btn-default"/>
    </form><br />
    <button class="btn btn-default" onClick="javascript :history.back(-1);">返回</button>
</div>
<script>
    reservedChange();
    selectionShow();
</script>
{% endblock %}