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

{% block title %}
    TimeProfile
{% 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">Time Profile</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);">Time Profile</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_timeprofile.web_timeprofile_add") }}" class="btn btn-primary">
                                <i class="fe fe-plus-square"></i>Add
                            </a>
                        </div>
                        <div>
                            1#: Free Time, 0#: all Forbidden [0#,1# fixed]
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-body tasks-table-container">
                                <div class="table-responsive">
                                    <table id="table-timeprofile"
                                           class="table editable-table table-nowrap table-bordered  wp-100 active-tb">
                                        <thead class="table-head">
                                        <tr>
                                            <th class="bg-transparent border-bottom-0">Time Profile ID</th>
                                            <th class="bg-transparent border-bottom-0">Description</th>
                                            <th class="bg-transparent border-bottom-0">Mon</th>
                                            <th class="bg-transparent border-bottom-0">Tue</th>
                                            <th class="bg-transparent border-bottom-0">Wed</th>
                                            <th class="bg-transparent border-bottom-0">Thur</th>
                                            <th class="bg-transparent border-bottom-0">Fri</th>
                                            <th class="bg-transparent border-bottom-0">Sat</th>
                                            <th class="bg-transparent border-bottom-0">Sun</th>
                                            <th class="bg-transparent border-bottom-0">Zone1# Start</th>
                                            <th class="bg-transparent border-bottom-0">1# End</th>
                                            <th class="bg-transparent border-bottom-0">2# Start</th>
                                            <th class="bg-transparent border-bottom-0">2# End</th>
                                            <th class="bg-transparent border-bottom-0">3# Start</th>
                                            <th class="bg-transparent border-bottom-0">3 #End</th>
                                            <th class="bg-transparent border-bottom-0">Next Linked</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 no-btn">Operation</th>
                                        </tr>
                                        </thead>
                                        <tbody class="table-body">
                                        {% for con in objlist %}
                                            <tr id="con-{{ con.f_ControlSegID }}">
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_ControlSegID }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_ControlSegName }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_Monday|OneToFlag }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_Tuesday|OneToFlag }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_Wednesday|OneToFlag }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_Thursday|OneToFlag }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_Friday|OneToFlag }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_Saturday|OneToFlag }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_Sunday|OneToFlag }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_BeginHMS1|hm }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_EndHMS1|hm }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_BeginHMS2|hm }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_EndHMS2|hm }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_BeginHMS3|hm }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_EndHMS3|hm }}</td>
                                                <td class="text-muted fs-15 fw-semibold text-start">{{ con.f_ControlSegIDLinked }}</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>
                                                    <div class="d-flex align-items-stretch">
                                                        <form action="{{ url_for('wgcomm_timeprofile.web_timeprofile_edit') }}"
                                                              method="post">
                                                            <input type="hidden" name="csrf_token"
                                                                   value="{{ csrf_token() }}">
                                                            <input type="hidden" name="f_ControlSegID"
                                                                   value="{{ con.f_ControlSegID }}">
                                                            <button class="btn btn-icon btn-primary-light me-2"
                                                                    data-id="{{ con.f_ControlSegID }}"
                                                                    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_ControlSegID }}"#}
                                                        {#                                                                data-name="TimeProfile{{ con.f_ControlSegID }}"#}
                                                        {#                                                                data-op="edit"#}
                                                        {#                                                                data-url="{{ editSeg }}"#}
                                                        {#                                                                data-bs-toggle="tooltip" title="Edit"#}
                                                        {#                                                                data-bs-original-title="Edit">#}
                                                        {#                                                            <i class="fe fe-edit"></i></button>#}

                                                        <button href="#"
                                                                class="btn btn-icon btn-warning-light me-2 active-btn"
                                                                data-id="{{ con.f_ControlSegID }}"
                                                                data-name="TimeProfile{{ con.f_ControlSegID }}"
                                                                data-op="delete"
                                                                data-url="{{ deleteUrl }}"
                                                                data-bs-toggle="tooltip" title="Delete"
                                                                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 %}
