<?php
session_start();
include("header.php");
$stat=1;
$grd=0;

if($_POST['action']!="")
	$action=$_POST['action'];
elseif($_GET['action']!="")
	$action=$_GET['action'];


if(trim($_POST['stat'])!="")
	$stat=$_POST['stat'];
else if(trim($_GET['stat'])!="")
	$stat=$_GET['stat'];



if(trim($_POST['id'])!="")
	$grd=$_POST['id'];
elseif(trim($_GET['id'])!="")
	$grd=$_GET['id'];

if(trim(strtoupper($action)) == "UPDATE")
	$strSql = mysql_query("update ma_grades set status='".$stat."' where grade_id='".$grd."'");

?>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<tr><td></td><td align="center" class="fs14"><u><b>School Grades</b></u></td></tr>
	<tr><td width="200" class="fs12" valign="top">
	<?php
	include("sidemenu.php");
	?>
	</td>
		<td width="680" class="fs12" valign="top">
			<table width="608" cellpadding="1" cellspacing="1" border="0">
				<tr align="center"><td width="80%"></td>
					<td width="10%"></td><td width="10%"></td></tr>
			<?php
			$strSql = mysql_query("SELECT * FROM ma_grades order by orderby");
			$rsc =@mysql_num_rows($strSql);
			If($rsc>0)
			{
				while($rs=@mysql_fetch_array($strSql))
				{
					$sStatus="In-active";
					$statVal=1;
					if($rs['status']== 1)
					{
						$sStatus="Active";
						$statVal=0;
					}

					echo "<tr><td colspan='3'><hr /></td></tr>";
					echo "<tr><td>&nbsp;".$rs['orderby']."&nbsp;".trim($rs['grade_name'])."</td>";
					echo "<td><a href='gradeUpdate.php?id=".$rs['grade_id']."'>Update</a></td><td><a href='grades.php?action=update&stat=".$statVal."&id=".$rs['grade_id']."'>".$sStatus."</a></td></tr>";
				}
			}
			echo "<tr><td colspan='3'><hr /></td></tr>";
			echo "<tr><td></td><td colspan='2'><a href='gradeNew.php'>Create New Grade</a></td></tr>";
			?>
			</table>
		</td>
	</tr>
</table>
<?php
include("footer.php");
?>