<?php
session_start();
include("header.php");
if(trim($_SESSION['accountName'])=="" &&  trim($_SESSION['accountID'])=="" && trim($_SESSION['pgid'])!="i3g3e3nious7")
{
	echo '<script>';
	echo 'location.replace("index.php");';
	echo '</script>';
}
else
{
$syID=0;

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

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


$syName=$_POST['syName'];

if($action== "UPDATE")
{
	if(trim($syName)=="")
	{
		$errmsg = $errmsg . "Sy Desc field is empty<br/>";
	}
	else
	{
		$strSql = mysql_query("update ma_schoolyear set syName='".$syName."' where syID='".$syID."'");
		$errmsg = "You have successfully updated your School Year (".$syName.").";
	}
}
else
{

	$strSql = mysql_query("SELECT * FROM ma_schoolyear where syID='".$syID."'");
	$rs = @mysql_fetch_array($strSql);
	$rscnt=@mysql_num_rows($strSql);
	if($rscnt>0)
	{
		$syID=$rs['syID'];
		$syName=$rs['syName'];
	}

}

?>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<tr><td></td><td align="center" class="fs14"><u><b>Update School Year <?=$syName?></b></u></td></tr>
	<tr><td width="200" class="fs12" valign="top">
	<?php include("sidemenu.php");?>
	</td>
		<td width="700" class="fs12" valign="top">
			<table width="680" cellpadding="1" cellspacing="1" border="0">
			<tr><td colspan="4" valign="top"><br/><hr /></td></tr>
		<?php
		if (substr(trim($errmsg),1,8) == "YOU HAVE")
		{
				echo "<tr><td colspan='4' align='center' valign='top'>".$errmsg."</td></tr>";
		?>
				<br/><meta http-equiv="Refresh" content="3;url=schoolYear.php"><br/>
		<?php
		}
		else 
		{
		?>
				<form action="schoolYearUpdate.php?id=<?=$syID?>" method="POST" name="frm">
				<input type="hidden" name="syID" value="<?=$syID?>" />
				<tr><td height="10" width="17%"></td><td width="33%" class="reqmsg"><i>* required fields</i></td><td height="10" width="15%"></td><td width="35%"></td></tr>
				<tr><td align="right"><b>* </b>SY DESC:&nbsp;</td><td><input class="formInput" type="text" name="syName" value="<?=$syName?>" /></td>
					<td colspan="2"><input class="fs12" type="submit" name="action" value="UPDATE" /></td></tr>
				<tr valign="top"><td></td><td class="errmsg" colspan="2"><?=$errmsg?></td><td></td></tr>
				</form>
		<?php
		}
		?>
			<tr><td colspan="4"><hr /></td></tr>
			</table></td></tr>
</table>
<?php
include("footer.php");
}
?>