<?= $tab; ?>
<br>
<?php if ($data->num_rows() > 0) {
    $row = $data->row();
?>
    <script type="text/javascript">
        function approve() {
            var l = Ladda.create(document.querySelector('#approve'));
            l.start();
            $.get('<?= route("master.karyawan.datadiri.pengajuan.approve"); ?>', {
                    id_karyawan: $('#id_karyawan').val()
                },
                function(result) {
                    l.stop();
                    if (result.success) {
                        $('.card-footer').hide();
                        $('.title').html(result.message);
                        $('.title font').attr('color', '#FFFFFF');
                        setTimeout(refresh_page, 5000);
                    } else {
                        $('#message_modal').html(result.message);
                    }
                },
                'json');
        }

        function revisi() {
            var l = Ladda.create(document.querySelector('#revisi'));
            l.start();
            $.get('<?= route("master.karyawan.datadiri.pengajuan.revisi"); ?>', {
                    id_karyawan: $('#id_karyawan').val(),
                    keterangan: $('#keterangan').val()
                },
                function(result) {
                    l.stop();
                    if (result.success) {
                        $('#revisi, #keterangan, #batal').prop('disabled', true);
                        setTimeout(refresh_page, 5000);
                    }
                    $('#message_modal').html(result.message);
                },
                'json');
        }

        function refresh_page() {
            location.reload();
        }

        function form_approve() {
            $('#tampil_form').load("<?= route('master.karyawan.datadiri.pengajuan.form') ?>/approve", function() {
                $('#modal_form').modal('show');
                $("#form_input :input").prop("disabled", true);
                $(".title").text("<?= strtoupper($this->lang->line('title_form_approve_pengajuan')) ?>");
            });
        }

        function form_revisi() {
            $('#tampil_form').load("<?= route('master.karyawan.datadiri.pengajuan.form') ?>/revisi", function() {
                $('#modal_form').modal('show');
                $("#form_input :input").prop("disabled", true);
                $(".title").text("<?= strtoupper($this->lang->line('title_form_revisi_pengajuan')) ?>");
            });
        }
    </script>
    <?= pengajuan($row->status, $row->ket_revisi) ?>
    <input type="text" id="id_karyawan" value="<?= $id_karyawan_md5 ?>" hidden>
    <div class="row form-detail-karyawan">
        <div class="col-md-8">
            <div class="row">
                <div class="col-md-12 text-primary">
                    <h5><?= ucwords(data_diri_action()) ?></h5>
                </div>
            </div>
            <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>
                        <?= data_sebelumnya($data_sebelumnya->nik, $row->nik) ?>
                    </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>
                        <?= data_sebelumnya($data_sebelumnya->nama_lengkap, $row->nama_lengkap) ?>
                    </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>
                        <?= data_sebelumnya($data_sebelumnya->pendidikan_terakhir, $row->pendidikan_terakhir) ?>
                    </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>
                        <?= data_sebelumnya($data_sebelumnya->gelar_depan, $row->gelar_depan) ?>
                    </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>
                        <?= data_sebelumnya($data_sebelumnya->gelar_belakang, $row->gelar_belakang) ?>
                    </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>
                        <?= data_sebelumnya($data_sebelumnya->jenis_kelamin, $row->jenis_kelamin, 'jkel') ?>
                    </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>
                        <?= data_sebelumnya($data_sebelumnya->golongan_darah, $row->golongan_darah) ?>
                    </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>
                        <?= data_sebelumnya($data_sebelumnya->tempat_lahir, $row->tempat_lahir) ?>
                    </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)) ? $this->fungsi->tgl_indo($row->tgl_lahir) : '-') ?></p>
                        <?= data_sebelumnya($data_sebelumnya->tgl_lahir, $row->tgl_lahir, 'tgl_indo') ?>
                    </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>
                        <?= data_sebelumnya($data_sebelumnya->telepon, $row->telepon) ?>
                    </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>
                        <?= data_sebelumnya($data_sebelumnya->email, $row->email) ?>
                    </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>
                        <?= data_sebelumnya($data_sebelumnya->agama, $row->agama) ?>
                    </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>
                        <?= data_sebelumnya($data_sebelumnya->no_ktp, $row->no_ktp) ?>
                    </fieldset>
                </div>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <fieldset class="form-group">
                        <label><?= $this->lang->line('no_bpjs_kes') ?></label>
                        <p class="form-control-static"><?= ((!empty($row->no_bpjs_kes)) ? $row->no_bpjs_kes : '-') ?></p>
                        <?= data_sebelumnya($data_sebelumnya->no_bpjs_kes, $row->no_bpjs_kes) ?>
                    </fieldset>
                </div>
                <div class="col-md-6">
                    <fieldset class="form-group">
                        <label><?= $this->lang->line('no_bpjs_tk') ?></label>
                        <p class="form-control-static"><?= ((!empty($row->no_bpjs_tk)) ? $row->no_bpjs_tk : '-') ?></p>
                        <?= data_sebelumnya($data_sebelumnya->no_bpjs_tk, $row->no_bpjs_tk) ?>
                    </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>
                        <?= data_sebelumnya($data_sebelumnya->nama_prov, $row->nama_prov) ?>
                    </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>
                        <?= data_sebelumnya($data_sebelumnya->nama_kota, $row->nama_kota) ?>
                    </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>
                        <?= data_sebelumnya($data_sebelumnya->nama_kec, $row->nama_kec) ?>
                    </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>
                        <?= data_sebelumnya($data_sebelumnya->nama_kel, $row->nama_kel) ?>
                    </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>
                        <?= data_sebelumnya($data_sebelumnya->rt, $row->rt) ?>
                    </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>
                        <?= data_sebelumnya($data_sebelumnya->rw, $row->rw) ?>
                    </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>
                        <?= data_sebelumnya($data_sebelumnya->alamat_domisili, $row->alamat_domisili) ?>
                    </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>
                        <?= data_sebelumnya($data_sebelumnya->kode_pos, $row->kode_pos) ?>
                    </fieldset>
                </div>
            </div>
            <hr>
        </div>
        <hr>
    </div>
    <?php if ($row->status == '1') { ?>
        <div class="row">
            <div class="col-md-7 text-left">
            </div>
            <div class="col-md-5 text-right">
                <button class="btn btn-success btn-min-width" onclick="form_approve();"><i class="fa fa-check"></i> <?= $this->lang->line('button_form_approve') ?></button>
                <button class="btn btn-secondary btn-min-width" onclick="form_revisi();"><i class="fa fa-undo"></i> <?= $this->lang->line('button_form_revisi') ?></button>
            </div>
        </div>
    <?php }
} else { ?>
    <div class="col-12"><?= $this->lang->line('data_tidak_ditemukan') ?></div>
<?php } ?>
