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

{% block title %}
    Department
{% endblock %}
{% block tail %}
    <script src="{{ url_for('static',filename='wgcomm/js/delete-check.js') }}"></script>
    <!-- INTERNAL DATATABLES JS -->
    <script src="static/wgcomm/js/table-editable.js"></script>
{% endblock %}
{% block tail_min %}
    <script src="{{ url_for('static',filename='wgcomm/js/delete-check.min.js') }}"></script>
    <!-- INTERNAL DATATABLES JS -->
    <script src="static/wgcomm/js/table-editable.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">Department</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);">Department</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_department_add") }}" class="btn btn-primary">
                                <i class="fe fe-plus-square"></i>Add
                            </a>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-body tasks-table-container">
                                <div class="table-responsive">
                                    <table id="editable-file-datatable"
                                           class="table editable-table table-nowrap table-bordered  wp-100 active-tb">
                                        <thead class="table-head">
                                        <tr>
                                            <th class="bg-transparent border-bottom-0">Department ID</th>
                                            <th class="bg-transparent border-bottom-0">Department Name</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_GroupID }}">
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_GroupNO }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_GroupName }}</td>
                                                <td>
                                                    <div class="d-flex align-items-stretch">
                                                        <form action="{{ url_for('wgcomm.web_department_edit') }}"
                                                              method="post">
                                                            <input type="hidden" name="csrf_token"
                                                                   value="{{ csrf_token() }}">
                                                            <input type="hidden" name="conID"
                                                                   value="{{ con.f_GroupID }}">
                                                            <button class="btn btn-icon btn-primary-light me-2"
                                                                    data-id="{{ con.f_GroupID }}"
                                                                    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_GroupID }}"
                                                                data-name="{{ con.f_GroupName }}"
                                                                data-url="{{ deleteUrl }}"
                                                                data-bs-toggle="tooltip" title=""
                                                                data-bs-original-title="Delete">
                                                            <i class="fe fe-trash"></i></button>
                                                    </div>
                                                </td>
                                            </tr>
                                        {% endfor %}
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!--ROW CLOSED-->

            </div>
        </div>
    </div>
    <!-- CONTAINER CLOSED -->
{% endblock %}
