<?php
session_start();
session_cache_limiter("private");
if(!isset($_SESSION['user']))
	{
	header("Location: login.php");
	}
$login="<p>Вы зашли, как ".$_SESSION['user'].".<input type='button' onclick='location.href=\"login.php?logoff\";'/ value='Выход'>";
?>
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
  <?php
  
$fh = fopen('login.cfg', "r") or die("Can't open file!");
$login = fread($fh, filesize('login.cfg'));
fclose($fh);
$fh = fopen('pass.cfg', "r") or die("Can't open file!");
$pass = fread($fh, filesize('pass.cfg'));
fclose($fh);
$fh = fopen('sid.cfg', "r") or die("Can't open file!");
$sid = fread($fh, filesize('sid.cfg'));
fclose($fh);
  
$c=OCILogon($login, $pass, $sid);
if(!$c)
			{
			echo "Невозможно подключится к базе: " . var_dump( OCIError() );
			die();
			}

$s = OCIParse($c, "select * from stat");
OCIExecute($s, OCI_DEFAULT);

$n=0;
while (OCIFetch($s))
	{
	$name[$n]=htmlspecialchars(ociresult($s,"TYPE_NAME"));
	$all[$n]=htmlspecialchars(ociresult($s,"ALL_P"));
	$made[$n]=htmlspecialchars(ociresult($s,"MADE"));
	$brak[$n]=htmlspecialchars(ociresult($s,"BRAK"));
	$pr[$n]=htmlspecialchars(ociresult($s,"PR_BRAK"));
	$del[$n]=htmlspecialchars(ociresult($s,"DELETED"));
	$n++;
	}
			
OCICommit($c);
OCILogoff($c);
?>
  <title>АСУ</title>
  <link rel="stylesheet" href="/style/style.css" type="text/css" />
 </head>
<body>
	<table border=1>
	<tr>
	<td width=300>
   <iframe src="menu.php" height=550 id="myIframe" scrolling=auto frameborder=0 ></iframe>
	</td>
	<td width=900 valign=top><table width="700"><td align='right'>Вы зашли как <?php echo $_SESSION['user'];?>, <input type='button' onclick='location.href="login.php?logoff";'/ value='Выход'></td></table><br/>
<?php
	echo "<table border=1>\n<tr><th>Устройство</th>\n<th>Удаленных</th>\n<th>Готовых</th>\n<th>Брака</th>\n<th>Всего</th>\n<th>Брак в процентах</th>\n</tr>";
	$rn=0;
	for($j=0;$j<$n;$j++)
		{
		if($rn>3)
			$rn=0;
		if($rn==0)
				$color="#fbec5d";
			if($rn==1)
				$color="#fcdd76";
			if($rn==2)
				$color="#ffdb58";
			if($rn==3)
				$color="#f0dc82";
		$rn++;
		echo "<tr bgcolor=".$color.">\n<td>".$name[$j]."</td>\n<td>".$del[$j]."</td>\n<td>".$made[$j]."</td>\n<td>".$brak[$j]."</td>\n<td>".$all[$j]."</td>\n<td>".$pr[$j]."%</td>\n</tr>";
		}
	echo "\n</table>";
?>
	</td>
	</tr>
	</table>
 
</body>
</html>