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

{% block title %}
    Add Controller
{% 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">Add Controller</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);">Controllers</a></li>
                            <li class="breadcrumb-item active" aria-current="page">Add</li>
                        </ol>
                    </div>
                </div>
                <!-- PAGE-HEADER END -->
                {% with messages = get_flashed_messages() %}
                    {% if messages %}
                        <div class="form-group">
                            <ul>
                                {% for message in messages %}
                                    <li class="text-danger">{{ message }}</li>
                                {% endfor %}
                            </ul>
                        </div>
                    {% endif %}
                {% endwith %}
                <!--ROW OPENED-->
                <div class="row">
                    <div class="col-lg-12 col-md-12">
                        <div class="card">
                            <form action="{{ url_for('wgcomm.web_controller_add') }}" method="post">
                                <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
                                {{ wgform._csrf }}

                                <div class="card-header border-bottom">
                                    <h4 class="mb-0">Controller Information</h4>
                                </div>
                                <div class="card-body">
                                    <div class="form-group">
                                        {{ wgform.f_ControllerNO.label }}
                                        {{ wgform.f_ControllerNO( class="form-control") }}
                                    </div>
                                    <div class="form-group">
                                        {{ 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 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_Enabled"
                                                       name="f_Enabled"
                                                       value="1" checked>
                                                <span class="custom-control-label">Active</span>
                                            </label>
                                        </div>
                                    </div>
                                </div>


                                <div class="row p-5"
                                        {% if (wgform.producttype.data>0) %}
                                     hidden
                                        {% endif %}>

                                    <div class="btn-list text-start">
                                        <button class="btn btn-primary" id="btnNext" title="next">
                                            <i class="fe fe-check-circle"></i>
                                            Next
                                        </button>
                                    </div>
                                </div>
                                <div class="row p-5 border-bottom" id="grpDoor1"  {% if (wgform.producttype.data<1) %}
                                     hidden
                                {% endif %}>
                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group">
                                            {{ wgform.f_DoorName1.label }}
                                            {{ wgform.f_DoorName1( class="form-control text-dark") }}

                                        </div>
                                    </div>

                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group">
                                            <label class="form-label">1# Door Enabled</label>
                                            <label class="input-group custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" id="f_DoorEnabled1" name="f_DoorEnabled1"
                                                       class="custom-control-input"
                                                       value="1" checked><span class="custom-control-label">Active</span>
                                            </label>
                                        </div>
                                    </div>
                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group">
                                            {{ wgform.f_DoorControl1.label }}
                                            {{ wgform.f_DoorControl1( class="form-control  form-select text-dark") }}
                                        </div>
                                    </div>
                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group">
                                            {{ wgform.f_DoorDelay1.label }}
                                            {{ wgform.f_DoorDelay1( class="form-control", oninput="if(value.length>3)value=value.slice(0,3)") }}
                                        </div>
                                    </div>
                                </div>
                                <div class="row p-5 border-bottom" id="grpDoor2"  {% if (wgform.producttype.data<2) %}
                                     hidden
                                {% endif %}>
                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group">
                                            {{ wgform.f_DoorName2.label }}
                                            {{ wgform.f_DoorName2( class="form-control text-dark") }}

                                        </div>
                                    </div>

                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group">
                                            <label class="form-label">2# Door Enabled</label>
                                            <label class="input-group custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" id="f_DoorEnabled2" name="f_DoorEnabled2"
                                                       class="custom-control-input"
                                                       value="1" checked><span class="custom-control-label">Active</span>
                                            </label>
                                        </div>
                                    </div>
                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group">
                                            {{ wgform.f_DoorControl2.label }}
                                            {{ wgform.f_DoorControl2( class="form-control   form-select  text-dark") }}
                                        </div>
                                    </div>
                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group">
                                            {{ wgform.f_DoorDelay2.label }}
                                            {{ wgform.f_DoorDelay2( class="form-control", oninput="if(value.length>3)value=value.slice(0,3)") }}
                                        </div>
                                    </div>
                                </div>
                                <div class="row p-5 border-bottom" id="grpDoor3"  {% if (wgform.producttype.data<4) %}
                                     hidden
                                {% endif %}>
                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group">
                                            {{ wgform.f_DoorName3.label }}
                                            {{ wgform.f_DoorName3( class="form-control text-dark") }}

                                        </div>
                                    </div>

                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group">
                                            <label class="form-label">3# Door Enabled</label>
                                            <label class="input-group custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" id="f_DoorEnabled3" name="f_DoorEnabled3"
                                                       class="custom-control-input"
                                                       value="1" checked><span class="custom-control-label">Active</span>
                                            </label>
                                        </div>
                                    </div>
                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group">
                                            {{ wgform.f_DoorControl3.label }}
                                            {{ wgform.f_DoorControl3( class="form-control  form-select  text-dark") }}
                                        </div>
                                    </div>
                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group">
                                            {{ wgform.f_DoorDelay3.label }}
                                            {{ wgform.f_DoorDelay3( class="form-control", oninput="if(value.length>3)value=value.slice(0,3)") }}
                                        </div>
                                    </div>
                                </div>
                                <div class="row p-5 border-bottom" id="grpDoor4"  {% if (wgform.producttype.data<4) %}
                                     hidden
                                {% endif %}>
                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group">
                                            {{ wgform.f_DoorName4.label }}
                                            {{ wgform.f_DoorName4( class="form-control text-dark") }}

                                        </div>
                                    </div>

                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group">
                                            <label class="form-label">4# Door Enabled</label>
                                            <label class="input-group custom-control custom-checkbox no-taskEnd-checkbox-container">
                                                <input type="checkbox" id="f_DoorEnabled4" name="f_DoorEnabled4"
                                                       class="custom-control-input"
                                                       value="1" checked><span class="custom-control-label">Active</span>
                                            </label>
                                        </div>
                                    </div>
                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group">
                                            {{ wgform.f_DoorControl4.label }}
                                            {{ wgform.f_DoorControl4( class="form-control  form-select text-dark") }}
                                        </div>
                                    </div>
                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group">
                                            {{ wgform.f_DoorDelay4.label }}
                                            {{ wgform.f_DoorDelay4( class="form-control", oninput="if(value.length>3)value=value.slice(0,3)") }}
                                        </div>
                                    </div>
                                </div>
                                <div class="row p-5">
                                    <div class="btn-list text-end">
                                        <button id="submitcancel" name="submitcancel" class="btn btn-outline-danger"
                                                type="submit" value="Cancel">
                                            <i class="fe fe-x-circle"></i>
                                            Cancel
                                        </button>
                                        <button id="submitsave" name="submitsave" class="btn btn-primary" type="submit"
                                                value="Save">
                                            <i class="fe fe-check-circle"></i>
                                            Save
                                        </button>
                                        <button id="submitsave" name="submitsaveandadd" class="btn btn-primary"
                                                type="submit" value="Save And Continue">
                                            <i class="fe fe-check-square"></i>
                                            Save And Continue
                                        </button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                <!--ROW CLOSED-->
            </div>
        </div>
    </div>
    <!-- CONTAINER CLOSED -->
{% endblock %}
