{% extends 'wgcomm/base.html' %}
{% block head %}
    {#    <link href="/static/wgcomm/bootstrap-datetimepicker.min.css" rel="stylesheet"/>#}
{% endblock %}
{% block tail %}
    <script src="static/wgcomm/js/datepicker.js"></script>
    <script src="static/wgcomm/js/wgdatepicker.js"></script>

{% endblock %}
{% block tail_min %}
    <script src="static/wgcomm/js/datepicker.min.js"></script>
    <script src="static/wgcomm/js/wgdatepicker.min.js"></script>
{% endblock %}
{% block title %}
    Add Task  
{% endblock %}


{% block main_content %}
    <!--app-content open-->
    <div class="app-content main-content mt-0">
        <div class="side-app">
            <!-- CONTAINER -->
            <div class="main-container container-fluid">

                <!-- PAGE-HEADER -->
                <div class="page-header">
                    <div>
                        <h1 class="page-title">Add Task  </h1>
                    </div>
                    <div class="ms-auto pageheader-btn">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item">Configuration</li>
                            <li class="breadcrumb-item"><a href="javascript:void(0);">Scheduled task</a></li>
                            <li class="breadcrumb-item active" aria-current="page">Add</li>
                        </ol>
                    </div>
                </div>
                <!-- PAGE-HEADER END -->
                {% with messages = get_flashed_messages() %}
                    {% if messages %}
                        <div class="form-group">
                            <ul>
                                {% for message in messages %}
                                    <li class="text-danger">{{ message }}</li>
                                {% endfor %}
                            </ul>
                        </div>
                    {% endif %}
                {% endwith %}
                <!--ROW OPENED-->
                <div class="row">
                    <div class="col-lg-12 col-md-12">
                        <div class="card">
                            <form action="{{ url_for('wgcomm_extern_tasklist.web_extern_tasklist_add') }}"
                                  method="post">
                                <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
                                {{ wgform._csrf }}
                                <div class="card-header border-bottom">
                                    <h4 class="mb-0">Task Info  </h4>
                                </div>
                                <div class="card-body">
                                    <div class="form-group">
                                        {{ wgform.f_Id.label }}
                                        {#                                        <br>{{ wgform.f_Id.data }}#}
                                        {#                                        <div hidden="hidden">#}
                                        {{ wgform.f_Id( class="form-control") }}
                                        {#                                        </div>#}
                                    </div>
                                    <div class="form-group">
                                        {{ wgform.f_Notes.label }}
                                        {{ wgform.f_Notes( class="form-control") }}
                                    </div>


                                    <div class="form-group">
                                        {{ wgform.f_BeginYMD.label }}
                                        <div id="begin-datepicker" class="input-group date"
                                             data-date-format="yyyy-mm-dd">
                                                <span class="input-group-addon input-group-text bg-primary-transparent"><i
                                                        class="fe fe-calendar text-primary-dark"></i></span>
                                            <input id="f_BeginYMD" name="f_BeginYMD" class="form-control" type="text"
                                                   value="2024-01-01" placeholder="Year-Month-Day  "/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        {{ wgform.f_EndYMD.label }}
                                        <div id="end-datepicker" class="input-group date"
                                             data-date-format="yyyy-mm-dd">
                                                <span class="input-group-addon input-group-text bg-primary-transparent"><i
                                                        class="fe fe-calendar text-primary-dark"></i></span>
                                            <input id="f_EndYMD" name="f_EndYMD" class="form-control" type="text"
                                                   value="2099-12-31" placeholder="Year-Month-Day  "/>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        {{ wgform.f_OperateTime.label }}

                                        <input type="time" style="border-width: 1px; border-style: solid"
                                               id="f_OperateTime" name="f_OperateTime" min="00:00" max="23:59"
                                               value="08:00">
                                    </div>
                                    <div class="form-group">
                                        {{ wgform.f_DoorControl.label }}
                                        {#                                        {{ wgform.f_DoorControl( class="form-control") }}#}
                                        <select class="form-control  form-select  text-dark" id="f_DoorControl"
                                                name="f_DoorControl">
                                            {#                                           <option value="0" >0</option>#}
                                            {% for i in range(13) %}
                                                {#                                                {% if i!=wgform.f_DoorControl.data %}#}
                                                {#                                                <option value="{{ i }}">{{controlmod[ i ]}}</option>#}
                                                {#                                                {% endif %}#}
                                                <option value="{{ i }}"
                                                        {% if i==wgform.f_DoorControl.data %}
                                                        selected
                                                        {% endif %}
                                                >{{ controlmod[ i ] }}</option>
                                            {% endfor %}
                                        </select>
                                    </div>
                                    <div>
                                        {#         <input type="checkbox"  class="custom-control-input" name="selectall2" value="1" checked id="chkalldoors2"  onclick="selectAll(this)">#}
                                        {#         <input type="checkbox"  class="form-control  form-select" name="selectall3" value="1" checked id="chkalldoors3"  onclick="selectAll(this)">#}
                                        {#             <label>All Doors  2</label></div>#}
                                        {#                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">#}
                                        {#                                            <input type="checkbox" class="custom-control-input" id="f_EnabledBaseConfig"#}
                                        {#                                                   name="f_EnabledBaseConfig"#}
                                        {#                                                   value="1" checked>#}
                                        {#                                            <span class="custom-control-label">Basic Configuration</span>#}
                                        {#                                        </label>#}
                                        {#                                <div class="form-group">#}
                                        {#                                    <select  class="form-control  form-select  text-dark" id="myMultiSelect" name="fruits" multiple size="4">#}
                                        {#            <option value="apple">苹果</option>#}
                                        {#            <option value="banana">香蕉</option>#}
                                        {#            <option value="orange">橙子</option>#}
                                        {#            <option value="grape">葡萄</option>#}
                                        {#            <option value="mango">芒果</option>#}
                                        {#        </select>#}
                                        {#                                </div>#}
                                        <!-- 使用 fieldset 将相Closed的复选框分组 -->
                                        <script>
                                            function selectAll(source) {
                                                const checkboxes = document.getElementById('selectdoors');
                                                if (source.checked) {
                                                    checkboxes.hidden = true; //"hidden";//"none"; //
                                                } else {
                                                    checkboxes.hidden = false; //"";
                                                }
                                                //const checkboxes = document.getElementsByName('citys');
                                                //for (let checkbox of checkboxes) {
                                                //   checkbox.checked = !source.checked;
                                                //}
                                            }
                                        </script>

                                        <div class="form-group">
                                            {{ wgform.f_FloorNames.label }}
                                            <div>
                                                <input type="checkbox" name="f_Door_All" value="0" id="f_Door_All"
                                                       onclick="selectAll(this)">
                                                <label>All Doors  </label></div>
                                            <fieldset class="checkbox-group col-sm-12 col-md-12 col-xl-12"
                                                      name="selectdoors" id="selectdoors">
                                                <!-- legend 作为这Unit分组的标题 -->
                                                {#            <legend>请选择您喜欢的城市 (最多显示5行)：</legend>#}

                                                <!-- 复选框的滚动容器 -->
                                                {#            选择门#}
                                                <div class="checkbox-container">
                                                    {% for door in doors %}
                                                        <label><input type="checkbox" name="f_Door_{{ door.f_DoorID }}"
                                                                      value="{{ door.f_DoorID }}"
                                                                      id="f_Door_{{ door.f_DoorID }}">{{ door.f_DoorName }}
                                                        </label>
                                                        {#                                     <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">#}
                                                        {#                                            <input type="checkbox" class="custom-control-input" id="f_EnabledBaseConfig_{{ door.f_DoorID }}"#}
                                                        {#                                                   name="f_EnabledBaseConfig"#}
                                                        {#                                                   value="1" checked>#}
                                                        {#                                            <span class="custom-control-label">{{ door.f_DoorName }}</span>#}
                                                        {#                                        </label>#}
                                                    {% endfor %}
                                                    {#                <label><input type="checkbox" name="city" value="beijing"> 北京</label>#}
                                                    {#                <label><input type="checkbox" name="city" value="shanghai"> 上海</label>#}
                                                    {#                <label><input type="checkbox" name="city" value="guangzhou"> 广州</label>#}
                                                    {#                <label><input type="checkbox" name="city" value="shenzhen"> 深圳</label>#}
                                                    {#                <label><input type="checkbox" name="city" value="hangzhou"> 杭州</label>#}
                                                    {#                <label><input type="checkbox" name="city" value="chengdu"> 成都</label>#}
                                                    {#                <label><input type="checkbox" name="city" value="xian"> 西安</label>#}
                                                    {#                <label><input type="checkbox" name="city" value="suzhou"> 苏州</label>#}
                                                    <!-- 更多选项可以继续Add，超Exit部分将可Pass滚动条查看 -->
                                                </div>
                                            </fieldset>
                                        </div>
                                    </div>

                                    {#                                <div class="form-group">#}
                                    {#                                <fieldset class="checkbox-group">#}
                                    {#            <!-- legend 作为这Unit分组的标题 -->#}
                                    {#            <legend>请选择您喜欢的水果:</legend>#}
                                    {#{{ wgform.f_FloorNames.label }}#}
                                    {#                                    <div class="checkbox-container">#}
                                    {#            <label>#}
                                    {#                <input type="checkbox" name="fruits" value="apple"> 苹果#}
                                    {#            </label>#}
                                    {#            <label>#}
                                    {#                <input type="checkbox" name="fruits" value="banana"> 香蕉#}
                                    {#            </label>#}
                                    {#            <label>#}
                                    {#                <input type="checkbox" name="fruits" value="orange"> 橙子#}
                                    {#            </label>#}
                                    {#            <label>#}
                                    {#                <input type="checkbox" name="fruits" value="grape"> 葡萄#}
                                    {#            </label>#}
                                    {#            <label>#}
                                    {#                <input type="checkbox" name="fruits" value="mango"> 芒果#}
                                    {#            </label>#}
                                    {#                                         </div>#}
                                    {#        </fieldset>#}
                                    {# </div>#}
                                    <div class="form-group">
                                        Week Options  
                                        <div>
                                            <fieldset class="checkbox-group col-sm-12 col-md-12 col-xl-12"
                                                      name="selectdoors2" id="selectdoors2">
                                                <div class="checkbox-container">
                                                    <label><input type="checkbox" name="f_Monday"
                                                            {% if wgform.f_Monday.data %}
                                                                  value="1" checked
                                                            {% else %}
                                                                  value="0"
                                                            {% endif %} id="f_Monday">{{ wgform.f_Monday.label }}
                                                    </label>
                                                    <label><input type="checkbox" name="f_Tuesday"
                                                            {% if wgform.f_Tuesday.data %}
                                                                  value="1" checked
                                                            {% else %}
                                                                  value="0"
                                                            {% endif %} id="f_Tuesday">{{ wgform.f_Tuesday.label }}
                                                    </label>
                                                    <label><input type="checkbox" name="f_Wednesday"
                                                            {% if wgform.f_Wednesday.data %}
                                                                  value="1" checked
                                                            {% else %}
                                                                  value="0"
                                                            {% endif %} id="f_Wednesday">{{ wgform.f_Wednesday.label }}
                                                    </label>
                                                    <label><input type="checkbox" name="f_Thursday"
                                                            {% if wgform.f_Thursday.data %}
                                                                  value="1" checked
                                                            {% else %}
                                                                  value="0"
                                                            {% endif %} id="f_Thursday">{{ wgform.f_Thursday.label }}
                                                    </label>
                                                    <label><input type="checkbox" name="f_Friday"
                                                            {% if wgform.f_Friday.data %}
                                                                  value="1" checked
                                                            {% else %}
                                                                  value="0"
                                                            {% endif %} id="f_Friday">{{ wgform.f_Friday.label }}
                                                    </label>
                                                    <label><input type="checkbox" name="f_Saturday"
                                                            {% if wgform.f_Saturday.data %}
                                                                  value="1" checked
                                                            {% else %}
                                                                  value="0"
                                                            {% endif %} id="f_Saturday">{{ wgform.f_Saturday.label }}
                                                    </label>
                                                    <label><input type="checkbox" name="f_Sunday"
                                                            {% if wgform.f_Sunday.data %}
                                                                  value="1" checked
                                                            {% else %}
                                                                  value="0"
                                                            {% endif %} id="f_Sunday">{{ wgform.f_Sunday.label }}
                                                    </label>
                                                </div>
                                            </fieldset>
                                        </div>
                                    </div>
                                    {#                                    <div class="col-sm-12 col-md-12 col-xl-3 no-taskEnd-checkbox">#}
                                    {#                                        <div class="form-group">#}
                                    {#                                            <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">#}
                                    {#                                                <input type="checkbox" class="custom-control-input" id="f_Monday"#}
                                    {#                                                       name="f_Monday"#}
                                    {#                                                        {% if wgform.f_Monday.data %}#}
                                    {#                                                       value="1" checked#}
                                    {#                                                        {% else %}#}
                                    {#                                                       value="0"#}
                                    {#                                                        {% endif %}#}
                                    {#                                                >#}
                                    {#                                                <span class="custom-control-label"> {{ wgform.f_Monday.label }}</span>#}
                                    {#                                            </label>#}
                                    {#                                        </div>#}
                                    {#                                        <div class="form-group">#}
                                    {#                                            <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">#}
                                    {#                                                <input type="checkbox" class="custom-control-input" id="f_Tuesday"#}
                                    {#                                                       name="f_Tuesday"#}
                                    {#                                                        {% if wgform.f_Tuesday.data %}#}
                                    {#                                                       value="1" checked#}
                                    {#                                                        {% else %}#}
                                    {#                                                       value="0"#}
                                    {#                                                        {% endif %}#}
                                    {#                                                >#}
                                    {#                                                <span class="custom-control-label"> {{ wgform.f_Tuesday.label }}</span>#}
                                    {#                                            </label>#}
                                    {#                                        </div>#}
                                    {#                                        <div class="form-group">#}
                                    {#                                            <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">#}
                                    {#                                                <input type="checkbox" class="custom-control-input" id="f_Wednesday"#}
                                    {#                                                       name="f_Wednesday"#}
                                    {#                                                        {% if wgform.f_Wednesday.data %}#}
                                    {#                                                       value="1" checked#}
                                    {#                                                        {% else %}#}
                                    {#                                                       value="0"#}
                                    {#                                                        {% endif %}#}
                                    {#                                                >#}
                                    {#                                                <span class="custom-control-label"> {{ wgform.f_Wednesday.label }}</span>#}
                                    {#                                            </label>#}
                                    {#                                        </div>#}
                                    {#                                        <div class="form-group">#}
                                    {#                                            <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">#}
                                    {#                                                <input type="checkbox" class="custom-control-input" id="f_Thursday"#}
                                    {#                                                       name="f_Thursday"#}
                                    {#                                                        {% if wgform.f_Thursday.data %}#}
                                    {#                                                       value="1" checked#}
                                    {#                                                        {% else %}#}
                                    {#                                                       value="0"#}
                                    {#                                                        {% endif %}#}
                                    {#                                                >#}
                                    {#                                                <span class="custom-control-label"> {{ wgform.f_Thursday.label }}</span>#}
                                    {#                                            </label>#}
                                    {#                                        </div>#}
                                    {#                                        <div class="form-group">#}
                                    {#                                            <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">#}
                                    {#                                                <input type="checkbox" class="custom-control-input" id="f_Friday"#}
                                    {#                                                       name="f_Friday"#}
                                    {#                                                        {% if wgform.f_Friday.data %}#}
                                    {#                                                       value="1" checked#}
                                    {#                                                        {% else %}#}
                                    {#                                                       value="0"#}
                                    {#                                                        {% endif %}#}
                                    {#                                                >#}
                                    {#                                                <span class="custom-control-label"> {{ wgform.f_Friday.label }}</span>#}
                                    {#                                            </label>#}
                                    {#                                        </div>#}
                                    {#                                        <div class="form-group">#}
                                    {#                                            <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">#}
                                    {#                                                <input type="checkbox" class="custom-control-input" id="f_Saturday"#}
                                    {#                                                       name="f_Saturday"#}
                                    {#                                                        {% if wgform.f_Saturday.data %}#}
                                    {#                                                       value="1" checked#}
                                    {#                                                        {% else %}#}
                                    {#                                                       value="0"#}
                                    {#                                                        {% endif %}#}
                                    {#                                                >#}
                                    {#                                                <span class="custom-control-label"> {{ wgform.f_Saturday.label }}</span>#}
                                    {#                                            </label>#}
                                    {#                                        </div>#}
                                    {#                                        <div class="form-group">#}
                                    {#                                            <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">#}
                                    {#                                                <input type="checkbox" class="custom-control-input" id="f_Sunday"#}
                                    {#                                                       name="f_Sunday"#}
                                    {#                                                        {% if wgform.f_Sunday.data %}#}
                                    {#                                                       value="1" checked#}
                                    {#                                                        {% else %}#}
                                    {#                                                       value="0"#}
                                    {#                                                        {% endif %}#}
                                    {#                                                >#}
                                    {#                                                <span class="custom-control-label"> {{ wgform.f_Sunday.label }}</span>#}
                                    {#                                            </label>#}
                                    {#                                        </div>#}
                                    {#                                    </div>#}


                                    {#                                    <div class="form-group">#}
                                    {#                                        {{ wgform.f_ControlSegIDLinked.label }}#}
                                    {#                                        {{ wgform.f_ControlSegIDLinked( class="form-control") }}#}
                                    {#                                        <select class="form-control  form-select  text-dark" id="f_ControlSegIDLinked"#}
                                    {#                                                name="f_ControlSegIDLinked">#}
                                    {#                                            <option value="0" >0</option>#}
                                    {#                                            {% for i in range(255) %}#}
                                    {#                                                {% if i!=1 and i!=wgform.f_ControlSegID.data %}#}
                                    {#                                                <option value="{{ i }}">{{ i }}</option>#}
                                    {#                                                {% endif %}#}
                                    {#                                            {% endfor %}#}
                                    {#                                        </select>#}
                                    {#                                    </div>#}

                                    <div class="row p-5">
                                        <div class="btn-list text-end">
                                            <button id="submitcancel" name="submitcancel" class="btn btn-outline-danger"
                                                    type="submit" value="Cancel">
                                                <i class="fe fe-x-circle"></i>
                                                Cancel
                                            </button>
                                            <button id="submitsave" name="submitsave" class="btn btn-primary"
                                                    type="submit"
                                                    value="Save">
                                                <i class="fe fe-check-circle"></i>
                                                Save
                                            </button>
                                            {#                                            <button id="submitsave" name="submitsaveandadd" class="btn btn-primary"#}
                                            {#                                                    type="submit" value="Save And Continue">#}
                                            {#                                                <i class="fe fe-check-square"></i>#}
                                            {#                                                Save And Continue#}
                                            {#                                            </button>#}
                                        </div>
                                    </div>
                                </div>
                            </form>

                            {#<form action="{{ url_for('wgcomm_extern_tasklist.web_extern_tasklist_add') }}" method="post">#}
                            {#                                <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">#}
                            {#                                {{ wgform._csrf }}#}
                            {#  <fieldset>#}
                            {#    <legend>选项</legend>#}
                            {#    <input type="checkbox" name="option1" value="on"> 选项一#}
                            {#    <input type="checkbox" name="option2" value="on" checked> 选项二（默认选中）#}
                            {#                      {% for door in doors %}#}
                            {#                <label><input type="checkbox" value="0" name="f_Door_{{ door.f_DoorID }}" id="f_Door_{{ door.f_DoorID }}">{{ door.f_DoorName }}</label>#}
                            {#                                     <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">#}
                            {#                                            <input type="checkbox" class="custom-control-input" id="f_EnabledBaseConfig_{{ door.f_DoorID }}"#}
                            {#                                                   name="f_EnabledBaseConfig"#}
                            {#                                                   value="1" checked>#}
                            {#                                            <span class="custom-control-label">{{ door.f_DoorName }}</span>#}
                            {#                                        </label>#}
                            {#                {% endfor %}#}
                            {##}
                            {#  </fieldset>#}
                            {#  <button type="submit">提交</button>#}
                            {#</form>#}

                        </div>
                    </div>
                </div>
                <!--ROW CLOSED-->
            </div>
        </div>
    </div>
    <!-- CONTAINER CLOSED -->
{% endblock %}
