<?php
session_start();
if (empty($_SESSION['username'])) {
header("location:../../../login.php"); // jika belum login, maka dikembalikan ke file form_login.php
}
$username=$_SESSION['username'];
$level=$_SESSION['level'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<title>.:SPK_Potensi Wilayah Bidang Pertanian:.</title>
	<link rel="shortcut icon" type="image/x-icon" href="../css/images/pavicon.png" />
	<link rel="stylesheet" href="../css/style.css" type="text/css" media="all" />
	<link rel="stylesheet" href="../css/tabel.css" type="text/css" media="all" />
	<link rel="stylesheet" href="../css/flexslider.css" type="text/css" media="all" />
	
	<script src="../js/jquery-1.7.2.min.js" type="text/javascript"></script>
	<!--[if lt IE 9]>
		<script src="js/modernizr.custom.js"></script>
	<![endif]-->
	<script src="../js/jquery.flexslider-min.js" type="text/javascript"></script>
	<script src="../js/functions.js" type="text/javascript"></script>
</head>
<body>
	<!-- wrapper -->
	<div  id="wrapper">
		<!-- header -->
		<header>
			<div class="shell">
				<h1 id="logo"><a href="#">Core</a></h1>
				
			</div>	
		</header>
		<!-- end of header -->
		<!-- navigation -->
		<nav id="navigation">
			<div class="shell">
				<ul>
					<?php
				if ($level=='super_admin')
				{
				echo "
				<li><a href='../tabel_user.php'><span class='bottom-arr'></span>USER</a></li>				
					<li><a href='../kriteria/tabel_kriteria.php'><span class='bottom-arr'></span>KRITERIA</a></li>
					<li><a href='../sub_kriteria/tabel_sub.php'><span class='bottom-arr'></span>SUB KRITERIA</a></li>
					<li><a href='../pemohon/tabel_pemohon.php'><span class='bottom-arr'></span>WILAYAH</a></li>
					<li><a href='../penilaian/penilaian.php'><span class='bottom-arr'></span>PENILAIAN</a></li>
					<li><a href='../penilaian/hasil_akhir.php''><span class='bottom-arr'></span>RANGKING</a></li>
					<li><a href='../../../logout.php'><span class='bottom-arr'></span>LOG OUT</a></li>
					
					";
				}
				else if ($level=='admin')
				{
				echo "
				<li><a href='../pemohon/tabel_pemohon.php'><span class='bottom-arr'></span>WILAYAH</a></li>	
				<li><a href='../penilaian/hasil_akhir.php''><span class='bottom-arr'></span>RANGKING</a></li>	
				<li><a href='../../../logout.php'><span class='bottom-arr'></span>LOG OUT</a></li>
				";
				}
				?>
					
				</ul>
			</div>	
		</nav>
		<!-- end of navigation -->
		<!-- slider-holder --><!-- end of slider-holder -->
        <!-- services -->
<section class="services">


<table>
<tr><td class="baris-ganjil" colspan="6" align="right"><a href="hasil.php"><img Src="backds.png" title="kembali Ke Matrix Normalisasi"></a></td></tr>
<caption><h3>Solusi Ideal Positif/Negatif</h3></caption>
    <tr>
        <th>NO</th>
         <th>Id Kriteria</th>
		<th>Solusi Ideal Positif</th>
		<th>Solusi Ideal Negatif</th>
		
    </tr>
	<?php
include "../../../koneksi.php";
$query = mysql_query("SELECT * FROM fungsid group by id_kriteria");
if(!$query){
	die( mysql_error() );
}
$i=1;
while($row = mysql_fetch_array($query)){
    $clas='baris-ganjil';
    echo "<tr class=$clas>
				  <td >$i</td>
				 <td >".$row['id_kriteria']."</td>
				<td >".$row['ymax']."</td>
				<td >".$row['ymin']."</td>
	</tr>";
			$i=$i+1;
		}	
	    echo "</table>";
			mysql_close();
		?>
		
	
	<?php
include "../../../koneksi.php";
$m=0;
$sql11 = mysql_query("SELECT * FROM fungsid group by y");
	  while ($dt11 = mysql_fetch_array($sql11)) {
	  $y[]=$dt11['y'];
$sql12 = mysql_query("SELECT sqrt(sum(pow(ymax-sy,2))) As Jumlah FROM fungsid As Jumlah WHERE y='$y[$m]'");
	  while ($dt12 = mysql_fetch_array($sql12)) {
	  $d[]=$dt12['Jumlah'];
	   
	  }
	  $m=$m+1;
	  }		
	  ?>
	  <table>
		<caption><h3>Jarak Antar Solusi Ideal</h3></caption>
		<tr><td class="baris-ganjil" colspan="6" align="right"><a href="hasil_akhir.php"><img Src="manual.png" title="Hasil Akhir"></a></td></tr>

    <tr>
        <th>NO</th>
         <th>Id_Wilayah</th>
		<th>Jarak Solusi Ideal Positif</th>
		<th>Jarak Solusi Ideal Negatif</th>
	</tr>
	  <?php
	  $m=0;
	  $i=1;
	  $sql15 = mysql_query("SELECT * FROM fungsid group by y");
	  while ($dt15 = mysql_fetch_array($sql15)) {
	  $y[]=$dt15['y'];
	$sql25 = mysql_query("SELECT sqrt(sum(pow(ymin-sy,2))) As Jumlah FROM fungsid As Jumlah WHERE y='$y[$m]'");
	  while ($dt25 = mysql_fetch_array($sql25)) {
	  $dm[]=$dt25['Jumlah'];
	   echo "<tr class=$clas>
				  <td>$i</td>
				 <td>".$y[$m]."</td>
				<td >".$d[$m]."</td>
				<td >".$dm[$m]."</td>	  	
			</tr>";
	 }
	  $m=$m+1; 
	  $i=$i+1;
	  }
	  echo "</table>";
			mysql_close();
			
?>
			
			











</section>
		<!-- end of services -->
		<!-- main -->
	  <div class="main"></div>
		<!-- end of main -->
		<div id="footer-push"></div>
	</div>
	<!-- end of wrapper -->
	<div id="footer">
		<div class="shell">
		<div class="shell">
			
			<p class="copy">Copyright &copy; 2017 FIKOM UNISAN, SAHIJA Reza</a></p>
			<div class="cl">&nbsp;</div>
		</div>
	</div>
</body>
</html>