<section class="content-header">
      <h1>Pelengkap <small><i>All Mhs Aktif</i></small></h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-university"></i>Pelengkap </a></li>
        <li class="active">All Mhs Aktif</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=all_mhs_aktif&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> Mahasiswa dibawah ini yang berstatus aktif, tapi belum di transaksikan aktifitasnya </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-4;
//		}
//		else {
//		$validasi=$data1-6;
//		}
		echo "Pelaporan semester ".$data;
		//@$myFile = "validasi.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;
			
			//menampilkan mahasiswa yang aktif di prodi ini
			$result=$proxy->GetRecordset($gettoken,'mahasiswa_pt',"p.id_jns_keluar isNull AND p.id_sms='".$keyfilter."'",'nipd ASC','','');
			$data=$result['result'];
			$x=0;
			foreach ($data as $mhs) {
				$x++;
				$id_reg_pd=$mhs['id_reg_pd'];
				$nipd=$mhs['nipd'];
				$nmpd=strtoupper($mhs['nm_pd']);
				
						// menandai mhs yg blom AKM di 20171
						$npm="p.id_reg_pd='$id_reg_pd' AND p.id_smt='".$th_smt."'";
						//echo "<br />".$npm;
						$result=$proxy->GetRecord($gettoken,'kuliah_mahasiswa',$npm,'','','');
						$daft=$result['result'];
						
						@$stat=$daft['id_stat_mhs'];
						@$ipk=$daft['ipk'];
						if ($stat!=''){
						echo "<br>".$x."|".$nipd."|".$nmpd." | status : ".@$stat." dengan IPK =".@$ipk;
						} else 
						echo "<br><b><font face='Palatino Linotype, Book Antiqua, Palatino, serif' size='+1'><span style='color: #F90A0A'>".$x."|".$nipd."|".$nmpd." | status : ???, tdk ada transaksi di $th_smt </font></b>";
						//}
//						$ipk=$result['result']['ipk'];
//						  if ($stat=="A" || $stat=="N" || $stat=="C" ){
//						  	echo "<br>".$x.".".$nipd."-".$nmpd." status : ".$stat." dengan IPK ='".$ipk."'";//$id_reg_pd;
//							} 
//							else
//							{
//							echo "<br>".$x.".".$nipd."-".$nmpd." status : ???, tdk ada transaksi di 20171";
//							}
		
  	 //var_dump($coba);
			}
			
			
			
			//$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 p.id_smt='$data'";
//						//echo "<br />".$npm;
//						$result=$proxy->GetRecord($gettoken,'kuliah_mahasiswa',$npm,'','','');
//						//print_r($result);
//						
//						@$id_smt=$result['result']['id_smt'];
//						@$id_stat_mhs=$result['result']['id_stat_mhs'];
//						if ($id_smt=='' || $id_stat_mhs=='') {
//								$smt='?';
//								$sts='?';
//								echo "<br />".$nipd."-".$nm_pd."-".$smt."-".$sts;
//								
//						
//						// untuk membuat file validasi.txt
//						
//						$myFile = "validasi.txt";
//						$fh = fopen($myFile, 'a') or die("can't open file");
//						$stringData = "\r\n $nipd - $nm_pd - $smt - $sts";
//						fwrite($fh, $stringData);
//						fclose($fh);
//						
//						
//						} /* end if */
//						//else {echo "<br />".$nipd."-".$nm_pd."-".$id_smt."-".$id_stat_mhs;}
//						
//				} /* end if */
//			} /* end for */
		//} /* end for */
		echo "</pre>";
	  } /* end ig get lihat */
} /* end if get OP */


/* sementara di blok dulu, di ganti optional per prodi
					
	  $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);
	  $a=0;
	  foreach ($coba as $rec) {
	  $a++;
	  	$id_sms=$rec['id_sms'];
		$jenj=$rec['id_jenj_didik'];
		$lemb=$rec['nm_lemb'];
		// Tampilkan Nama Prodi-jenjang
		$result=$proxy->GetRecord($gettoken,'jenjang_pendidikan',"id_jenj_didik='".$jenj."'");
			$res=$result['result'];
			$j=$res['nm_jenj_didik'];
			//echo "<br><h3>".$a."-".$lemb."-".$j."-".$id_sms."</h3><br>";
			echo "<br><b>".$a."-".$lemb."-".$j."</b>";
			
			//menampilkan mahasiswa yang aktif di prodi ini
			$result=$proxy->GetRecordset($gettoken,'mahasiswa_pt',"p.id_jns_keluar isNull AND p.id_sms='".$id_sms."'",'nipd ASC','','');
			$data=$result['result'];
			$x=0;
			foreach ($data as $mhs) {
				$x++;
				$id_reg_pd=$mhs['id_reg_pd'];
				$nipd=$mhs['nipd'];
				$nmpd=$mhs['nm_pd'];
				
						// menandai mhs yg blom AKM di 20171
						$npm="p.id_reg_pd='$id_reg_pd' AND p.id_smt='20171'";
						//echo "<br />".$npm;
						$result=$proxy->GetRecord($gettoken,'kuliah_mahasiswa',$npm,'','','');
						$daft=$result['result'];
						
						@$stat=$daft['id_stat_mhs'];
						@$ipk=$daft['ipk'];
						if ($stat!=''){
						echo "<br>".$x.".".$nipd."-".$nmpd." ---> status : ".@$stat." dengan IPK ='".@$ipk."'";
						} else 
						echo "<br><b><font face='Palatino Linotype, Book Antiqua, Palatino, serif' size='+1'><span style='color: #F90A0A'>".$x.".".$nipd."-".$nmpd." ---> status : ???, tdk ada transaksi di 20171 </font></b>";
						//}
//						$ipk=$result['result']['ipk'];
//						  if ($stat=="A" || $stat=="N" || $stat=="C" ){
//						  	echo "<br>".$x.".".$nipd."-".$nmpd." status : ".$stat." dengan IPK ='".$ipk."'";//$id_reg_pd;
//							} 
//							else
//							{
//							echo "<br>".$x.".".$nipd."-".$nmpd." status : ???, tdk ada transaksi di 20171";
//							}
		
  	 //var_dump($coba);
			}
	  }
?>
*/