<?
	include("connection.php");

	$tijdarray = array(
		"12:00",
		"12:15",
		"12:30",
		"12:45",
		"13:00",
		"13:45",
		"18:00",
		"18:15",
		"18:30",
		"18:45",
		"19:00",
		"19:15",
		"19:30",
		"19:45",
		"20:00",
		"20:15",
		"20:30",
		"20:45",
		"21:00",
		
	);
	
	$string = $_GET['string'];
	list($dag, $maand, $jaar) = explode("/", $string);

	$query	= "SELECT tijden, tijden_nietbeschikbaar FROM tijd WHERE maand ='" . mysql_real_escape_string($maand) . "' AND jaar ='" . mysql_real_escape_string($jaar) . "' AND dag = '" . mysql_real_escape_string($dag) . "'";
	$result	= mysql_query($query);
	if(mysql_num_rows($result) > 0){
		$row = mysql_fetch_assoc($result);
		$array = explode(",", $row['tijden']);
		$array2 = explode(",", $row['tijden_nietbeschikbaar']);
		
		foreach($tijdarray as $tijd){
			if(in_array($tijd, $array)) {
				$totalarray[] = $tijd;
			} elseif(in_array($tijd, $array2)) {
				$totalarray[] = $tijd . "u (NIET BESCHIKBAAR)";
			} else {
				$totalarray[] = $tijd . "u (VOLZET)";
			}
		}
		
		echo json_encode($totalarray);
	} else {
		$array = $tijdarray;
		echo json_encode($array);
	}
?>