<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript">
var htmlobjek;
$(document).ready(function(){
  //apabila terjadi event onchange terhadap object <select id=propinsi>
  $("#keyfilter").change(function(){
    var propinsi = $("#keyfilter").val();
    $.ajax({
        url: "tahun_smt.php",
        data: "keyfilter="+keyfilter,
        cache: false,
        success: function(msg){
            //jika data sukses diambil dari server kita tampilkan
            //di <select id=kota>
            $("#tahun_msk").html(msg);
        }
    });
  });
});

</script>
<section class="content-header">
      <h1>Pelengkap <small><i>Histori Kuliah Mahasiswa</i></small></h1>
      <ol class="breadcrumb">
        <li><a href="?module=histori_kuliah"><i class="fa fa-university"></i>Pelengkap </a></li>
        <li class="active">Histori Kuliah Mahasiswa</li>
      </ol>
    </section>
    <br />
<?php
@$keyfilter=$_REQUEST['keyfilter'];
@$th_msk=$_REQUEST['tahun_msk'];
//include "session.php";

echo "<h1> Histori Kuliah Mahasiswa</h1>";
				
				
					//echo "Program Studi :";
					
						$nama_pt="id_sp='$id_sp'";
						//echo $nama_pt;
						$result=$proxy->GetRecordset($gettoken,'sms',$nama_pt,'id_jenj_didik,nm_lemb asc','','');
						//print_r($result);
						$coba=$result['result'];
						@$coba1=array_unique($coba);
					
					
					?>
                    
					<form method="post" name="prodi" action="<?php echo $_SERVER['PHP_SELF'];?>?module=histori_mhs&op=lihat">
					<table width="100%" border="0">
                    <tr>
                    
                    <td width="10">Program Studi&nbsp;
                    
							<select name="keyfilter" class="inputbox" id="keyfilter">
                            <option>--Pilih Prodi--</option>

							<?php
							
							for($i=0;$i<count($coba);$i++){
								$prodi = $coba[$i]['nm_lemb'];
								$id_sms = $coba[$i]['id_sms'];
								$jenjang=$coba[$i]['id_jenj_didik'];
								
								// untuk menggabungkan jenjang dengan prodi
								$result=$proxy->GetRecord($gettoken,'jenjang_pendidikan',"id_jenj_didik='$jenjang'");
								$jenj=$result['result'];
								$j=$jenj['nm_jenj_didik'];
								
								//echo "$j"."-"."$prodi<br>";
								
								
								if (isset($_POST['keyfilter']))
								   {
								   $selected = (isset($_POST['keyfilter']) and $_POST['keyfilter'] == $test) ? 'selected' : '';
								   echo "<option value='$id_sms' $selected>$j"." ("."$prodi".")</option>\n";
								   }
								else
								   {
								   $selected = (isset($_GET['keyfilter']) and $_GET['keyfilter'] == $test) ? 'selected' : '';
								   echo "<option value='$id_sms' $selected>$j"." ("."$prodi".")</option>\n";
								   }
							}
							?>
                            
							</select>
                             &nbsp;Th Masuk Semester :&nbsp; 
                            <?php
							
							//$result=$proxy->GetRecordset($gettoken,'semester','','id_smt ASC','','');
//							//print_r($result);
//							$smt=$result['result'];
//                            ?>
                          
                            
                            <select name="tahun_msk" class="inputbox" id="tahun_msk">
                            <option>--tahun semester--</option>
                            <?php
//                            
//                                for($i=0;$i<count($smt);$i++){
//								$nm_smt = $smt[$i]['nm_smt'];
//								$id_smt = $smt[$i]['id_smt'];
//								
//								  if (isset($_POST['tahun_msk']))
//									 {
//									 $selected = (isset($_POST['tahun_msk']) and $_POST['tahun_msk'] == $nm_smt) ? 'selected' : '';
//									 echo "<option value='$id_smt' $selected>$nm_smt</option>\n";
//									 
//									 }
//								  else
//									 {
//									 $selected = (isset($_GET['tahun_msk']) and $_GET['tahun_msk'] == $nm_smt) ? 'selected' : '';
//									 echo "<option value='$id_smt' $selected>$nm_smt</option>\n";
//									 
//									 }
//								}
                            
                            
                            
                            ?>
                            
                            </select>
                            
                            
                             
							<button class="btn btn-primary" name="Submit" type="image" value="Submit" data-toggle="submit">OK</button>
                            
							</form>
                            </td>
                            </tr>
                            
                            </table>
<?php
if(isset($_GET['op'])){
	if($_GET['op']=='lihat')
	  {
		  //echo "lihat prodi = $keyfilter <br>";
		  //echo "semester = $th_msk <br>";
		  
		  		$filt="p.id_sms='$keyfilter' AND mulai_smt='$th_msk'";
				$result=$proxy->GetRecordset($gettoken,'mahasiswa_pt',$filt,'nipd ASC','','');
				$coba=$result['result'];
				//print_r($coba);
				@$coba1=array_unique($coba);

				for($i=0;$i<count($coba);$i++){
					$nipd = $coba[$i]['nipd'];
					$nm_pd = $coba[$i]['nm_pd'];
					$id_reg_pd=$coba[$i]['id_reg_pd'];
					$fk__sms=$coba[$i]['fk__sms'];
					
					//echo $id_reg_pd."-".$nipd."-".$nm_pd."-".$fk__sms."<br>";
					echo "<br>";
					echo "<b>$fk__sms<b><br>";	
					?>
                    <table border="1" cellspacing="10" cellpadding="10" class="box_cccccc">
                    <thead bgcolor="#FFCC33">
                    <tr>
                    <?php
					//echo $keyfilter;
									
					echo "<th width='290'>NPM : $nipd </th>
						  <th width='380'>Nama : $nm_pd</th>";
					?>
                    </tr>
                    </thead>
                    <?php
					$npm="p.id_reg_pd='$id_reg_pd'";
					//echo $npm."<br>";
					$result=$proxy->GetRecordset($gettoken,'kuliah_mahasiswa',$npm,'id_smt ASC','','');
					//print_r($result);
					$hist=$result['result'];
					@$hist1=array_unique($hist);
					?>
                    <table border="1" cellspacing="1" cellpadding="5">
                    <thead bgcolor="#6CF">
					<tr>
						<th width="50px"><center>No</center></th>
						<th width="80px"><center>Semester</center></th>
						<th width="80px"><center>IPs</center></th>
						<th width="80px"><center>SKS Semt</center></th>
                        <th width="80px"><center>IPk</center></th>
						<th width="80px"><center>SKS Total</center></th>
                        <th width="100px"><center>Status</center></th>
						<th width="120px"><center>Nama Semester</center></th>
					</tr>
					</thead>
                    <?php
					$x=0;
					$tot_sks=0;
					for($a=0;$a<count($hist);$a++){
						$x=$x+1;
						$id_smt=$hist[$a]['id_smt'];
						$ips=$hist[$a]['ips'];
						$sks_smt=$hist[$a]['sks_smt'];
						$ipk=$hist[$a]['ipk'];
						$sks_total=$hist[$a]['sks_total']; 	
						$nm_stat_mhs=$hist[$a]['nm_stat_mhs'];
						$nm_smt=$hist[$a]['nm_smt'];

						if ($x%2==1)
							$warna="CFDDF4";
						else
							$warna="E1EBFB";	
						$tot_sks=$tot_sks+$sks_smt;
					?>
                    
                    <tr bgcolor="<?php echo $warna; ?>"> 
                    <td><?php echo "<center>$x</center>";?></td>
                    <td><?= $id_smt;?></td>
                    <td align="center"><?= $ips;?></td>
                    <td align="center"><?= $sks_smt;?></td>
                    <td align="center"><?= $ipk;?></td>
                    <td align="center"><?= $sks_total;?></td>
                    <td><?= $nm_stat_mhs;?></td>
                    <td><?= $nm_smt;?></td>
                    </tr>
                    <?php
					}
					?>
					<tr>
                    <td colspan="3" align="center"><b>Jumlah SKS Total</b></td>
                    <td align="center"><?= "<b>".$tot_sks."<b>";?></td>
                    <td colspan="4"></td>
                    </tr>
					</table>
                    
                    </table>
					<?php
				}
	}
}
?>

