                            <div class="box-body">
  <h4>Peserta Aktivitas Mahasiswa</h4>
<div class="box box-danger">

            <div class="box-header with-border">
              <h3 class="box-title">Filter</h3>
            </div>
            <div class="box-body">
            <form class="form-horizontal">
<div class="form-group">
                        <label for="Semester" class="control-label col-lg-2">Semester</label>
                        <div class="col-lg-5">
                        <select id="sem_filter" data-placeholder="Pilih Semester ..." class="form-control chzn-select" tabindex="2">
            <?php 

               $semester = $db->fetch_custom('select *,left(semester,4) as smt from semester order by semester desc');
                    foreach ($semester as $isi) {
                      if ($isi->smt <= date('Y')) {
                        if ($isi->smt==date('Y')-1) {
                          echo "<option value='".$isi->semester."' selected>".$isi->nama_semester."</option>";    
                        } else {
                          echo "<option value='".$isi->semester."'>".$isi->nama_semester."</option>";    
                        }
                    
                      }
                  } ?>
              </select>

 </div>
                      </div><!-- /.form-group -->
<div class="form-group">
                                        <label for="Semester" class="control-label col-lg-2">Program Studi</label>
                                        <div class="col-lg-5">
                                        <select id="jurusan" name="jurusan" data-placeholder="Pilih Semester ..." class="form-control chzn-select" tabindex="2">
                               <?php
        $jurusan_sms = "";
        if ($_SESSION['level']!=1) {
              $jurusan_sms = "where id_sms='".$_SESSION['id_sms']."'";
        } else {
          echo '<option value="all">Semua</option>';
        }
        
                                foreach ($db->fetch_custom("select * from jurusan $jurusan_sms") as $isi) {
                                  echo "<option value='$isi->id_sms'>$isi->jenjang $isi->nama_jurusan</option>";
                               } ?>
                              </select>
 <div id="error_prodi"></div>
                 </div>
                                      </div><!-- /.form-group -->
<div class="form-group">
                        <label for="Kode Matakuliah" class="control-label col-lg-2">Jenis Aktivitas</label>
                        <div class="col-lg-5">
                      <select class="form-control chzn-select" name="jenis" id="jenis">
                    <option value="all">Semua</option>
                     <?php 

               $jenis = $db->fetch_custom('select * from jenis_akt_mhs');
               $add_kampus_merdeka = "";
                    foreach ($jenis as $isi) {
                      if ($isi->a_kegiatan_kampus_merdeka==1) {
                        $add_kampus_merdeka = " (Kampus Merdeka)";
                      }
                      echo "<option value='".$isi->id_jns_akt_mhs."'>".$isi->nm_jns_akt_mhs.$add_kampus_merdeka."</option>";      
                  } ?>

                  </select> </div>
                      </div><!-- /.form-group -->

 <div class="form-group">
                        <label for="Semester" class="control-label col-lg-2">Pencarian</label>
                        <div class="col-lg-3" >
                        <select id="pencarian" name="pencarian" data-placeholder="Pilih Pencarian ..." class="form-control chzn-select" tabindex="2" style="z-index: 1" required="">
                        <option value="all">Semua</option>
                        <option value="nim">NIM</option>
                        <option value="judul">Judul Aktivitas</option>
                        <option value="id">ID Aktivitas/Keterangan</option>
              </select>
            </div>
            <div class="col-lg-6" style="padding-left: 0;">
              <input type="text" name="keyword" id="keyword" class="form-control" placeholder="Input Keyword Pencarian" style="display: none" required="">
              <div id="error_nim"></div>
            </div>
              
                      </div><!-- /.form-group -->

                      <div class="form-group">
                        <label for="tags" class="control-label col-lg-2">&nbsp;</label>
                        <div class="col-lg-10">
                          <span id="filter" class="btn btn-primary btn-flat">Submit</span>
                        </div>
                      </div><!-- /.form-group -->
                    </form>
            </div>
            <!-- /.box-body -->
          </div>
 <div class="alert alert-warning fade in error_data_delete" style="display:none">
          <button type="button" class="close hide_alert_notif">&times;</button>
          <i class="icon fa fa-warning"></i> <span class="isi_warning_delete"></span>
        </div>
                         <table id="dtb_hapus_kelas" class="table table-bordered table-striped" width="100%">
                                   <thead>
                                     <tr>
   <th><input type="checkbox"  id="bulkDelete"  /> <button id="deleteTriger"><i class="fa fa-trash"></i></button></th>
                          
                          <th>Semester</th>
                          <th>Jenis</th>
                          <th>Judul</th>
                          <th>NIM</th>
                          <th>Nama</th>
                          <th>Peran Peserta</th>
                          <th>ID/Keterangan</th>
                          <th>Prodi</th>
                          <th>Action</th>
                        </tr>
                                      </thead>
                                        <tbody>
                                        </tbody>
                                    </table>
                    </div><!-- /.box-body -->

<div class="modal" id="modal_kelas_jadwal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog modal-lg"> <div class="modal-content"><div class="modal-header"> <button type="button" class="close btn btn-danger" data-dismiss="modal" aria-label="Close"><span aria-hidden="true" style="font-size:30px" data-toggle="tooltip" data-title="Tutup"><i class="fa fa-times"></i></span></button> <h4 class="modal-title">Detail Aktivitas</h4> </div> <div class="modal-body" ><div id="isi_kelas_jadwal"></div><div id="panel_pindah_kelas"></div> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div>
   <?php

      
  foreach ($db->fetch_all("sys_menu") as $isi) {

  //jika url = url dari table menu
  if ($path_url==$isi->url) {

 $detail = "<span data-id='+aData[indek]+'".' class="btn btn-info btn-sm detail-aktivitas btn-flat" data-toggle="tooltip" data-title="Lihat Anggota/Pembimbing"><i class="fa fa-eye"></i></span>';

  if ($role_act['del_act']=='Y') {
   $del = "<span data-id='+aData[indek]+' data-uri=".base_admin()."modul/hapus__aktivitas_mahasiswa/peserta/hapus.php".' class="btn btn-danger hapus_feeder_kelass btn-flat btn-sm" data-toggle="tooltip" data-title="Hapus Aktivitas"><i class="fa fa-trash"></i></span>';
  } else {
    $del="";
  }
                   } 
  }
  
?>     <script type="text/javascript">
$(document).ready(function() {
  $("#pencarian").change(function(){
    if (this.value=='all') {
      $("#keyword").hide();
      $("#pencarian").parent().parent().removeClass('has-error');
      $("#error_nim").html('');
    } else {
      $("#keyword").show();
    }

  });


var dataTable;

dataTable = $("#dtb_hapus_kelas").DataTable({
           "fnCreatedRow": function( nRow, aData, iDataIndex ) {
            var indek = aData.length-1;           
     $('td:eq('+indek+')', nRow).html('<?=$detail;?> <?=$del;?>');
       $(nRow).attr('id', 'line_'+aData[indek]);
   },
           'bProcessing': true,
            'bServerSide': true,
              "searching": false,
               "ordering": false,
                 "columnDefs": [ {
              "targets": [0],
              "orderable": false,
              "searchable": false

            },
            {
              "targets": [-1],
              "orderable": false,
              "searchable": false,
              "width":"10%"

            }  ],
            "ajax":{
              url :"<?=base_admin();?>modul/hapus__aktivitas_mahasiswa/peserta/data.php",
            type: "post",  // method  , by default get
            data: function ( d ) {
             <?php
            if ($_SESSION['level']!=1) {
              ?>
              d.jurusan = "<?=$_SESSION['id_sms'];?>";
              <?php
            } else {
              ?>
              d.jurusan = $("#jurusan").val();
                <?php
              }
              ?>
              d.pencarian = $("#pencarian").val();
              d.keyword = $("#keyword").val();
              d.semester = $("#sem_filter").val();
              d.jenis = $("#jenis").val();
            },
          error: function (xhr, error, thrown) {
            console.log(xhr);
              $(".dtb_akm-error").html("");
              $("#dtb_akm").append('<tbody class="dtb_akm-error"><tr><th colspan="9">No data found in the server</th></tr></tbody>');
              $("#dtb_akm_processing").css("display","none");

            }
          },
          "language": {
             searchPlaceholder: "Pencarian dengan Judul /ket/ID Aktivitas",
          "processing": "<i class=\"fa fa-spinner fa-spin\"></i> Loading data, please wait..." //add a loading image,simply putting <img src="loader.gif" /> tag.
   },

        });


//filter
$('#filter').on('click', function() {
    if($("#keyword").is(":visible") && $("#keyword").val()=="") {
      $("#pencarian").parent().parent().addClass('has-error');
      $("#error_nim").html('<span for="nim" class="help-block">Silakan isi Keyword Pencarian</span>');
      return;
    } 

  dataTable.ajax.reload();
});


$("#bulkDelete").on('click',function() { // bulk checked
          var status = this.checked;
          $(".deleteRow").each( function() {
            $(this).prop("checked",status);
          });
        });

$('#deleteTriger').on("click", function(event){
          if( $('.deleteRow:checked').length > 0 ){
            event.preventDefault();


            var ids = [];
            $('.deleteRow').each(function(){
              if($(this).is(':checked')) {
                ids.push($(this).val());
              }
            });
            var ids_string = ids.toString();


            $('#ucing')
        .modal({ keyboard: false })
        .one('click', '#delete', function (e) {

          $("#loadnya").show();
          $.ajax({
              type: "POST",
              url: "<?=base_admin();?>modul/hapus__aktivitas_mahasiswa/peserta/hapus.php?act=del_massal",
              data: {data_ids:ids_string},
               async: true,
              success: function(result) {
                $("#loadnya").hide();
                dataTable.draw(false);
              }
            });
          $('#ucing').modal('hide');



        });


          }
        });


$(".table").on('click','.detail-aktivitas',function(event) {
  $("#loadnya").show();
  event.preventDefault();
  var currentBtn = $(this);

  id = currentBtn.attr('data-id');

  $.ajax({
    url : "<?=base_admin();?>modul/hapus__aktivitas_mahasiswa/peserta/detail_aktivitas.php",
    type : "post",
    data : {akt_id:id},
    success: function(data) {
      $("#isi_kelas_jadwal").html(data);
      $("#loadnya").hide();
    }
  });

  $('#modal_kelas_jadwal').modal({ keyboard: false,backdrop:'static' });

});


    $(".table").on('click','.hapus_feeder_kelass',function(event) {

    event.preventDefault();
    var currentBtn = $(this);

    uri = currentBtn.attr('data-uri');
    id = currentBtn.attr('data-id'); 
    

    $('#ucing')
        .modal({ keyboard: false })
        .one('click', '#delete', function (e) {
        $("#loadnya").show();
                $.ajax({
          type: "POST",
          url: uri+"?act=delete&id="+id,
          success: function(data){
             $("#loadnya").hide();
              console.log(data);
              $("#line_"+id).fadeOut("slow");
              dataTable.draw(false);
          }
          });
          $('#ucing').modal('hide');

        });

  });


       //hapus semua data
      $("#hapus_massal_kelas").click(function(event){

          event.preventDefault();
          var currentBtn = $(this);

          uri = currentBtn.attr('data-uri');
         // id = currentBtn.attr('data-id');

         var valid;
          



          $('#mass_info')
              .modal({ keyboard: false })
              .one('click', '#delete', function (e) {
                sem = $("#sem_delete").val();
                jurusan = $("#jurusan_delete").val();
                jenis = $("#jenis_del").val();
              //  alert(id);
                
              $("#loadnya").show();
              $('#mass_info').modal('hide');
                      $.ajax({
                type: "POST",
                data: {sem:sem,jurusan:jurusan,jenis:jenis},
                url: uri+"?act=delete_all",
                success: function(data){
                    console.log(data);
                    $("#loadnya").hide();
                    dataTable.draw(false);
                    //window.location.reload();
                }
                });
             
                

              });

      });

});
</script>  