<!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                      History Pendidikan
                    </h1>
                    <ol class="breadcrumb">
                        <li><a href="<?=base_index();?>"><i class="fa fa-dashboard"></i> Home</a></li>
                        <li><a href="<?=base_index();?>history-pendidikan">History Pendidikan</a></li>
                        <li class="active">Edit History Pendidikan</li>
                    </ol>
                </section>

                <!-- Main content -->
                <section class="content">
<div class="row">
    <div class="col-lg-12">
        <div class="box box-solid box-primary">
                                   <div class="box-header">
                                    <h3 class="box-title">Edit History Pendidikan</h3>
                                    <div class="box-tools pull-right">
                                        <button class="btn btn-info btn-sm" data-widget="collapse"><i class="fa fa-minus"></i></button>
                                        <button class="btn btn-info btn-sm" data-widget="remove"><i class="fa fa-times"></i></button>
                                    </div>
                                </div>

                  <div class="box-body">
                     <form id="update" method="post" class="form-horizontal" action="<?=base_admin();?>modul/history_pendidikan/history_pendidikan_action.php?act=up">
                      <div class="form-group">
                        <label for="Mulai Semester" class="control-label col-lg-2">Mulai Semester</label>
                        <div class="col-lg-10">
                          <input type="text" data-rule-number="true" name="mulai_smt" value="<?=$data_edit->mulai_smt;?>" class="form-control" required> 
                        </div>
                      </div><!-- /.form-group -->
<div class="form-group">
                        <label for="NIPD" class="control-label col-lg-2">NIPD</label>
                        <div class="col-lg-10">
                          <input type="text" name="nipd" value="<?=$data_edit->nipd;?>" class="form-control" required> 
                        </div>
                      </div><!-- /.form-group -->
<div class="form-group">
                        <label for="Jenis Pendaftaran " class="control-label col-lg-2">Jenis Pendaftaran </label>
                        <div class="col-lg-10">
                          <select name="id_jns_daftar" id="id_jns_daftar" data-placeholder="Pilih Jenis Pendaftaran ..." class="form-control chzn-select" tabindex="2" >
               <option value=""></option>
               <?php foreach ($db->fetch_all("jenis_pendaftaran") as $isi) {

                  if ($data_edit->id_jns_daftar==$isi->id_jns_daftar) {
                    echo "<option value='$isi->id_jns_daftar' selected>$isi->nm_jns_daftar</option>";
                  } else {
                  echo "<option value='$isi->id_jns_daftar'>$isi->nm_jns_daftar</option>";
                    }
               } ?>
              </select>
                        </div>
                      </div><!-- /.form-group -->


<?php
if ($data_edit->id_jns_daftar!=1) {
  $show = "";
} else {
  $show = "style='display:none'";
}
?>
<div class="form-group" id="show_asal_pt" <?=$show?>>
                        <label for="Jenis Pendaftaran" class="control-label col-lg-2">Asal Perguruan Tinggi</label>
                        <div class="col-lg-10">
                          <select name="kode_pt_asal" id="kode_pt_asal" data-placeholder="Pilih Asal Perguruan Tinggi ..." class="form-control" tabindex="2" >
                          <?php
                          if ($data_edit->id_jns_daftar!=1 && $data_edit->kode_pt_asal!="") {
                            $kampus = $db->fetch_single_row("satuan_pendidikan","npsn",$data_edit->kode_pt_asal);
                             echo "<option value='$kampus->npsn'>$kampus->nm_lemb</option>";
                          }
                          ?>

              </select>
                        </div>
                      </div><!-- /.form-group -->
<div class="form-group" id="show_asal_prodi" <?=$show?>>
                        <label for="Jenis Pendaftaran" class="control-label col-lg-2">Asal Program Studi</label>
                        <div class="col-lg-10">
                          <select name="kode_prodi_asal" id="kode_prodi_asal" data-placeholder="Pilih Asal Program Studi ..." class="form-control chzn-select" tabindex="2">
                            <option value=""></option>
                          <?php
                          $npsn = "";
                          if ($data_edit->id_jns_daftar!=1 && $data_edit->kode_prodi_asal!="") {
                            $id_sp = $db->fetch_single_row("satuan_pendidikan","npsn",$data_edit->kode_pt_asal);
                            $prodis = $db->fetch_custom("SELECT concat(nm_jenj_didik,' ',nm_lemb) as nama_jurusan,kode_prodi from jenjang_pendidikan INNER join sms USING(id_jenj_didik) where id_sp=?",array('id_sp' => $id_sp->id_sp));
                            foreach ($prodis as $prodi) {
                              if ($data_edit->kode_prodi_asal==$prodi->kode_prodi) {
                                 echo "<option value='$prodi->kode_prodi' selected>$prodi->nama_jurusan</option>";
                              } else {
                                echo "<option value='$prodi->kode_prodi'>$prodi->nama_jurusan</option>";
                              }
                          }
                        }
                          ?>
              </select>
                        </div>
                      </div><!-- /.form-group -->

<div class="form-group">
                        <label for="Jalur Pendaftaran" class="control-label col-lg-2">Jalur Pendaftaran</label>
                        <div class="col-lg-10">
                          <select name="id_jalur_masuk" data-placeholder="Pilih Jalur Pendaftaran..." class="form-control chzn-select" tabindex="2" >
               <option value=""></option>
               <?php foreach ($db->fetch_all("jalur_masuk") as $isi) {

                  if ($data_edit->id_jalur_masuk==$isi->id) {
                    echo "<option value='$isi->id' selected>$isi->jalur</option>";
                  } else {
                  echo "<option value='$isi->id'>$isi->jalur</option>";
                    }
               } ?>
              </select>
                        </div>
                      </div><!-- /.form-group -->
<div class="form-group">
                        <label for="Tanggal Pendaftaran " class="control-label col-lg-2">Tanggal Masuk </label>
                        <div class="col-lg-10">
                          <input type="text" id="tgl1" data-rule-date="true" name="tgl_masuk_sp" value="<?=$data_edit->tgl_masuk_sp;?>" class="form-control" > 
                        </div>
                      </div><!-- /.form-group -->
<div class="form-group">
                        <label for="Penghasilan" class="control-label col-lg-2">Jenis Pembiayaan</label>
                        <div class="col-lg-10">
                          <select name="id_pembiayaan" data-placeholder="Jenis Pembiayaan..." class="form-control chzn-select" tabindex="2" >
               <option value=""></option>
               <?php foreach ($db->fetch_all("pembiayaan") as $isi) {

                  if ($data_edit->id_pembiayaan==$isi->id_pembiayaan) {
                    echo "<option value='$isi->id_pembiayaan' selected>$isi->nm_pembiayaan</option>";
                  } else {
                  echo "<option value='$isi->id_pembiayaan'>$isi->nm_pembiayaan</option>";
                    }
               } ?>
              </select>
                        </div>
                      </div><!-- /.form-group -->
<div class="form-group">
                        <label for="biaya_masuk_kuliah" class="control-label col-lg-2">Biaya Masuk Kuliah</label>
                        <div class="col-lg-10">
                          <input type="number" name="biaya_masuk_kuliah" value="<?=$data_edit->biaya_masuk_kuliah;?>" class="form-control" > 
                        </div>
                      </div><!-- /.form-group -->
<div class="form-group">
                        <label for="Jurusan" class="control-label col-lg-2">Prodi</label>
                        <div class="col-lg-10">
                          <select name="jurusan" data-placeholder="Pilih Jurusan..." class="form-control chzn-select" tabindex="2" required>

               <?php 
if ($_SESSION['level']==1) {
  $jur = $db->fetch_custom("select * from jurusan");
} else {
  $jur = $db->fetch_custom("select * from jurusan where kode_jurusan='".$_SESSION['jurusan']."'");
}
foreach ($jur as $isi) {

                  if ($data_edit->kode_jurusan==$isi->kode_jurusan) {
                    echo "<option value='$isi->kode_jurusan' selected>$isi->jenjang $isi->nama_jurusan</option>";
                  } else {
                    echo "<option value='$isi->kode_jurusan'>$isi->jenjang $isi->nama_jurusan</option>";
                  }
               } ?>
              </select>
                        </div>
                      </div><!-- /.form-group -->

<div class="form-group">
                        <label for="id_bidang_minat" class="control-label col-lg-2">ID Peminatan</label>
                        <div class="col-lg-10">
                          <input type="text" name="id_bidang_minat" value="<?=$data_edit->id_bidang_minat;?>" class="form-control" > 
                        </div>
                      </div><!-- /.form-group -->

                      <input type="hidden" name="jenis_method" value="<?=$data_edit->jenis_method;?>">
                      <input type="hidden" name="id" value="<?=$data_edit->id;?>">
                      <div class="form-group">
                        <label for="tags" class="control-label col-lg-2">&nbsp;</label>
                        <div class="col-lg-10">
                          <a onclick="window.history.back(-1)" class="btn btn-success btn-flat"><i class="fa fa-step-backward"></i> Kembali</a>
           <button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> Simpan</button>
                        </div>
                      </div><!-- /.form-group -->
                    </form>
                  
                  </div>
                  </div>
              </div>
</div>
                  
                </section><!-- /.content -->

<script type="text/javascript">
$(document).ready(function(){
  //trigger validation onchange
$('select').on('change', function() {
    $(this).valid();
});
  $( "#kode_pt_asal" ).select2({
    ajax: {
      url: '<?=base_admin();?>modul/mahasiswa/get_kampus.php',
      dataType: 'json'
      // Additional AJAX parameters go here; see the end of this chapter for the full code of this example
    },
    formatInputTooShort: "Cari Nama Kampus",
    width: "100%",
  });
  $("#id_jns_daftar").change(function(){
    if ($(this).val()!=1) {
        //$("#show_sks_diakui").show();
        $("#show_asal_pt").show();
        $("#show_asal_prodi").show();
        $("#sks_diakui").prop('required',true);
        $("#kode_pt_asal").prop('required',true);
     
    } else {
        //$("#show_sks_diakui").hide();
        $("#show_asal_pt").hide();
        $("#show_asal_prodi").hide();
        $("#sks_diakui").prop('required',false);
        $("#kode_pt_asal").prop('required',false);
    }
});

$("#kode_pt_asal").change(function(){
      $.ajax({
      type : "post",
      url : "<?=base_admin();?>modul/mahasiswa/get_prodi_asal.php",
      data : {id_sp:this.value},
      success : function(data) {
          $("#kode_prodi_asal").html(data);
          $("#kode_prodi_asal").trigger("chosen:updated");
      }
  });
});

});
</script>
        
 