<%@ page contentType="text/html; charset=ISO-8859-15" language="java" %>
<%@ include file="/header.jsp" %>

<h2>>> Users >> Edit</h2>

<%@ include file="navigation.jsp" %>

<%@ include file="errors.jsp" %>
<br>

<html:form action="/user/UserRH.do" method="post">
<html:hidden property="userId"/>

<table cellpadding="2">
	<tr>
		<td align="right" width="500">
			<html:submit property="Save" value=" Save "/>
		</td>
	</tr>
</table>

<table cellpadding="2">
	<c:choose>
		<c:when test="${administrator}">
			<tr>
				<td align="right"><b>ID</b></td>
				<td align="left">
					<c:choose>
						<c:when test="${userForm.userId == 0}">-</c:when>
						<c:otherwise><c:out value="${userForm.userId}"/></c:otherwise>
					</c:choose></td>
			</tr>
			<tr>
				<td align="right"><b>Enabled</b></td>
				<td align="left">
					<html:radio property="enabled" value="true"/>yes
					<html:radio property="enabled" value="false"/>no</td>
			</tr>
			<tr>
				<td align="right"><b>Administrator</b></td>
				<td align="left">
					<html:radio property="administrator" value="true"/>yes
					<html:radio property="administrator" value="false"/>no
					<b class="gray">(report/edit projects and users)</b></td>
			</tr>
			<tr>
				<td align="right"><b>Guest</b></td>
				<td align="left">
					<html:radio property="guest" value="true"/>yes
					<html:radio property="guest" value="false"/>no
					<b class="gray">(prevent editing account, disable emails)</b></td>
			</tr>
		</c:when>
		<c:otherwise>
			<html:hidden property="enabled"/>
			<html:hidden property="administrator"/>
			<html:hidden property="guest"/>
		</c:otherwise>
	</c:choose>
	<tr>
		<td align="right"><b>Name</b></td>
		<td align="left">
			<html:text property="name" size="40" maxlength="64"/></td>
	</tr>
	<tr>
		<td align="right"><b>New password</b></td>
		<td align="left">
			<html:password property="password1" size="40" maxlength="64"/>
			&nbsp;(fill in only to change the password)</td>
	</tr>
	<tr>
		<td align="right"><b>Password verification</b></td>
		<td align="left">
			<html:password property="password2" size="40" maxlength="64"/></td>
	</tr>
	<tr>
		<td align="right"><b>Email</b></td>
		<td align="left">
			<html:text property="email" size="40" maxlength="128"/></td>
	</tr>

	<c:if test="${administrator && userForm.userId != 0}">
		<tr>
			<td colspan="2" height="20"><spacer height="20"></td>
		</tr>
		<tr>
			<td align="left" valign="top"><b>Project Roles</b></td>
			<td align="left">
				<c:if test="${not empty projectsWithoutRole}">
					<html:select property="newProjectId">
						<html:options collection="projectsWithoutRole" property="id" labelProperty="name"/>
					</html:select>&nbsp;&nbsp;<html:submit property="Add" value=" Add "/>
				</c:if>
			</td>
		</tr>
		<c:forEach items="${projectsWithRole}" var="project">
			<tr>
				<td align="right"><b><c:out value="${project.name}"/></b></td>
				<td align="left">
					<html:multibox property="managerProjects" value="${project.id}"/>Manager
					<html:multibox property="developerProjects" value="${project.id}"/>Developer
					<html:multibox property="reporterProjects" value="${project.id}"/>Reporter
					<c:set var="removeUrl">
						<c:url value="/user/UserRH.do">
							<c:param name="Remove" value="true"/>
							<c:param name="userId" value="${userForm.userId}"/>
							<c:param name="projectId" value="${project.id}"/>
						</c:url>
					</c:set>
					&nbsp;&nbsp;<a href="${removeUrl}">Remove</a></td>
			</tr>
		</c:forEach>
	</c:if>
</table>

</html:form>

<c:if test="${administrator && userForm.userId != 0}">
	<b class="gray">Manager: Edit issues, assign/unassign issues.</b><br>
	<b class="gray">Developer: Process assigned issues.</b><br>
	<b class="gray">Reporter: Create (report) issues.</b>
</c:if>

<%@ include file="/footer.jsp" %>
