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

{% block title %}
    Anti-Passback 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 }}]-Anti-Passback 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);">Antiback</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_anti_back.web_extern_anti_back_edit') }}"
                                  method="post">
                                <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
                                {{ wgform._csrf }}
                                <div class="card-body">
                                    <div class="form-group">
                                        {{ wgform.f_AntiBack_option.label }}
                                        <select class="form-control  form-select  text-dark" id="f_AntiBack_option"
                                                name="f_AntiBack_option">
                                            <option value="0"
                                                    {% if wgform.f_AntiBack_option.data == 0 %}
                                                    selected
                                                    {% endif %}
                                            >(Not enabled)
                                            </option>
                                            {% if  wgform.producttype.data == 1 %}
                                                <option value="1"
                                                        {% if wgform.f_AntiBack_option.data == 1 %}
                                                        selected
                                                        {% endif %}
                                                >Door 1 Anti-Passback
                                                </option>

                                            {% endif %}
                                            {% if  wgform.producttype.data == 2 %}
                                                <option value="1"
                                                        {% if wgform.f_AntiBack_option.data == 1 %}
                                                        selected
                                                        {% endif %}
                                                >Doors 1,2 Independent Anti-Passback
                                                </option>
                                                <option value="2"
                                                        {% if wgform.f_AntiBack_option.data == 2 %}
                                                        selected
                                                        {% endif %}
                                                >Doors 1,2 Mutual Anti-Passback
                                                </option>
                                            {% endif %}
                                            {% if  wgform.producttype.data == 4 %}
                                                <option value="1"
                                                        {% if wgform.f_AntiBack_option.data == 1 %}
                                                        selected
                                                        {% endif %}
                                                >Doors 1,2 Mutual; Doors 3,4 Mutual Anti-Passback
                                                </option>
                                                <option value="2"
                                                        {% if wgform.f_AntiBack_option.data == 2 %}
                                                        selected
                                                        {% endif %}
                                                >Doors 1,2 & Doors 3,4 Mutual Anti-Passback
                                                </option>
                                                <option value="3"
                                                        {% if wgform.f_AntiBack_option.data == 3 %}
                                                        selected
                                                        {% endif %}
                                                >Door 1 & Doors 2,3 Mutual Anti-Passback
                                                </option>
                                                <option value="4"
                                                        {% if wgform.f_AntiBack_option.data == 4 %}
                                                        selected
                                                        {% endif %}
                                                >Door 1 & Doors 2,3,4 Mutual Anti-Passback
                                                </option>
                                            {% endif %}
                                        </select>
                                    </div>
                                    <div class="form-group">
                                        {{ wgform.f_AntiBack_IndoorPersonsMax.label }}
                                        {{ wgform.f_AntiBack_IndoorPersonsMax( class="form-control") }}
                                    </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 %}
