<?php 
	include "php_class/class_mysql.php";
	include "php_class/class_dosen.php";
	$DataDosen = new dataDosen;

?>

<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);?>;
		$("#namaPendamping1").click(function(){
			$("#myModal1").modal('show');
		});
		$("#namaPendamping2").click(function(){
			$("#myModal2").modal('show');
		});
		$("#namaPendamping3").click(function(){
			$("#myModal3").modal('show');
		});

		$('#NPM').keyup(function(e){
	  		if(e.keyCode == 13){
				var npm = $('#NPM').val();
				var action = '3';
				var program = $('#program').val();
				var tahun = $('#tahun').val();
				var semester = $('#semester').val();
				var idgrup = $('#idgrup').val();
				if (npm==''){
					$('.peringatan').html('<div id="warning"><div class="alert alert-warning" role="alert">NPM Masih Kosong!</div></div>')			
				}else{
					$('.peringatan').html('<div id="warning"><img src="img/ld.gif"></div>')			
					$.ajax({
						type:"POST",
						data: "index=" + npm + "&program=" + program + "&tahun=" + tahun + "&semester=" + semester + "&grup=" + idgrup ,
						url:"<?php echo $base?>cek-data-proposal.php",     
						success: function(data){
							var tampung = data;
							if(tampung!=404){
								$('#form1').show();
								var pecah=tampung.split(":");
								$('#namaMhs').val(pecah[1]);
								$('#idMhs').val(pecah[9]);
								$('#judul').val(pecah[2]);
								$('#idPendamping1').val(pecah[3]);
								$('#namaPendamping1').val(pecah[4]);
								$('#idPendamping2').val(pecah[5]);
								$('#namaPendamping2').val(pecah[6]);
								$('#bungkus').show();
								$('.peringatan').html('<div id="warning"><div role="alert"></div></div>')
							}else{
								$('.peringatan').html('<div id="warning"><div class="alert alert-warning" role="alert">Mahasiswa dengan NPM ini tidak ditemukan!</div></div>')
								$('#NPM').focus();	
								$('#simpan').hide();
								}
						}
					});
				}
			} 
		});

	});
</script>

<style>
	.checkbox2{	width:20px; height:20px; float:left; }
</style>
<section class="content-header">
  <h1>
   Surat Penugasan
  </h1>
  <ol class="breadcrumb">
    <li><a href="<?php echo $base?>"><i class="fa fa-dashboard"></i> Home</a></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">Buat Surat Penugasan</h3>
                </div>
                <div class="box-body">
                        
                        <div class="peringatan">
                        </div>

                	<form method="post" action="<?php echo $base?>query-add-penugasan">
                    	<input type="hidden" name="idMhs" id="idMhs">
                        <input type="hidden" name="idPendamping1" id="idPendamping1">
                        <input type="hidden" name="idPendamping2" id="idPendamping2">
                        
                        <div class="form-group">
                            <label class="control-label">NPM</label>
                            <input type="text" name="npm"  class="form-control"  placeholder="masukkan NPM kemudian tekan enter" id="NPM">
                        </div>
                        <div id="bungkus" style="display:none">
                            <div class="form-group">
                                <label for="Operator" class="control-label">Nama Mahasiswa</label>
                                <input type="text" name="namaMhs" required="required" class="form-control"  placeholder="nama mahasiswa" id="namaMhs">
                             </div>
                             <div class="form-group">
                                <label for="Operator" class="control-label">Judul</label>
                                <input type="text" name="judul" required="required" class="form-control"  placeholder="judul" id="judul">
                             </div>
                             <div class="form-group">
                                <label for="Operator" class="control-label">No Surat Penugasan</label>
                                <input type="text" name="noUndanganProposal" required="required" class="form-control"  placeholder="no undangan proposal">
                             </div>

                             <div class="form-group">
                                <label for="Operator" class="control-label">Pembimbing I</label>
                                <input type="text" name="namaPendamping1" class="form-control"  placeholder="nama pembimbing 1" id="namaPendamping1">
                             </div>

                             <div class="form-group">
                                <label for="Operator" class="control-label">Pembimbing II</label>
                                <input type="text" name="namaPendamping2" required="required" class="form-control"  placeholder="nama pembimbing 2" id="namaPendamping2">
                             </div>
							<?php 

								$namawadek = $DataDosen->get_dosen_ttd('Nama', 'wadek');
								$IdWadek = $DataDosen->get_dosen_ttd('Id', 'wadek');
							?>
                             <div class="form-group">
                                <label for="Operator" class="control-label">Wakil Dekan I</label>
                                <input type="text" name="wadek" required="required" class="form-control"  placeholder="nama wakil dekan I" id="wadek" value="<?php echo $namawadek?>">
                                <input type="hidden" name="idWadek" value="<?php echo $IdWadek?>">
                             </div>

                             <div class="form-group">
                                <button type="submit" class="btn btn-default"><i class='glyphicon glyphicon-ok'></i> Simpan</button>
                             </div>
                         </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 - Pendamping 1</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];
				bendahara = pecah[1];
				nip = pecah[2];
				
			$('#idPendamping1').val(kodeDosen);
			$('#namaPendamping1').val(bendahara);
			$('#myModal1').modal('hide')
		});
	});
</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">Daftar Dosen - Pendamping 2</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 pilih2'>";
						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(){
		$('.pilih2').click(function(){
			var kode = $(this).attr('ids');
			var pecah = kode.split("-");	
				kodeDosen = pecah[0];
				bendahara = pecah[1];
				nip = pecah[2];
				
			$('#idPendamping2').val(kodeDosen);
			$('#namaPendamping2').val(bendahara);
			$('#myModal2').modal('hide')
		});
	});
</script>
   
   
