<%@ include file="/includes.jsp"%>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>
	<script type="text/javascript">

        function selectAllOrNone(option){
        var max = 0;
            if(document.forms[0].userIds != null)
            {
                max = document.forms[0].userIds.length;
            }
            for(var idx=0; idx<max; idx++)
            {
                 var ckbox = eval("document.getElementById('importLdapUserForm').userIds["+idx+"]");
                 if(option == 'ALL'){
                 ckbox.checked = true;
                 }else if(option == 'NONE'){
                 ckbox.checked = false;
                 }
            }
        }

	</script>
	<br/>
	<br/>
	
	<c:if test="${!empty exportProblem and importProblem == 'noUserSelected'}" >
		<div id="exportProblem">
		<fieldset style="width: 380px" class="nobg" >
			<table align = "left">
				<tr><td>
					<span class="error" >
						Please select a user to import.
					</span>
				</td></tr>
			</table>
		</fieldset>
		</div>
	</c:if>
		<c:if test="${!empty successMessage and successMessage == 'importSuccessfull'}" >
		<div id="exportProblem">
		<fieldset style="width: 380px" class="nobg" >
			<table align = "left">
				<tr><td>
					<span >
					 	Users imported Successfully from AD.
					</span>
				</td></tr>
			</table>
		</fieldset>
		</div>
	</c:if>
	<form id="importLdapUserForm" action="importldapUsers.form">
	<input type="hidden" id="importLdapUsers" name="importLdapUsers" value="true"/>
	<input type="hidden" id="selectedUserIds" name="selectedUserIds" value=""/>
	<table border="0" width="40%">
		<tr>
			<td>
			<fieldset class="nobg"><legend>Import Ldap user login accounts</legend>
			<fieldset>
			<table border="0" width="100%" style="border-color: #F8F8FF" >
			     <tr>
                        <th style="font-size: 10pt;" align="center" width="15%">Select:</th>    
                        <td align="left" colspan="2" width="35%"><a onclick="selectAllOrNone('ALL');" style="cursor: pointer">All, </a>
                        <a onclick="selectAllOrNone('NONE');" style="cursor: pointer">None</a></td>
                    </tr>
				<tr>
				    <th style="font-size: 10pt;" align="left" width="15%">&#160;</th>
					<th style="font-size: 10pt;" align="left" width="35%">Username</th>
					<th style="font-size: 10pt;" align="left" width="40%"> Full name</th>
				</tr>
				<c:forEach var="user" items="${ldapUserList }">
					<tr valign="top">
					   <td align="center" valign="middle" width="15%"><input type="checkbox" name="userIds" value="<c:out value="${user.externalLdapId}"/>" /></td>    
						<td align="left"  width="35%"><c:out value="${user.username}"/>&#160;</td>
						<td align="left" width="40%"><c:out value="${user.name }"/>&#160;</td>
					</tr>
				</c:forEach>
			</table>
			</fieldset>
			<fieldset class="buttonFieldset">
			<table border="0">
			<tr>
			<th style="font-size: 10pt;" align="center" width="15%">Select:&#160;</th>    
            <td align="left" width="35%"><a onclick="selectAllOrNone('ALL');" style="cursor: pointer">All, </a>
            <a onclick="selectAllOrNone('NONE');" style="cursor: pointer">None</a></td>
            <td align="right">
            <input type="submit"
				value="Export Users"/>
			</td>
			</tr>
			</table>
			</fieldset>
			</fieldset>
			</td>
		</tr>
	</table>
	</form>
