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

	$id = $xcode;
	$idDosen = $DataDosen->get_pejabat_by_id('idDosen', $id);
	$nama = $DataDosen->get_pejabat_by_id('nama', $id);
	$NIP = $DataDosen->get_pejabat_by_id('NIP', $id);
	$jabatan = $DataDosen->get_pejabat_by_id('jabatan', $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 type="text/javascript">
    var countries = <?php echo json_encode($item);?>;
		
		jQuery(function ($) {
        $("#NPM").shieldAutoComplete({
            dataSource: {
                data: countries
            },
            minLength: 1
        });
        
    });
</script>
<script>
	$(document).ready(function(){
		$("#bendahara").click(function(){
			$("#myModal").modal('show');
		});

		$('#NPM').keyup(function(e){
	  		if(e.keyCode == 13){
				var npm = $('#NPM').val();
				var action = '3';
				if (npm==''){
					$('.peringatan').html('<div id="warning"><div class="alert alert-warning" role="alert">NPM Masih Kosong!</div></div>')			
				}else{
					$.ajax({
						type:"POST",
						data: "index=" + npm + "&action=" + action,
						url:"<?php echo $base?>cek-npm.php",     
						success: function(data){
							var tampung = data;
							if(tampung!=404){
								$('.peringatan').html('<div id="warning"><div class="alert alert-warning" role="alert">NPM sudah ada!</div></div>')	
								$('#Nama').val(data);
							}else{
								$('.peringatan').html('<div id="warning"></div>')
								$('#Nama').focus();	
								}
						}
					});
				}
			} 
		});
	});
</script>
<section class="content-header">
  <h1>
   Data Pejabat
  </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-pejabat">Data Pejabat</a></li>
    <li class="active">Ubah Data Pejabat</li>
  </ol>
</section>
<section class="content">
 	<div class="row">
    	<div class="row">
        	<div class="col-md-12">
            </div>
        </div>
    	<div class="col-md-12">
        	 <div class="box box-info">
                <div class="box-header">
                  <h3 class="box-title">Ubah Data Pejabat</h3>
                </div>

                <div class="box-body">
                    <form method="post" action="<?php echo $base?>query-edit-pejabat">
                        <input type="hidden" name="id" value="<?php echo $id?>" >
                        <input type="hidden" name="idDosen" value="<?php echo $idDosen?>" id="idBendahara">
                         <div class="form-group">
                            <label class="control-label">Jabatan</label>
                            <input type="text" class="form-control" placeholder="jabatan" name="jabatan" value="<?php echo $jabatan?>" readonly>
                         </div>
                         <div class="form-group">
                            <label class="control-label">Nama Pejabat</label>
                            <input type="text" class="form-control" placeholder="nama pejabat" name="nama" value="<?php echo $nama?>" id="bendahara">
                         </div>
                         <div class="form-group">
                            <label class="control-label">NIP</label>
                            <input type="text" class="form-control" placeholder="NIP" name="NIP" value="<?php echo $NIP?>" id="nip">
                         </div>
                         <div class="form-group">
                        <button type="submit" class="btn btn-primary" id="simpan"> <i class="glyphicon glyphicon-floppy-saved"></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="myModal" 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 pilih'>";
						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(){
		$('.pilih').click(function(){
			var kode = $(this).attr('ids');
			var pecah = kode.split("-");	
				kodeDosen = pecah[0];
				bendahara = pecah[1];
				nip = pecah[2];
				
			$('#idBendahara').val(kodeDosen);
			$('#bendahara').val(bendahara);
			$('#nip').val(nip);
			$('#myModal').modal('hide')
		});
	});
</script>

    	
    	
   