<section class="content-header">
      <h1>Pelengkap <small><i>Histori Studi</i></small></h1>
      <ol class="breadcrumb">
        <li><a href="?module=histori_studi"><i class="fa fa-university"></i>Pelengkap </a></li>
        <li class="active">Histori Studi</li>
      </ol>
    </section>
    <br />

<?php
@$keyfilter=$_REQUEST['keyfilter'];
@$th_msk=$_REQUEST['tahun_msk'];
@$mhs=$_REQUEST['mhs'];
@$filter=$_GET['$filt'];
@$_GET['keyfilter']=$keyfilter;
@$_GET['tahun_msk']=$th_msk;

//echo "<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 />";
echo "<h1> Histori Studi</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_studi&op=lihat">
					<table width="100%" border="0">
                    <tr>
                    
                    <td width="10">Program Studi&nbsp;
                    
							<select name="keyfilter" class="inputbox" id="keyfilter">
							<?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 DESC','','');
							//print_r($result);
							$smt=$result['result'];
                            ?>
                           
                            
                            <select name="tahun_msk" class="inputbox" id="tahun_msk">
                            <!--<option>--struktur--</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')
	  {
		  $id_prodi="id_sms='$keyfilter'";
		  $result=$proxy->GetRecord($gettoken,'sms',$id_prodi,'','','');
		  $jur=$result['result']['nm_lemb'];
		  echo "<br /><b>Filter : Prodi $jur dan Tahun Masuk $th_msk </b><br />";
	  	
		  $filt="p.id_sms='$keyfilter' AND mulai_smt='$th_msk'";
		  $result=$proxy->GetRecordset($gettoken,'mahasiswa_pt',$filt,'nipd ASC','','');
		  $coba=$result['result'];
		  //var_dump($coba);
		  @$coba1=array_unique($coba);
		  ?>
          <form method="post" name="prodi" action="<?php echo $_SERVER['PHP_SELF'];?>?module=histori_studi&op=mhs">
		  &nbsp;NPM | Nama Mahasiswa :&nbsp;
                           
          <select name="mhs" class="inputbox" id="mhs">
          <!--<option>--struktur--</option>-->
          <?php
          		
				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'];
					
				
              
                if (isset($_POST['mhs']))
                   {
                   $selected = (isset($_POST['mhs']) and $_POST['mhs'] == $nm_smt) ? 'selected' : '';
                   echo "<option value='$id_reg_pd' $selected>$nipd | $nm_pd</option>\n";
                   
                   }
                else
                   {
                   $selected = (isset($_GET['mhs']) and $_GET['mhs'] == $nm_smt) ? 'selected' : '';
                   echo "<option value='$id_reg_pd' $selected>$nipd | $nm_pd</option>\n";
                   
                   }
              }
          ?>
          </select>
          <button class="btn btn-primary" name="Submit" type="image" value="Submit" data-toggle="submit">Lihat</button>
          </form>
          <?php
	
	}
		elseif($_GET['op']=='mhs'){
		  //echo "$mhs";
		  
		  $filt="p.id_reg_pd='$mhs'";
		  $result=$proxy->GetRecord($gettoken,'mahasiswa_pt',$filt,'id_smt ASC','','');
		  $pro=$result['result']['id_sms'];
		  //echo $pro;
		  $result=$proxy->GetRecord($gettoken,'nilai',$filt,'id_smt ASC','','');
		  $npm=$result['result']['nipd'];
		  $nm=$result['result']['nm_pd'];
	
		  
			echo "<table border='1' cellspacing='10' cellpadding='10' class='box_cccccc'>
                    <thead bgcolor='#FFCC33'>
                    <tr>";
					echo "<th width='220'>&nbsp;NPM : $npm </th>
						  <th width='703'>&nbsp;Nama : $nm</th>";
					echo "</tr>
					
					</thead>";
					
					//echo $npm."-".$nm;
					
					$result=$proxy->GetRecordset($gettoken,'nilai',$filt,'id_smt ASC','','');
					$mk=$result['result'];
					
					echo "<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='90px'><center>Kode Matakuliah</center></th>
						<th width='130px'><center>Nama Matakuliah</center></th>
						<th width='80px'><center>SKS Matakuliah</center></th>
						<th width='80px'><center>Nilai</center></th>
						<th width='80px'><center>Nilai Indeks</center></th>
						<th width='80px'><center>K x M</center></th>
					</tr>
					</thead>";
					$x=0;
					$tot_km=0;
					$sks_t=0;
					$t_indeks=0;
					for($i=0;$i<count($mk);$i++){
						$id_smt = $mk[$i]['id_smt'];
						$kd_mk = $mk[$i]['kode_mk'];
						$id_kls=$mk[$i]['id_kls'];
						$filt_kdm="kode_mk='$kd_mk' AND p.id_sms='$pro'";
						$result=$proxy->GetRecord($gettoken,'mata_kuliah',$filt_kdm,'','','');
		  				$sks_mk =$result['result']['sks_mk'];
						
						//$sks_mk=$mk[$i]['sks_mk'];
						$filt_kd="kode_mk='$kd_mk' and id_kls='$id_kls'";
						//echo $filt_kd;
						$result=$proxy->GetRecord($gettoken,'kelas_kuliah',$filt_kd,'id_smt ASC','','');
		  				$nm_mk =$result['result']['fk__id_mk'];
						
						$nilai = $mk[$i]['nilai_huruf'];
						$nilai_indeks=$mk[$i]['nilai_indeks'];
						$k_m=$sks_mk*$nilai_indeks;
						//$id_reg_pd=$mk[$i]['id_reg_pd'];
						//$fk__sms=$mk[$i]['fk__sms'];
						$x=$x+1;
						$sks_t=$sks_t+$sks_mk;
						$t_indeks=$t_indeks+$nilai_indeks;
						$tot_km=$tot_km+$k_m;
						echo "
						<td><center>$x</center></td><td><center>$id_smt</center></td><td>&nbsp;$kd_mk</td><td>&nbsp;&nbsp;$nm_mk</td><td><center>$sks_mk</center></td><td><center>$nilai</center></td>
						<td><center>$nilai_indeks</center></td><td><center>$k_m</center></td>
						</tr>";				
						
					}
					echo "<tr> 
					<td colspan='4'><center> Total </center></td><td><center>$sks_t</center></td><td></td><td><center>$t_indeks</center></td><td><center>$tot_km</center></td>
					<tr>";
					$ipk=number_format($tot_km/$sks_t,2);
					echo "<tr><td colspan='4'><center> IPk : $ipk</center></td><td colspan='4'></td></tr>";
			echo "</table>";
		}
}
?>

