
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                        Manage Matakuliah
                    </h1>
                        <ol class="breadcrumb">
                        <li><a href="<?=base_index();?>"><i class="fa fa-dashboard"></i> Home</a></li>
                        <li><a href="<?=base_index();?>manage-matakuliah">Manage Matakuliah</a></li>
                        <li class="active">Manage Matakuliah List</li>
                    </ol>
                </section>
                <!-- Main content -->
                <section class="content">
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="box">
                             
                                <div class="box-body table-responsive">

<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">Program Studi</label>
                                        <div class="col-lg-5">
                                        <select id="jurusan" name="jurusan" data-placeholder="Pilih Semester ..." class="form-control chzn-select" tabindex="2">

                                        <option value="all">Semua</option>
                               <?php
                                $jurusan_sms = "";
                                if ($_SESSION['level']!=1) {
                                  $jurusan_sms = "where id_sms='".$_SESSION['id_sms']."'";
                                } 
                               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">Kurikulum</label>
                        <div class="col-lg-5">
                      <select class="form-control" name="kurikulum" id="kurikulum">
                    <option value="all">Semua</option>
                  </select> </div><img id="img_loader" style="display:none" src="<?=base_admin();?>assets/dist/img/ajax-loader.gif">
                      </div><!-- /.form-group -->

<div class="form-group">
                        <label for="Kode Matakuliah" class="control-label col-lg-2">Jenis Matakuliah</label>
                        <div class="col-lg-3">
                    <select class="form-control chzn-select" name="jns_mk" id="jns_mk">
                      <option value="all">Semua</option>
<?php

foreach ($db->fetch_custom("select * from jenis_mk") as $key) {
      echo "<option value='$key->id_jns_mk'>".$key->nm_jns_mk."</option>";
 }
  ?>
                  </select> </div>
                      </div><!-- /.form-group -->

<div class="form-group">
                        <label for="Kode Matakuliah" class="control-label col-lg-2">Tampilkan Data</label>
                        <div class="col-lg-5">
                      <select class="form-control chzn-select" name="tampil_data" id="tampil_data">
                    <option value="all">Semua</option>
                    <option value="1">Tampilkan Matakuliah tidak ada di Kurikulum</option>
                    <option value="2">Tampilkan Matakuliah Belum ada Rencana Pembelajaran</option>
                    <option value="3">Tampilkan Matakuliah Belum ada Rencana Evaluasi</option>
                    <option value="4">Tampilkan Matakuliah Sudah ada Rencana Pembelajaran</option>
                    <option value="5">Tampilkan Matakuliah Sudah ada Rencana Evaluasi</option>
                  </select> </div>
                      </div><!-- /.form-group -->


                      <div class="form-group">
                        <label for="tags" class="control-label col-lg-2">&nbsp;</label>
                        <div class="col-lg-10">
                          <div class="btn-group">
                 <span id="filter" class="btn btn-primary btn-flat">Filter</span>
                </div>
                        </div>
                      </div><!-- /.form-group -->
                      <input type="hidden" name="jurusan" value="<?=$id_jur;?>">

                    </form>
            </div>
            <!-- /.box-body -->
          </div>


<div class="alert alert-success success_data" style="display:none">
<h4><i class="icon fa fa-check"></i> Berhasil!</h4>
Rencana Evaluasi Matakuliah berhasil di Salin ke Kelas Kuliah
</div>

            <div class="row" id="show_progress" style="display: none">
   <div class="col-md-11">
    Mohon Tunggu Sedang Menyalin Rencana Evaluasi <img src="<?=base_admin();?>assets/dist/img/squares.gif">
    </div>
               <div class="col-md-11">
                        <div class="progress">
                          <div class="progress-bar progress-bar-striped" id="progressbar" role="progressbar"  aria-valuemin="0" aria-valuemax="100" style="width: 10%">
                            10%
                          </div>

          </div></div><div class='col-md-1' id="message"><span class='current-count'>1</span>/<span class="total-count">13 Akm</span></div></div>
                      <div class="alert alert-danger alert-dismissible" id="ada_error" style="display: none">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                <h4><i class="icon fa fa-ban"></i> Error! , Contact saya ke wildannudin@gmail.com, screenshoot, kasih tahu saya error dibawah</h4><span class="isi_error"></span>
              </div>

 <div class="row" id="aksi_top_krs" style="display: none">
                                   
                                    <div class="col-sm-4" style="margin-bottom: 10px;">
                                      
                                      <div class="input-group input-group-sm">
                                          <span class="input-group-btn">
                                            <button type="button" class="btn btn-danger btn-flat selected-data">Terpilih</button>
                                          </span>
                                       <select class="form-control col-lg-3" name="aksi_krs" id="aksi_krs">
                                      <option value="0">Salin data Evaluasi ke Kelas</option>
                                    </select>
                                          <span class="input-group-btn">
                                            <button  class="btn btn-success btn-flat" id="salinTriger" data-toggle="tooltip" data-title="Klik untuk Salin Data">Submit</button>
                                          </span>
                                    </div>
                                    </div>
                                  </div>

                                    <table id="dtb_manage_matakuliah" class="table table-bordered table-striped" width="100%">
                                   <thead>
                                     <tr>

<th rowspan="2">#</th>
                          <th rowspan="2">Kode Matakuliah</th>
                          <th rowspan="2">Nama Matakuliah</th>
                          <th rowspan="2">SKS</th>
                          <th rowspan="2">Jenis MK</th>
                          <th colspan="2" style="text-align: center;">Ada Rencana</th>
                          <th rowspan="2">SMT</th>
                          <th rowspan="2">Kurikulum</th>
                          <th rowspan="2">Prodi</th>
                          <th rowspan="2">Action</th>
                        </tr>
                        <tr>
                            <th>Pembelajaran</th>
                            <th>Evaluasi</th>
                        </tr>
                                      </thead>
                                        <tbody>
                                        </tbody>
                                    </table>
                                                       <div class="row">
        <div class="col-lg-12">
        </div>
        <!-- /.col-lg-12 -->
    </div>
                                </div><!-- /.box-body -->
                            </div><!-- /.box -->
                        </div>
                    </div>
<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"> <a data-dismiss="modal" class="btn btn-danger btn-flat" style="float:right"><i class="fa fa-close"></i> Tutup</a> <h4 class="modal-title modal-title-utama">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>
                </section><!-- /.content -->
<link href="<?=base_admin();?>assets/plugins/jquery-confirm/jquery-confirm.min.css" rel="stylesheet" type="text/css" />
<script src="<?=base_admin();?>assets/plugins/jquery-confirm/jquery-confirm.min.js" type="text/javascript"></script>

        <script type="text/javascript">
$(".table").on('click','.edit-matakuliah',function(event) {
  $("#loadnya").show();
  event.preventDefault();
  var currentBtn = $(this);

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

 
  $(".modal-title-utama").html("Edit Matakuliah");

  $.ajax({
    url : "<?=base_admin();?>modul/manage_matakuliah/manage_matakuliah_edit.php",
    type : "post",
    data : {id_matkul:id},
    success: function(data) {
      $("#isi_kelas_jadwal").html(data);
      $("#loadnya").hide();
    }
  });
  $('#modal_kelas_jadwal').modal({ keyboard: false,backdrop:'static' });

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

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

 
  $(".modal-title-utama").html("Tambah Matakuliah Ke Kurikulum");

  $.ajax({
    url : "<?=base_admin();?>modul/manage_matakuliah/add_to_kurikulum.php",
    type : "post",
    data : {id_matkul:id},
    success: function(data) {
      $("#isi_kelas_jadwal").html(data);
      $("#loadnya").hide();
    }
  });
  $('#modal_kelas_jadwal').modal({ keyboard: false,backdrop:'static' });

});

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

  id = currentBtn.attr('data-id');
  $(".modal-title-utama").html("Detail Matakuliah");

  $.ajax({
    url : "<?=base_admin();?>modul/manage_matakuliah/detail_matakuliah.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' });

});
$("#jurusan").change(function(){
        $("#kurikulum").html('');
        $("#kurikulum").chosen();
        $("#matkul").html('');
        $("#matkul").chosen();
        $("#loadnya").show();
        $("#img_loader").show();
    
      $.ajax({
          url : "<?=base_admin();?>modul/download_matkul/kurikulum.php",
          type : "post",
          data : {semester : $("#sem_filter").val(),jurusan :  $(this).val() },
          success : function(data) {
              $("#loadnya").hide();
              $("#img_loader").hide();
              $("#kurikulum").html(data);
              $("#kurikulum").trigger('chosen:updated');
              $("#matkul").html(data);
              $("#matkul").trigger('chosen:updated');
          }

      });
     
  });


var dataTable;

dataTable = $("#dtb_manage_matakuliah").DataTable({
           'bProcessing': true,
            'bServerSide': true,
             // "searching": false,
               "ordering": false,
                 "columnDefs": [ {
              "targets": [0],
              "orderable": false,
              "searchable": false

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

            } ],
            "ajax":{
              url :"<?=base_admin();?>modul/manage_matakuliah/manage_matakuliah_data.php",
            type: "post",  // method  , by default get
            data: function ( d ) {
            <?php
            if ($_SESSION['level']!=1) {
              ?>
             
              d.id_sms_user = "<?=$_SESSION['id_sms'];?>";
             
              <?php
            }
            ?>
              d.jurusan = $("#jurusan").val();
              d.jns_mk = $("#jns_mk").val();
              d.kurikulum = $("#kurikulum").val();
              d.tampil_data = $("#tampil_data").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 Kode Matakuliah",
          "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() {
  dataTable.ajax.reload();
});


$('#salinTriger').on("click", function(event){
          if( $('.check-selected:checked').length > 0 ){
            event.preventDefault();


            var ids = [];
            $('.check-selected').each(function(){
              if($(this).is(':checked')) {
                ids.push($(this).val());
              }
            });
            var ids_string = ids.toString();
            $('.ids').val(ids_string);
            $.confirm({
                title: 'Konfirmasi',
                content: 'Apakah Yakin akan Salin Evaluasi Matakuliah ke Kelas ini ?',
                 theme: 'modern',
                buttons: {
                      ok: {
                        text: "Ya Salin !",
                        btnClass: 'btn-primary',
                        keys: ['enter'],
                        action: function(){
                              $("#show_progress").show();
                              $(".batal").show();
                              var start_time = new Date().getTime();
                              var totaldata;
                              var datas = {
                              ids_string : $(".ids").val(),
                            }
                           
                                 $.ajax({
                                  url: "<?=base_admin();?>modul/manage_matakuliah/get_jumlah.php",
                                  type : "post",
                                  dataType: 'json',
                                  //'async':false,
                                  data : datas,
                                  success: function(data) {
                                      totaldata = data.jumlah;
                                      total_data = parseInt(totaldata);
                                      var bagi = Math.ceil(total_data/4);
                                        
                                        getData(bagi,total_data,start_time,0);

                                  }
                                });
                        }
                    },
                    cancel: {
                         text: "Batal"
                    }
                }
            });
          }
        });

$("#ok_info_download").click(function(){
   var currentBtn = $(this);
   uri = currentBtn.attr('data-uri');
   file_data = currentBtn.attr('data-file');

   //alert(uri);
        $.ajax({
            type: "POST",
            data: {uri:uri,file_data:file_data},
            url: "<?=base_admin();?>modul/manage_matakuliah/manage_matakuliah_action.php?act=delete_download",
            success: function(data){
              console.log(data);
              dataTable.draw(false);
              $('#informasi_download').modal('hide');
            }
        });
  });

</script>  
            