<style>
    .dark-blue-color {
        color: #1c77d4 !important;
        font-weight: bold !important;
    }
</style>

<div class="content-header mt-4">
    <div class="row align-items-center">
        <div class="content-header-left col-md-6 col-12 mb-md-0 mb-1">
            <h3 class="content-header-title"><?= $judul ?></h3>
            <div class="row breadcrumbs-top">
                <div class="breadcrumb-wrapper col-12">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="#"><?= $this->lang->line('menu_pengaturan'); ?></a>
                        </li>
                        <li class="breadcrumb-item active"><?= $judul ?>
                        </li>
                    </ol>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="row match-height">
    <div class="col-xl-12 col-lg-12">
        <div class="card card-rounded card-detail-karyawan">
            <div class="card-content">
                <div class="card-body p-custom">
                    <div class="nav-vertical row">
                        <!-- Navbar -->
                        <div class="col-md-2 border-kanan">
                            <ul class="tab_menu nav nav-tabs nav-left flex-column">
                                <li class="nav-item" onclick="select_tab_menu($(this).find('a'))">
                                    <a id="tab_adm_absensi" class="nav-link" aria-expanded="false">
                                        <?= $this->lang->line('menu_admin_absensi'); ?>
                                    </a>
                                </li>

                                <li class="nav-item" onclick="select_tab_menu($(this).find('a'))">
                                    <a id="tab_adm_reimburse" class="nav-link" aria-expanded="false">
                                        <?= $this->lang->line('menu_admin_reimbursement'); ?>
                                        &nbsp;
                                        <?php
                                            if ($this->paket_arr['reimburse'] === false) {
                                                echo '<i class="fa fa-lock text-danger"></i>';
                                            }
                                        ?>
                                    </a>
                                </li>

                                <li class="nav-item" onclick="select_tab_menu($(this).find('a'))">
                                    <a id="tab_adm_payroll" class="nav-link" aria-expanded="false">
                                        <?= $this->lang->line('menu_admin_payroll'); ?>
                                        &nbsp;
                                        <?php
                                            if ($this->paket_arr['payroll'] === false) {
                                                echo '<i class="fa fa-lock text-danger"></i>';
                                            }
                                        ?>
                                    </a>
                                </li>
                            </ul>
                        </div>

                        <!-- Isi Konten -->
                        <div class="col-md-10" style="padding: 20px;">
                            <div id="myTabContent" class="tab-content">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function() {
        loading('#myTabContent');

        if (localStorage.getItem("pengaturan-admin-menu") != null) {
            let thisTab = document.getElementById(localStorage.getItem("pengaturan-admin-menu"));
            if (!thisTab) {
                thisTab = document.querySelector('.tab_menu a');
            }
            thisTab.closest('li').click();
            thisTab.classList.add("active");
        } else {
            const thisTab = document.querySelector('.tab_menu a');
            thisTab.closest('li').click();
            thisTab.classList.add("active");
        }

        $('.tab_menu li a').click(function() {
            $('.tab_menu li a').removeClass("active");
            $(this).addClass("active");
        });
    });

    function loading(id) {
        $(id).html('<div class="modal-body"><div class="text-center"><div class="custom-lds-ring"><div></div><div></div><div></div></div></div></div>');
    }

    function select_tab_menu(e) {
        loading('#myTabContent');
        switch (e.attr("id")) {
            case "tab_adm_absensi":
                $("#myTabContent").load("<?= route('pengaturan.admin.absensi.home') ?>");
                localStorage.setItem("pengaturan-admin-menu", "tab_adm_absensi");
                break;

            case "tab_adm_reimburse":
                $("#myTabContent").load("<?= route('pengaturan.admin.reimburse.home') ?>");
                localStorage.setItem("pengaturan-admin-menu", "tab_adm_reimburse");
                break;

            case "tab_adm_payroll":
                $("#myTabContent").load("<?= route('pengaturan.admin.payroll.home') ?>");
                localStorage.setItem("pengaturan-admin-menu", "tab_adm_payroll");
                break;

            default:
                $("#myTabContent").html("Data Tidak Ditemukan");
                localStorage.setItem("pengaturan-admin-menu", "tab_adm_absensi");
                break;
        }
    }

</script>