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

<script type="text/javascript"> 
function confirmdelete(DestURL) {
	var ok = confirm("Are you sure you want to delete this?");
	if (ok) {location.href = DestURL;}
	return ok;
	} 
</script>
<?php 
$stat=1;
$studentID=0;
$schoolID=0;
$yearRef=0;
$action = $_GET["action"];

if(trim($_GET["dID"])!="")
	$dID=$_GET["dID"];
if(trim($_GET["schlID"])!="")
	$schoolID=$_GET["schlID"];
if(trim(strtoupper($action)) == "RMVD")
{
	$strSql =@mysql_query("delete from tr_school_dates where date_id=".$dID);
}
 ?>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<tr><td></td><td align="center" class="fs14 black"><u><b>School Ordering Dates</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 align="center"><td width="80%"></td>
					<td width="10%"></td><td width="10%"></td></tr>
					<?php
			
					$strSql =@mysql_query("select a.date_id, a.orderDate from tr_school_dates a where a.school_id=".$schoolID." order by a.orderDate");
					$cnt=@mysql_num_rows($strSql);
					if($cnt>0)
					{
						while($rs=@mysql_fetch_array($strSql))
						{
						//	$bDate = WeekDayName(WeekDay(cDate(rs("orderDate")))).", ".MonthName(Month(cDate(rs("orderDate"))),true)." ".Day(cDate(rs("orderDate"))).", ".Year(cDate(rs("orderDate")));

						
							$bDate=date('l',strtotime($rs["orderDate"])).",".date('F',strtotime($rs["orderDate"]))." ".date('d',strtotime($rs["orderDate"]))." ".date('Y',strtotime($rs["orderDate"]));

							echo "<tr><td colspan='2'><hr /></td></tr>";
							echo "<tr><td>".$bDate."</td>";
							
							?>
							
								 <td align="center"><a href="#" onClick="confirmdelete('<?="schoolDates.php?schlID=".$schoolID."&dID=".$rs["date_id"]?>&action=rmvd'); return false;">delete</a></td>
							<?php
						}
					}
					else
					{
						echo "<tr><td colspan='2'><hr /></td></tr>";
						echo "<tr><td colspan='2'>There's no Order Dates found for this School.</td></tr>";
					}
					
					echo "<tr><td colspan='3'><hr /></td></tr>";
					echo "<tr><td></td><td colspan='2'><a href='schoolDateNew.php?schlID=".$schoolID."'>Add Dates</a></td></tr>";
					
			?>
			</table></td></tr>
</table>
<?php
include("footer.php");
}
?>
