<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<html>
<head>
<title>${project.description} - Project Access</title>
<style type="text/css">
@import "/WEB-CONTENT/CSS/layout.css";
</style>
<link rel="stylesheet"
	href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script>
	$(function() {

		jQuery.ajax({
			type : "GET",
			dataType : "json",
			url : '/json/allUsers',
			success : function(data, statusText) {
				$("#username").autocomplete({
					source : data
				});
			},
			error : function(xhr, ajaxOptions, thrownError) {
				alert('Fout tijdens het ophalen van de content');
			}
		});
	});
</script>
</head>
<body>
	<div id="container">
		<%@include file="/WEB-CONTENT/header.jsp"%>
		<div id="content" class="rounded-corners">
			<h1>
				Project Access: ${project.description}
			</h1>
			<h2>Set Access Role</h2>
			<div class="span-12 last">
				<form:form modelAttribute="projectAccess" action="access/set"
					method="post">
					<form:hidden path="projectIdGenerated" />
						<form:label for="username" path="username" cssErrorClass="error">User</form:label>
						<form:input path="username" id="username" />
						<form:label for="role" path="role" cssErrorClass="error">Role</form:label>
						<form:select path="role" items="${accessRoles}" />
						<input type="submit" />
				</form:form>
			</div>
			<h2>Overview</h2>
			<ul>
				<c:forEach items="${projectAccessList}" var="projectAccess">
					<li><c:forEach items="${userList}" var="userb">

							<c:if test="${userb.id == projectAccess.userId}">
								${userb.username}
							</c:if>
						</c:forEach> (${projectAccess.role})</li>
				</c:forEach>
			</ul>
		</div>
		<%@include file="/WEB-CONTENT/footer.jsp"%>
	</div>
</body>
</html>