{% extends 'wgcomm/base.html' %}

{% block title %}
    Alarm & Fire Linkage Configuration
{% endblock %}
{% block tail %}
    <script src="{{ url_for('static',filename='wgcomm/js/controller-add.js') }}"></script>
{% endblock %}
{% block tail_min %}
    <script src="{{ url_for('static',filename='wgcomm/js/controller-add.min.js') }}"></script>
{% 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">{{ wgform.f_ControllerNO.data }}-[SN:{{ wgform.f_ControllerSN.data}}]-Alarm & Fire Linkage Configuration</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);">Alarm Linkage</a></li>
                            <li class="breadcrumb-item active" aria-current="page">Configure</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_peripheral_control.web_extern_peripheral_control_edit') }}" method="post">
                                <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
                                {{ wgform._csrf }}
                                <div class="card-header border-bottom">
                                    <h4 class="mb-0">Warn</h4>
                                </div>
                                <div class="card-body">
                                    <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_ForceWarn"
                                                       name="f_ForceWarn"
                                                        {% if wgform.f_ForceWarn.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_ForceWarn.label}}</span>
                                            </label>
                                        </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_DoorOpenTooLong"
                                                       name="f_DoorOpenTooLong"
                                                        {% if wgform.f_DoorOpenTooLong.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_DoorOpenTooLong.label}}</span>
                                            </label>
                                        </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_DoorInvalidOpen"
                                                       name="f_DoorInvalidOpen"
                                                        {% if wgform.f_DoorInvalidOpen.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_DoorInvalidOpen.label}}</span>
                                            </label>
                                        </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_InvalidCardWarn"
                                                       name="f_InvalidCardWarn"
                                                        {% if wgform.f_InvalidCardWarn.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_InvalidCardWarn.label}}</span>
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <div class="card-header border-bottom">
                                    <h4 class="mb-0">Expansion Board Output Settings  </h4>
                                </div>
{#                                <div class="card-header border-bottom">#}
{#                                    <h5 class="mb-0">1# Port Output  </h5>#}
{#                                </div>#}
                                <div class="card-body">
                                    <div class="form-group">
                                       <h5 class="mb-0"> #1 # Port Output  -{{wgform.f_PeripheralControl_1_source.label}}</h5>
                                        <select class="form-control  form-select  text-dark" id="f_PeripheralControl_1_source"
                                                name="f_PeripheralControl_1_source">
                                        <option value="0"
                                                    {% if wgform.f_PeripheralControl_1_source.data == 0  %}
                                                    selected
                                                    {% endif %}
                                                >(Not enabled)
                                                </option>
                                        {% for i in (1,2,3,4) %}
                                            {% if i<=wgform.producttype.data %}
                                                <option value="{{ i }}"
                                                    {% if wgform.f_PeripheralControl_1_source.data == i  %}
                                                    selected
                                                    {% endif %}
                                                >{{ i }}#
                                                </option>
                                            {% endif %}
                                        {% endfor %}
                                        </select>
                                    </div>
{#                                    <div class="col-sm-12 col-md-12 col-xl-3 no-taskEnd-checkbox">#}
                                    <div class="col-sm-12 col-md-12 col-xl-12 no-taskEnd-checkbox">
                                        Trigger Event
                                        <div class="form-group">
                                            <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_1_event1"
                                                       name="f_PeripheralControl_1_event1"
                                                        {% if wgform.f_PeripheralControl_1_event1.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_1_event1.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_PeripheralControl_1_event2"
                                                       name="f_PeripheralControl_1_event2"
                                                        {% if wgform.f_PeripheralControl_1_event2.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_1_event2.label}}</span>
                                            </label>
                                             <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_1_event3"
                                                       name="f_PeripheralControl_1_event3"
                                                        {% if wgform.f_PeripheralControl_1_event3.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_1_event3.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_1_event4"
                                                       name="f_PeripheralControl_1_event4"
                                                        {% if wgform.f_PeripheralControl_1_event4.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_1_event4.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_1_event5"
                                                       name="f_PeripheralControl_1_event5"
                                                        {% if wgform.f_PeripheralControl_1_event5.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_1_event5.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_1_event6"
                                                       name="f_PeripheralControl_1_event6"
                                                        {% if wgform.f_PeripheralControl_1_event6.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_1_event6.label}}</span>
                                            </label>
                                        </div>
                                        <div class="form-group">
                                            {{ wgform.f_PeripheralControl_1_output_duration.label }}
                                            {{ wgform.f_PeripheralControl_1_output_duration( class="form-control") }}
                                        </div>
                                    <div class="form-group">
                                            {{ wgform.f_PeripheralControl_1_control_mode.label }}
                                        <select class="form-control  form-select  text-dark" id="f_PeripheralControl_1_control_mode"
                                                name="f_PeripheralControl_1_control_mode">
                                        <option value="1"
                                                    {% if wgform.f_PeripheralControl_1_control_mode.data == 1  %}
                                                    selected
                                                    {% endif %}
                                                >1-Fixed Delay  
                                                </option>
                                        <option value="2"
                                                    {% if wgform.f_PeripheralControl_1_control_mode.data == 2  %}
                                                    selected
                                                    {% endif %}
                                                >2-Output continues until alarm reset [for intrusion/door-ajar alarms]  
                                                </option>
                                        <option value="3"
                                                    {% if wgform.f_PeripheralControl_1_control_mode.data == 3  %}
                                                    selected
                                                    {% endif %}
                                                >3-Sync with alarm trigger [no delay]  
                                                </option>
                                                 <option value="4"
                                                    {% if wgform.f_PeripheralControl_1_control_mode.data == 4  %}
                                                    selected
                                                    {% endif %}
                                                >4-Output if any selected I/O triggers (no delay)  
                                                </option>
                                                <option value="5"
                                                    {% if wgform.f_PeripheralControl_1_control_mode.data == 5  %}
                                                    selected
                                                    {% endif %}
                                                >5-Output only if all selected I/O trigger (no delay)  
                                                </option>
                                        </select>
                                    </div>

                                    Related I/O signals [Mode 4,5]  
                                        <div class="form-group">
                                            <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_1_signal_1"
                                                       name="f_PeripheralControl_1_signal_1"
                                                        {% if wgform.f_PeripheralControl_1_signal_1.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_1_signal_1.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_PeripheralControl_1_signal_2"
                                                       name="f_PeripheralControl_1_signal_2"
                                                        {% if wgform.f_PeripheralControl_1_signal_2.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_1_signal_2.label}}</span>
                                            </label>
                                             <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_1_signal_3"
                                                       name="f_PeripheralControl_1_signal_3"
                                                        {% if wgform.f_PeripheralControl_1_signal_3.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_1_signal_3.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_1_signal_4"
                                                       name="f_PeripheralControl_1_signal_4"
                                                        {% if wgform.f_PeripheralControl_1_signal_4.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_1_signal_4.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_1_signal_5"
                                                       name="f_PeripheralControl_1_signal_5"
                                                        {% if wgform.f_PeripheralControl_1_signal_5.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_1_signal_5.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_1_signal_6"
                                                       name="f_PeripheralControl_1_signal_6"
                                                        {% if wgform.f_PeripheralControl_1_signal_6.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_1_signal_6.label}}</span>
                                            </label>

                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_1_signal_7"
                                                       name="f_PeripheralControl_1_signal_7"
                                                        {% if wgform.f_PeripheralControl_1_signal_7.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_1_signal_7.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_1_signal_8"
                                                       name="f_PeripheralControl_1_signal_8"
                                                        {% if wgform.f_PeripheralControl_1_signal_8.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_1_signal_8.label}}</span>
                                            </label>
                                        </div>



                                    </div>

                                </div>
                            <div class="card-body">
                                    <div class="form-group">
                                       <h5 class="mb-0">#2 # Port Output  -{{wgform.f_PeripheralControl_2_source.label}}</h5>
                                        <select class="form-control  form-select  text-dark" id="f_PeripheralControl_2_source"
                                                name="f_PeripheralControl_2_source">
                                        <option value="0"
                                                    {% if wgform.f_PeripheralControl_2_source.data == 0  %}
                                                    selected
                                                    {% endif %}
                                                >(Not enabled)
                                                </option>
                                        {% for i in (1,2,3,4) %}
                                            {% if i<=wgform.producttype.data %}
                                                <option value="{{ i }}"
                                                    {% if wgform.f_PeripheralControl_2_source.data == i  %}
                                                    selected
                                                    {% endif %}
                                                >{{ i }}#
                                                </option>
                                            {% endif %}
                                        {% endfor %}
                                        </select>
                                    </div>
                                    <div class="col-sm-12 col-md-12 col-xl-12 no-taskEnd-checkbox">
                                        Trigger Event
                                        <div class="form-group">
                                            <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_2_event1"
                                                       name="f_PeripheralControl_2_event1"
                                                        {% if wgform.f_PeripheralControl_2_event1.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_2_event1.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_PeripheralControl_2_event2"
                                                       name="f_PeripheralControl_2_event2"
                                                        {% if wgform.f_PeripheralControl_2_event2.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_2_event2.label}}</span>
                                            </label>
                                             <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_2_event3"
                                                       name="f_PeripheralControl_2_event3"
                                                        {% if wgform.f_PeripheralControl_2_event3.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_2_event3.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_2_event4"
                                                       name="f_PeripheralControl_2_event4"
                                                        {% if wgform.f_PeripheralControl_2_event4.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_2_event4.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_2_event5"
                                                       name="f_PeripheralControl_2_event5"
                                                        {% if wgform.f_PeripheralControl_2_event5.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_2_event5.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_2_event6"
                                                       name="f_PeripheralControl_2_event6"
                                                        {% if wgform.f_PeripheralControl_2_event6.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_2_event6.label}}</span>
                                            </label>
                                        </div>
                                        <div class="form-group">
                                            {{ wgform.f_PeripheralControl_2_output_duration.label }}
                                            {{ wgform.f_PeripheralControl_2_output_duration( class="form-control") }}
                                        </div>
                                    <div class="form-group">
                                            {{ wgform.f_PeripheralControl_2_control_mode.label }}
                                        <select class="form-control  form-select  text-dark" id="f_PeripheralControl_2_control_mode"
                                                name="f_PeripheralControl_2_control_mode">
                                        <option value="1"
                                                    {% if wgform.f_PeripheralControl_2_control_mode.data == 1  %}
                                                    selected
                                                    {% endif %}
                                                >1-Fixed Delay  
                                                </option>
                                        <option value="2"
                                                    {% if wgform.f_PeripheralControl_2_control_mode.data == 2  %}
                                                    selected
                                                    {% endif %}
                                                >2-Output continues until alarm reset [for intrusion/door-ajar alarms]  
                                                </option>
                                        <option value="3"
                                                    {% if wgform.f_PeripheralControl_2_control_mode.data == 3  %}
                                                    selected
                                                    {% endif %}
                                                >3-Sync with alarm trigger [no delay]  
                                                </option>
                                                 <option value="4"
                                                    {% if wgform.f_PeripheralControl_2_control_mode.data == 4  %}
                                                    selected
                                                    {% endif %}
                                                >4-Output if any selected I/O triggers (no delay)  
                                                </option>
                                                <option value="5"
                                                    {% if wgform.f_PeripheralControl_2_control_mode.data == 5  %}
                                                    selected
                                                    {% endif %}
                                                >5-Output only if all selected I/O trigger (no delay)  
                                                </option>
                                        </select>
                                    </div>

                                    Related I/O signals [Mode 4,5]  
                                    <div class="form-group">
                                            <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_2_signal_1"
                                                       name="f_PeripheralControl_2_signal_1"
                                                        {% if wgform.f_PeripheralControl_2_signal_1.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_2_signal_1.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_PeripheralControl_2_signal_2"
                                                       name="f_PeripheralControl_2_signal_2"
                                                        {% if wgform.f_PeripheralControl_2_signal_2.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_2_signal_2.label}}</span>
                                            </label>
                                             <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_2_signal_3"
                                                       name="f_PeripheralControl_2_signal_3"
                                                        {% if wgform.f_PeripheralControl_2_signal_3.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_2_signal_3.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_2_signal_4"
                                                       name="f_PeripheralControl_2_signal_4"
                                                        {% if wgform.f_PeripheralControl_2_signal_4.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_2_signal_4.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_2_signal_5"
                                                       name="f_PeripheralControl_2_signal_5"
                                                        {% if wgform.f_PeripheralControl_2_signal_5.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_2_signal_5.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_2_signal_6"
                                                       name="f_PeripheralControl_2_signal_6"
                                                        {% if wgform.f_PeripheralControl_2_signal_6.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_2_signal_6.label}}</span>
                                            </label>

                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_2_signal_7"
                                                       name="f_PeripheralControl_2_signal_7"
                                                        {% if wgform.f_PeripheralControl_2_signal_7.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_2_signal_7.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_2_signal_8"
                                                       name="f_PeripheralControl_2_signal_8"
                                                        {% if wgform.f_PeripheralControl_2_signal_8.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_2_signal_8.label}}</span>
                                            </label>
                                        </div>
                                    </div>
                                </div>
                            <div class="card-body">
                                    <div class="form-group">
                                       <h5 class="mb-0">#3 # Port Output  -{{wgform.f_PeripheralControl_3_source.label}}</h5>
                                        <select class="form-control  form-select  text-dark" id="f_PeripheralControl_3_source"
                                                name="f_PeripheralControl_3_source">
                                        <option value="0"
                                                    {% if wgform.f_PeripheralControl_3_source.data == 0  %}
                                                    selected
                                                    {% endif %}
                                                >(Not enabled)
                                                </option>
                                        {% for i in (1,2,3,4) %}
                                            {% if i<=wgform.producttype.data %}
                                                <option value="{{ i }}"
                                                    {% if wgform.f_PeripheralControl_3_source.data == i  %}
                                                    selected
                                                    {% endif %}
                                                >{{ i }}#
                                                </option>
                                            {% endif %}
                                        {% endfor %}
                                        </select>
                                    </div>
                                    <div class="col-sm-12 col-md-12 col-xl-12 no-taskEnd-checkbox">
                                        Trigger Event
                                        <div class="form-group">
                                            <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_3_event1"
                                                       name="f_PeripheralControl_3_event1"
                                                        {% if wgform.f_PeripheralControl_3_event1.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_3_event1.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_PeripheralControl_3_event2"
                                                       name="f_PeripheralControl_3_event2"
                                                        {% if wgform.f_PeripheralControl_3_event2.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_3_event2.label}}</span>
                                            </label>
                                             <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_3_event3"
                                                       name="f_PeripheralControl_3_event3"
                                                        {% if wgform.f_PeripheralControl_3_event3.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_3_event3.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_3_event4"
                                                       name="f_PeripheralControl_3_event4"
                                                        {% if wgform.f_PeripheralControl_3_event4.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_3_event4.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_3_event5"
                                                       name="f_PeripheralControl_3_event5"
                                                        {% if wgform.f_PeripheralControl_3_event5.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_3_event5.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_3_event6"
                                                       name="f_PeripheralControl_3_event6"
                                                        {% if wgform.f_PeripheralControl_3_event6.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_3_event6.label}}</span>
                                            </label>
                                        </div>
                                                                            <div class="form-group">
                                            {{ wgform.f_PeripheralControl_3_output_duration.label }}
                                            {{ wgform.f_PeripheralControl_3_output_duration( class="form-control") }}
                                        </div>

                                    <div class="form-group">
                                            {{ wgform.f_PeripheralControl_3_control_mode.label }}
                                        <select class="form-control  form-select  text-dark" id="f_PeripheralControl_3_control_mode"
                                                name="f_PeripheralControl_3_control_mode">
                                        <option value="1"
                                                    {% if wgform.f_PeripheralControl_3_control_mode.data == 1  %}
                                                    selected
                                                    {% endif %}
                                                >1-Fixed Delay  
                                                </option>
                                        <option value="2"
                                                    {% if wgform.f_PeripheralControl_3_control_mode.data == 2  %}
                                                    selected
                                                    {% endif %}
                                                >2-Output continues until alarm reset [for intrusion/door-ajar alarms]  
                                                </option>
                                        <option value="3"
                                                    {% if wgform.f_PeripheralControl_3_control_mode.data == 3  %}
                                                    selected
                                                    {% endif %}
                                                >3-Sync with alarm trigger [no delay]  
                                                </option>
                                                 <option value="4"
                                                    {% if wgform.f_PeripheralControl_3_control_mode.data == 4  %}
                                                    selected
                                                    {% endif %}
                                                >4-Output if any selected I/O triggers (no delay)  
                                                </option>
                                                <option value="5"
                                                    {% if wgform.f_PeripheralControl_3_control_mode.data == 5  %}
                                                    selected
                                                    {% endif %}
                                                >5-Output only if all selected I/O trigger (no delay)  
                                                </option>
                                        </select>
                                    </div>

                                    Related I/O signals [Mode 4,5]  
                                    <div class="form-group">
                                            <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_3_signal_1"
                                                       name="f_PeripheralControl_3_signal_1"
                                                        {% if wgform.f_PeripheralControl_3_signal_1.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_3_signal_1.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_PeripheralControl_3_signal_2"
                                                       name="f_PeripheralControl_3_signal_2"
                                                        {% if wgform.f_PeripheralControl_3_signal_2.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_3_signal_2.label}}</span>
                                            </label>
                                             <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_3_signal_3"
                                                       name="f_PeripheralControl_3_signal_3"
                                                        {% if wgform.f_PeripheralControl_3_signal_3.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_3_signal_3.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_3_signal_4"
                                                       name="f_PeripheralControl_3_signal_4"
                                                        {% if wgform.f_PeripheralControl_3_signal_4.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_3_signal_4.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_3_signal_5"
                                                       name="f_PeripheralControl_3_signal_5"
                                                        {% if wgform.f_PeripheralControl_3_signal_5.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_3_signal_5.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_3_signal_6"
                                                       name="f_PeripheralControl_3_signal_6"
                                                        {% if wgform.f_PeripheralControl_3_signal_6.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_3_signal_6.label}}</span>
                                            </label>
                                            <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_3_signal_7"
                                                       name="f_PeripheralControl_3_signal_7"
                                                        {% if wgform.f_PeripheralControl_3_signal_7.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_3_signal_7.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_3_signal_8"
                                                       name="f_PeripheralControl_3_signal_8"
                                                        {% if wgform.f_PeripheralControl_3_signal_8.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_3_signal_8.label}}</span>
                                            </label>
                                        </div>
                                    </div>
                                </div>
                            <div class="card-body">
                                    <div class="form-group">
                                       <h5 class="mb-0">#4 # Port Output  -{{wgform.f_PeripheralControl_4_source.label}}</h5>
                                        <select class="form-control  form-select  text-dark" id="f_PeripheralControl_4_source"
                                                name="f_PeripheralControl_4_source">
                                        <option value="0"
                                                    {% if wgform.f_PeripheralControl_4_source.data == 0  %}
                                                    selected
                                                    {% endif %}
                                                >(Not enabled)
                                                </option>
                                        {% for i in (1,2,3,4) %}
                                            {% if i<=wgform.producttype.data %}
                                                <option value="{{ i }}"
                                                    {% if wgform.f_PeripheralControl_4_source.data == i  %}
                                                    selected
                                                    {% endif %}
                                                >{{ i }}#
                                                </option>
                                            {% endif %}
                                        {% endfor %}
                                        </select>
                                    </div>
                                    <div class="col-sm-12 col-md-12 col-xl-12 no-taskEnd-checkbox">
                                        Trigger Event
                                        <div class="form-group">
                                            <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_4_event1"
                                                       name="f_PeripheralControl_4_event1"
                                                        {% if wgform.f_PeripheralControl_4_event1.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_4_event1.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_PeripheralControl_4_event2"
                                                       name="f_PeripheralControl_4_event2"
                                                        {% if wgform.f_PeripheralControl_4_event2.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_4_event2.label}}</span>
                                            </label>
                                             <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_4_event3"
                                                       name="f_PeripheralControl_4_event3"
                                                        {% if wgform.f_PeripheralControl_4_event3.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_4_event3.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_4_event4"
                                                       name="f_PeripheralControl_4_event4"
                                                        {% if wgform.f_PeripheralControl_4_event4.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_4_event4.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_4_event5"
                                                       name="f_PeripheralControl_4_event5"
                                                        {% if wgform.f_PeripheralControl_4_event5.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_4_event5.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_4_event6"
                                                       name="f_PeripheralControl_4_event6"
                                                        {% if wgform.f_PeripheralControl_4_event6.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_4_event6.label}}</span>
                                            </label>
                                        </div>
                                                                            <div class="form-group">
                                            {{ wgform.f_PeripheralControl_4_output_duration.label }}
                                            {{ wgform.f_PeripheralControl_4_output_duration( class="form-control") }}
                                        </div>

                                    <div class="form-group">
                                            {{ wgform.f_PeripheralControl_4_control_mode.label }}
                                        <select class="form-control  form-select  text-dark" id="f_PeripheralControl_4_control_mode"
                                                name="f_PeripheralControl_4_control_mode">
                                        <option value="1"
                                                    {% if wgform.f_PeripheralControl_4_control_mode.data == 1  %}
                                                    selected
                                                    {% endif %}
                                                >1-Fixed Delay  
                                                </option>
                                        <option value="2"
                                                    {% if wgform.f_PeripheralControl_4_control_mode.data == 2  %}
                                                    selected
                                                    {% endif %}
                                                >2-Output continues until alarm reset [for intrusion/door-ajar alarms]  
                                                </option>
                                        <option value="3"
                                                    {% if wgform.f_PeripheralControl_4_control_mode.data == 3  %}
                                                    selected
                                                    {% endif %}
                                                >3-Sync with alarm trigger [no delay]  
                                                </option>
                                                 <option value="4"
                                                    {% if wgform.f_PeripheralControl_4_control_mode.data == 4  %}
                                                    selected
                                                    {% endif %}
                                                >4-Output if any selected I/O triggers (no delay)  
                                                </option>
                                                <option value="5"
                                                    {% if wgform.f_PeripheralControl_4_control_mode.data == 5  %}
                                                    selected
                                                    {% endif %}
                                                >5-Output only if all selected I/O trigger (no delay)  
                                                </option>
                                        </select>
                                    </div>

                                    Related I/O signals [Mode 4,5]  
                                    <div class="form-group">
                                            <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_4_signal_1"
                                                       name="f_PeripheralControl_4_signal_1"
                                                        {% if wgform.f_PeripheralControl_4_signal_1.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_4_signal_1.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_PeripheralControl_4_signal_2"
                                                       name="f_PeripheralControl_4_signal_2"
                                                        {% if wgform.f_PeripheralControl_4_signal_2.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_4_signal_2.label}}</span>
                                            </label>
                                             <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_4_signal_3"
                                                       name="f_PeripheralControl_4_signal_3"
                                                        {% if wgform.f_PeripheralControl_4_signal_3.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_4_signal_3.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_4_signal_4"
                                                       name="f_PeripheralControl_4_signal_4"
                                                        {% if wgform.f_PeripheralControl_4_signal_4.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_4_signal_4.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_4_signal_5"
                                                       name="f_PeripheralControl_4_signal_5"
                                                        {% if wgform.f_PeripheralControl_4_signal_5.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_4_signal_5.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_4_signal_6"
                                                       name="f_PeripheralControl_4_signal_6"
                                                        {% if wgform.f_PeripheralControl_4_signal_6.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_4_signal_6.label}}</span>
                                            </label>

                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_4_signal_7"
                                                       name="f_PeripheralControl_4_signal_7"
                                                        {% if wgform.f_PeripheralControl_4_signal_7.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_4_signal_7.label}}</span>
                                            </label>
                                                                                    <label class="custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" class="custom-control-input" id="f_PeripheralControl_4_signal_8"
                                                       name="f_PeripheralControl_4_signal_8"
                                                        {% if wgform.f_PeripheralControl_4_signal_8.data %}
                                                       value="1" checked
                                                        {% else %}
                                                       value="0"
                                                        {% endif %}
                                                >
                                                <span class="custom-control-label">{{wgform.f_PeripheralControl_4_signal_8.label}}</span>
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <div class="card-body">
                                    <input type="hidden" name="f_ControllerID" value="{{ wgform.f_ControllerID.data }}">
                                    <input type="hidden" name="producttype" value="{{ wgform.producttype.data }}">
                                    <div class="form-group" hidden="hidden">
                                        {{ wgform.f_ControllerNO.label }}
                                        {{ wgform.f_ControllerNO( class="form-control") }}
                                    </div>
                                    <div class="form-group" hidden="hidden">
                                        {{ wgform.f_ControllerSN.label }}
                                        {{ wgform.f_ControllerSN( class="form-control",placeholder="please input controller SN", oninput="if(value.length>9)value=value.slice(0,9)") }}
                                    </div>
                                </div>

                                <div class="row p-5">
                                    <div class="btn-list text-end">
                                          <button id="submitsave" name="submitsaveandadd" class="btn btn-primary"
                                                type="submit" value="Get Default Value">
                                            <i class="fe fe-check-square"></i>
                                            Get Default Value
                                        </button>
                                        <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>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                <!--ROW CLOSED-->
            </div>
        </div>
    </div>
    <!-- CONTAINER CLOSED -->
{% endblock %}
