<?php
if ($data != null) {
    $jml_data = count($data);
    $nomor = 0;
    foreach ($data as $key => $value) {
        $nomor++;
        $karyawan = $value['data_karyawan'];
        $lembur      = $value['data_lembur'];

        $lembur_mulai   = strtotime($field->jam_absen);
        $lembur_selesai = strtotime($field->jam_lembur_selesai);
        $selisih_detik  = $lembur_selesai - $lembur_mulai;
        $lama_lembur    = floor($selisih_detik/60);
?>
        <h3 style="text-align: center;"><?= strtoupper(strtolower($title)) ?></h3>
        <h4 style="text-align: center;">PERIODE : <?php echo $tanggal_mulai . ' s/d ' . $tanggal_selesai ?></h4>
        <h4> </h4>
        <table width="100%" border="1">
            <tr>
                <td style="border:1px solid #fff; text-align:left" colspan="2"><?= strtoupper($this->lang->line('nik')); ?></td>
                <td style="border:1px solid #fff; text-align:left" colspan="4">: <?php echo $karyawan['nik']; ?></td>
                <td style="border:1px solid #fff; text-align:left" colspan="4"></td>
                <td style="border:1px solid #fff; text-align:left" colspan="2"><?= strtoupper($this->lang->line('cabang')); ?></td>
                <td style="border:1px solid #fff; text-align:left" colspan="4">: <?php echo $karyawan['nama_cabang']; ?></td>
            </tr>
            <tr>
                <td style="border:1px solid #fff; text-align:left" colspan="2"><?= strtoupper($this->lang->line('nama')); ?></td>
                <td style="border:1px solid #fff; text-align:left" colspan="4">: <?php echo $karyawan['nama_karyawan']; ?></td>
                <td style="border:1px solid #fff; text-align:left" colspan="4"></td>
                <td style="border:1px solid #fff; text-align:left" colspan="2"><?= strtoupper($this->lang->line('departemen')); ?></td>
                <td style="border:1px solid #fff; text-align:left" colspan="4">: <?php echo $karyawan['nama_departemen']; ?></td>
            </tr>
            <tr>
                <td style="border:1px solid #fff; text-align:left" colspan="2"></td>
                <td style="border:1px solid #fff; text-align:left" colspan="4"></td>
                <td style="border:1px solid #fff; text-align:left" colspan="4"></td>
                <td style="border:1px solid #fff; text-align:left" colspan="2"><?= strtoupper($this->lang->line('jabatan')); ?></td>
                <td style="border:1px solid #fff; text-align:left" colspan="4">: <?php echo $karyawan['nama_jabatan']; ?></td>
            </tr>
            <tr>
                <td style="border:1px solid #fff; border-bottom:1px solid #000" colspan="16"></td>
            </tr>
            <tr>
                <th rowspan="2">NO</th>
                <th rowspan="2"><?= strtoupper($this->lang->line('tgl_pengajuan')); ?></th>
                <th colspan="2"><?= strtoupper($this->lang->line('jam_waktu2')); ?></th>
                <th rowspan="2"><?= strtoupper($this->lang->line('lama_lembur')); ?></th>
                <th colspan="4"><?= strtoupper($this->lang->line('keterangan')); ?></th>
                <th colspan="2"><?= strtoupper($this->lang->line('lokasi')); ?></th>
                <th colspan="5">APPROVAL</th>
                <th rowspan="2">STATUS</th>
            </tr>
            <tr>
                <th><?= strtoupper($this->lang->line('mulai')); ?></th>
                <th><?= strtoupper($this->lang->line('selesai')); ?></th>
                <th colspan="2"><?= strtoupper($this->lang->line('mulai')); ?></th>
                <th colspan="2"><?= strtoupper($this->lang->line('selesai')); ?></th>
                <th><?= strtoupper($this->lang->line('mulai')); ?></th>
                <th><?= strtoupper($this->lang->line('selesai')); ?></th>
                <th><?= strtoupper($this->lang->line('supervisi')); ?></th>
                <th><?= strtoupper($this->lang->line('menu_kepala_departemen')); ?></th>
                <th><?= strtoupper($this->lang->line('menu_kepala_cabang')); ?></th>
                <th><?= strtoupper($this->lang->line('direksi')); ?></th>
                <th>Admin</th>
            </tr>
            <?php
            if (count($lembur) > 0) {
                $no = 1;

                $data_lembur = array();
                foreach ($lembur as $k => $v) {
                    $lembur_mulai   = strtotime($v['lm_jam']);
                    $lembur_selesai = strtotime($v['ls_jam']);
                    $selisih_detik  = $lembur_selesai - $lembur_mulai;
                    $lama_lembur    = floor($selisih_detik/60);

                ?>
                        <tr <?= $css ?>>
                            <td><?php echo $no ?></td>
                            <td><?php echo $v['tgl_absen'] ?></td>
                            <td><?php echo $v['lm_jam'] ?></td>
                            <td><?php echo $v['ls_jam'] ?></td>
                            <td><?php echo $lama_lembur ?></td>
                            <td colspan="2"><?php echo $v['lm_keterangan'] ?></td>
                            <td colspan="2"><?php echo $v['ls_keterangan'] ?></td>
                            <td><?php echo $v['lm_lokasi'] ?></td>
                            <td><?php echo $v['ls_lokasi'] ?></td>
                            <td><?php echo $v['apv_spv'] ?></td>
                            <td><?php echo $v['apv_kedep'] ?></td>
                            <td><?php echo $v['apv_kacab'] ?></td>
                            <td><?php echo $v['apv_direksi'] ?></td>
                            <td><?php echo $v['apv_hrd'] ?></td>
                            <td><?php echo $v['status'] ?></td>
                        </tr>
                <?php
                    $no++;
                }
            }
            ?>
        </table>
        <?php
        if ($is_excel === true) {
            echo '<h5>--PAGEBREAK--</h5>';
        } else {
            if ($nomor >= 1 && $nomor != $jml_data) {
                echo '<pagebreak>';
            }
        }
        ?>
<?php
    }
}
?>