<%@ include file="/includes.jsp" %>
<jsp:useBean id="helper" scope="page" class="com.ardeo.autoforms.FileUploadDispatcher"/>

<!-- printForm.jsp -->

<style>
.printFormPart {
	padding: 0;
}

.printFormDefinitionPropertyName {
	font-size: 10pt;
	font-weight: bold;
	color: #555;
	margin-left:	10px;
}

.printFormDefinitionPropertyValue {
	font-size: 10pt;
	font-weight: normal;
	color: #555;
}

.printFormDefinition {
	border: 1px solid grey;
    background-color: #f0f5fB;
	width: 100%;
}

.printFormDefinitionSection {
	border: 1px solid lightgrey;
	width: 100%;
	padding: 10px;
}
table.printFormDefinitionSection td {
	padding-bottom:	10px;
}

.printFormDefinitionSectionTitle {
	color:	#8ab2b8;
	font-size: 12pt;
	font-weight: bold;
	padding: 1px 2px 1px 2px;
}

.printPatientSectionTitle {
	color:	#8ab2b8;
	
	font-size: 12pt;
	font-weight: bold;
	margin-top: 10px;
}

.printFormPageTitle {
	display: none;
	font-size: 14pt;
	padding: 1px 2px 1px 10px;
}

.printFormDefinitionTitle {
	color:	#8ab2b8;
	font-size: 16pt;
	text-align: left;
	margin: 5px;
	margin-bottom: 20px;
}

.printFormFieldLabel {
	width: 50%;
	font-weight: bold;
	vertical-align: top;
}
.printFormFieldValue {
	width: 50%;
	vertical-align: top;
}
</style>
<c:set var="definition" value="${emdt.meetingForm }"/>
<c:if test="${not empty definition.colourCode}">
	<style>
		.formBgColor {
			background-color: ${definition.colourCode}
		}
	</style>
</c:if>

<c:choose>
	<c:when test="${empty printMeetingNote.id}">
		(Form is empty)
	</c:when>
	<c:otherwise>

		<div class="printFormPart" align="center" style="page-break-after: always">
			<div class="printFormDefinition" align="left">
				<div class="printFormDefinitionTitle formBgColor">
					<c:out value="${definition.label}"/>
				</div>
				<span class="printFormDefinitionPropertyName">Date Created: </span><span class="printFormDefinitionPropertyValue"><fmt:formatDate value="${printMeetingNote.creationDate }" type="date" pattern="dd/MM/yyyy HH:mm" /></span><br/>
				<span class="printFormDefinitionPropertyName">Date Last Modified: </span><span class="printFormDefinitionPropertyValue"><fmt:formatDate value="${printMeetingNote.modifiedDate }" type="date" pattern="dd/MM/yyyy HH:mm" /></span>

				<br/>
				<br/>
				<c:forEach var="page" items="${definition.children }">
					<div >
						<div class="printFormPage" align="left">
							<div class="printFormPageTitle formBgColor">
								<c:out value="${page.label}"/>
							</div>
							<c:forEach var="section" items="${page.children }">
								<div class="printFormPart" align="center">
									<table class="printFormDefinitionSection">
										<tr>
											<td colspan="2" class="printFormDefinitionSectionTitle formBgColor" align="left">
												<c:out value="${section.label }"/>
											</td>
										</tr>

										<c:forEach var="field" items="${section.children }">

											<tr>
												<td class="printFormFieldLabel" align="left">&nbsp;&nbsp;<c:out value="${field.label }"/></td>
												<td class="printFormFieldValue" align="left">

													<c:forEach var="value" items="${printMeetingNote.values[field.name].valueArray }">
														<c:choose>
															<c:when test="${field.inputType eq 5}">
																<webapp:listValue listName="${field.optionsMapName }" key="${value.code }" domain="${field.optionsMapDomain }"></webapp:listValue>
															</c:when>
															<c:when test="${field.inputType eq 9}">

																<c:forTokens var="filesName" items="${value.code}" delims="|" varStatus="status">

																<c:set var="dotIndex" value="${fn:indexOf(filesName, '.') }"/>
																<c:set var="displayFile" value="${fn:substring(filesName, 37, dotIndex-21)}"/>
																<c:set var="displayExt" value="${fn:substring(filesName, dotIndex, fn:length(filesName))}"/>
																<img src="../images/16x16/page.png" alt="Document" /> <c:out value="${displayFile}"></c:out><c:out value="${displayExt}"></c:out><br/>
																</c:forTokens>
															</c:when>
															<c:otherwise>
																<c:set var="newline" value="<%='\n'%>" />
																<div style="vertical-align: top;"><pre><c:out value="${value.code }"/></pre></div>
															</c:otherwise>
														</c:choose>
													</c:forEach>
												</td>
											</tr>
										</c:forEach>
									</table>
								</div>
							</c:forEach>
						</div>
					</div>
				</c:forEach>


			</div>
		</div>
	</c:otherwise>
</c:choose>
