<?php
	include "php_class/class_mysql.php";
	include "php_class/class_mahasiswa.php";
	$DataMahasiswa = new DataMahasiswa;
?>


<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(){
		$('#NP').keyup(function(e){
	  		if(e.keyCode == 13){
				var npm = $('#NP').val();
				var nama1 = $('#Nama1').val();
				var action = '3';
				if (npm==''){
					$('.peringatan').html('<div id="warning"><div class="alert alert-warning" role="alert">Nomer Pendaftaran Masih Kosong!</div></div>')			
				}else{
					$('.peringatan').html('<div id="warning"><img src="img/ld.gif"></div>')			
					$.ajax({
						type:"POST",
						data: "index=" + npm + "&action=" + action,
						url:"<?php echo $base?>cek-daftar-ulang.php",     
						success: function(data){
							var tampung = data;
							
							if(tampung==404){
								$('.peringatan').html('<div id="warning"><div class="alert alert-warning" role="alert">Nomer Pendaftaran tidak ditemukan !</div></div>')	
							}else{
								var pecah=tampung.split(":");
								$('.peringatan').html('<div id="warning"><div role="alert"></div></div>')
								$('#NoPendaftaran').val(pecah[3]);
								status = pecah[13];
								
								if (status == 'sudah'){
									$('.peringatan').html('<div id="warning"><div class="alert alert-warning" role="alert">Nomer Pendaftaran ini sudah melakukan pendaftaran ulang!</div></div>')	
									$('#form1').hide();
								}else{
									$('#Nama').val(pecah[0]);
									$('#Nama1').val(pecah[0]);
									$('#Jurusan').val(pecah[1]);
									$('#Jurusan1').val(pecah[1]);
									$('#Jurusan2').val(pecah[1]);
									$('#email').val(pecah[2]);
									$('#Email1').val(pecah[2]);
									$('#NPM').val(pecah[4]);
									$('#npm1').val(pecah[4]);
									$('#tempatlahir').val(pecah[6]);
									$('#tgllahir').val(pecah[7]);
									$('#tgllahir2').val(pecah[7]);
									$('#jenisKelamin').val(pecah[8]);
									$('#agama').val(pecah[9]);
									$('#alamat').val(pecah[10]);
									$('#notelp').val(pecah[11]);
									$('#asalsekolah').val(pecah[12]);
									$('#form1').show();
								}
							}
						}
					});
				}
			} 
		});
	});
</script>
<script type="text/javascript">
 function hourChange(selectObj) {
   var selectIndex=selectObj.selectedIndex;
   var selectValue=selectObj.options[selectIndex].text;
   if (selectValue != 'BARU'){
			$('#hd').show();
   } else {
			$('#hd').hide;
	   }
 }

</script>
<script type="text/javascript">
 function hourChange2(selectObj) {
   var selectIndex=selectObj.selectedIndex;
   var selectValue=selectObj.options[selectIndex].text;
   if (selectValue != 'BELUM BEKERJA'){
			$('#hd2').show();
   } else {
			$('#hd2').hide;
	   }
 }

</script>

<section class="content-header">
  <h1>
   Daftar Ulang
  </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="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">Data Pendaftar</h3>
                </div>

                <div class="box-body">
                <div class="peringatan">
                </div>
    	             <form method="post" >
                        <div class="form-group">
                            <label class="control-label">No Pendaftaran</label>
                            <input type="text" class="form-control" placeholder="masukkan nomer pendaftaran kemudian tekan enter" id="NP" name="NP" required="required">
                         </div>
                         <div class="form-group" style="display:none">
                            <label class="control-label">Nama</label>
                            <input type="text" name="Nama" required="required" class="form-control" id="Nama" disabled >
                         </div>
                        <div class="form-group" style="display:none">
                            <label class="control-label">Jurusan</label>
                            <input type="text" required="required" class="form-control" id="Jurusan" disabled>
                         </div>
                        <div class="form-group" style="display:none">
                            <label class="control-label">Email</label>
                            <input type="text" required="required" class="form-control" id="Email" disabled>
                         </div>
					</form>

                    <form method="post" style="display:none" id="form1" action="<?php echo $base?>query-add-daftar-ulang">
                    	<input type="hidden" id="NoPendaftaran" name="NoPendaftaran">
                        <input type="hidden" id="npm1" name="npm1">
                        <input type="hidden" id="Jurusan1"  name="Jurusan1">
                         <div class="form-group">
                            <label class="control-label">NPM</label>
                            <input type="text" class="form-control"  id="NPM" name="NPM" >
                         </div>
                         <div class="form-group">
                            <label class="control-label">Nama</label>
                            <input type="text" name="Nama" required="required" class="form-control"  placeholder="Nama Konsumen" id="Nama1">
                         </div>
                        <div class="form-group">
                            <label class="control-label">Jurusan</label>
                            <input type="text" name="Jurusan1" required="required" class="form-control" id="Jurusan2" disabled>
                         </div>
                         <div class="form-group">
                            <label class="control-label">Tempat Lahir</label>
                            <input type="text" name="tempatLahir" required="required" class="form-control"  placeholder="Tempat Lahir" id="tempatlahir">
                         </div>
                         <div class="form-group">
                            <label class="control-label">Tanggal Lahir</label>
                            <div class="input-group date form_date" data-date="" data-date-format="dd-mm-yyyy" data-link-field="tglspk">
                                <input required="required" class="form-control" type="text" value="" placeholder="tanggal lahir" readonly id="tgllahir">
                                <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                                <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                                <input type="hidden" id="tgllahir2" name="tgl" value="" />
                                <script type="text/javascript">
                                    $('.form_date').datetimepicker({
                                        language:  'id',
                                        weekStart: 1,
                                        todayBtn:  1,
                                        autoclose: 1,
                                        todayHighlight: 1,
                                        startView: 2,
                                        minView: 2,
                                        forceParse: 0
                                    });
                                </script>  
                            </div>
 		                 </div>
                         <div class="form-group">
                            <label class="control-label">Jenis Kelamin</label>
                            <select class="form-control" name="jenisKelamin" id="jenisKelamin">
                            	<option>PRIA</option>
                                <option>WANITA</option>
                            </select>
                         </div>
                         <div class="form-group">
                            <label class="control-label">Agama</label>
                            <select class="form-control" name="agama" id="agama">
                            	<option>ISLAM</option>
                                <option>HINDU</option>
                                <option>BUDHA</option>
                                <option>KRISTEN PROTESTAN</option>
                                <option>KRISTEN KATOLIK</option>
                                <option>KONGHUCU</option>
                            </select>
                         </div>
                         <div class="form-group">
                            <label class="control-label">Alamat</label>
                            <input type="text" name="alamat" required="required" class="form-control"  placeholder="alamat" id="alamat">
                         </div>
                         <div class="form-group">
                            <label class="control-label">No Telepon</label>
                            <input type="text" name="notelp" required="required" class="form-control"  placeholder="no telepon" id="notelp">
                         </div>
                         <div class="form-group">
                            <label class="control-label">Email</label>
                            <input type="text" name="email" required="required" class="form-control"  placeholder="Email" id="email">
                         </div>
                         <div class="form-group">
                            <label class="control-label">Asal Sekolah</label>
                            <input type="text" name="asalSekolah" required="required" class="form-control"  placeholder="asal sekolah" id="asalsekolah">
                         </div>
                         <div class="form-group">
                            <label class="control-label">Status Perkawinan</label>
                            <select class="form-control" name="statusPerkawinan">
                            	<option>MENIKAH</option>
                                <option>BELUM MENIKAH</option>
                            </select>
                         </div>
                         <div class="form-group">
                            <label class="control-label">Status Pekerjaan</label>
                            <select class="form-control" name="statusPekerjaan" onchange="hourChange2(this);">
                                <option>BELUM BEKERJA</option>
                            	<option>SUDAH BEKERJA</option>
                            </select>
                         </div>
                         <div id="hd2" style="display:none">
                             <div class="form-group">
                                <label class="control-label">Nama Instansi / Perusahaan</label>
                                <input type="text" name="perusahaan"  class="form-control"  placeholder="nama instansi / perusahaan">
                             </div>
                             <div class="form-group">
                                <label class="control-label">Jabatan</label>
                                <input type="text" name="jabatan" class="form-control"  placeholder="jabatan">
                             </div>
                             <div class="form-group">
                                <label class="control-label">Alamat Perusahaan</label>
                                <input type="text" name="alamatPerusahaan" class="form-control"  placeholder="alamat perusahaan">
                             </div>
						</div>
                         <div class="form-group">
                            <label class="control-label">Status Mahasiswa</label>
                            <select class="form-control" name="statusMahasiswa" id="statusmahasiswa" onchange="hourChange(this);">
                                <option>BARU</option>
                            	<option>PINDAHAN</option>
                            </select>
                         </div>
                         <div id="hd" style="display:none">
                             <div class="form-group">
                                <label class="control-label">Perguruan Tinggi Asal</label>
                                <input type="text" name="perguruanTinggiAsal"  class="form-control"  placeholder="perguruan tinggi asal" id="pg">
                             </div>
                             <div class="form-group">
                                <label class="control-label">Program Studi</label>
                                <input type="text" name="programStudi"  class="form-control"  placeholder="programStudi" id="ps" >
                             </div>
                             <div class="form-group">
                                <label class="control-label">Jenjang</label>
                                <input type="text" name="jenjang"  class="form-control"  placeholder="jenjang" id="jenjang">
                             </div>
                             <div class="form-group">
                                <label class="control-label">SKS Diakui</label>
                                <input type="text" name="sks" class="form-control"  placeholder="sks diakui" id="sks">
                             </div>
						</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>

    	
    	
   