<?php
if (!isset($_SESSION))
{
	session_start();
}
require_once('header.php');
echo "<h1>Catalogus instellen</h1>";
if ($aangemeld == "ja")
{
	if ($member_status == "manager")
	{
		if (ISSET($_POST['change']))
		{
			$csql = "SELECT * FROM catalogus WHERE id!=1 AND id!=2 AND id!=31 AND id!=32;";
			$cres = mysql_query($csql); 
			if (mysql_num_rows($cres) >= 1) 
			{
				while ($row = mysql_fetch_array($cres)) 
    			{
	    			if (ISSET($_POST['cat_'.$row['id']]))
	    			{
		   				$set = "ja";
    				}
    				else
    				{
	    				$set = "nee";
    				}
	    			mysql_query("UPDATE catalogus SET actief='".$set."' WHERE id='".$row['id']."';");
				}
			}
		}
		echo "<center>";
		echo "<form name='change_form' method='post' action='?'>";
		echo "<input type='hidden' name='change' value='change'>";
		echo "<table border='1' class='tabel'>";
		$csql = "SELECT * FROM catalogus WHERE id!=1 AND id!=2 AND id!=31 AND id!=32;";
		$cres = mysql_query($csql); 
		if (mysql_num_rows($cres) >= 1) 
		{
			while ($row = mysql_fetch_array($cres)) 
			{
    			echo "<tr>";
	    		echo "<td><img src='hotel/images/catalogus/logo/".$row['id'].".gif'></td>";
	    		if ($row['actief'] == "ja")
	    		{
		    		echo "<td><input type='checkbox' name='cat_".$row['id']."' checked></td>";
	    		}
	    		else
	    		{
		    		echo "<td><input type='checkbox' name='cat_".$row['id']."'></td>";
	    		}
    			echo "</tr>";
			}
		}
		echo "</table>";
		echo "<br><input type='submit' value='Wijzig'>";
		echo "</form>";
		echo "</center>";
	}
	else
	{
		action("probeert zonder rechten de catalogus in te stellen");
		echo "Oeps! Hiervoor moet je <b>manager</b> zijn.";	
	}
}
else
{
	echo "Oeps! Hiervoor moet je aangemeld zijn!";
}
require_once('footer.php');
?>