<%@ include file="/includes.jsp"%>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>
<br />
<sec:authorize access="hasRole('ADMIN')">
<smvc:form action="/admin/updateRoles" modelAttribute="rolesForm">
	<input type="hidden" name="redirectParams" value="<c:out value="${requestScope['javax.servlet.forward.query_string']}" />" />
 	<c:if test="${successMsg ne null }">
       <span class="info"><c:out value="${successMsg}"/></span><br>
    </c:if>
	<c:if test="${errorMsg ne null}">
		<div class="error"><img src="../images/16x16/error.png" alt="!"
			border="0" />&nbsp;&nbsp;<c:out value="${errorMsg}"/></div>
	</c:if>
	<table width="50%">
		<tr>
			<td>
			<h3>Roles Inventory - Role usage by User
			</h3>
			</td>
		</tr>
		<tr>
			<td><c:forEach var="role" items="${rolesForm.userListByRole}"
				varStatus="s">
				<c:if test="${role.key !=null}">
					<fieldset>
					<table width="100%">
						<tr>
							<td valign="top" colspan="4"><legend><c:out value="${role.key}"/></legend></td>
						</tr>
						<tr>
							<td><br /></td>
						</tr>
						<c:choose>
							<c:when test="${role.value!=null and (fn:length(role.value))>0}">
								<c:forEach var="user" items="${role.value}" varStatus="s1">
									<tr>
										<td width="10%"><a href="userform.form?userId=${user.guid}"><c:out value="${s1.index+1}"/>)</a></td>
										<td width="20%"><a href="userform.form?userId=<c:out value="${user.guid}"/>"><c:out value="${user.username}"/></a></td>
										<td width="35%"><c:out value="${user.fullName}"/></td>
										<td width="35%"><c:out value="${user.hospital.hospitalName}"/></td>
									</tr>
								</c:forEach>
							</c:when>
							<c:otherwise>
								<tr>
									<td width=3%></td>
									<td>No users have this role.</td>
								</tr>
							</c:otherwise>
						</c:choose>
					</table>
					</fieldset>
				</c:if>
			</c:forEach></td>
		</tr>
	</table>
</smvc:form></sec:authorize>
