<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js" integrity="sha512-GsLlZN/3F2ErC5ifS5QtgpiJtWd43JWSuIgh7mbzZ8zBps+dvLusV+eNQATqgA/HdeKFVgA5v3S/cIrLF7QnIg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</head>

<body>
  <!-- <button id="download-button">Download as PDF</button>
  <button onclick="exportTableToExcel('invoice')">Export Table Data To Excel File</button> -->
  <div id="invoice">
    <table style="width: 100%;">
      <tr>
        <td width="2%">
        <td width="17%">
          <img src="<?= base_url() ?>assets/images/logo_mamuju_tengah.png" width="100px" height="120px">
        </td>
        <td width="60%" style="text-align: center;">
          <h3 style="display: block;font-size: 20px;">PEMERINTA KABUPATEN MAMUJU TENGAH<br>DINAS PARIWISATA KEPEMUDAAN DAN OLAHRAGA</h3>
          <p style="font-style: italic;"> <b>Alamat : </b> Jl, Abdul Majid Pattaro Pura Kab. Mamuju Tengah, Prov. Sulawesi Barat</p>
        </td>
        <td width="17%"></td>
        <td width="2%">
      </tr>


    </table>
    <!-- create hr with black 2px -->
    <hr style="border: 3px solid black;"><br>
    <center><b><u><?=$title2?></u></b></center>
    <center><?=$title3?></center><br>
    <?php
    // get the first day full name
    $CI = &get_instance();
    $CI->load->model('model');
    $first_day = date('l', strtotime($year . '-' . $month . '-01'));
    // get the number of days in the month
    $days_in_month = date('t', strtotime($year . '-' . $month . '-01'));
    // print_r($days_in_month);

    // loop the days in the month start from day monday to friday, if day is saturday or sunday, skip it, if day start not from monday, add empty cell

    // $week_array = [];
    $day_array = [];

    for ($i = 1; $i <= $days_in_month; $i++) {
      $tanggal = strlen($i) == 1 ? "0" . $i : $i;
      $date = $year . '-' . $month . '-' . $tanggal;
      $day = date('l', strtotime($date));
      if ($day == 'Saturday' || $day == 'Sunday') {
        continue;
      }

      // if the day is not monday, add the previous to monday but null 


      // if reach day friday, add the week array to week array


      $day_array[] = ['date' => $date, 'day' => $day];
      // echo '<div class="col-md-1" style="background-color: #f2f2f2; border: 1px solid #ddd; padding: 10px; margin: 5px; text-align: center; height: 100px; width: 100px; float: left;">';
      // echo $i;
      // echo '</div>';
    }

    // print_r($day_array[0]['day']);
    // if $day_array[0]['day'] is tuesday, add monday to array, if $day_array[0]['day'] is wednesday, add monday and tuesday to array, if $day_array[0]['day'] is thursday, add monday, tuesday, and wednesday to array, if $day_array[0]['day'] is friday, add monday, tuesday, wednesday, and thursday to array
    if ($day_array[0]['day'] == 'Tuesday') {
      $day_array = array_merge([['date' => '', 'day' => 'Monday']], $day_array);
    } else if ($day_array[0]['day'] == 'Wednesday') {
      $day_array = array_merge([['date' => '', 'day' => 'Monday'], ['date' => '', 'day' => 'Tuesday']], $day_array);
    } else if ($day_array[0]['day'] == 'Thursday') {
      $day_array = array_merge([['date' => '', 'day' => 'Monday'], ['date' => '', 'day' => 'Tuesday'], ['date' => '', 'day' => 'Wednesday']], $day_array);
    } else if ($day_array[0]['day'] == 'Friday') {
      $day_array = array_merge([['date' => '', 'day' => 'Monday'], ['date' => '', 'day' => 'Tuesday'], ['date' => '', 'day' => 'Wednesday'], ['date' => '', 'day' => 'Thursday']], $day_array);
    }

    // if $day_array[count($day_array) - 1]['day'] is monday, add tuesday , wednesday, thursday, and friday to array, if $day_array[count($day_array) - 1]['day'] is tuesday, add wednesday, thursday, and friday to array, if $day_array[count($day_array) - 1]['day'] is wednesday, add thursday and friday to array, if $day_array[count($day_array) - 1]['day'] is thursday, add friday to array

    if ($day_array[count($day_array) - 1]['day'] == 'Monday') {
      $day_array = array_merge($day_array, [['date' => '', 'day' => 'Tuesday'], ['date' => '', 'day' => 'Wednesday'], ['date' => '', 'day' => 'Thursday'], ['date' => '', 'day' => 'Friday']]);
    } else if ($day_array[count($day_array) - 1]['day'] == 'Tuesday') {
      $day_array = array_merge($day_array, [['date' => '', 'day' => 'Wednesday'], ['date' => '', 'day' => 'Thursday'], ['date' => '', 'day' => 'Friday']]);
    } else if ($day_array[count($day_array) - 1]['day'] == 'Wednesday') {
      $day_array = array_merge($day_array, [['date' => '', 'day' => 'Thursday'], ['date' => '', 'day' => 'Friday']]);
    } else if ($day_array[count($day_array) - 1]['day'] == 'Thursday') {
      $day_array = array_merge($day_array, [['date' => '', 'day' => 'Friday']]);
    }

    // print_r($day_array);

    $week_array = [];

    for ($i = 0; $i < count($day_array); $i++) {
      if ($i % 5 == 0) {
        $week_array[] = [$day_array[$i], $day_array[$i + 1], $day_array[$i + 2], $day_array[$i + 3], $day_array[$i + 4]];
      }
    }
    foreach ($week_array as $week) {
    ?>
      <table border="1" style="margin-left:auto;margin-right:auto;width:97%;" cellpadding="0" cellspacing="0">
        <thead>
          <tr>
            <th rowspan="3" valign="middle" style="text-align: center;">NO</th>
            <th rowspan="3" valign="middle" style="text-align: center;">NAMA</th>
            <th rowspan="3" style="text-align: center;" width="5%">JAM/<br>PARAF</th>
            <th colspan="4" style="text-align: center;" width="15%">
              <?php
              // change the date format to d-m-Y
              $date = $week[0]['date'] != null ?    date('d/m/Y', strtotime($week[0]['date'])) : '-';
              echo $CI->model->hari($week[0]['day'])  . ', ' . $date;
              ?>
            </th>
            <!-- <th>Status</th> -->
            <th colspan="4" style="text-align: center;" width="15%">
              <?php
              // change the date format to d-m-Y
              $date = $week[1]['date'] != null ?    date('d/m/Y', strtotime($week[1]['date'])) : '-';
              echo $CI->model->hari($week[1]['day'])  . ', ' . $date;
              ?>
            </th>
            <!-- <th>Jam Istirehat</th> -->
            <th colspan="4" style="text-align: center;" width="15%">
              <?php
              // change the date format to d-m-Y
              $date = $week[2]['date'] != null ?    date('d/m/Y', strtotime($week[2]['date'])) : '-';
              echo $CI->model->hari($week[2]['day'])  . ', ' . $date;
              ?>
            </th>
            <th colspan="4" style="text-align: center;" width="15%">
              <?php
              // change the date format to d-m-Y
              $date = $week[3]['date'] != null ?    date('d/m/Y', strtotime($week[3]['date'])) : '-';
              echo $CI->model->hari($week[3]['day'])  . ', ' . $date;
              ?>
            </th>
            <th colspan="4" style="text-align: center;" width="15%">
              <?php
              // change the date format to d-m-Y
              $date = $week[4]['date'] != null ?    date('d/m/Y', strtotime($week[4]['date'])) : '-';
              echo $CI->model->hari($week[4]['day'])  . ', ' . $date;
              ?>
            </th>
            <th rowspan="3" style="text-align: center;">Ket</th>
          </tr>
          <tr>
            <!-- <th rowspan="3">NAMA</th> -->
            <!-- <th>JAM/PARAF</th> -->
            <th colspan="2" style="text-align: center;" width="7.5%">Pagi</th>
            <th colspan="2" style="text-align: center;" width="7.5%">Siang</th>
            <th colspan="2" style="text-align: center;" width="7.5%">Pagi</th>
            <th colspan="2" style="text-align: center;" width="7.5%">Siang</th>
            <th colspan="2" style="text-align: center;" width="7.5%">Pagi</th>
            <th colspan="2" style="text-align: center;" width="7.5%">Siang</th>
            <th colspan="2" style="text-align: center;" width="7.5%">Pagi</th>
            <th colspan="2" style="text-align: center;" width="7.5%">Siang</th>
            <th colspan="2" style="text-align: center;" width="7.5%">Pagi</th>
            <th colspan="2" style="text-align: center;" width="7.5%">Siang</th>
            <!-- <th>Aksi</th> -->
          </tr>
          <tr>
            <!-- <th rowspan="3">NAMA</th> -->
            <!-- <th>JAM/PARAF</th> -->
            <th style="text-align: center;" width="3.75%">M</th>
            <th style="text-align: center;" width="3.75%">P</th>
            <th style="text-align: center;" width="3.75%">M</th>
            <th style="text-align: center;" width="3.75%">P</th>
            <th style="text-align: center;" width="3.75%">M</th>
            <th style="text-align: center;" width="3.75%">P</th>
            <th style="text-align: center;" width="3.75%">M</th>
            <th style="text-align: center;" width="3.75%">P</th>
            <th style="text-align: center;" width="3.75%">M</th>
            <th style="text-align: center;" width="3.75%">P</th>
            <th style="text-align: center;" width="3.75%">M</th>
            <th style="text-align: center;" width="3.75%">P</th>
            <th style="text-align: center;" width="3.75%">M</th>
            <th style="text-align: center;" width="3.75%">P</th>
            <th style="text-align: center;" width="3.75%">M</th>
            <th style="text-align: center;" width="3.75%">P</th>
            <th style="text-align: center;" width="3.75%">M</th>
            <th style="text-align: center;" width="3.75%">P</th>
            <th style="text-align: center;" width="3.75%">M</th>
            <th style="text-align: center;" width="3.75%">P</th>
            <!-- <th>Aksi</th> -->
          </tr>
        </thead>
        <tbody>
          <?php
          $no = 1;
          foreach ($list_karyawan as $key => $value) {
            if ($value->status == $stat) {
          ?>
              <tr>
                <td rowspan="4" style="text-align: center;"><b><?= $no++; ?></b></td>
                <td><b><?= $value->nama; ?></b></td>
                <td rowspan="2" style="text-align: center;">Jam</td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  $cek_data_senin =  null;
                  if ($week[0]['date'] != null) {
                    $cek_data_senin = $CI->model->tampil_data_where('tb_absensi_karyawan', ['nik' => $value->nik, 'tanggal' => $week[0]['date'], 'id_dinas' => $id_dinas])->result();

                    if (count($cek_data_senin) > 0) {
                      $cek_data_senin = $cek_data_senin[0];
                    } else {
                      $cek_data_senin = null;
                    }
                  }
                  echo ($cek_data_senin != null && $cek_data_senin->jam_masuk != '') ? "&nbsp " . $cek_data_senin->jam_masuk . "&nbsp &nbsp " : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_senin != null && $cek_data_senin->jam_istirehat != '') ?  "&nbsp " . $cek_data_senin->jam_istirehat . "&nbsp &nbsp " : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_senin != null && $cek_data_senin->jam_masuk_kembali != '') ?  "&nbsp " . $cek_data_senin->jam_masuk_kembali . "&nbsp &nbsp " : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_senin != null && $cek_data_senin->jam_pulang != '')  ?  "&nbsp " . $cek_data_senin->jam_pulang . "&nbsp &nbsp " : '-';
                  ?>
                </td>

                <td rowspan="2" style="text-align: center;">
                  <?php
                  $cek_data_selasa =  null;
                  if ($week[1]['date'] != null) {
                    $cek_data_selasa = $CI->model->tampil_data_where('tb_absensi_karyawan', ['nik' => $value->nik, 'tanggal' => $week[1]['date'], 'id_dinas' => $id_dinas])->result();

                    if (count($cek_data_selasa) > 0) {
                      $cek_data_selasa = $cek_data_selasa[0];
                    } else {
                      $cek_data_selasa = null;
                    }
                  }
                  echo ($cek_data_selasa != null && $cek_data_selasa->jam_masuk != '') ?  "&nbsp " . $cek_data_selasa->jam_masuk . "&nbsp &nbsp " : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_selasa != null && $cek_data_selasa->jam_istirehat != '') ?  "&nbsp " . $cek_data_selasa->jam_istirehat . "&nbsp &nbsp " : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_selasa != null && $cek_data_selasa->jam_masuk_kembali != '') ?  "&nbsp " . $cek_data_selasa->jam_masuk_kembali . "&nbsp &nbsp " : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_selasa != null && $cek_data_selasa->jam_pulang != '') ?  "&nbsp " . $cek_data_selasa->jam_pulang . "&nbsp &nbsp " : '-';
                  ?>
                </td>


                <td rowspan="2" style="text-align: center;">
                  <?php
                  $cek_data_rabu =  null;
                  if ($week[2]['date'] != null) {
                    $cek_data_rabu = $CI->model->tampil_data_where('tb_absensi_karyawan', ['nik' => $value->nik, 'tanggal' => $week[2]['date'], 'id_dinas' => $id_dinas])->result();

                    if (count($cek_data_rabu) > 0) {
                      $cek_data_rabu = $cek_data_rabu[0];
                    } else {
                      $cek_data_rabu = null;
                    }
                  }
                  echo ($cek_data_rabu != null && $cek_data_rabu->jam_masuk != '') ?  "&nbsp " . $cek_data_rabu->jam_masuk . "&nbsp &nbsp " : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_rabu != null && $cek_data_rabu->jam_istirehat != '') ?  "&nbsp " . $cek_data_rabu->jam_istirehat . "&nbsp &nbsp " : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_rabu != null && $cek_data_rabu->jam_masuk_kembali != '') ?  "&nbsp " . $cek_data_rabu->jam_masuk_kembali . "&nbsp &nbsp " : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_rabu != null && $cek_data_rabu->jam_pulang != '') ?  "&nbsp " . $cek_data_rabu->jam_pulang . "&nbsp &nbsp " : '-';
                  ?>
                </td>


                <td rowspan="2" style="text-align: center;">
                  <?php
                  $cek_data_kamis =  null;
                  if ($week[3]['date'] != null) {
                    $cek_data_kamis = $CI->model->tampil_data_where('tb_absensi_karyawan', ['nik' => $value->nik, 'tanggal' => $week[3]['date'], 'id_dinas' => $id_dinas])->result();

                    if (count($cek_data_kamis) > 0) {
                      $cek_data_kamis = $cek_data_kamis[0];
                    } else {
                      $cek_data_kamis = null;
                    }
                  }
                  echo ($cek_data_kamis != null && $cek_data_kamis->jam_masuk != '') ?  "&nbsp " . $cek_data_kamis->jam_masuk . "&nbsp &nbsp " : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_kamis != null && $cek_data_kamis->jam_istirehat != '') ?  "&nbsp " . $cek_data_kamis->jam_istirehat . "&nbsp &nbsp " : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_kamis != null && $cek_data_kamis->jam_masuk_kembali != '') ?  "&nbsp " . $cek_data_kamis->jam_masuk_kembali . "&nbsp &nbsp " : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_kamis != null && $cek_data_kamis->jam_pulang != '') ?  "&nbsp " . $cek_data_kamis->jam_pulang . "&nbsp &nbsp " : '-';
                  ?>
                </td>


                <td rowspan="2" style="text-align: center;">
                  <?php
                  $cek_data_jumat =  null;
                  if ($week[4]['date'] != null) {
                    $cek_data_jumat = $CI->model->tampil_data_where('tb_absensi_karyawan', ['nik' => $value->nik, 'tanggal' => $week[4]['date'], 'id_dinas' => $id_dinas])->result();

                    if (count($cek_data_jumat) > 0) {
                      $cek_data_jumat = $cek_data_jumat[0];
                    } else {
                      $cek_data_jumat = null;
                    }
                  }
                  echo ($cek_data_jumat != null && $cek_data_jumat->jam_masuk != '') ?  "&nbsp " . $cek_data_jumat->jam_masuk . "&nbsp &nbsp " : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_jumat != null && $cek_data_jumat->jam_istirehat != '') ?  "&nbsp " . $cek_data_jumat->jam_istirehat . "&nbsp &nbsp " : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_jumat != null && $cek_data_jumat->jam_masuk_kembali != '') ?  "&nbsp " . $cek_data_jumat->jam_masuk_kembali . "&nbsp &nbsp " : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_jumat != null && $cek_data_jumat->jam_pulang != '') ?  "&nbsp " . $cek_data_jumat->jam_pulang . "&nbsp &nbsp " : '-';
                  ?>
                </td>


                <td rowspan="2"></td>
              </tr>
              <tr>
                <td><b><?= $value->nik; ?>  &nbsp</b></td>
              </tr>
              <tr>
                <td><?= $value->pangkat; ?></td>
                <td rowspan="2" style="text-align: center;">Paraf</td>

                <td rowspan="2" style="text-align: center;">
                  <?php
                  $cek_data_senin =  null;
                  if ($week[0]['date'] != null) {
                    $cek_data_senin = $CI->model->tampil_data_where('tb_absensi_karyawan', ['nik' => $value->nik, 'tanggal' => $week[0]['date'], 'id_dinas' => $id_dinas])->result();

                    if (count($cek_data_senin) > 0) {
                      $cek_data_senin = $cek_data_senin[0];
                    } else {
                      $cek_data_senin = null;
                    }
                  }
                  echo ($cek_data_senin != null && $cek_data_senin->jam_masuk != '') ? '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_senin != null && $cek_data_senin->jam_istirehat != '') ?  '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_senin != null && $cek_data_senin->jam_masuk_kembali != '') ?  '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_senin != null && $cek_data_senin->jam_pulang != '')  ?  '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>

                <td rowspan="2" style="text-align: center;">
                  <?php
                  $cek_data_selasa =  null;
                  if ($week[1]['date'] != null) {
                    $cek_data_selasa = $CI->model->tampil_data_where('tb_absensi_karyawan', ['nik' => $value->nik, 'tanggal' => $week[1]['date'], 'id_dinas' => $id_dinas])->result();

                    if (count($cek_data_selasa) > 0) {
                      $cek_data_selasa = $cek_data_selasa[0];
                    } else {
                      $cek_data_selasa = null;
                    }
                  }
                  echo ($cek_data_selasa != null && $cek_data_selasa->jam_masuk != '') ?  '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_selasa != null && $cek_data_selasa->jam_istirehat != '') ? '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_selasa != null && $cek_data_selasa->jam_masuk_kembali != '') ?  '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_selasa != null && $cek_data_selasa->jam_pulang != '') ?  '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>


                <td rowspan="2" style="text-align: center;">
                  <?php
                  $cek_data_rabu =  null;
                  if ($week[2]['date'] != null) {
                    $cek_data_rabu = $CI->model->tampil_data_where('tb_absensi_karyawan', ['nik' => $value->nik, 'tanggal' => $week[2]['date'], 'id_dinas' => $id_dinas])->result();

                    if (count($cek_data_rabu) > 0) {
                      $cek_data_rabu = $cek_data_rabu[0];
                    } else {
                      $cek_data_rabu = null;
                    }
                  }
                  echo ($cek_data_rabu != null && $cek_data_rabu->jam_masuk != '') ? '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_rabu != null && $cek_data_rabu->jam_istirehat != '') ? '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_rabu != null && $cek_data_rabu->jam_masuk_kembali != '') ?  '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_rabu != null && $cek_data_rabu->jam_pulang != '') ?  '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>


                <td rowspan="2" style="text-align: center;">
                  <?php
                  $cek_data_kamis =  null;
                  if ($week[3]['date'] != null) {
                    $cek_data_kamis = $CI->model->tampil_data_where('tb_absensi_karyawan', ['nik' => $value->nik, 'tanggal' => $week[3]['date'], 'id_dinas' => $id_dinas])->result();

                    if (count($cek_data_kamis) > 0) {
                      $cek_data_kamis = $cek_data_kamis[0];
                    } else {
                      $cek_data_kamis = null;
                    }
                  }
                  echo ($cek_data_kamis != null && $cek_data_kamis->jam_masuk != '') ?  '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_kamis != null && $cek_data_kamis->jam_istirehat != '') ?  '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_kamis != null && $cek_data_kamis->jam_masuk_kembali != '') ?  '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_kamis != null && $cek_data_kamis->jam_pulang != '') ?  '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>


                <td rowspan="2" style="text-align: center;">
                  <?php
                  $cek_data_jumat =  null;
                  if ($week[4]['date'] != null) {
                    $cek_data_jumat = $CI->model->tampil_data_where('tb_absensi_karyawan', ['nik' => $value->nik, 'tanggal' => $week[4]['date'], 'id_dinas' => $id_dinas])->result();

                    if (count($cek_data_jumat) > 0) {
                      $cek_data_jumat = $cek_data_jumat[0];
                    } else {
                      $cek_data_jumat = null;
                    }
                  }
                  echo ($cek_data_jumat != null && $cek_data_jumat->jam_masuk != '') ? '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_jumat != null && $cek_data_jumat->jam_istirehat != '') ?  '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_jumat != null && $cek_data_jumat->jam_masuk_kembali != '') ?  '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>
                <td rowspan="2" style="text-align: center;">
                  <?php
                  echo ($cek_data_jumat != null && $cek_data_jumat->jam_pulang != '') ? '<i class="fa fa-check-circle" aria-hidden="true"></i> ' : '-';
                  ?>
                </td>

                <td rowspan="2"></td>
              </tr>
              <tr>
                <td><?= $value->jabatan; ?></td>
              </tr>
          <?php
            }
          }

          ?>
        </tbody>


      </table>
      <br><br>
    <?php
    }
    ?>
    <br><br>
    <table style="width: 97%;">
      <tr>
        <td width="5%"></td>
        <td width="25%">
          <b>Keterangan :</b>
        </td>
        <td width="40%"></td>
        <td width="25%">
          Topoyo, / <?php echo date('d / '); echo $CI->model->bulan( date('m'));?> / 2022
        </td>
        <td width="5%"></td>
      </tr>
      <tr>
        <td></td>
        <td>
          TK = Tanpa Keterangan
        </td>
        <td></td>
        <td>
          <b>Kepala Dinas Pariwisata</b>
        </td>
        <td></td>
      </tr>
      <tr>
        <td></td>
        <td>
          S = Sakit
        </td>
        <td></td>
        <td>
          <b>Kepemudaaan Dan Olahraga</b>
        </td>
        <td></td>
      </tr>
      <tr>
        <td></td>
        <td>
          I = Izin
        </td>
        <td></td>
        <td></td>
        <td></td>
      </tr>
      <tr>
        <td></td>
        <td>
          DL = Dinas Luar
        </td>
        <td></td>
        <td></td>
        <td></td>
      </tr>
      <tr>
        <td></td>
        <td>
          C = Cuti
        </td>
        <td></td>
        <td></td>
        <td></td>
      </tr>
      <tr>
        <td></td>
        <td>
          M = Masuk
        </td>
        <td></td>
        <td>
          <b>HJ. NANDA . S. Kep ., MM</b>
        </td>
        <td></td>
      </tr>
      <tr>
        <td></td>
        <td>
          P = Pulang
        </td>
        <td></td>
        <td>
          Pangkat: Pembina Tk. IIVb
        </td>
        <td></td>
      </tr>
      <tr>
        <td></td>
        <td></td>
        <td></td>
        <td>
          Nip . 12312321
        </td>
        <td></td>
      </tr>


    </table>
  </div>
  <script>
    const button = document.getElementById('download-button');

    function generatePDF() {
      // Choose the element that your content will be rendered to.
      const element = document.getElementById('invoice');
      // Choose the element and save the PDF for your user.
      // add margin on top and bottom every new page
      html2pdf().from(element).set({
        margin: 1,
        filename: '<?= $title; ?>.pdf',
        html2canvas: {
          scale: 2, // A mayor escala, mejores gráficos, pero más peso
          letterRendering: true,
        },
        jsPDF: {
          unit: 'in',
          format: 'a4',
          orientation: 'landscape' // landscape o portrait
        }
      }).save();
    }

    generatePDF();
  </script>
  <script>
    function exportTableToExcel(tableID, filename = '') {
      var downloadLink;
      var dataType = 'application/vnd.ms-excel';
      var tableSelect = document.getElementById(tableID);
      var tableHTML = tableSelect.outerHTML.replace(/ /g, '%20');

      // Specify file name
      filename = filename ? filename + '.xls' : 'excel_data.xls';

      // Create download link element
      downloadLink = document.createElement("a");

      document.body.appendChild(downloadLink);

      if (navigator.msSaveOrOpenBlob) {
        var blob = new Blob(['\ufeff', tableHTML], {
          type: dataType
        });
        navigator.msSaveOrOpenBlob(blob, filename);
      } else {
        // Create a link to the file
        downloadLink.href = 'data:' + dataType + ', ' + tableHTML;

        // Setting the file name
        downloadLink.download = filename;

        //triggering the function
        downloadLink.click();
      }
    }
  </script>
</body>

</html>