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

{% block title %}
    user
{% endblock %}
{% block tail %}
    <!-- INTERNAL DATATABLES JS -->
    <script src="static/wgcomm/js/table-userlist.js"></script>
{% endblock %}
{% block tail_min %}
    <!-- INTERNAL DATATABLES JS -->
    <script src="static/wgcomm/js/table-userlist.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">user</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">List</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-md-12 mb-3">
                        <div class="btn-list">
                            <a href="{{ url_for("wgcomm.web_user_add") }}" class="btn btn-primary">
                                <i class="fe fe-plus-square"></i>Add
                            </a>
                            <a class="btn btn-primary" id="btnImportFromExcel">
                                <i class="fa fa-file-excel-o"></i>Import From Excel
                            </a>
                        </div>

                    </div>
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-body tasks-table-container">
                                <div class="table-responsive">
                                    <table id="table-userlist"
                                           class="table table-nowrap table-bordered  wp-100 active-tb">
                                        <thead class="table-head">
                                        <tr>
                                            <th class="bg-transparent border-bottom-0">User ID</th>
                                            <th class="bg-transparent border-bottom-0">Name</th>
                                            <th class="bg-transparent border-bottom-0">Card NO</th>
                                            <th class="bg-transparent border-bottom-0">BeginDate</th>
                                            <th class="bg-transparent border-bottom-0">EndDate</th>
                                            <th class="bg-transparent border-bottom-0">Department</th>
                                            <th class="bg-transparent border-bottom-0 no-btn">Operation</th>
                                        </tr>
                                        </thead>
                                        <tbody class="table-body">


                                        {% for con in objlist %}
                                            <tr id="con-{{ con.f_ConsumerID }}">
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_ConsumerNO }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_ConsumerName }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start"
                                                    id="cardno-{{ con.f_ConsumerID }}">
                                                    {% if con.f_CardNO==None %}
                                                    {% else %}
                                                        {{ con.f_CardNO }}
                                                    {% endif %}
                                                </td>
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_BeginYMD|ymd }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_EndYMD|ymd }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start">
                                                    {% if con.f_GroupName %}
                                                        {{ con.f_GroupName }}
                                                    {% endif %}
                                                </td>
                                                <td>
                                                    <div class="d-flex align-items-stretch">
                                                        <form action="{{ url_for('wgcomm.web_user_edit') }}"
                                                              method="post">
                                                            <input type="hidden" name="csrf_token"
                                                                   value="{{ csrf_token() }}">
                                                            <input type="hidden" name="conID"
                                                                   value="{{ con.f_ConsumerID }}">
                                                            <button class="btn btn-icon btn-primary-light me-2"
                                                                    data-id="{{ con.f_ConsumerID }}"
                                                                    data-bs-toggle="tooltip" title=""
                                                                    data-bs-original-title="Edit">
                                                                <i class="fe fe-edit"></i></button>
                                                        </form>
                                                        <button href="#"
                                                                class="btn btn-icon btn-warning-light me-2 active-btn"
                                                                data-id="{{ con.f_ConsumerID }}"
                                                                data-name="{{ con.f_ConsumerName }}"
                                                                data-url="{{ deleteUrl }}"
                                                                data-bs-toggle="tooltip" title=""
                                                                data-bs-original-title="Delete">
                                                            <i class="fe fe-trash"></i>
                                                        </button>
                                                        {% if con.f_CardNO==None %}
                                                        {% else %}
                                                            <button href="#"
                                                                    class="btn btn-icon btn-warning-light me-2 active-btn"
                                                                    data-id="{{ con.f_ConsumerID }}"
                                                                    data-name="{{ con.f_CardNO }}"
                                                                    data-url="{{ losecardUrl }}"
                                                                    data-op="losecard"
                                                                    data-bs-toggle="tooltip" title=""
                                                                    data-bs-original-title="Lose"
                                                                    id="lose-{{ con.f_ConsumerID }}">
                                                                <i class="fe fe-shield-off"></i>
                                                            </button>
                                                        {% endif %}
                                                    </div>
                                                </td>
                                            </tr>
                                        {% endfor %}
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!--ROW CLOSED-->
            </div>
        </div>
    </div>
    <!-- CONTAINER CLOSED -->
{% endblock %}
