<?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
{

$stat=1;
$schlID=0;

$action =$_GET['action'];

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

if(trim($_GET['id'])!="")
	$schlID=$_GET['id'];


if(trim(strtoupper($action)) == "UPDATE")
{
	$strSql = mysql_query("update tr_schools set status='".$stat."' where school_id='".$schlID."'");
}
?>

<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<tr><td></td><td align="center" class="fs14 black"><u><b>Schools</b></u></td></tr>
	<tr><td width="200" class="fs12" valign="top"><?php include("sidemenu.php");?></td>
		<td width="700" class="fs12">
			<table width="680" 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 b.country_name,a.* from tr_schools a left join ma_country b on b.country_code=a.country order by school_name");

			$rescnt=mysql_num_rows($strSql);

			If($rescnt>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['school_name']."<br/>&nbsp;".$rs['address'].", ".$rs['city'].", ".$rs['state'].", ".$rs['country_name'];
					echo "<br/>&nbsp;<a href='teachers.php?schlID=".$rs['school_id']."'>Teachers</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
					echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='students.php?schlID=".$rs['school_id']."'>Students</a>";
					echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='schoolDates.php?schlID=".$rs['school_id']."'>Dates</a></td>";
					echo "<td><a href='schoolUpdate.php?id=".$rs['school_id']."'>Update</a></td><td><a href='schools.php?action=update&stat=".$statVal."&id=".$rs['school_id']."'>".$sStatus."</a></td></tr>";
				}
			}

			echo "<tr><td colspan='3'><hr /></td></tr>";
			echo "<tr><td></td><td colspan='2'><a href='schoolNew.php'>Create New School</a></td></tr>";
			?>
			</table></td></tr>
</table>

<?php
include("footer.php");
}
?>