{% extends 'wgcomm/base.html' %}
{% block tail %}
    <script src="static/wgcomm/js/datepicker.js"></script>
    <script src="static/wgcomm/js/wgdatepicker.js"></script>
    <script src="static/wgcomm/js/user-photo.js"></script>
{% endblock %}
{% block tail_min %}
    <script src="static/wgcomm/js/datepicker.min.js"></script>
    <script src="static/wgcomm/js/wgdatepicker.min.js"></script>
    <script src="static/wgcomm/js/user-photo.min.js"></script>

{% endblock %}
{% block title %}
    Adduser
{% 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 User And Privilege</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);">user</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_user_add') }}" method="post"
                                  enctype="multipart/form-data">
                                <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
                                {{ wgform._csrf }}
                                <div class="card-header border-bottom">
                                    <h4 class="mb-0">User Information</h4>
                                </div>
                                <div class="card-body">
                                    <div class="form-group">
                                        {{ wgform.f_ConsumerNO.label }}
                                        {{ wgform.f_ConsumerNO( class="form-control") }}
                                    </div>
                                    <div class="form-group">
                                        {{ wgform.f_ConsumerName.label }}
                                        {{ wgform.f_ConsumerName( class="form-control") }}
                                    </div>
                                    <div class="form-group">
                                        {{ wgform.f_CardNO.label }}
                                        {{ wgform.f_CardNO( class="form-control",placeholder="Please input Card NO", oninput="if(value.length>19)value=value.slice(0,19)") }}
                                    </div>
                                    <div class="form-group">
                                        {{ wgform.f_GroupID.label }}
                                        <select class="form-control  form-select  text-dark" id="f_GroupID"
                                                name="f_GroupID">
                                            <option value="0" selected>---</option>
                                            {% for dept in departments %}
                                                <option value="{{ dept.f_GroupID }}">{{ dept.f_GroupName }}</option>
                                            {% endfor %}
                                        </select>
                                    </div>
                                    <div class="form-group">
                                        {{ wgform.f_BeginYMD.label }}
                                        <div id="begin-datepicker" class="input-group date"
                                             data-date-format="yyyy-mm-dd">
                                                <span class="input-group-addon input-group-text bg-primary-transparent"><i
                                                        class="fe fe-calendar text-primary-dark"></i></span>
                                            <input id="f_BeginYMD" name="f_BeginYMD" class="form-control" type="text"
                                                   value="2024-01-01" placeholder="Year-Month-Day  "/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        {{ wgform.f_EndYMD.label }}
                                        <div id="end-datepicker" class="input-group date"
                                             data-date-format="yyyy-mm-dd">
                                                <span class="input-group-addon input-group-text bg-primary-transparent"><i
                                                        class="fe fe-calendar text-primary-dark"></i></span>
                                            <input id="f_EndYMD" name="f_EndYMD" class="form-control" type="text"
                                                   value="2099-12-31" placeholder="Year-Month-Day  "/>
                                        </div>
                                    </div>
                                    {% if  g.extfunc5678_photo %}
                                        <div class="form-group">
                                            <label for="file">Select Photo</label>
                                            {#                                        <input type="file" name="file" accept="image/*"  id = "imageInput">#}
                                            <input type="file" accept="image/*" id="imageInput">
                                        </div>
                                        <div hidden>
                                            {{ wgform.f_photostr( class="form-control") }}</div>
                                        <div class="card custom-card overflow-hidden mb-0 " style=""
                                             id="imageDisplayStyle">
                                            <a href="#"><img src="" alt="" id="imageDisplay"></a>
                                        </div>
                                    {% endif %}
                                </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>
                    <!--ROW CLOSED-->
                </div>
            </div>
        </div>
    </div>
    <!-- CONTAINER CLOSED -->
{% endblock %}
