<%@ taglib uri="/tags/struts-bean-el" prefix="bean-el" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html-el" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/tags/esr-core" prefix="esrcore" %>
<%@ taglib uri="/tags/fw" prefix="fw" %> 

<c:set var="requiredText"><bean-el:message key="label.required"/></c:set>
<c:set var="requiredFlag"><%= Boolean.TRUE.toString() %></c:set>
<script type="text/javascript">

function EditField()
{
  var elem = document.getElementById('passwordText');
  elem.disabled=false;
   elem.value="";
 }
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShell" role="presentation">
<html-el:form action="/serviceUser.do" method="post">	
<%@ include file="/admin/csrfgentoken.jsp" %>

<c:set var ="edit" value="true"/>
<c:if test="${empty serviceUserForm.userId}">
  <c:set var ="edit" value="false"/>
  </c:if>
  <tr>
    <td>
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTable" role="presentation">
        <tr>
          <td>
            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableHead" role="presentation">
              <tr>
	            <td class="moduleBlueBox">&nbsp;</td>
                 <c:choose>
                <c:when test="${edit == true}">
                 	 <td class="moduleHeadline" nowrap><bean-el:message key="label.eeService.edituser.mainHeader"/></td>
                  	  <td width="100%"></td>
               	 	 <td nowrap class="moduleBlueLink" style="padding: 1px 8px 1px 8px"><fw:link action="/serviceUser.do?methodName=displayNew"><bean-el:message
            key="text.serviceUserNew"/></fw:link></td>
           		 </c:when>
           		 <c:otherwise>
           			 <td class="moduleHeadline" nowrap><bean-el:message key="label.eeService.createuser.mainHeader"/></td>
              </c:otherwise>  
            </c:choose>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td>
    	    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="moduleShellTableBody" role="presentation">
                <tr>
                    <td colspan="2">
                      <%@ include file="/tiles/common/instructionalText.jsp" %>
                    </td>
                </tr>
    			<tr><td>&nbsp;</td></tr>	
    			<tr><td>&nbsp;</td></tr>	
    			 <c:choose>
                <c:when test="${edit == true}">
                  <c:set var="readOnlypassword" value="true"/>
                  </c:when>
				<c:otherwise>
				  <c:set var="readOnlypassword" value="false" />
				</c:otherwise>
				</c:choose>
    			<html-el:hidden  property="userId"/>				
				<tr>
					<td width="45%" class="moduleLabel"><fw:label required="${requiredFlag}" property="userName" forId="txtUserName"><bean-el:message 

key="label.eeServiceUsers.header.username" />:</fw:label></td>
					<td width="55%" class="moduleValue">
				    <c:set var="nameText"><bean-el:message key="label.eeServiceUsers.header.username"/></c:set>
						<html-el:text  title="${requiredText}${nameText}" property="userName" styleClass="moduleEdit" styleId="txtUserName" size="30" 

maxlength="25" />
					</td>
				</tr>
				<tr>
					<td width="45%" class="moduleLabel"><fw:label required="${requiredFlag}" property="password" forId="passwordText"><bean-el:message 

key="label.eeServiceUsers.header.password" />:</fw:label></td>
					<td width="35%" class="moduleValue">
				    <c:set var="passwordText"><bean-el:message key="label.eeServiceUsers.header.password"/></c:set>
						<html-el:password title="${requiredText} ${passwordText}" property="password" size="30" maxlength="25" styleId="passwordText"  

styleClass="moduleEdit" disabled="${readOnlypassword}" />
						  <c:choose>
             			   <c:when test="${edit == true}"><fw:label forId="changePasswordId" property="changePassword">Change Password</fw:label><input 

id="changePasswordId" type="checkbox" name="changePassword" onclick="EditField()">
              				</c:when>
           				 </c:choose>
					</td>
				</tr>
				<tr>
					<td width="45%" class="moduleLabel"><fw:label required="${requiredFlag}" property="contactName" forId="contactNameText"><bean-el:message 

key="label.eeServiceUsers.header.contactName" />:</fw:label></td>
					<td width="55%" class="moduleValue">
				    <c:set var="contactNameText"><bean-el:message key="label.eeServiceUsers.header.contactName"/></c:set>
						<html-el:text  title="${requiredText}${contactNameText}" property="contactName" styleClass="moduleEdit" styleId="contactNameText" 

size="30" maxlength="25" />
					</td>
				</tr>
				<tr>
					<td width="45%" class="moduleLabel"><fw:label required="${requiredFlag}" property="contactPhone" forId="contactPhoneText"><bean-el:message 

key="label.eeServiceUsers.header.phone" />:</fw:label></td>
					<td width="55%" class="moduleValue">
				    <c:set var="phoneText"><bean-el:message key="label.eeServiceUsers.header.phone"/></c:set>
						<html-el:text  title="${requiredText} ${phoneText}" property="contactPhone" styleClass="moduleEdit" styleId="contactPhoneText" 

size="30" maxlength="14" />
					</td>
				</tr>	
				 <tr>
            <td width="45%" class="moduleLabel">
             	<fw:label required="${requiredFlag}" property="active" forId="activeId"><bean-el:message key="label.eeServiceUsers.header.active" />:</fw:label>
             	<input name="activeId" id="activeId" type="hidden" value="none"/>
             </td>

					<td width="55%" class="moduleValue">
                        <c:set var="activeRadioButtonTitleBegin"><bean-el:message key="label.required"/>,<bean-el:message key="label.eeServiceUsers.header.active"/>,</c:set>
				        <c:set var="activeYesText"><c:out value="${activeRadioButtonTitleBegin}"/><bean-el:message key="label.eeServiceUsers.header.active.yes"/></c:set>
              			 <html-el:radio title="${activeYesText}" property="active" styleId="active_yes" value="true"><bean-el:message key="label.yes"/></html-el:radio>
                        <c:set var="activeNoText"><c:out value="${activeRadioButtonTitleBegin}"/><bean-el:message key="label.eeServiceUsers.header.active.no"/></c:set>
                        <html-el:radio title="${activeNoText}" property="active" styleId="active_no" value="false"><bean-el:message key="label.no"/></html-el:radio>
             </td>
          </tr>
           <tr></tr>
           <tr></tr>	
       <tr>
          
                <td class="moduleLabel" nowrap><bean-el:message key="label.eeService.edituser.selectRequest"/></td>
               
        </tr>        
        
        
        <c:forEach var="requestlite" items="${serviceUserForm.requestList}" >
        	<c:set var="requestId" value="${requestlite.requestId}" />
        	<c:set var="requestName" value="${serviceUserForm.selectedRequestMap[requestId]}}" />

        	
        	<c:choose>
	        	<c:when test="${serviceUserForm.selectedRequestMap[requestId] != null}">
				  <c:set var="reqSelected" value="CHECKED" />
				</c:when>
				<c:otherwise>
				  <c:set var="reqSelected" value="" />
				</c:otherwise>
			</c:choose>
        	
        	
        <tr>
               <!--    
				 <td class="moduleValue" style="padding:5 5 5 5"> 
					-->
					<td width="45%" class="moduleLabel">
						<input id="checkbox${requestId}" type="checkbox" name="selectedRequests" value="<c:out value="${requestId}"/>" <c:out 

value="${reqSelected}"/>	/>				
					</td>
					<td width="55%" class="moduleValue">
						<fw:label forId="checkbox${requestId}" property="selectedRequests"><c:out value="${requestlite.name}"></c:out></fw:label>
					</td>
        </tr>
        </c:forEach>
        
        
        
        
           <%-- Button Row --%>
           	
          <tr>
              	<td>&nbsp;</td>
						</tr>
						<tr>
							<td colspan=2>
							<table border="0" align="center" cellspacing="3" cellpadding="0" role="presentation">
								<tr>
								 <c:choose>
               					 <c:when test="${edit == true}">
									<td><img alt="" src="../images/buttonEndLeft.gif" /><html-el:submit 
									property="methodName" style="width:80; vertical-align: top;"
										styleClass="buttonText">
										<bean-el:message key="button.eeserviceUser.update" />
 										</html-el:submit><img alt="" src="../images/buttonEndRight.gif" />
									</td>
                           
                                  </c:when>
                                  <c:otherwise>
                                        <td><img alt="" src="../images/buttonEndLeft.gif" /><html-el:submit
                                         property="methodName" style="width:80; vertical-align: top;"
										styleClass="buttonText">
										<bean-el:message key="button.eeserviceUser.add" />
										</html-el:submit><img alt="" src="../images/buttonEndRight.gif" />
									</td>
								</c:otherwise>
                                </c:choose>
									<td><img alt="" src="../images/buttonEndLeft.gif" /><html-el:submit 
									property="methodName" style="width:50; vertical-align: top;" styleClass="buttonText">
                  						  <bean-el:message key="button.eeserviceUser.reset"/>
                						  </html-el:submit><img alt="" src="../images/buttonEndRight.gif" />
									</td>
									<td>
										<img alt="" src="../images/buttonEndLeft.gif" /><html-el:submit property="methodName" 

style="width:50; vertical-align: top;" styleClass="buttonText">
                   							 <bean-el:message key="button.eeserviceUser.cancel"/>
                 							 </html-el:submit><img alt="" src="../images/buttonEndRight.gif" />
									</td>

								</tr>
							</table>
                        	</td>
						</tr>
						<tr>
							<td>&nbsp;</td>
						</tr>
					</table>
					</td>
				</tr>
			</table>
			</td>
		</tr>
	</html-el:form>
</table>