{% load i18n %} {% load static %}{% include "filter_tags.html" %}
<div class="oh-tabs oh-wrapper">
    <ul class="oh-tabs__tablist">
        <li class="oh-tabs__tab" data-target="#reimbursement_tab">
            {% trans "Loan" %}
        </li>
        <!-- normal user can't view all objective  -->
        <li class="oh-tabs__tab" data-target="#leave_encashment_tab">
            {% trans "Advanced Salary" %}
        </li>
        <li class="oh-tabs__tab" data-target="#bonus_encashment_tab">
            {% trans "Fine" %}
        </li>
    </ul>
    <!-- start of tabs -->
    <div class="oh-tabs__contents">
        <!--start of Loan tab-->
        <div class="oh-tabs__content" id="reimbursement_tab">
            {% if loan %}
                <!-- start of column toggle button-->
                <div class="oh-table_sticky--wrapper">
                    <div class="oh-sticky-dropdown--header">
                        <div class="oh-dropdown" x-data="{open: false}">
                            <button class="oh-sticky-dropdown_btn " @click="open = !open"><ion-icon name="ellipsis-vertical-sharp"
                                role="img" class="md hydrated" aria-label="ellipsis vertical sharp"></ion-icon></button>
                            <div class="oh-dropdown__menu oh-sticky-table_dropdown" x-show="open" @click.outside="open = false">
                                <ul class="oh-dropdown__items" id="ReimbursementCells">
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- end of column toggle button-->
                <div id="reimbursement-table" data-table-name="reimbursement_table">
                    <!-- start of sticky table -->
                    <div class="oh-sticky-table">
                        <div class="oh-sticky-table__table oh-table--sortable">
                            <div class="oh-sticky-table__thead">
                                <div class="oh-sticky-table__tr">
                                    {% comment %} <div class="oh-sticky-table__th" style="width: 20px">
                                        <input
                                        type="checkbox"
                                        title='{% trans "Select All" %}'
                                        class="oh-input oh-input__checkbox mt-1 mr-2 all-attendances"
                                        style="margin-left: -5px"
                                        />
                                    </div> {% endcomment %}
                                    <div
                                        class="oh-sticky-table__th {% if request.sort_option.order == '-employee_id' %}arrow-up {% elif request.sort_option.order == 'employee_id' %}arrow-down {% else %}arrow-up-down {% endif %}"
                                        hx-get="{% url 'search-loan' %}?{{pd}}&sortby=employee_id"
                                        hx-target="#loanContainer"
                                    >
                                        {% trans "Employee" %}
                                    </div>
                                    <div data-cell-index="1" data-cell-title='{% trans "Title" %}' class="oh-sticky-table__th">{% trans "Title" %}</div>

                                    <div data-cell-index="2" data-cell-title='{% trans "Provided Date" %}'
                                        class="oh-sticky-table__th {% if request.sort_option.order == '-provided_date' %}arrow-up {% elif request.sort_option.order == 'provided_date' %}arrow-down {% else %}arrow-up-down {% endif %}"
                                        hx-get="{% url 'search-loan' %}?{{pd}}&sortby=provided_date"
                                        hx-target="#loanContainer"

                                    >
                                        {% trans "Provided Date" %}
                                    </div>
                                    <div data-cell-index="3" data-cell-title='{% trans "Installment Start Date" %}'
                                        class="oh-sticky-table__th {% if request.sort_option.order == '-installment_start_date' %}arrow-up {% elif request.sort_option.order == 'installment_start_date' %}arrow-down {% else %}arrow-up-down {% endif %}"
                                        hx-get="{% url 'search-loan' %}?{{pd}}&sortby=installment_start_date"
                                        hx-target="#loanContainer"

                                    >
                                        {% trans "Installment Start Date" %}
                                    </div>
                                    <div data-cell-index="4" data-cell-title='{% trans "Total Installments" %}'
                                        class="oh-sticky-table__th {% if request.sort_option.order == '-installments' %}arrow-up {% elif request.sort_option.order == 'installments' %}arrow-down {% else %}arrow-up-down {% endif %}"
                                        hx-get="{% url 'search-loan' %}?{{pd}}&sortby=installments"
                                        hx-target="#loanContainer"

                                    >
                                        {% trans "Total Installments" %}
                                    </div>
                                    <div data-cell-index="5" data-cell-title='{% trans "Amount" %}'
                                        class="oh-sticky-table__th {% if request.sort_option.order == '-loan_amount' %}arrow-up {% elif request.sort_option.order == 'loan_amount' %}arrow-down {% else %}arrow-up-down {% endif %}"
                                        hx-get="{% url 'search-loan' %}?{{pd}}&sortby=loan_amount"
                                        hx-target="#loanContainer"
                                    >{% trans "Amount" %}
                                    </div>
                                    <div
                                        data-cell-index="6" data-cell-title='{% trans "Description" %}' class="oh-sticky-table__th" style="width:200px"
                                    >
                                        {% trans "Description" %}
                                    </div>
                                    {% if perms.payroll.change_loanaccount or perms.payroll.delete_loanaccount %}
                                        <div class="oh-sticky-table__th"> {% trans "Actions" %} </div>
                                    {% endif %}
                                </div>
                            </div>
                            <div class="oh-sticky-table__tbody">
                                {% for req in loan %}
                                    <div class="oh-sticky-table__tr"
                                        hx-get="{% url 'view-installments' %}?loan_id={{ req.id }}&instances_ids={{loan_ids}}" hx-target="#objectDetailsModalTarget" data-target="#objectDetailsModal" data-toggle="oh-modal-toggle">
                                        {% comment %} <div class="oh-sticky-table__sd" onclick="event.stopPropagation();">
                                        <input
                                            type="checkbox"
                                            id="{{attendance.id}}"
                                            class="oh-input attendance-checkbox oh-input__checkbox mt-2 mr-2 all-attendance-row"
                                        />
                                        </div> {% endcomment %}
                                        <div class="oh-sticky-table__sd">
                                            <div class="d-flex">
                                                <div class="oh-profile oh-profile--md">
                                                    <div class="oh-profile__avatar mr-1">
                                                        <img
                                                        src="{{req.employee_id.get_avatar}}"
                                                        class="oh-profile__image"
                                                        alt=""
                                                        />
                                                    </div>
                                                    <span class="oh-profile__name oh-text--dark">{{req.employee_id}}</span>
                                                </div>
                                            </div>
                                        </div>
                                        <div data-cell-index="1" class="oh-sticky-table__td">
                                            {{req.title|truncatechars:20 }}
                                        </div>
                                        <div data-cell-index="2" class="oh-sticky-table__td dateformat_changer">
                                            {{req.provided_date|date:"F j, Y"}}
                                        </div>
                                        <div data-cell-index="3" class="oh-sticky-table__td dateformat_changer">
                                            {{req.installment_start_date|date:"F j, Y"}}
                                        </div>
                                        <div data-cell-index="4" class="oh-sticky-table__td">
                                            {{req.installments}}
                                        </div>
                                        <div data-cell-index="5" class="oh-sticky-table__td">
                                        {{req.loan_amount}}
                                        </div>
                                        <div data-cell-index="6" class="oh-sticky-table__td">
                                        {{req.description}}
                                        </div>
                                        {% if perms.payroll.change_loanaccount or perms.payroll.delete_loanaccount %}
                                            <div class="oh-sticky-table__td" onclick="event.stopPropagation()">
                                                <div class="oh-btn-group">
                                                    {% if perms.payroll.change_loanaccount %}
                                                        <a class="oh-btn oh-btn--light-bkg w-100" hx-get="{% url 'create-loan' %}?instance_id={{ req.id }}" hx-target="#objectCreateModalTarget" data-toggle="oh-modal-toggle" data-target="#objectCreateModal" title="{% trans 'Edit' %}">
                                                            <ion-icon class="text-dark" name="create-outline"></ion-icon></a>
                                                    {% endif %}
                                                    {% if perms.payroll.delete_loanaccount %}
                                                        <a class="oh-btn oh-btn--light-bkg w-100" href="{% url 'delete-loan' %}?ids={{ req.id }}" onclick="return confirm('Do you want to delete this record?')" title='{% trans "Delete" %}'>
                                                            <ion-icon class="text-danger" name="trash-outline"></ion-icon></a>
                                                    {% endif %}
                                                </div>
                                            </div>
                                        {% endif %}
                                    </div>
                                {% endfor %}
                            </div>
                        </div>
                    </div>
                    <!-- end of sticky table -->
                    <!-- start of pagination -->
                    <div class="oh-wrapper w-100">
                        <div class="oh-pagination">
                            <span
                                class="oh-pagination__page"
                                data-toggle="modal"
                                data-target="#addEmployeeModal"
                                >{% trans 'Page'  %} {{ loan.number }} {% trans 'of' %} {{ loan.paginator.num_pages }}.</span
                            >

                            <nav class="oh-pagination__nav">
                                <div class="oh-pagination__input-container me-3">
                                    <span class="oh-pagination__label me-1"
                                        >{% trans 'Page' %}</span
                                    >

                                    <input
                                        type="number"
                                        name="page"
                                        class="oh-pagination__input"
                                        value="{{ loan.number }}"
                                        hx-get="{% url 'search-loan' %}?{{ pd }}"
                                        hx-target="#loanContainer"
                                        min="1"
                                    />
                                    <span class="oh-pagination__label"
                                        >{% trans 'of' %} {{ loan.paginator.num_pages }}</span
                                    >
                                </div>

                                <ul class="oh-pagination__items">
                                    {% if loan.has_previous %}
                                    <li
                                        class="oh-pagination__item oh-pagination__item--wide"
                                    >
                                        <a
                                            hx-target="#loanContainer"
                                            hx-get="{% url 'search-loan' %}?{{ pd }}&lpage=1"
                                            class="oh-pagination__link"
                                            >{% trans 'First' %}</a
                                        >
                                    </li>
                                    <li
                                        class="oh-pagination__item oh-pagination__item--wide"
                                    >
                                        <a
                                            hx-target="#loanContainer"
                                            hx-get="{% url 'search-loan' %}?{{ pd }}&lpage={{ loan.previous_page_number }}"
                                            class="oh-pagination__link"
                                            >{% trans 'Previous' %}</a
                                        >
                                    </li>
                                    {% endif %} {% if loan.has_next %}
                                    <li
                                        class="oh-pagination__item oh-pagination__item--wide"
                                    >
                                        <a
                                            hx-target="#loanContainer"
                                            hx-get="{% url 'search-loan' %}?{{ pd }}&lpage={{ loan.next_page_number }}"
                                            class="oh-pagination__link"
                                            >{% trans 'Next' %}</a
                                        >
                                    </li>
                                    <li
                                        class="oh-pagination__item oh-pagination__item--wide"
                                    >
                                        <a
                                            hx-target="#loanContainer"
                                            hx-get="{% url 'search-loan' %}?{{ pd }}&lpage={{ loan.paginator.num_pages }}"
                                            class="oh-pagination__link"
                                            >{% trans 'Last' %}</a
                                        >
                                    </li>
                                    {% endif %}
                                </ul>
                            </nav>
                        </div>
                    </div>
                    <!-- end of pagination -->
                </div>
            {% else %}
                <!-- start of empty page -->
                <div style="display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%;" >
                    <img
                    style="width: 150px; height: 150px"
                    src="{% static 'images/ui/no-results.png' %}"
                    class="oh-404__image mb-4"
                    />
                    <h5 class="oh-404__subtitle">
                    {% trans "No search result found!" %}
                    </h5>
                </div>
                <!-- end of empty page -->
            {% endif %}
        </div>
        <!--end of Reimbursement tab-->

        <!-- start of Advanced Salary-->
        <div class="oh-tabs__content" id="leave_encashment_tab">
            {% if adv_salary %}
                <!-- start of column toggle button-->
                <div class="oh-table_sticky--wrapper">
                    <div class="oh-sticky-dropdown--header">
                        <div class="oh-dropdown" x-data="{open: false}">
                            <button class="oh-sticky-dropdown_btn " @click="open = !open"><ion-icon name="ellipsis-vertical-sharp"
                                role="img" class="md hydrated" aria-label="ellipsis vertical sharp"></ion-icon></button>
                            <div class="oh-dropdown__menu oh-sticky-table_dropdown" x-show="open" @click.outside="open = false">
                                <ul class="oh-dropdown__items" id="LeaveEncashmentCells">
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- end of column toggle button-->
                <div id="leave-encashment-table" data-table-name="leave_encashment_table">
                    <!-- start of sticky table -->
                    <div class="oh-sticky-table">
                        <div class="oh-sticky-table__table oh-table--sortable">
                            <div class="oh-sticky-table__thead">
                                <div class="oh-sticky-table__tr">
                                    {% comment %} <div class="oh-sticky-table__th" style="width: 20px">
                                        <input
                                        type="checkbox"
                                        title='{% trans "Select All" %}'
                                        class="oh-input oh-input__checkbox mt-1 mr-2 all-attendances"
                                        style="margin-left: -5px"
                                        />
                                    </div> {% endcomment %}
                                    <div
                                        class="oh-sticky-table__th {% if request.sort_option.order == '-employee_id' %}arrow-up {% elif request.sort_option.order == 'employee_id' %}arrow-down {% else %}arrow-up-down {% endif %}"
                                        hx-get="{% url 'search-loan' %}?{{pd}}&sortby=employee_id"
                                        hx-target="#loanContainer"
                                    >
                                        {% trans "Employee" %}
                                    </div>
                                    <div data-cell-index="1" data-cell-title='{% trans "Title" %}' class="oh-sticky-table__th">{% trans "Title" %}</div>

                                    <div data-cell-index="2" data-cell-title='{% trans "Provided Date" %}'
                                        class="oh-sticky-table__th {% if request.sort_option.order == '-provided_date' %}arrow-up {% elif request.sort_option.order == 'provided_date' %}arrow-down {% else %}arrow-up-down {% endif %}"
                                        hx-get="{% url 'search-loan' %}?{{pd}}&sortby=provided_date"
                                        hx-target="#loanContainer"

                                    >
                                        {% trans "Provided Date" %}
                                    </div>
                                    <div data-cell-index="3" data-cell-title='{% trans "Installment Start Date" %}'
                                        class="oh-sticky-table__th {% if request.sort_option.order == '-installment_start_date' %}arrow-up {% elif request.sort_option.order == 'installment_start_date' %}arrow-down {% else %}arrow-up-down {% endif %}"
                                        hx-get="{% url 'search-loan' %}?{{pd}}&sortby=installment_start_date"
                                        hx-target="#loanContainer"

                                    >
                                        {% trans "Installment Start Date" %}
                                    </div>
                                    <div data-cell-index="4" data-cell-title='{% trans "Total Installments" %}'
                                        class="oh-sticky-table__th {% if request.sort_option.order == '-installments' %}arrow-up {% elif request.sort_option.order == 'installments' %}arrow-down {% else %}arrow-up-down {% endif %}"
                                        hx-get="{% url 'search-loan' %}?{{pd}}&sortby=installments"
                                        hx-target="#loanContainer"

                                    >
                                        {% trans "Total Installments" %}
                                    </div>
                                    <div data-cell-index="5" data-cell-title='{% trans "Amount" %}'
                                        class="oh-sticky-table__th {% if request.sort_option.order == '-loan_amount' %}arrow-up {% elif request.sort_option.order == 'loan_amount' %}arrow-down {% else %}arrow-up-down {% endif %}"
                                        hx-get="{% url 'search-loan' %}?{{pd}}&sortby=loan_amount"
                                        hx-target="#loanContainer"
                                    >{% trans "Amount" %}
                                    </div>
                                    <div
                                        data-cell-index="6" data-cell-title='{% trans "Description" %}' class="oh-sticky-table__th" style="width:200px"
                                    >
                                        {% trans "Description" %}
                                    </div>
                                    {% if perms.payroll.change_loanaccount or perms.payroll.delete_loanaccount %}
                                        <div class="oh-sticky-table__th"> {% trans "Actions" %} </div>
                                    {% endif %}
                                </div>
                            </div>
                            <div class="oh-sticky-table__tbody">
                                {% for req in adv_salary %}
                                    <div class="oh-sticky-table__tr"
                                        hx-get="{% url 'view-installments' %}?loan_id={{ req.id }}&instances_ids={{adv_salary_ids}}" hx-target="#objectDetailsModalTarget" data-target="#objectDetailsModal" data-toggle="oh-modal-toggle">
                                        {% comment %} <div class="oh-sticky-table__sd" onclick="event.stopPropagation();">
                                        <input
                                            type="checkbox"
                                            id="{{attendance.id}}"
                                            class="oh-input attendance-checkbox oh-input__checkbox mt-2 mr-2 all-attendance-row"
                                        />
                                        </div> {% endcomment %}
                                        <div class="oh-sticky-table__sd">
                                            <div class="d-flex">
                                                <div class="oh-profile oh-profile--md">
                                                    <div class="oh-profile__avatar mr-1">
                                                        <img
                                                        src="{{req.employee_id.get_avatar}}"
                                                        class="oh-profile__image"
                                                        alt=""
                                                        />
                                                    </div>
                                                    <span class="oh-profile__name oh-text--dark">{{req.employee_id}}</span>
                                                </div>
                                            </div>
                                        </div>
                                        <div data-cell-index="1" class="oh-sticky-table__td">
                                            {{req.title|truncatechars:20 }}
                                        </div>
                                        <div data-cell-index="2" class="oh-sticky-table__td dateformat_changer">
                                            {{req.provided_date|date:"F j, Y"}}
                                        </div>
                                        <div data-cell-index="3" class="oh-sticky-table__td dateformat_changer">
                                            {{req.installment_start_date|date:"F j, Y"}}
                                        </div>
                                        <div data-cell-index="4" class="oh-sticky-table__td">
                                            {{req.installments}}
                                        </div>
                                        <div data-cell-index="5" class="oh-sticky-table__td">
                                        {{req.loan_amount}}
                                        </div>
                                        <div data-cell-index="6" class="oh-sticky-table__td">
                                        {{req.description}}
                                        </div>
                                        {% if perms.payroll.change_loanaccount or perms.payroll.delete_loanaccount %}
                                            <div class="oh-sticky-table__td" onclick="event.stopPropagation()">
                                                <div class="oh-btn-group">
                                                    {% if perms.payroll.change_loanaccount %}
                                                        <a class="oh-btn oh-btn--light-bkg w-100" hx-get="{% url 'create-loan' %}?instance_id={{ req.id }}" hx-target="#objectCreateModalTarget" data-toggle="oh-modal-toggle" data-target="#objectCreateModal" title="{% trans 'Edit' %}">
                                                            <ion-icon class="text-dark" name="create-outline"></ion-icon></a>
                                                    {% endif %}
                                                    {% if perms.payroll.delete_loanaccount %}
                                                        <a class="oh-btn oh-btn--light-bkg w-100" href="{% url 'delete-loan' %}?ids={{ req.id }}" onclick="return confirm('Do you want to delete this record?')" title="{% trans 'Delete' %}">
                                                            <ion-icon class="text-danger" name="trash-outline"></ion-icon></a>
                                                    {% endif %}
                                                </div>
                                            </div>
                                        {% endif %}
                                    </div>
                                {% endfor %}
                            </div>
                        </div>
                    </div>
                    <!-- end of sticky table -->
                    <!-- start of pagination -->
                    <div class="oh-wrapper w-100">
                        <div class="oh-pagination">
                            <span
                                class="oh-pagination__page"
                                data-toggle="modal"
                                data-target="#addEmployeeModal"
                                >{% trans 'Page'  %} {{ adv_salary.number }} {% trans 'of' %} {{ adv_salary.paginator.num_pages }}.</span
                            >

                            <nav class="oh-pagination__nav">
                                <div class="oh-pagination__input-container me-3">
                                    <span class="oh-pagination__label me-1"
                                        >{% trans 'Page' %}</span
                                    >

                                    <input
                                        type="number"
                                        name="page"
                                        class="oh-pagination__input"
                                        value="{{ adv_salary.number }}"
                                        hx-get="{% url 'search-loan' %}?{{ pd }}"
                                        hx-target="#loanContainer"
                                        min="1"
                                    />
                                    <span class="oh-pagination__label"
                                        >{% trans 'of' %} {{ adv_salary.paginator.num_pages }}</span
                                    >
                                </div>

                                <ul class="oh-pagination__items">
                                    {% if adv_salary.has_previous %}
                                    <li
                                        class="oh-pagination__item oh-pagination__item--wide"
                                    >
                                        <a
                                            hx-target="#loanContainer"
                                            hx-get="{% url 'search-loan' %}?{{ pd }}&apage=1"
                                            class="oh-pagination__link"
                                            >{% trans 'First' %}</a
                                        >
                                    </li>
                                    <li
                                        class="oh-pagination__item oh-pagination__item--wide"
                                    >
                                        <a
                                            hx-target="#loanContainer"
                                            hx-get="{% url 'search-loan' %}?{{ pd }}&apage={{ adv_salary.previous_page_number }}"
                                            class="oh-pagination__link"
                                            >{% trans 'Previous' %}</a
                                        >
                                    </li>
                                    {% endif %} {% if adv_salary.has_next %}
                                    <li
                                        class="oh-pagination__item oh-pagination__item--wide"
                                    >
                                        <a
                                            hx-target="#loanContainer"
                                            hx-get="{% url 'search-loan' %}?{{ pd }}&apage={{ adv_salary.next_page_number }}"
                                            class="oh-pagination__link"
                                            >{% trans 'Next' %}</a
                                        >
                                    </li>
                                    <li
                                        class="oh-pagination__item oh-pagination__item--wide"
                                    >
                                        <a
                                            hx-target="#loanContainer"
                                            hx-get="{% url 'search-loan' %}?{{ pd }}&apage={{ adv_salary.paginator.num_pages }}"
                                            class="oh-pagination__link"
                                            >{% trans 'Last' %}</a
                                        >
                                    </li>
                                    {% endif %}
                                </ul>
                            </nav>
                        </div>
                    </div>
                    <!-- end of pagination -->
                </div>
            {% else %}
                <!-- start of empty page -->
                <div style="display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%;" >
                    <img
                    style="width: 150px; height: 150px"
                    src="{% static 'images/ui/no-results.png' %}"
                    class="oh-404__image mb-4"
                    />
                    <h5 class="oh-404__subtitle">
                    {% trans "No search result found!" %}
                    </h5>
                </div>
                <!-- end of empty page -->
            {% endif %}
        </div>
        <!-- end of Leave Encashments-->

        <!-- start of Bonus Encashments-->
        <div class="oh-tabs__content" id="bonus_encashment_tab">
            {% if fine %}
                <!-- start of column toggle button-->
                <div class="oh-table_sticky--wrapper">
                    <div class="oh-sticky-dropdown--header">
                        <div class="oh-dropdown" x-data="{open: false}">
                            <button class="oh-sticky-dropdown_btn " @click="open = !open"><ion-icon name="ellipsis-vertical-sharp"
                                role="img" class="md hydrated" aria-label="ellipsis vertical sharp"></ion-icon></button>
                            <div class="oh-dropdown__menu oh-sticky-table_dropdown" x-show="open" @click.outside="open = false">
                                <ul class="oh-dropdown__items" id="BonusEncashmentCells">
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- end of column toggle button-->
                <div id="bonus-encashment-table" data-table-name="bonus_encashment_table">
                    <!-- start of sticky table -->
                    <div class="oh-sticky-table">
                        <div class="oh-sticky-table__table oh-table--sortable">
                            <div class="oh-sticky-table__thead">
                                <div class="oh-sticky-table__tr">
                                    {% comment %} <div class="oh-sticky-table__th" style="width: 20px">
                                        <input
                                        type="checkbox"
                                        title='{% trans "Select All" %}'
                                        class="oh-input oh-input__checkbox mt-1 mr-2 all-attendances"
                                        style="margin-left: -5px"
                                        />
                                    </div> {% endcomment %}
                                    <div
                                        class="oh-sticky-table__th {% if request.sort_option.order == '-employee_id' %}arrow-up {% elif request.sort_option.order == 'employee_id' %}arrow-down {% else %}arrow-up-down {% endif %}"
                                        hx-get="{% url 'search-loan' %}?{{pd}}&sortby=employee_id"
                                        hx-target="#loanContainer"
                                    >
                                        {% trans "Employee" %}
                                    </div>
                                    <div data-cell-index="1" data-cell-title='{% trans "Title" %}' class="oh-sticky-table__th">{% trans "Title" %}</div>

                                    <div data-cell-index="2" data-cell-title='{% trans "Provided Date" %}'
                                        class="oh-sticky-table__th {% if request.sort_option.order == '-provided_date' %}arrow-up {% elif request.sort_option.order == 'provided_date' %}arrow-down {% else %}arrow-up-down {% endif %}"
                                        hx-get="{% url 'search-loan' %}?{{pd}}&sortby=provided_date"
                                        hx-target="#loanContainer"

                                    >
                                        {% trans "Provided Date" %}
                                    </div>
                                    <div data-cell-index="3" data-cell-title='{% trans "Installment Start Date" %}'
                                        class="oh-sticky-table__th {% if request.sort_option.order == '-installment_start_date' %}arrow-up {% elif request.sort_option.order == 'installment_start_date' %}arrow-down {% else %}arrow-up-down {% endif %}"
                                        hx-get="{% url 'search-loan' %}?{{pd}}&sortby=installment_start_date"
                                        hx-target="#loanContainer"

                                    >
                                        {% trans "Installment Start Date" %}
                                    </div>
                                    <div data-cell-index="4" data-cell-title='{% trans "Total Installments" %}'
                                        class="oh-sticky-table__th {% if request.sort_option.order == '-installments' %}arrow-up {% elif request.sort_option.order == 'installments' %}arrow-down {% else %}arrow-up-down {% endif %}"
                                        hx-get="{% url 'search-loan' %}?{{pd}}&sortby=installments"
                                        hx-target="#loanContainer"

                                    >
                                        {% trans "Total Installments" %}
                                    </div>
                                    <div data-cell-index="5" data-cell-title='{% trans "Amount" %}'
                                        class="oh-sticky-table__th {% if request.sort_option.order == '-loan_amount' %}arrow-up {% elif request.sort_option.order == 'loan_amount' %}arrow-down {% else %}arrow-up-down {% endif %}"
                                        hx-get="{% url 'search-loan' %}?{{pd}}&sortby=loan_amount"
                                        hx-target="#loanContainer"
                                    >{% trans "Amount" %}
                                    </div>
                                    <div
                                        data-cell-index="6" data-cell-title='{% trans "Description" %}' class="oh-sticky-table__th" style="width:200px"
                                    >
                                        {% trans "Description" %}
                                    </div>
                                    {% if perms.payroll.change_loanaccount or perms.payroll.delete_loanaccount %}
                                        <div class="oh-sticky-table__th"> {% trans "Actions" %} </div>
                                    {% endif %}
                                </div>
                            </div>
                            <div class="oh-sticky-table__tbody">
                                {% for req in fine %}
                                    <div class="oh-sticky-table__tr"
                                        hx-get="{% url 'view-installments' %}?loan_id={{ req.id }}&instances_ids={{fine_ids}}" hx-target="#objectDetailsModalTarget" data-target="#objectDetailsModal" data-toggle="oh-modal-toggle">
                                        {% comment %} <div class="oh-sticky-table__sd" onclick="event.stopPropagation();">
                                        <input
                                            type="checkbox"
                                            id="{{attendance.id}}"
                                            class="oh-input attendance-checkbox oh-input__checkbox mt-2 mr-2 all-attendance-row"
                                        />
                                        </div> {% endcomment %}
                                        <div class="oh-sticky-table__sd">
                                            <div class="d-flex">
                                                <div class="oh-profile oh-profile--md">
                                                    <div class="oh-profile__avatar mr-1">
                                                        <img
                                                        src="{{req.employee_id.get_avatar}}"
                                                        class="oh-profile__image"
                                                        alt=""
                                                        />
                                                    </div>
                                                    <span class="oh-profile__name oh-text--dark">{{req.employee_id}}</span>
                                                </div>
                                            </div>
                                        </div>
                                        <div data-cell-index="1" class="oh-sticky-table__td">
                                            {{req.title|truncatechars:20 }}
                                        </div>
                                        <div data-cell-index="2" class="oh-sticky-table__td dateformat_changer">
                                            {{req.provided_date|date:"F j, Y"}}
                                        </div>
                                        <div data-cell-index="3" class="oh-sticky-table__td dateformat_changer">
                                            {{req.installment_start_date|date:"F j, Y"}}
                                        </div>
                                        <div data-cell-index="4" class="oh-sticky-table__td">
                                            {{req.installments}}
                                        </div>
                                        <div data-cell-index="5" class="oh-sticky-table__td">
                                        {{req.loan_amount}}
                                        </div>
                                        <div data-cell-index="6" class="oh-sticky-table__td">
                                        {{req.description}}
                                        </div>
                                        {% if perms.payroll.change_loanaccount or perms.payroll.delete_loanaccount %}
                                            <div class="oh-sticky-table__td" onclick="event.stopPropagation()">
                                                <div class="oh-btn-group">
                                                    {% if perms.payroll.change_loanaccount %}
                                                        <a class="oh-btn oh-btn--light-bkg w-100" hx-get="{% url 'create-loan' %}?instance_id={{ req.id }}" hx-target="#objectCreateModalTarget" data-toggle="oh-modal-toggle" data-target="#objectCreateModal" title="{% trans 'Edit' %}">
                                                            <ion-icon class="text-dark" name="create-outline"></ion-icon></a>
                                                    {% endif %}
                                                    {% if perms.payroll.delete_loanaccount %}
                                                        <a class="oh-btn oh-btn--light-bkg w-100" href="{% url 'delete-loan' %}?ids={{ req.id }}" onclick="return confirm('Do you want to delete this record?')" title="{% trans 'Delete' %}">
                                                            <ion-icon class="text-danger" name="trash-outline"></ion-icon></a>
                                                    {% endif %}
                                                </div>
                                            </div>
                                        {% endif %}
                                    </div>
                                {% endfor %}
                            </div>
                        </div>
                    </div>
                    <!-- end of sticky table -->
                    <!-- start of pagination -->
                    <div class="oh-wrapper w-100">
                        <div class="oh-pagination">
                            <span
                                class="oh-pagination__page"
                                data-toggle="modal"
                                data-target="#addEmployeeModal"
                                >{% trans 'Page'  %} {{ fine.number }} {% trans 'of' %} {{ fine.paginator.num_pages }}.</span
                            >

                            <nav class="oh-pagination__nav">
                                <div class="oh-pagination__input-container me-3">
                                    <span class="oh-pagination__label me-1"
                                        >{% trans 'Page' %}</span
                                    >

                                    <input
                                        type="number"
                                        name="page"
                                        class="oh-pagination__input"
                                        value="{{ fine.number }}"
                                        hx-get="{% url 'search-loan' %}?{{ pd }}"
                                        hx-target="#loanContainer"
                                        min="1"
                                    />
                                    <span class="oh-pagination__label"
                                        >{% trans 'of' %} {{ fine.paginator.num_pages }}</span
                                    >
                                </div>

                                <ul class="oh-pagination__items">
                                    {% if fine.has_previous %}
                                    <li
                                        class="oh-pagination__item oh-pagination__item--wide"
                                    >
                                        <a
                                            hx-target="#loanContainer"
                                            hx-get="{% url 'search-loan' %}?{{ pd }}&fpage=1"
                                            class="oh-pagination__link"
                                            >{% trans 'First' %}</a
                                        >
                                    </li>
                                    <li
                                        class="oh-pagination__item oh-pagination__item--wide"
                                    >
                                        <a
                                            hx-target="#loanContainer"
                                            hx-get="{% url 'search-loan' %}?{{ pd }}&fpage={{ fine.previous_page_number }}"
                                            class="oh-pagination__link"
                                            >{% trans 'Previous' %}</a
                                        >
                                    </li>
                                    {% endif %} {% if fine.has_next %}
                                    <li
                                        class="oh-pagination__item oh-pagination__item--wide"
                                    >
                                        <a
                                            hx-target="#loanContainer"
                                            hx-get="{% url 'search-loan' %}?{{ pd }}&fpage={{ fine.next_page_number }}"
                                            class="oh-pagination__link"
                                            >{% trans 'Next' %}</a
                                        >
                                    </li>
                                    <li
                                        class="oh-pagination__item oh-pagination__item--wide"
                                    >
                                        <a
                                            hx-target="#loanContainer"
                                            hx-get="{% url 'search-loan' %}?{{ pd }}&fpage={{ fine.paginator.num_pages }}"
                                            class="oh-pagination__link"
                                            >{% trans 'Last' %}</a
                                        >
                                    </li>
                                    {% endif %}
                                </ul>
                            </nav>
                        </div>
                    </div>
                    <!-- end of pagination -->
                </div>
            {% else %}
                <!-- start of empty page -->
                <div style="display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%;" >
                    <img
                    style="width: 150px; height: 150px"
                    src="{% static 'images/ui/no-results.png' %}"
                    class="oh-404__image mb-4"
                    />
                    <h5 class="oh-404__subtitle">
                    {% trans "No search result found!" %}
                    </h5>
                </div>
                <!-- end of empty page -->
            {% endif %}
        </div>
        <!-- end of Bonus Encashments-->

    </div>
    <!-- end of tabs -->

    <script>
        function reimbursementConfirm(params, target, approve = false) {
            Swal.fire({
                text: params,
                icon: "question",
                showCancelButton: true,
                confirmButtonColor: "#008000",
                cancelButtonColor: "#d33",
                confirmButtonText: "Confirm",
                cancelButtonText: "Close",
            }).then((result) => {
                if (result.isConfirmed) {
                    if (approve) {
                        $(`${target} [name=amount]`).attr("required", true);
                    }
                    $(target + "Button").click();
                    if (event.target.tagName.toLowerCase() === "form") {
                        event.target.submit();
                    } else if (event.target.tagName.toLowerCase() === "a") {
                        window.location.href = event.target.href;
                    }
                } else {
                }
            });
        }
        $(document).ready(function () {
            var activeTab = localStorage.getItem("activeTabReimbursment");
            if (activeTab != null) {
                var tab = $(`[data-target="${activeTab}"]`);
                var tabContent = $(activeTab);
                $(tab).addClass( "oh-tabs__tab--active");
                $(tabContent).addClass( "oh-tabs__content--active");
            } else {
                $('[data-target="#reimbursement_tab"]').attr(
                    "class",
                    "oh-tabs__tab oh-tabs__tab--active"
                );
                $("#reimbursement_tab").attr("class", "oh-tabs__content oh-tabs__content--active");
            }

            $(".oh-tabs__tab").click(function (e) {
                var activeTab = $(this).attr("data-target");
                $(".oh-tabs__content--active").toggleClass('oh-tabs__content--active');
                $(".oh-tabs__tab--active").toggleClass('oh-tabs__tab--active');
                $(`[data-target="${activeTab}"]`).toggleClass("oh-tabs__tab--active");
                $(activeTab).toggleClass("oh-tabs__content--active");
                localStorage.setItem("activeTabReimbursment", activeTab);
            });
        });
        // toggle colums //

        //Reiumbursement
        toggleColumns("reimbursement-table","ReimbursementCells")
        localStorageReimbursementCells = localStorage.getItem("reimbursement_table")
        if (!localStorageReimbursementCells) {
            $("#ReimbursementCells").find("[type=checkbox]").prop("checked",true)
        }
        $("[type=checkbox]").change()

        //Leave encashments
        toggleColumns("leave-encashment-table","LeaveEncashmentCells")
        localStorageLeaveEncashmentCells = localStorage.getItem("leave_encashment_table")

        if (!localStorageLeaveEncashmentCells) {
            $("#LeaveEncashmentCells").find("[type=checkbox]").prop("checked",true)
        }
        $("[type=checkbox]").change()

        //Bonus encashments
        toggleColumns("bonus-encashment-table","BonusEncashmentCells")
        localStorageBonusEncashmentCells = localStorage.getItem("bonus_encashment_table")

        if (!localStorageBonusEncashmentCells) {
            $("#BonusEncashmentCells").find("[type=checkbox]").prop("checked",true)
        }
        $("[type=checkbox]").change()
    </script>
</div>
