<?php
if (!isset($_SESSION))
{
	session_start();
}
require_once('header.php');
echo "<h1>Catalogus instellen</h1>";
if ($aangemeld == "ja")
{
	if ($member_status == "manager")
	{
		if (ISSET($_GET['id']))
		{
			if (ISSET($_POST['change']))
			{
				$csql = "SELECT * FROM prijslijst WHERE cat=".$_GET['id'].";"; 
				$cres = mysql_query($csql); 
				if (mysql_num_rows($cres) >= 1) 
				{
					while ($row = mysql_fetch_array($cres)) 
    				{
	    				if (ISSET($_POST['furni_'.$row['catnr']]))
	    				{
		    				$set = "ja";
	    				}
	    				else
	    				{
		    				$set = "nee";
	    				}
		    			mysql_query("UPDATE prijslijst SET actief='".$set."' WHERE cat='".$_GET['id']."' AND catnr='".$row['catnr']."';");
					}
				}
			}
			echo "<center>";
			echo "<a href='furni_control.php'><img src='hotel/images/catalogus/logo/".$_GET['id'].".gif'></a><br><br>";
			echo "<form name='change_form' method='post' action='?id=".$_GET['id']."'>";
			echo "<input type='hidden' name='change' value='change'>";
			echo "<table border='1' class='tabel'>";
			$csql = "SELECT * FROM prijslijst WHERE cat=".$_GET['id'].";"; 
			$cres = mysql_query($csql); 
			if (mysql_num_rows($cres) >= 1) 
			{
				while ($row = mysql_fetch_array($cres)) 
    			{
	    			echo "<tr>";
		    		echo "<td><img src='hotel/images/items/".$_GET['id']."/".$row['catnr']."/icon.gif'></td>";
		    		if ($row['actief'] == "ja")
		    		{
			    		echo "<td><b>".$row['naam']."</b></td>";
		    		}
		    		else
		    		{
			    		echo "<td>".$row['naam']."</td>";
		    		}
		    		if ($row['actief'] == "ja")
		    		{
			    		echo "<td><input type='checkbox' name='furni_".$row['catnr']."' checked></td>";
		    		}
		    		else
		    		{
			    		echo "<td><input type='checkbox' name='furni_".$row['catnr']."'></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');
?>