<%@ include file="/includes.jsp"%>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>
<sec:authorize access="hasRole('ADMIN')">
	<smvc:form action="ReportingExport.form" method="post">
		<input type="hidden" name="redirectParams" value="<c:out value="${requestScope['javax.servlet.forward.query_string']}" />" />
		<br/>
		<fieldset class="nobg" style="width: 45%; text-align: left"><legend>Reporting Export</legend>

		<fieldset class="buttonFieldset">
			<div align="left">
			This will export all patient information and forms to the external reporting database.<br/>
			This process may take some time.<br/><br/>
			To begin, click this button:
			</div>
			<c:choose>
				<c:when test="${requestScope.allowExport ne null and requestScope.allowExport eq true}">
					<input type="submit" name="startExport" value="Start export"  onclick="showPleaseWait();"/>
				</c:when>
				<c:otherwise>
					<input type="submit" disabled="disabled" name="startExport" value="Start export"  onclick="showPleaseWait();"/>
				</c:otherwise>
			</c:choose>
		</fieldset>

		<c:if test="${results != null or requestScope.message !=null}">
			
			<fieldset class="nobg">
				<legend>Results</legend>
			     <c:if test="${requestScope.message ne null}">
					<br/><div class="message"><img src="../images/16x16/information.png"
						alt="i" /> <c:out value="${requestScope.message}"/></div><br/>
				</c:if>
				<c:if test="${not empty results}">
				<div class="message">
					<img src="../images/16x16/information.png" alt="i" /> Result of export:
					<ul>
						<c:forEach var="row" items="${results }" varStatus="ss">
							<li><c:out value="${row}" /></li>
						</c:forEach>
					</ul>
				</div>
				</c:if>
			</fieldset>	
			
		</c:if> 
		<c:if test="${not empty errors}">
			<fieldset class="nobg">
			<img src="../images/16x16/error.png" alt="Error" /><font color="red"> Errors:</font>
			
			<ul>
				<c:forEach var="row" items="${errors }" varStatus="ss">
					<li><c:out value="${row}"/></li>
				</c:forEach>
			</ul>
			</fieldset>
		</c:if>
		</fieldset>
		
		<iframe id="waitframe" src="reports/pleaseWait.jsp" frameborder="0" width="200" style="visibility:hidden;" ></iframe>

		
	</smvc:form>

</sec:authorize>

