<?php 
	include "php_class/class_mysql.php";
	include "php_class/class_dosen.php";
	include "php_class/class_jadwal.php";
	$DataJadwal = new dataJadwal;
	$DataDosen = new dataDosen;
	
	$id = $xcode;
	$idmatakuliah = $DataJadwal->get_jadwal_single_by_id('idmatakuliah',$id);
	$matakuliah = $DataJadwal->get_jadwal_single_by_id('matakuliah',$id);
	$dosen = $DataJadwal->get_jadwal_single_by_id('dosen',$id);
	$sks = $DataJadwal->get_jadwal_single_by_id('sks',$id);
	$semester = $DataJadwal->get_jadwal_single_by_id('semester',$id);
	$jurusan = $DataJadwal->get_jadwal_single_by_id('jurusan',$id);
	$kelas = $DataJadwal->get_jadwal_single_by_id('kelas',$id);
	$hari = $DataJadwal->get_jadwal_single_by_id('hari',$id);
	$ruang = $DataJadwal->get_jadwal_single_by_id('ruang',$id);
	$waktu = $DataJadwal->get_jadwal_single_by_id('waktu',$id);
	$sm = $DataJadwal->get_jadwal_single_by_id('sm',$id);
	$tahun = $DataJadwal->get_jadwal_single_by_id('tahun',$id);

?>

<link href="<?php echo $base?>plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $base?>plugins/iCheck/all.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $base?>plugins/timepicker/bootstrap-timepicker.min.css" rel="stylesheet"/>
<script src="<?php echo $base?>plugins/input-mask/jquery.inputmask.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/input-mask/jquery.inputmask.date.extensions.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/input-mask/jquery.inputmask.extensions.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/timepicker/bootstrap-timepicker.min.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/iCheck/icheck.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $base?>plugins/autocomplete/shieldui-all.css" />
<link href="<?php echo $base?>bootstrap/css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="<?php echo $base?>bootstrap/js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
<script type="text/javascript" src="<?php echo $base?>bootstrap/js/locales/bootstrap-datetimepicker.id.js" charset="UTF-8"></script>
<script type="text/javascript" src="<?php echo $base?>plugins/autocomplete/shieldui-all.min.js"></script>
<script>
	$(document).ready(function(){
	var base = <?php echo json_encode($base);?>;
		$("#cari").click(function(){
			$("#myModal1").modal('show');
		});
		$("#matkul").click(function(){
			$("#myModal2").modal('show');
		});

	});
</script>

<style>
	.checkbox2{	width:20px; height:20px; float:left; }
</style>
<section class="content-header">
  <h1>
   Data Jadwal
  </h1>
  <ol class="breadcrumb">
    <li><a href="<?php echo $base?>"><i class="fa fa-dashboard"></i> Home</a></li>
    <li><a href="<?php echo $base?>data-jadwal">Data Jadwal</a></li>
    <li class="active">Edit Data Jadwal</li>
  </ol>
</section>
<section class="content">
 	<div class="row">
    	<div class="col-md-12">
        	 <div class="box box-info">
                <div class="box-header">
                  <h3 class="box-title">Edit Data Jadwal</h3>
                </div>
                <div class="box-body">
                        
                        <div class="peringatan">
                        </div>

                	<form method="post" action="<?php echo $base?>query-edit-jadwal">
                    	<input type="hidden" name="id" value="<?php echo $id?>">
                        <div class="form-group">
                            <label class="control-label">Mata Kuliah</label>
                            <input type="text" name="matakuliah"  class="form-control"  placeholder="mata kuliah" id="matkul" value="<?php echo $matakuliah?>">
                        </div>
                        <div class="form-group">
                            <label class="control-label">Sandi Mata Kuliah</label>
                            <input type="text" name="idmatakuliah"  class="form-control"  placeholder="sandi mata kuliah" value="<?php echo $idmatakuliah?>" id="idmatkul">
                        </div>
                        <div class="form-group">
                            <label for="Operator" class="control-label">Nama Dosen *cari nama dosen apabila sudah pernah dimasukkan sebelumnya</label>
                            <div class="input-group">
                                <input type="text" name="dosen" required="required" class="form-control"  placeholder="nama" id="nama" value="<?php echo $dosen?>">
                                <span class="input-group-addon" id="cari">
                                    <i class="glyphicon glyphicon-search" ></i>
                                </span>
							</div>
                         </div>
                         <div class="form-group">
                            <label for="Operator" class="control-label">SKS</label>
                            <input type="text" name="sks" required="required" class="form-control"  placeholder="sks" value="<?php echo $sks ?>">
                         </div>
                         <div class="form-group">
                            <label for="Operator" class="control-label">Semester</label>
                            <input type="text" name="semester" required="required" class="form-control"  placeholder="semester" value="<?php echo $semester ?>">
                         </div>

                        <div class="form-group">
                            <label for="Operator" class="control-label">Jurusan</label>
                            <select class="form-control" name="jurusan">
                            	<option value="<?php echo $jurusan?>"><?php echo $jurusan?></option>
                            	<option value="Akuntansi">Akuntansi</option>
                                <option value="IESP">IESP</option>
                                <option value="Manajemen">Manajemen</option>
                            </select>
                         </div>
                         <div class="form-group">
                            <label for="Operator" class="control-label">Kelas</label>
                            <input type="text" name="kelas" required="required" class="form-control"  placeholder="kelas" value="<?php echo $kelas ?>">
                         </div>
                         <div class="form-group">
                            <label for="Operator" class="control-label">Hari</label>
                            <input type="text" name="hari" required="required" class="form-control"  placeholder="hari" value="<?php echo $hari ?>">
                         </div>
                         <div class="form-group">
                            <label for="Operator" class="control-label">Ruang</label>
                            <input type="text" name="ruang" required="required" class="form-control"  placeholder="ruang" value="<?php echo $ruang ?>">
                         </div>
                         <div class="form-group">
                            <label for="Operator" class="control-label">Waktu</label>
                            <input type="text" name="waktu" required="required" class="form-control"  placeholder="waktu" value="<?php echo $waktu ?>">
                         </div>
                         <div class="form-group">
                            <label for="Operator" class="control-label">Semester Akademik</label>
                            <input type="text" name="sm" required="required" class="form-control"  placeholder="semester akademik"  value="<?php echo $sm?>">
                         </div>
                         <div class="form-group">
                            <label for="Operator" class="control-label">Tahun Akademik</label>
                            <input type="text" name="tahun" required="required" class="form-control"  placeholder="tahun akademik" value="<?php echo $tahun?>">
                         </div>
                         <div class="form-group">
                            <button type="submit" class="btn btn-default"><i class='glyphicon glyphicon-ok'></i> Simpan</button>
                         </div>
                    </form>
                </div>
               </div>
         </div>
    </div>
</section>

    	
    	
<link href="<?php echo $base?>plugins/datatables/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
<script src="<?php echo $base?>plugins/datatables/jquery.dataTables.min.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/datatables/dataTables.bootstrap.min.js" type="text/javascript"></script>
<script type="text/javascript">
  $(document).ready(function(){
	$("#example1").dataTable();
	
  });
</script>

<div id="myModal1" class="modal fade" role="dialog">
  <div class="modal-dialog modal-lg">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Daftar Dosen</h4>
      </div>
      <div class="modal-body">
      	<div class="table-responsive">
          <table id="example1" class="table table-bordered table-striped table-hover">
             <thead>
                <tr>
                    <th>No</th>
                    <th>Nama Dosen</th>
                    <th>NIK / NIP</th>
                </tr>
            </thead>
            <tbody>
            <?php
            	$JumlahData = $DataDosen->get_data_dosen('',$a,'jumlah');
				if ($JumlahData<=0){
					echo "<tr class='odd gradeX'>";
					echo "<td>No Data</td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "</tr>";	
				}else{
					for ($a=1;$a<=$JumlahData;$a++){
						$id = $DataDosen->get_data_dosen('Id',$a,'');
						$NIDN = $DataDosen->get_data_dosen('NIDN', $a, '');
						$Nama = $DataDosen->get_data_dosen('Nama',$a,'');
						$NIK = $DataDosen->get_data_dosen('NIP',$a,'');
						
						echo "<tr ids='".$id."-".$Nama."-".$NIK."' class='odd gradeX context pilih1'>";
						echo "<td>".$id."</td>";
						echo "<td>".$Nama."</td>";
						echo "<td>".$NIK."</td>";
						echo "</tr>";
					}
				}
			?>
        	</tbody>
          </table>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" id="closemodal" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>
<script>
	$(document).ready(function(){
		$('.pilih1').click(function(){
			var kode = $(this).attr('ids');
			var pecah = kode.split("-");	
				kodeDosen = pecah[0];
				dosen = pecah[1];
				
			$('#nama').val(dosen);
			$('#myModal1').modal('hide')
		});
	});
</script>
   
<link href="<?php echo $base?>plugins/datatables/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
<script src="<?php echo $base?>plugins/datatables/jquery.dataTables.min.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/datatables/dataTables.bootstrap.min.js" type="text/javascript"></script>
<script type="text/javascript">
  $(document).ready(function(){
	$("#example2").dataTable();
	
  });
</script>

<div id="myModal2" class="modal fade" role="dialog">
  <div class="modal-dialog modal-lg">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Data Mata Kuliah</h4>
      </div>
      <div class="modal-body">
      	<div class="table-responsive">
          <table id="example2" class="table table-bordered table-striped table-hover">
             <thead>
                <tr>
                    <th>Kode</th>
                    <th>Mata Kuliah</th>
                </tr>
            </thead>
            <tbody>
            <?php
            	$JumlahData = $DataJadwal->get_data_matkul('',$a,'jumlah');
				if ($JumlahData<=0){
					echo "<tr class='odd gradeX'>";
					echo "<td>No Data</td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "</tr>";	
				}else{
					for ($a=1;$a<=$JumlahData;$a++){
						$id = $DataJadwal->get_data_matkul('idmatakuliah',$a,'');
						$Nama = $DataJadwal->get_data_matkul('matakuliah',$a,'');
						$kode = $DataJadwal->get_data_matkul('kode',$a,'');
						
						echo "<tr ids='".$kode."-".$Nama."' class='odd gradeX context pilih2'>";
						echo "<td>".$id."</td>";
						echo "<td>".$Nama."</td>";
						echo "</tr>";
					}
				}
			?>
        	</tbody>
          </table>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" id="closemodal" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>
<script>
	$(document).ready(function(){
		$('.pilih2').click(function(){
			var kode = $(this).attr('ids');
			var pecah = kode.split("-");	
				id = pecah[0];
				mat = pecah[1];
				
			$('#idmatkul').val(id);
			$('#matkul').val(mat);
			$('#myModal2').modal('hide')
		});
	});
</script>
