<section class="content-header">
      <h1>Pelengkap <small><i>Cek SKS Per Semester</i></small></h1>
      <ol class="breadcrumb">
        <li><a href=""><i class="fa fa-university"></i>Pelengkap </a></li>
        <li class="active">Cek SKS Per Semester</li>
      </ol>
    </section>
    <br />
<?php
@$keyfilter=$_REQUEST['keyfilter'];
@$th_smt=$_REQUEST['semester'];

//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=cek_sks_smt&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;Semester :&nbsp; 
		  <?php
		  
		  $result=$proxy->GetRecordset($gettoken,'semester','','id_smt DESC','','');
		  //print_r($result);
		  $smt=$result['result'];
		  ?>
		 
		  
		  <select name="semester" class="inputbox" id="semester">
		  <!--<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['semester']))
				 {
				 $selected = (isset($_POST['semester']) and $_POST['semester'] == $nm_smt) ? 'selected' : '';
				 echo "<option value='$id_smt' $selected>$nm_smt</option>\n";
				 
				 }
			  else
				 {
				 $selected = (isset($_GET['semester']) and $_GET['semester'] == $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_sms="id_sms='$keyfilter'"; 
		$result=$proxy->GetRecord($gettoken,'sms',$id_sms);
		$prodi=$result['result']['nm_lemb'];
		$id_jenj_didik=$result['result']['id_jenj_didik'];
		
			$result=$proxy->GetRecord($gettoken,'jenjang_pendidikan',"id_jenj_didik='$id_jenj_didik'");
			$jenj=$result['result'];
			$j=$jenj['nm_jenj_didik'];
		echo "<pre style='background-color:#BFE3FE'>";
		echo "<h4> Report Transaksi KRS Untuk SKS Per Semester </h4>";			
		echo "Program Studi : $prodi ($j) <br />";
		
		$data=$th_smt;
		$data1=substr($data,0,4);
		if ($id_jenj_didik==35 || $id_jenj_didik==40){			
			$validasi=$data1-4;			
		}
		elseif($id_jenj_didik==31){
			$validasi=$data1-1;
		}
		else {
		$validasi=$data1-6;
		}
		echo "<br />Cek KRS Semester ".$data;
		echo "<br /> =======================================================";
		
		@$myFile = "sks_smt.txt";
		@unlink(@$myFile);
		for ($a=$validasi;$a<$data1+1;$a++) {
		echo "<br /> <br /><b>Th_masuk - $a</b>";		
			//echo "<br />berarti validasi dimulai dari ".$a;
			
			$mulai_smt="p.id_sms='$keyfilter' AND mulai_smt='".$a."1' OR p.id_sms='$keyfilter' AND mulai_smt='".$a."2'";
			$result=$proxy->GetRecordset($gettoken,'mahasiswa_pt',$mulai_smt,'nipd ASC','','');
			$coba=$result['result'];
			//var_dump($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'];
				$id_jns_keluar=$coba[$i]['id_jns_keluar'];
				
				//echo $nipd."-".$nm_pd."-".$id_jns_keluar."<br />";
				if($id_jns_keluar==''){
					 $status="AKTIF";
					 //echo "<br />".$nipd."-".$nm_pd."-".$status;
					 
					   $npm="p.id_reg_pd='$id_reg_pd' AND id_smt='$data'";
						//echo "<br />".$npm;
						$result1=$proxy->GetRecordset($gettoken,'nilai',$npm,'','','');
						//print_r($result);
						$rec=$result1['result'];
						$sks=0;
						for($x=0;$x<count($rec);$x++){
							  $sks=$sks+$rec[$x]['sks_mk'];
							  }
							if ($sks>24) {
									echo "<br /><b><font face='Palatino Linotype, Book Antiqua, Palatino, serif' size='+1'><span style='color: #F90A0A'>".$nipd."-".$nm_pd."- SKS Semst : ".$sks."</font></b></span>";
							}else {
								echo "<br />".$nipd."-".$nm_pd."- SKS Semst : ".$sks;
							}
						
						// untuk membuat file validasi.txt
						
						$myFile = "sks_smt.txt";
						$fh = fopen($myFile, 'a') or die("can't open file");
						$stringData = "\r\n $nipd - $nm_pd - $sks";
						fwrite($fh, $stringData);
						fclose($fh);
						
						
				} /* end if */
			} /* end for */
		} /* end for */
		echo "</pre>";
	  } /* end ig get lihat */
} /* end if get OP */
?>