<script type="text/javascript">
    var id_kar = 0;
    $(function() {
        $('.tab_detail_karyawan li').click(function() {
            $('.tab_detail_karyawan li').removeClass("active");
            $(this).addClass("active");
        });

        form_datadiri();
        set_back_notif_kepegawaian();
    });

    function set_back_notif_kepegawaian() {
        if (sessionStorage.getItem("back_notif_kepegawaian") != null) {
            $('#kembali').attr('href', sessionStorage.getItem("back_notif_kepegawaian"));
        } else if (sessionStorage.getItem("back_kepegawaian") != null) {
            $('#kembali').attr('href', sessionStorage.getItem("back_kepegawaian"));
        }
    }

    function form_datadiri() {
        $("#myTabContent").load("<?= route('master.karyawan.datadiri.detail') . '/' . $id_karyawan ?>");
    }

    function edit_informasi_datadiri(id) {
        $("#myTabContent").load("<?= route('master.karyawan.datadiri.form.edit') ?>" + "/" + id);
    }

    function tab_keluarga() {
        $("#myTabContent").load("<?= route('master.karyawan.keluarga.main') . '/' . $id_karyawan ?>");
    }

    function tab_pendidikan() {
        $("#myTabContent").load("<?= route('master.karyawan.riwayatpendidikan.main') . '/' . $id_karyawan ?>");
    }

    function tab_pengalamankerja() {
        $("#myTabContent").load("<?= route('master.karyawan.pengalamankerja.main') . '/' . $id_karyawan ?>");
    }

    function tab_karirpekerjaan() {
        $("#myTabContent").load("<?= route('master.karyawan.karirpekerjaan.main') . '/' . $id_karyawan ?>");
    }

    function tab_sertifikat() {
        $("#myTabContent").load("<?= route('master.karyawan.sertifikat.main') . '/' . $id_karyawan ?>");
    }

    function tab_akun() {
        $(document).off('click', '.btn_reset_deviceid');
        $(document).off('click', '.btn_reset_facerecognition');
        $(document).off('click', '.btn_proses_reset_deviceid');
        $(document).off('click', '.btn_proses_reset_facerecognition');
        $(document).off('click', '#btn_confrim_camera');
        $("#myTabContent").load("<?= route('master.karyawan.akun.home') . '/' . $id_karyawan ?>");
    }

    function tab_file() {
        $("#myTabContent").load("<?= route('master.karyawan.kelengkapanfile.main') . '/' . $id_karyawan ?>");
    }
    <?php if ($this->paket_arr['payroll'] || $this->paket_payroll == '1') { ?>

        function tab_payroll() {
            $("#myTabContent").load("<?= route('master.karyawan.payroll.home') . '/' . $id_karyawan ?>");
        }
    <?php } ?>

    // save back button state session menggunakan session storage
    function save_filter_session() {
        sessionStorage.setItem("back_button", true);
    }
</script>

<div class="content-header">
    <div class="row align-items-center">
        <div class="content-header-left col-md-6 col-12 mb-md-0">
            <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_master_data') ?></a>
                        </li>
                        <li class="breadcrumb-item active"><?= $judul ?>
                        </li>
                    </ol>
                </div>
            </div>
        </div>
        <div class="content-header-right col-md-6 col-12">
            <div class="float-md-right">
                <a id="kembali" href="<?= site_url('master/karyawan') ?>" class="btn btn-secondary btn-min-width" onclick="save_filter_session();">
                    <i class="fa fa-arrow-left"></i> <?= $this->lang->line('button_form_kembali') ?>
                </a>
            </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">
                        <div class="col-md-2 border-kanan">
                            <ul class="tab_detail_karyawan nav nav-tabs nav-left flex-column">
                                <li onclick="tab_datadiri();" class="nav-item active">
                                    <a class="nav-link active" data-toggle="tab" aria-expanded="true">
                                        <?= $this->lang->line('data_diri') . $this->notif_status->data_diri($id_karyawan); ?>
                                    </a>
                                </li>
                                <?php
                                if ($this->level_user == "1") {
                                ?>
                                    <li onclick="tab_keluarga();" class="nav-item">
                                        <a class="nav-link" data-toggle="tab" aria-expanded="false">
                                            <?= $this->lang->line('data_keluarga') . $this->notif_status->keluarga($id_karyawan); ?>
                                        </a>
                                    </li>
                                    <li onclick="tab_pendidikan();" class="nav-item">
                                        <a class="nav-link" data-toggle="tab" aria-expanded="false">
                                            <?= $this->lang->line('data_pendidikan') . $this->notif_status->pendidikan($id_karyawan); ?>
                                        </a>
                                    </li>
                                    <li onclick="tab_pengalamankerja();" class="nav-item">
                                        <a class="nav-link" data-toggle="tab" aria-expanded="false">
                                            <?= $this->lang->line('pengalaman_kerja') . $this->notif_status->pengalaman($id_karyawan); ?>
                                        </a>
                                    </li>
                                    <li onclick="tab_karirpekerjaan();" class="nav-item">
                                        <a class="nav-link" data-toggle="tab" aria-expanded="false">
                                            <?= $this->lang->line('karir_pekerjaan') ?>
                                        </a>
                                    </li>
                                    <li onclick="tab_sertifikat();" class="nav-item">
                                        <a class="nav-link" data-toggle="tab" aria-expanded="false">
                                            <?= $this->lang->line('sertifikat_pelatihan') . $this->notif_status->sertifikat($id_karyawan); ?>
                                        </a>
                                    </li>
                                    <li onclick="tab_akun();" class="nav-item">
                                        <a class="nav-link" data-toggle="tab" aria-expanded="false">
                                            <?= $this->lang->line('akses_akun') ?>
                                        </a>
                                    </li>
                                    <li onclick="tab_file();" class="nav-item">
                                        <a class="nav-link" data-toggle="tab" aria-expanded="false">
                                            <?= $this->lang->line('kelengkapan_file') . $this->notif_status->file($id_karyawan); ?>
                                        </a>
                                    </li>
                                    <?php if ($this->paket_arr['payroll'] || $this->paket_payroll == '1') { ?>
                                        <li onclick="tab_payroll();" class="nav-item">
                                            <a class="nav-link" data-toggle="tab" aria-expanded="false">
                                                Payroll
                                            </a>
                                        </li>
                                <?php
                                    }
                                }
                                ?>
                            </ul>
                        </div>
                        <div class="col-md-10">
                            <div id="myTabContent" class="tab-content">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
