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


<?php $this->load->view("kepaladinas/header"); ?>

<body>

  <?php $this->load->view("kepaladinas/side_topbar"); ?>

  <div id="wrapper">
    <div class="main-content">
      <div class="row small-spacing">
        <div class="col-xs-2"></div>
        <div class="col-xs-8">
          <div class="box-content card">
            <h4 class="box-title">Filter Laporan </h4>
            <form class="card-content" onsubmit="return filter_laporan(event)">
              <div class="form-group">
                <label for="bulan">Bulan</label>
                <select class="form-control" id="bulan" required>
                  <option value="" disabled selected>-Pilih Bulan</option>
                  <option value="09">September</option>
                  <option value="10">Oktober</option>
                  <option value="11">November</option>
                </select>
              </div>
              <div class="form-group">
                <label for="tahun">Tahun</label>
                <select class="form-control" id="tahun">
                  <option value="" selected disabled>-Pilih Tahun</option>
                  <option value="2022">2022</option>
                </select>
              </div>
              <div class="form-group text-center">
                <button type="submit" class="btn btn-primary btn-xs waves-effect waves-light">Filter Laporan</button>
              </div>
            </form>
          </div>
          <!-- /.box-content -->
        </div>
        <!-- /.col-xs-12 -->
        <div class="col-xs-2"></div>



      </div>

      <div class="row small-spacing">
        <div class="col-xs-12">
          <div class="box-content card">
            <h4 class="box-title" style="cursor: pointer;" onclick="myFunction('div_laporan_pns')">Laporan Absensi Pegawai PNS Bulan <?= $month ?>, Tahun <?= $year ?></h4>

            <div class="card-content" id="div_laporan_pns" style="display: none;">
              <div class="form-group">

                <button type="button" id="create_pdf" class="btn btn-primary btn-xs waves-effect waves-light" onclick="cetak_laporan('pns')">Cetak Laporan</button>
              </div>
              <div style="overflow-x: auto;" class="form-group" id="form_pns">
                <?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]];
                  }
                }

                // print_r($week_array);


                foreach ($week_array as $week) {


                ?>
                  <table id="example" class="table-striped table-bordered display" style="margin-left:auto;margin-right:auto;width:100%;">
                    <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;">JAM/PARAF</th>
                        <th colspan="4" style="text-align: center;">
                          <?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;">
                          <?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;">
                          <?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;">
                          <?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;">
                          <?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;">Pagi</th>
                        <th colspan="2" style="text-align: center;">Siang</th>
                        <th colspan="2" style="text-align: center;">Pagi</th>
                        <th colspan="2" style="text-align: center;">Siang</th>
                        <th colspan="2" style="text-align: center;">Pagi</th>
                        <th colspan="2" style="text-align: center;">Siang</th>
                        <th colspan="2" style="text-align: center;">Pagi</th>
                        <th colspan="2" style="text-align: center;">Siang</th>
                        <th colspan="2" style="text-align: center;">Pagi</th>
                        <th colspan="2" style="text-align: center;">Siang</th>
                        <!-- <th>Aksi</th> -->
                      </tr>
                      <tr>
                        <!-- <th rowspan="3">NAMA</th> -->
                        <!-- <th>JAM/PARAF</th> -->
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <!-- <th>Aksi</th> -->
                      </tr>
                    </thead>
                    <tbody>
                      <?php
                      $no = 1;
                      foreach ($list_karyawan as $key => $value) {
                        if ($value->status == 'PNS') {
                      ?>
                          <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; ?></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>
                <?php
                  echo "<br><br>";
                }
                ?>

              </div>


            </div>

          </div>
          <!-- /.box-content -->
        </div>
        <!-- /.col-xs-12 -->



      </div>
      <!-- /.row -->

      <div class="row small-spacing">
        <div class="col-xs-12">
          <div class="box-content card">
            <h4 class="box-title" style="cursor: pointer;" onclick="myFunction('div_laporan_kontrak')">Laporan Absensi Pegawai Kontrak Bulan <?= $month ?>, Tahun <?= $year ?></h4>

            <div class="card-content" id="div_laporan_kontrak" style="display: none;">
              <div class="form-group">
                <button type="button" id="button_cetak" class="btn btn-primary btn-xs waves-effect waves-light" onclick="cetak_laporan('kontrak')">Cetak Laporan</button>
              </div>
              <div style="overflow-x: auto;" class="form-group">
                <?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]];
                  }
                }

                // print_r($week_array);


                foreach ($week_array as $week) {


                ?>
                  <table class="table-striped table-bordered display" style="margin-left:auto;margin-right:auto;width:100%;">
                    <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;">JAM/PARAF</th>
                        <th colspan="4" style="text-align: center;">
                          <?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;">
                          <?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;">
                          <?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;">
                          <?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;">
                          <?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;">Pagi</th>
                        <th colspan="2" style="text-align: center;">Siang</th>
                        <th colspan="2" style="text-align: center;">Pagi</th>
                        <th colspan="2" style="text-align: center;">Siang</th>
                        <th colspan="2" style="text-align: center;">Pagi</th>
                        <th colspan="2" style="text-align: center;">Siang</th>
                        <th colspan="2" style="text-align: center;">Pagi</th>
                        <th colspan="2" style="text-align: center;">Siang</th>
                        <th colspan="2" style="text-align: center;">Pagi</th>
                        <th colspan="2" style="text-align: center;">Siang</th>
                        <!-- <th>Aksi</th> -->
                      </tr>
                      <tr>
                        <!-- <th rowspan="3">NAMA</th> -->
                        <!-- <th>JAM/PARAF</th> -->
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <th style="text-align: center;">M</th>
                        <th style="text-align: center;">P</th>
                        <!-- <th>Aksi</th> -->
                      </tr>
                    </thead>
                    <tbody>
                      <?php
                      $no = 1;
                      foreach ($list_karyawan as $key => $value) {
                        if ($value->status == 'Kontrak') {
                      ?>
                          <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; ?></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>
                <?php
                  echo "<br><br>";
                }
                ?>

              </div>


            </div>

          </div>
          <!-- /.box-content -->
        </div>
        <!-- /.col-xs-12 -->



      </div>

      <?php $this->load->view('kepaladinas/footer') ?>

    </div>
    <!-- /.main-content -->
  </div>

  <!-- <div class="modal fade" id="modal_pdf" tabindex="-1" role="dialog" aria-labelledby="myModalLabel-1" data-keyboard="false">
    <div class="modal-dialog modal-lg" role="document">
      <div class="modal-content">

      </div>
    </div>
  </div> -->
  <!-- create modal for who pdf -->
  <div class="modal fade" id="modal_pdf" tabindex="-1" role="dialog" aria-labelledby="modal_pdf" aria-hidden="true">
    <div class="modal-dialog modal-lg" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <h4 class="modal-title" id="modal_pdf">Isi Surat</h4>

        </div>
        <div class="modal-body" id="isi_laporan">
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary btn-xs" data-dismiss="modal">Tutup</button>

        </div>
      </div>
    </div>
  </div>

  <?php $this->load->view('kepaladinas/scripts') ?>

  <script src="<?= base_url() ?>assets/plugin/datatables/media/js/jquery.dataTables.min.js"></script>
  <script src="<?= base_url() ?>assets/plugin/datatables/media/js/dataTables.bootstrap.min.js"></script>

  <script>
    $(document).ready(function() {
      $('#example').DataTable({
        dom: 'Bfrtip',
        buttons: [
          'copyHtml5',
          'excelHtml5',
          'csvHtml5',
          'pdfHtml5'
        ]
      });
    });
    // $(document).ready(function() {
    //   var groupColumn = 2;
    //   var table = $('#example').DataTable({
    //     columnDefs: [{
    //       visible: false,
    //       targets: groupColumn
    //     }],
    //     order: [
    //       [groupColumn, 'asc']
    //     ],
    //     displayLength: 25,
    //     drawCallback: function(settings) {
    //       var api = this.api();
    //       var rows = api.rows({
    //         page: 'current'
    //       }).nodes();
    //       var last = null;

    //       api
    //         .column(groupColumn, {
    //           page: 'current'
    //         })
    //         .data()
    //         .each(function(group, i) {
    //           if (last !== group) {
    //             $(rows)
    //               .eq(i)
    //               .before('<tr class="group text-center"><td colspan="8">' + group + '</td></tr>');

    //             last = group;
    //           }
    //         });
    //     },
    //   });

    //   // Order by the grouping
    //   $('#example tbody').on('click', 'tr.group', function() {
    //     var currentOrder = table.order()[0];
    //     if (currentOrder[0] === groupColumn && currentOrder[1] === 'asc') {
    //       table.order([groupColumn, 'desc']).draw();
    //     } else {
    //       table.order([groupColumn, 'asc']).draw();
    //     }
    //   });
    // });
  </script>

  <script>
    var month = <?= $month ?>;
    var year = <?= $year ?>;

    selectElement('bulan', month);
    selectElement('tahun', year);

    function filter_laporan(e) {
      e.preventDefault();
      window.location.href = server_url + 'kepaladinas/laporan/' + $('#bulan').val() + '/' + $('#tahun').val();
    }

    // function displayIframe() {
    //   document.getElementById("iframeDisplay").innerHTML = "<iframe src=\"../HtmlPage1.html\" height=\"200\" width=\"300\" ></iframe>";

    // }
  </script>
  <!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.5/jspdf.min.js"></script> -->
  <script>
    // $(document).ready(function () {
    //   var form = $('#form_pns'),
    //     cache_width = form.width(),
    //     a4 = [595.28, 841.89]; // for a4 size paper width and height  

    //   $('#create_pdf').on('click', function () {
    //     $('body').scrollTop(0);
    //     createPDF();
    //   });

    //   function createPDF() {
    //     getCanvas().then(function (canvas) {
    //       var
    //         img = canvas.toDataURL("image/png"),
    //         doc = new jsPDF({
    //           unit: 'px',
    //           format: 'a4'
    //         });
    //       doc.addImage(img, 'JPEG', 20, 20);
    //       doc.save('Bhavdip-html-to-pdf.pdf');
    //       form.width(cache_width);
    //     });
    //   }

    //   function getCanvas() {
    //     form.width((a4[0] * 1.33333) - 80).css('max-width', 'none');
    //     return html2canvas(form, {
    //       imageTimeout: 2000,
    //       removeContainer: true
    //     });
    //   }
    // });

    async function cetak_laporan(stat) {
      // ajax
      const laporan = `<embed src="${server_url}kepaladinas/cetakPDF/${stat}" frameborder="1" width="100%" height="600px">`;

      $("#isi_laporan").empty();
      $("#isi_laporan").append(laporan);
      $("#modal_pdf").modal("show");
      // await 2 sec
      await new Promise(r => setTimeout(r, 5000));
      // close modal
      $("#modal_pdf").modal("hide");
    }
  </script>


</body>

<!-- Dibuat oleh Kicap Karan. https://www.kicap-karan.com -->

</html>