<%@page import="com.ardeo.entities.autoforms.FormField"%>
<%@ include file="/includes.jsp" %>
<tiles:importAttribute /><%--This imports all tiles atributes to page --%>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>
<input type="hidden" id="styleId" value="<c:out value="${field.style}"/>" />
<c:set var="fieldWritable" value="true"/>
<c:choose>
	<c:when test="${fieldWritable != 'true'}">
		<c:set var="disabled" value="true"/>
	</c:when>
	<c:otherwise>
		<c:set var="disabled" value="false"/>
	</c:otherwise>
</c:choose>
	<c:set var="readOnly" value="false"/>
<c:if test="${field.defaultValueMode==4 || consultationNoteForm.view.note.locked eq true}">
	<c:set var="readOnly" value="true"/>
</c:if>
<c:if test="${empty parentPage}">
	<c:set var="parentPage" value=""/>
</c:if>
<tr title='<c:out value="${field.description }"/>'>
	<c:set var="FormFieldNONE" value="<%= FormField.NONE %>"/>
	<c:set var="FormFieldSCORING" value="<%= FormField.SCORING %>"/>
	<c:choose>
	<c:when test="${field.inputType eq FormFieldNONE  && field.fieldType ne FormFieldSCORING}">
		<td class="label" colspan="2" height="1" align="<c:out value="${field.labelAlign }"/>" id="labelId">
			<c:if test="${not empty field.labelUrl}">
				<a href="<c:out value="${field.labelUrl }"/>">
			</c:if>
			<c:if test="${field.labelType eq 'text' }">
				<c:out value="${field.label}"/>
			</c:if>
			<c:if test="${field.labelType eq 'separator' }">
				<hr height="1" width="95%"/>
			</c:if>
			<c:if test="${not empty field.labelUrl}">
				</a>
			</c:if>
		</td>
	</c:when>
	<c:otherwise>
		<td class="label" align="<c:out value="${field.labelAlign }"/>" id="labelId">
			<c:if test="${not empty field.labelUrl}">
				<a target="_blank" href="<c:out value="${field.labelUrl }"/>">
			</c:if>
			<c:if test="${field.inputType ne 8 }">
				<c:if test="${field.labelType eq 'text' }"><c:out value="${field.label}"/>
				</c:if>
			</c:if>
			<c:if test="${field.labelType eq 'separator' }">
				<hr height="1" width="95%"/>
			</c:if>
			<c:if test="${not empty field.labelUrl}">
				</a>
			</c:if>
		</td>
		<td class="input">
			<c:choose>
				<c:when test="${isPrintPage}">
					<tiles:insertTemplate template='printFieldRenderer.jsp'>
						<c:if test="${field.inputType eq 5}">
							<tiles:putAttribute name="fieldOptionsMapName" value="${field.optionsMapName }" />
							<tiles:putAttribute name="fieldOptionsMapDomain" value="${field.optionsMapDomain }" />
						</c:if>
						<tiles:putAttribute name="fieldType" value="${field.fieldType }" />
						<tiles:putAttribute name="fieldInputType" value="${field.inputType }" />
						<tiles:putAttribute name="fieldName" value="${field.name }" />
					</tiles:insertTemplate>
				</c:when>
				<c:otherwise>
					<tiles:insertTemplate template='fieldRenderer${field.inputType}.jsp'>
						<tiles:putAttribute name="field" value="${field}" />
						<tiles:putAttribute name="fieldWritable" value="true" />
						<tiles:putAttribute name="disabled" value="${disabled}"/>
						<tiles:putAttribute name="readOnly" value="${readOnly}" />
						<tiles:putAttribute name="parentPage" value="${parentPage}" /> 
					</tiles:insertTemplate>
					<%-- START EDIT LIST BUTTON --%>
					 <sec:authorize access="hasAnyRole('ADMIN')">
						<c:if test="${field.inputType eq 5 and field.optionsMapDomain != 'SYSTEM' and field.optionsMapName != null and fn:length(field.optionsMapName) gt 0}">
							<webapp:namedList id="nl" domain="${field.optionsMapDomain}" name="${field.optionsMapName}" />
							<c:if test="${nl != null and nl.editable == true }">
								&nbsp;<a style="color: blue;" href="javascript:editList('<c:out value="${nl.domain}"/>', '<c:out value="${nl.name}"/>')"
								title="Edit list"><img src="../images/16x16/edit.png" alt="Edit list" border="0" /></a>
							</c:if>
						</c:if>
					</sec:authorize>
				</c:otherwise>
			</c:choose>
		</td>
	</c:otherwise></c:choose>
</tr>