<script type="text/javascript">
    var id_karyawan = "<?= md5($row->id_karyawan) ?>";

    function tab_datadiri() {
        $("#myTabContent").load("<?= route('master.karyawan.datadiri.detail') ?>" + "/" + id_karyawan);
    }
</script>
<?php if ($this->session->userdata('level_user') == 1) {
    echo $tab . "<br>";
} ?>
<?php
if (in_array($this->session->userdata('level_user'), array("1"))) {
?>
    <div class="row mb-2">
        <div class="col-md-12 text-right">
            <a href="<?= site_url('master/karyawan/export-pdf') ?>/<?= md5($row->id_karyawan) ?>" target="_blank" class="btn btn-outline-secondary round btn-min-width">
                <i class="fa fa-print"></i> <?= $this->lang->line('cetak_biodata') ?>
            </a>
            <?php if ($jml >= 2) { ?>
                <a href="javascript:;" onclick="edit_informasi_datadiri('<?= md5($row->id_karyawan) ?>')" class="btn btn-outline-secondary round btn-min-width">
                    <i class="fa fa-pencil"></i> Edit Data
                </a>
            <?php } else if ($row->level_user != 1) { ?>
                <a href="javascript:;" onclick="edit_informasi_datadiri('<?= md5($row->id_karyawan) ?>')" class="btn btn-outline-secondary round btn-min-width">
                    <i class="fa fa-pencil"></i> Edit Data
                </a>
            <?php } ?>
        </div>
    </div>
<?php
}
?>
<div class="row form-detail-karyawan">
    <div class="col-md-8">
        <div class="row">
            <div class="col-md-12 text-primary">
                <h5><?= $this->lang->line('data_diri') ?></h5>
            </div>
        </div>
        <hr>
        <div class="row">
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('nomor_induk_karyawan') ?></label>
                    <p class="form-control-static"><?= $row->nik ?></p>
                </fieldset>
            </div>
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('nama_lengkap') ?></label>
                    <p class="form-control-static"><?= $row->nama_lengkap ?></p>
                </fieldset>
            </div>
        </div>
        <div class="row">
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('pendidikan_terakhir') ?></label>
                    <p class="form-control-static"><?= ((!empty($row->pendidikan_terakhir)) ? $row->pendidikan_terakhir : "-") ?></p>
                </fieldset>
            </div>
        </div>
        <div class="row">
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('gelar_depan') ?></label>
                    <p class="form-control-static"><?= ((!empty($row->gelar_depan)) ? $row->gelar_depan : '-') ?></p>
                </fieldset>
            </div>
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('gelar_belakang') ?></label>
                    <p class="form-control-static"><?= ((!empty($row->gelar_belakang)) ? $row->gelar_belakang : '-') ?></p>
                </fieldset>
            </div>
        </div>
        <div class="row">
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('jenis_kelamin') ?></label>
                    <p class="form-control-static"><?= ((!empty($row->jenis_kelamin)) ? $this->fungsi->jkel($row->jenis_kelamin) : '-') ?></p>
                </fieldset>
            </div>
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('golongan_darah') ?></label>
                    <p class="form-control-static"><?= ((!empty($row->golongan_darah)) ? $row->golongan_darah : "-") ?></p>
                </fieldset>
            </div>
        </div>
        <div class="row">
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('tempat_lahir') ?></label>
                    <p class="form-control-static">
                        <?= $row->tempat_lahir ?>
                    </p>
                </fieldset>
            </div>
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('tgl_lahir') ?></label>
                    <p class="form-control-static"><?= ((!empty($row->tgl_lahir)) && $row->tgl_lahir != '1970-01-01' ? $this->fungsi->tgl_indo($row->tgl_lahir) : '-') ?></p>
                </fieldset>
            </div>
        </div>

        <div class="row">
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('no_telp') ?></label>
                    <p class="form-control-static"><?= ((!empty($row->telepon)) ? $row->telepon : '-') ?></p>
                </fieldset>
            </div>
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('email') ?></label>
                    <p class="form-control-static"><?= ((!empty($row->email)) ? $row->email : '-') ?></p>
                </fieldset>
            </div>
        </div>
        <div class="row">
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('agama') ?></label>
                    <p class="form-control-static"><?= ((!empty($row->agama)) ? $row->agama : '-') ?></p>
                </fieldset>
            </div>
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('no_ktp') ?></label>
                    <p class="form-control-static"><?= ((!empty($row->no_ktp)) ? $row->no_ktp : '-') ?></p>
                </fieldset>
            </div>
        </div>
        <!-- <div class="row">
            <div class="col-md-6">
                <div class="form-group">
                    <label class="form-label" for="no_bpjs_kes"><?= $this->lang->line('no_bpjs_kes') ?></label>
                    <p class="form-control-static"><?= $row->no_bpjs_kes != '' ? $row->no_bpjs_kes : '-' ?></p>
                </div>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label class="form-label" for="no_bpjs_kes"><?= $this->lang->line('no_bpjs_tk') ?></label>
                    <p class="form-control-static"><?= $row->no_bpjs_tk != '' ? $row->no_bpjs_tk : '-' ?></p>
                </div>
            </div>
        </div> -->
       <!--  <div class="row">
            <div class="col-md-6">
                <label class="form-label" for="jml_anak"><?= $this->lang->line('jml_anak') ?></label>
                <p class="form-control-static"><?= $row->jml_anak != '' ? $row->jml_anak : '-' ?></p>
            </div>
        </div> -->

        <div class="row mt-3">
            <div class="col-md-12 text-primary">
                <h5><?= $this->lang->line('data_alamat_ktp') ?></h5>
            </div>
        </div>
        <hr>
        <div class="row">
            <div class="col-md-12">
                <fieldset class="form-group">
                    <p class="form-control-static"><?= ((!empty($row->alamat_ktp)) ? $row->alamat_ktp : '-') ?></p>
                </fieldset>
            </div>
        </div>

        <div class="row mt-3">
            <div class="col-md-12 text-primary">
                <h5><?= $this->lang->line('data_alamat_domisili') ?></h5>
            </div>
        </div>
        <hr>
        <div class="row">
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('provinsi') ?></label>
                    <p class="form-control-static"><?= ((!empty($row->nama_prov)) ? $row->nama_prov : '-') ?></p>
                </fieldset>
            </div>
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('kota_kabupaten') ?></label>
                    <p class="form-control-static"><?= ((!empty($row->nama_kota)) ? $row->nama_kota : '-') ?></p>
                </fieldset>
            </div>
        </div>
        <div class="row">
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('kecamatan') ?></label>
                    <p class="form-control-static"><?= ((!empty($row->nama_kec)) ? $row->nama_kec : '-') ?></p>
                </fieldset>
            </div>
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('kelurahan') ?></label>
                    <p class="form-control-static"><?= ((!empty($row->nama_kel)) ? $row->nama_kel : '-') ?></p>
                </fieldset>
            </div>
        </div>
        <div class="row">
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label>RT</label>
                    <p class="form-control-static"><?= ((!empty($row->rt)) ? $row->rt : '-') ?></p>
                </fieldset>
            </div>
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label>RW</label>
                    <p class="form-control-static"><?= ((!empty($row->rw)) ? $row->rw : '-') ?></p>
                </fieldset>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('alamat') ?></label>
                    <p class="form-control-static"><?= ((!empty($row->alamat_domisili)) ? $row->alamat_domisili : '-') ?></p>
                </fieldset>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('kode_pos') ?></label>
                    <p class="form-control-static"><?= ((!empty($row->kode_pos)) ? $row->kode_pos : '-') ?></p>
                </fieldset>
            </div>
        </div>

        <div class="row mt-3">
            <div class="col-md-12 text-primary">
                <h5><?= $this->lang->line('data_kepegawaian') ?></h5>
            </div>
        </div>
        <hr>
        <?php
        $level_user = $row->level_user;
        if (in_array($level_user, array('1', '6'))) { # Admin HR, Admin Finance
            $hidden_cabang = "d-none ";
            $hidden_departemen = "d-none ";
            $hidden_supervisi = "d-none ";
            $hidden_cuti = "d-none ";
            $hidden_status = "d-none ";
            $hidden_mulai_kerja = "d-none ";
            $hidden_berakhir_kerja = "d-none ";
        } else if ($level_user == '4') { #Direksi
            $hidden_departemen = "d-none ";
            $hidden_supervisi = "d-none ";
        } else if ($level_user == '5') { # Kepala Cabang
            $hidden_departemen = "d-none ";
            $hidden_supervisi = "d-none ";
        } else if ($level_user == '2') { # Kepala Departemen
            $hidden_departemen = " ";
            $hidden_supervisi = "d-none ";
        } else if ($level_user == '7') { # Supervisi
            $hidden_departemen = " ";
            $hidden_supervisi = "d-none ";
        } else { # STaff
            $hidden_departemen = " ";
            $hidden_supervisi = " ";
        }
        ?>

        <div class="row">
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('jabatan') ?></label>
                    <p class="form-control-static"><?= isset($row->nama_jabatan) ? $row->kode_jabatan . " - " . $row->nama_jabatan : "" ?></p>
                </fieldset>
            </div>
            <div class="col-md-6 <?= $hidden_cabang ?>">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('cabang') ?></label>
                    <p class="form-control-static"><?= isset($row->nama_cabang) ? $row->kode_cabang . " - " . $row->nama_cabang : "" ?></p>
                </fieldset>
            </div>
        </div>
        <div class="row">
            <div class="col-md-6 <?= $hidden_departemen ?>">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('departemen') ?></label>
                    <p class="form-control-static"><?= isset($row->nama_departemen) ? $row->kode_departemen . " - " . $row->nama_departemen : "-" ?></p>
                </fieldset>
            </div>
            <div class="col-md-6 <?= $hidden_supervisi ?>">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('supervisi') ?></label>
                    <p class="form-control-static"><?= isset($row->nama_supervisi) ? $row->nik_supervisi . " - " . $row->nama_supervisi : "-" ?></p>
                </fieldset>
            </div>
        </div>

        <div class="row">
            <div class="col-md-6 <?= $hidden_cuti ?>">
                <fieldset class="form-group">
                    <label><?= $this->lang->line('jatah_cuti') ?></label>
                    <p class="form-control-static"><?= $row->jatah_cuti ?></p>
                </fieldset>
            </div>
            <div class="col-md-6 <?= $hidden_status ?>">
                <fieldset class="form-group">
                    <label>Status</label>
                    <p class="form-control-static"><?= $this->fungsi->status_karyawan($row->status) ?></p>
                </fieldset>
            </div>
        </div>

        <?php
        $status_karyawan = $row->status;
        if ($status_karyawan == "1") {
            $label_aktif_bekerja    = $this->lang->line('tgl_mulai_kontrak');
            $label_berhenti_bekerja = $this->lang->line('tgl_berakhir_kontrak');
        } else if (in_array($status_karyawan, ["2", "3", "4"])) {
            $label_aktif_bekerja    = $this->lang->line('tgl_aktif');
            $label_berhenti_bekerja = "";
        } else if ($status_karyawan == "5") {
            $label_aktif_bekerja    = $this->lang->line('tgl_aktif');
            $label_berhenti_bekerja = $this->lang->line('tgl_resign');
        } else if ($status_karyawan == "6") {
            $label_aktif_bekerja    = $this->lang->line('tgl_aktif');
            $label_berhenti_bekerja = $this->lang->line('tgl_phk');
        } else if ($status_karyawan == "7") {
            $label_aktif_bekerja    = $this->lang->line('tgl_aktif');
            $label_berhenti_bekerja = $this->lang->line('tgl_pensiun');
        }
        ?>
        <div class="row">
            <div class="col-md-6 <?= $hidden_mulai_kerja ?>">
                <fieldset class="form-group">
                    <label><?= $label_aktif_bekerja ?></label>
                    <p class="form-control-static"><?= ((!empty($this->fungsi->tgl_indo($row->tgl_aktif_bekerja))) ? $this->fungsi->tgl_indo($row->tgl_aktif_bekerja) : '-') ?></p>
                </fieldset>
            </div>
            <?php
            if (in_array($row->status, ["1", "5", "6", "7"])) {
            ?>
                <div class="col-md-6 <?= $hidden_berakhir_kerja ?>">
                    <fieldset class="form-group">
                        <label><?= $label_berhenti_bekerja ?></label>
                        <p class="form-control-static">
                            <?php
                            if ($row->tgl_berhenti_bekerja != '0000-00-00') {
                                $periode = $this->fungsi->tgl_indo($row->tgl_berhenti_bekerja);
                            } else {
                                $periode = "-";
                            }

                            echo $periode;
                            ?>
                        </p>
                    </fieldset>
                </div>
            <?php
            }
            ?>
        </div>

        <div class="row">
            <div class="col-md-6">
                <fieldset class="form-group">
                    <label>Join Date</label>
                    <p class="form-control-static"><?= ((empty($this->fungsi->tgl_indo($row->join_date))) ? '-' : (($this->code_lang == 'id') ? $this->fungsi->tgl_indo($row->join_date) : date('d F Y', strtotime($row->join_date)))) ?></p>
                </fieldset>
            </div>
        </div>
    </div>

    <div class="col-md-4 text-center">
        <div class="row">
            <div class="col-md-12 text-primary">
                <h5><?= $this->lang->line('foto_profil') ?></h5>
            </div>
        </div>
        <hr>
        <div class="row">
            <div class="col-md-12 thumbnail">
                <?php
                $foto = $this->config->item('base_image') . 'imagebiodata?_t=photo&_d=' . $row->foto;
                ?>
                <img src="<?= $foto; ?>" class="portrait" style="max-height:200px">
            </div>
        </div>
    </div>
</div>

<!-- jQuery file upload -->
<script>
    $(document).ready(function() {
        $('.dropify').dropify();
    });
</script>
