<%@ include file="/includes.jsp"%>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>
	<br/>
	<br/>
	<sec:authorize access="hasRole('ADMIN')">
	<smvc:form action="formDefinitionImport.form?${_csrf.parameterName}=${_csrf.token}" method="post" modelAttribute="formDefinitionImportBean" enctype="multipart/form-data">
		<input type="hidden" name="redirectParams" value="<c:out value="${requestScope['javax.servlet.forward.query_string']}"/>" />
		<table>
			<tr>
				<td class="error"><smvc:errors /></td>
			</tr>
		</table>
		<fieldset style="width: 500px" class="nobg">
			<legend>Import Form Definitions</legend>
			<fieldset>
				<table>
					<tr>
						<td>Import&#160;into&#160;group</td>
						<td>
							<smvc:select path="groupId">
								<c:forEach var="group" items="${emdt.formDomain.children}">
									<smvc:option value="${group.id}" label="${group.label}"><c:out value="${group.label}"/></smvc:option>
								</c:forEach>
							</smvc:select>
							<br/>
						</td>
					</tr>
					<tr>
						<td>File</td>
						<td><input type="file" name="data" title="Select an XML file containing eMDT Form Definitions" onchange="setFileSize(this);"/></td>
					</tr>
				</table>
			</fieldset>
			<fieldset class="buttonFieldset">
				<input type="submit" value="Start import" onclick="fullScreenPleaseWait()" />
			</fieldset>
		</fieldset>
		
		          <c:if test="${totalForms != null}">
                    <div class="message">
                    <table border="0" align="center" class="message">
                    <tr>
                    <td colspan="2">
                        <img src="../images/16x16/information.png" alt="i" />&#160;  
                        <c:if test="${totalForms == 1 }">There was 1 form definition in the import file</c:if>
                        <c:if test="${totalForms != 1 }">There were <c:out value="${totalForms}"/> form definitions in the import file</c:if>
                        </td>
                        </tr>
                        
                        <ul>
                        <c:if test="${numberOfInsertedForms != null}">
                        <tr>
                        <td width="10%">&#160;</td>
                        <td  nowrap="nowrap">
                             <li>Forms imported : <c:out value="${numberOfInsertedForms}"/></li>                       
                        </td>
                        </tr>
                        </c:if>

                        <c:if test="${numberOfDuplcateForms > 0}">
                        <c:if test="${numberOfDuplcateForms != null}">
                        <tr>
                        <td width="10%">&#160;</td>
                        <td nowrap="nowrap">
                                 <li>Duplicate form(s): <c:out value="${numberOfDuplcateForms}"/></li>
                        </td>
                        </tr>
                        </c:if>
                        <tr>
                        <td width="10%">&#160;</td>
                        <td  nowrap="nowrap">&#160;&#160;&#160;&#160;
                               Form name(s): <c:out value="${duplicateFormNames}"/>
                        </td>
                        </tr>
                        </c:if>
                        

                        <c:if test="${numberOfFailedForms > 0}">
                        <c:if test="${numberOfFailedForms != null}">
                        <tr>
                        <td width="10%">&#160;</td>
                        <td class="error" nowrap="nowrap">
                                <li>Imports Failed : <c:out value="${numberOfFailedForms}"/></li>
                        </td>
                        </tr>
                        </c:if>

                        <tr>
                        <td width="10%">&#160;</td>
                        <td  class="error" nowrap="nowrap">&#160;&#160;&#160;&#160;
                                Form name(s): <c:out value="${failedFormNames}"/>
                        </td>
                        </tr>
                        </c:if>
                        
                        </ul>
                        </table>
                    </div>
                </c:if>

	</smvc:form></sec:authorize>
