<%@ page language="java"%>
<%@ taglib uri="struts-html" prefix="html"%>
<%@ taglib uri="struts-bean" prefix="bean"%>
<%@ taglib uri="struts-logic" prefix="logic"%>
<%@ taglib uri="vkc-taglib" prefix="vkc"%>
<%@ page import="org.apache.struts.Globals"%>
<%@ page import="vkc.administration.form.SystemMaintenanceForm"%>
<%@ page import="org.apache.struts.upload.FormFile"%>

<vkc:init />
 <script type="text/javascript" src="<vkc:rewrite page='/common/overlib/overlib.js'/>"><!-- overLIB (c) Erik Bosrup --></script>
<script type="text/javascript" src="<vkc:rewrite page='/common/overlib/overlib_positioncap.js'/>"></script>
<script type="text/javascript">
	function changeName(element){		
		document.getElementsByName(element.name)[0].value = element.value;		
	};
	 function showHelpText() {
    	var text = '<vkc:message javascript="true" filter="false" key="vkc.import.help"/>';
        
        return overlib( text, STICKY, SCROLLBARS, MOUSEOFF, HEIGHT, 150, WIDTH, 600, OFFSETX, 0, OFFSETY, 20, CENTER );
    }
</script>
<html:form action="/import" method="post" enctype="multipart/form-data">	
	<table align='left' width='100%' cellpadding='0' cellspacing='0'
		border='0'>	
		<html:hidden property="categoryId"/> 
		<bean:define id="form" name="importMaintenanceForm"
			type="vkc.administration.form.ImportMaintenanceForm" />	
		<html:hidden name="form" property="selectedContext"/>
		<html:hidden  name="form" property="step" />	
		<bean:define id="step" name="form" property="step" />
		<html:hidden  name="form" property="pathForObjects" />	
		<logic:iterate id="iun" name="form" property="importUserName" type="java.lang.String">
  			<html:hidden name="form" property="importUserName" value='<%=iun%>'/>
		</logic:iterate>
		<logic:iterate id="ign" name="form" property="importGroupName" type="java.lang.String">
  			<html:hidden name="form" property="importGroupName" value='<%=ign%>'/>
		</logic:iterate>		
		<logic:present name="succeeded">
			<tr>
				<td colspan="2" bgcolor="#77D369" align="center"><font
					color="white"><b><vkc:write name="succeeded" /></b></font></td>
			</tr>
			<tr>
				<td align="left" nowrap="nowrap" colspan="2">&nbsp;</td>
			</tr>
		</logic:present>
		<logic:notPresent name="succeeded">
			<logic:equal name="step" value="1">
				<table>
					<td align="left" valign="top" nowrap="nowrap"><b><vkc:message
									key="vkc.administration.systemmaintenance.import.selectedcategory" />:</b></td>
								<td width="100%" align="left" valign="top" colspan="4">
								<table cellpadding="0" cellspacing="0" border="0">
									<tr>
										<td><vkc:image page="/templates/${template.name}/gfx/navigator.gif"	property="btn_explorer"	onclick="this.blur();return showExplorer();" titleKey="vkc.string.show.explorer" /></td>
										<td>&nbsp;</td>
										<td><vkc:link page="/showCategory.do" name="form" property="importCategoryParams">
											<vkc:write name="form" property="categoryPath" />
										</vkc:link></td>
									</tr>
								</table>
								</td>
								</tr>
								<tr>
									<td align="left" nowrap="nowrap" ><b><vkc:message
										key="vkc.document.file" />:</b>&nbsp;<vkc:img
										page="/templates/${template.name}/gfx/mandatoryField.gif" alt="*"
										border="0" /></td>
									<td width="100%" align="left"><html:file name="form"
										property="importFile" size="50" /></td>
								</tr>
								<tr>
									<td nowrap="nowrap"><b><vkc:message
										key="vkc.administration.systemmaintenance.import.conflictSolution" />:</b></td>
									<td nowrap="nowrap"><html:checkbox property='selfNameGen' /></td>
								</tr>
					
								<tr>
									<td align="left">
										<vkc:button property="action.import" onclick="javascript:disableAllButtonsAndSubmit(this);">
											<vkc:message key="vkc.administration.button.import" />
										</vkc:button>
									</td>
								</tr>	
				</table>		
			</logic:equal>				 
			<logic:equal name="step" value="2">			
				 <table  border="0" cellspacing="0" cellpadding="0">
				 	
				 	<logic:notEmpty name="form" property="userConflictNames">
				 	
				 		<tr>
				 			<td>
				 				<table border="0" cellspacing="0" cellpadding="0">
				 					<tr>
						 			<td><b><vkc:message key="vkc.administration.systemmaintenance.import.namesconflicts"/>:</b></td>
						 			<td align="rigth">
		                  				<vkc:img page="/templates/${template.name}/gfx/help.bmp" onmouseover='return showHelpText();' onmouseout="return nd();" width="16" height="16" border="0"/>
		               				</td>		
		               				</tr>
		               			</table>	
		               		</td>			
						</tr>
						<tr>
					 		<td><b><vkc:message key="vkc.administration.systemmaintenance.import.importeduser"/>:</b></td>
					 		<td><b><vkc:message key="vkc.administration.systemmaintenance.import.newname"/>:</b></td>
					 		<td><b><vkc:message key="vkc.administration.systemmaintenance.import.existinguser"/>:</b></td>
				 		</tr>
						<bean:define id="userInfos" name="form" property="userInfos" type="java.util.Collection"/>
						
						<logic:iterate name="form" property="userConflictNames" id="userName" type="org.apache.struts.util.LabelValueBean">
							<tr>
								<vkc:hidden name="userName" property="label" indexed="true"/>
								<td width="30%"><vkc:write name="userName" property="label" /></td>
								<td width="30%"><vkc:text name="userName" property="value" indexed="true" styleClass="inputField" maxlengthProperty="user.username"/></td>
								<td width="40%">
									<html:select name="userName" property="value" indexed="true" onchange='<%="javascript:changeName(this);"%>'>
										<vkc:optionsCollection name="form" property="userInfos" value="value"/>
									</html:select>
								</td>
							<td>	
						</logic:iterate>
					</logic:notEmpty>
					<logic:notEmpty name="form" property="groupConflictNames">
						<tr>							
							<td width="30%"><b><vkc:message key="vkc.administration.systemmaintenance.import.importedgroup"/>:</b></td>
					 		<td width="30%"><b><vkc:message key="vkc.administration.systemmaintenance.import.newname"/>:</b></td>
					 		<td width="40%"><b><vkc:message key="vkc.administration.systemmaintenance.import.existinggroup"/>:</b></td>
						</tr>	
											
						<logic:iterate name="form" property="groupConflictNames" id="groupName" type="org.apache.struts.util.LabelValueBean">
							<tr>
							<vkc:hidden name="groupName" property="label" indexed="true"/>
								<td><vkc:write name="groupName" property="label"/></td>
								<td><vkc:text name="groupName" property="value" indexed="true" styleClass="inputField" maxlengthProperty="group.name"/></td>								
								<td>
									<html:select name="groupName" property="value" indexed="true" onchange='<%="javascript:changeName(this);"%>'>
										<vkc:optionsCollection name="form" property="groupInfos" value="value"/>
									</html:select>
								</td>
						</logic:iterate>
					</logic:notEmpty>
					<!-- 
						<tr>
							<td colspan="3"><b><vkc:message key="vkc.administration.systemmaintenance.import.note"/></b></td>
						</tr>
					 -->
						<tr>
							<td align="left"><vkc:button property="action.import" onclick="javascript:disableAllButtonsAndSubmit(this);">
							<vkc:message key="vkc.administration.button.import" />
							</vkc:button></td>
						</tr>
				</table>

			</logic:equal>
		</logic:notPresent>
	</table>
</html:form>
