<?

#---[ Inladen standaard bestanden ]---

	include('beheer/connectit.php3');
	include('beheer/functies.php3');
	include('copyright.php3');

#---[ Initialiseren ]---


#---[ Submenus samenstellen ]---


	$submenu="";

	if ($RType == "") { $RType="L"; }

	if ($RType == "L")
	{
		$submenu.="<span class=submenugekozen>Leerlingen</span><img src=images/alpha_pixel.gif width=20 height=1>";
	}
	else
	{
		$submenu.="<a href=roosterwijzigingen.php3?RType=L class=submenu>Leerlingen</a><img src=images/alpha_pixel.gif width=20 height=1>";
	}
	if ($RType == "D")
	{
		$submenu.="<span class=submenugekozen>Docenten</span><img src=images/alpha_pixel.gif width=20 height=1>";
	}
	else
	{
		$submenu.="<a href=roosterwijzigingen.php3?RType=D class=submenu>Docenten</a><img src=images/alpha_pixel.gif width=20 height=1>";

	}
		


#---[ Header inladen ]---

	$menu="roosterwijzigingen";
	include("header.php3");
	
#---[ Content ]---

?>

<table border="0" width="738" cellspacing="0" cellpadding="0">
<tr>
	<td width="15"></td>
	<td width="708" valign="top">
<?

$CurDate = getdate();
$YearToShow = $CurDate['year'];
$MonthToShow = $CurDate['mon'];
$DayToShow = $CurDate['mday'];
$MonthNames = array(1=>'januari','februari','maart','april','mei','juni','juli','augustus','september','oktober','november','december');
$WeekDag = array(0=>'ZO','MA','DI','WO','DO','VR','ZA');
$WeekDagL = array(0=>'zondag','maandag','dinsdag','woensdag','donderdag','vrijdag','zaterdag');

echo "<table border=0 width=708 cellspacing=0 cellpadding=0><tr><td valign=top>";

function NulNr($Nummer) { if ($Nummer <= 9) { return "0"."$Nummer"; } else { return "$Nummer"; }}
$ishuidgemaand="ja";
if ($MonthToShow <= 12) { include("kalender.php3"); }
$ishuidgemaand="nee";
echo "<br>";
if ($MonthToShow <= 11) { $MonthToShow++; include("kalender.php3"); }
else if ($MonthToShow == 12) { $YearToShow++; $MonthToShow = 1; include("kalender.php3"); $YearToShow--;} 

if (file_exists("data/GROOTW.HTML"))
{
	print "<a href=roosterwijzigingen.php3?Rooster=GROOTW.HTML><b>Grote Wijziging!</b></a><br><br>\n";
}
elseif (file_exists("data/GROOTW.TXT"))
{
	print "<a href=roosterwijzigingen.php3?Rooster=GROOTW.TXT><b>Grote Wijziging!</b></a><br><br>\n";
}
elseif (file_exists("data/GROOTW.323"))
{
	print "<a href=roosterwijzigingen.php3?Rooster=GROOTW.323><b>Grote Wijziging!</b></a><br><br>\n";
}
$MonthToShow = $CurDate['mon'];


#-----------------------------------

echo "</td><td width=15></td><td valign=top>";

$Bestand = addslashes($_GET['Rooster']);

$Kdag = date(w,mktime(0,0,0,$MonthToShow,$DayToShow,$YearToShow));
if ("$Bestand" == "")
{
	if (file_exists("data/"."GROOTW.HTML"))
	{
		$Bestand = "GROOTW.HTML";
	}
	elseif (file_exists("data/"."GROOTW.TXT"))
	{
		$Bestand = "GROOTW.TXT";
	}
	elseif (file_exists("data/"."GROOTW.323"))
	{
		$Bestand = "GROOTW.323";
	}
	elseif ("$RType" == "")
	{
		$Bestand = "L".NulNr($DayToShow).NulNr($MonthToShow).$WeekDag[$Kdag].".323";
	}
	else
	{
		$Bestand = "$RType".NulNr($DayToShow).NulNr($MonthToShow).$WeekDag[$Kdag].".323";
	}
}

if (ereg("^[A-Z0-9]+\.323$", $Bestand))
{
	if (file_exists("data/$Bestand"))
	{
		$lines = file ("data/$Bestand");
		echo "<TABLE border=1 bordercolor=#FFFFFF bordercolorlight=#FFFFFF bordercolordark=#FFFFFF cellpadding=5 cellspacing=0 bgcolor=#F2056F>" ;
		foreach ($lines as $line_num => $line)
		{
			if ($line_num == 0)
			{
				$NCount = 1;
				$T1Count = 1;
				$T2Count = 2;
				echo "<TR><TD><PRE><font color=#ffffff>";
			}
			elseif (($NCount == 10) OR (ereg("^0f0f", bin2hex($line))) OR (ereg("^1f1f", bin2hex($line))) OR (ereg("^///", $line)))
			{
				if ($NCount == 9)
				{
					echo "</font></PRE></TD>";
					if ($T1Count == 2)
					{
						echo "</TR>";
						$T1Count = 1;
					}
					else
					{
						echo "\n";
						$T1Count = 2;
					}
				}
				if ($NCount == 10)
				{
					if ($T2Count == 1)
					{
						echo "<TR>";
						$T2Count = 2;
					}
					else
					{
						$T2Count = 1;
					}
					echo "<TD><PRE><font color=#ffffff>";
				}
				$NCount++;
				if ($NCount == 11)
				{
					$NCount = 1;
				}
			}
			else
			{
				echo htmlspecialchars(trim($line))."\n";
			}
		}
		echo "</TABLE>";
	}
	else
	{
		
		echo "<span class=titel>Geen gegevens gevonden voor<br> " . "$WeekDagL[$Kdag] " . "$DayToShow " . "$MonthNames[$MonthToShow] " . "$YearToShow" . "<br></span>";
		echo "<span class=tekst>(Dit betekent niet dat er geen wijzigingen kunnen zijn!!!)</span>";
		
	}
}
else
{
	if ("$Bestand" == "GROOTW.TXT")
	{
		echo "<PRE>" . "\n";
		readfile ("data/"."GROOTW.TXT");
		echo "</PRE>" . "\n";
	}
	elseif ("$Bestand" == "GROOTW.HTML")
	{
                	readfile ("data/"."GROOTW.HTML");
	}
}
echo "</td></tr></table>";

?><br><br>
	</td>
	<td width="15"></td>
	
</tr>
</table><?

#---[ Footer inladen ]---

	include("footer.php3");

?>
