<h3 style="text-align: center;"><?= strtoupper($this->lang->line('data_karyawan')) ?></h3>
<h4 style="text-align: center;"><?= $title ?></h4>
<h4> </h4>
<table id="list_data" class="table table-striped" style="width:100%">
    <thead>
        <tr>
            <th>NO</th>
            <th><?= strtoupper($this->lang->line('nik')) ?></th>
            <th><?= strtoupper($this->lang->line('nama_lengkap')) ?></th>
            <th><?= strtoupper($this->lang->line('jabatan')) ?></th>
            <th><?= strtoupper($this->lang->line('cabang')) ?></th>
            <th><?= strtoupper($this->lang->line('departemen')) ?></th>
            <th><?= strtoupper($this->lang->line('sisa_cuti_tahunan')) ?></th>
            <th>STATUS</th>
            <th>JOIN DATE</th>
            <th><?= strtoupper($this->lang->line('tgl_mulai_kontrak')) ?></th>
            <th><?= strtoupper($this->lang->line('tgl_berakhir_kontrak')) ?></th>
            <th><?= strtoupper($this->lang->line('tgl_mulai_aktif')) ?></th>
            <th><?= strtoupper($this->lang->line('tgl_berhenti_bekerja')) ?></th>
            <th><?= strtoupper($this->lang->line('jenis_kelamin')) ?></th>
            <th><?= strtoupper($this->lang->line('agama')) ?></th>
            <th><?= strtoupper($this->lang->line('tempat_lahir')) ?></th>
            <th><?= strtoupper($this->lang->line('tgl_lahir')) ?></th>
            <th><?= strtoupper($this->lang->line('data_alamat_domisili')) ?></th>
            <th><?= strtoupper($this->lang->line('no_telp')) ?></th>
            <th><?= strtoupper($this->lang->line('email')) ?></th>
            <th><?= strtoupper($this->lang->line('no_ktp')) ?></th>
        </tr>
    </thead>
    <tbody>
        <?php
        $no = 0;
        foreach ($data as $row) {
            $no++;
            $status = $row->status;

            if ($status == '1') {
                $ket_status = 'Kontrak';
                $tgl_mulai_kontrak = (!empty($row->tgl_aktif_bekerja) && $row->tgl_aktif_bekerja != '1970-01-01' && $row->tgl_aktif_bekerja != '0000-00-00' ? date_format(date_create($row->tgl_aktif_bekerja), "d-m-Y") : '-');
                $tgl_selesai_kontrak = (!empty($row->tgl_berhenti_bekerja) && $row->tgl_berhenti_bekerja != '1970-01-01' && $row->tgl_berhenti_bekerja != '0000-00-00' ? date_format(date_create($row->tgl_berhenti_bekerja), "d-m-Y") : '-');
                $tgl_mulai_aktif = "-";
                $tgl_berhenti_kerja = "-";
            } else if ($status == '2') {
                $ket_status = 'Tetap';
                $tgl_mulai_kontrak = "-";
                $tgl_selesai_kontrak = "-";
                $tgl_mulai_aktif = (!empty($row->tgl_aktif_bekerja) && $row->tgl_aktif_bekerja != '1970-01-01' && $row->tgl_aktif_bekerja != '0000-00-00' ? date_format(date_create($row->tgl_aktif_bekerja), "d-m-Y") : '-');
                $tgl_berhenti_kerja = "-";
            } else if ($status == '3') {
                $ket_status = 'Izin Belajar';
                $tgl_mulai_kontrak = "-";
                $tgl_selesai_kontrak = "-";
                $tgl_mulai_aktif = (!empty($row->tgl_aktif_bekerja) && $row->tgl_aktif_bekerja != '1970-01-01' && $row->tgl_aktif_bekerja != '0000-00-00' ? date_format(date_create($row->tgl_aktif_bekerja), "d-m-Y") : '-');
                $tgl_berhenti_kerja = "-";
            } else if ($status == '4') {
                $ket_status = 'Tugas Belajar';
                $tgl_mulai_kontrak = "-";
                $tgl_selesai_kontrak = "-";
                $tgl_mulai_aktif = (!empty($row->tgl_aktif_bekerja) && $row->tgl_aktif_bekerja != '1970-01-01' && $row->tgl_aktif_bekerja != '0000-00-00' ? date_format(date_create($row->tgl_aktif_bekerja), "d-m-Y") : '-');
                $tgl_berhenti_kerja = "-";
            } else if ($status == '5') {
                $ket_status = 'Resign';
                $tgl_mulai_kontrak = "-";
                $tgl_selesai_kontrak = "-";
                $tgl_mulai_aktif = "-";
                $tgl_berhenti_kerja = (!empty($row->tgl_berhenti_bekerja) && $row->tgl_berhenti_bekerja != '1970-01-01' && $row->tgl_berhenti_bekerja != '0000-00-00' ? date_format(date_create($row->tgl_berhenti_bekerja), "d-m-Y") : '-');
            } else if ($status == '6') {
                $ket_status = 'Dikeluarkan (PHK)';
                $tgl_mulai_kontrak = "-";
                $tgl_selesai_kontrak = "-";
                $tgl_mulai_aktif = "-";
                $tgl_berhenti_kerja = (!empty($row->tgl_berhenti_bekerja) && $row->tgl_berhenti_bekerja != '1970-01-01' && $row->tgl_berhenti_bekerja != '0000-00-00' ? date_format(date_create($row->tgl_berhenti_bekerja), "d-m-Y") : '-');
            } else if ($status == '7') {
                $ket_status = 'Pensiun';
                $tgl_mulai_kontrak = "-";
                $tgl_selesai_kontrak = "-";
                $tgl_mulai_aktif = "-";
                $tgl_berhenti_kerja = (!empty($row->tgl_berhenti_bekerja) && $row->tgl_berhenti_bekerja != '1970-01-01' && $row->tgl_berhenti_bekerja != '0000-00-00' ? date_format(date_create($row->tgl_berhenti_bekerja), "d-m-Y") : '-');
            }

            $join_date = (!empty($row->join_date) && $row->join_date != '1970-01-01' && $row->join_date != '0000-00-00' ? date_format(date_create($row->join_date), "d-m-Y") : '-');

            $kelamin = $this->fungsi->jkel($row->jenis_kelamin);

            $agama = $row->agama;
        ?>
            <tr>
                <td><?= $no ?></td>
                <td>#<?= $row->nik ?>#</td>
                <td><?= ucwords(strtolower($row->nama_lengkap)) ?></td>
                <td><?= ucwords(strtolower($row->nama_jabatan)) ?></td>
                <td><?= ucwords(strtolower($row->nama_cabang)) ?></td>
                <td><?= ucwords(strtolower($row->nama_departemen)) ?></td>
                <td><?= $row->jatah_cuti ?></td>
                <td><?= $ket_status ?></td>
                <td><?= $join_date ?></td>
                <td><?= $tgl_mulai_kontrak ?></td>
                <td><?= $tgl_selesai_kontrak ?></td>
                <td><?= $tgl_mulai_aktif ?></td>
                <td><?= $tgl_berhenti_kerja ?></td>
                <td><?= $kelamin ?></td>
                <td><?= $agama ?></td>
                <td><?= ucwords(strtolower($row->tempat_lahir)) ?></td>
                <td><?= (!empty($row->tgl_lahir) && $row->tgl_lahir != '1970-01-01' && $row->tgl_lahir != '0000-00-00' ? date_format(date_create($row->tgl_lahir), "d-m-Y") : '-') ?></td>
                <td><?= ucwords(strtolower($row->alamat_domisili)) ?></td>
                <td>#<?= $row->telepon ?>#</td>
                <td><?= $row->email ?></td>
                <td>#<?= $row->no_ktp ?>#</td>
            </tr>
        <?php
        }
        ?>
    </tbody>
</table>
