<%@ include file="/includes.jsp" %>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>
<tr>
	<td class="label">Button Style</td>
	<td class="input">
		<smvc:select path="formField.fieldType" onchange="update()">
			<smvc:option  value="104">Calculation</smvc:option >
			<smvc:option  value="105">Invoke Function</smvc:option >
		</smvc:select>
		 &nbsp;	<a href="../help/form-admin.smvc#Button" title="Help on calculations" target="_blank"><img src="../images/16x16/help.png" alt="Help" border="0"/></a>
	</td>
</tr>
<c:if test="${formObjectForm.formField.fieldType eq 104}">
<tr>
	<td class="label">Calculation</td>
	<td class="input">
		<a id="showHelp"><img src="../images/16x16/help.png" alt="Help" border="0"/> show help</a>
		 <p style="width: 40em; display: none;" id="help">
		 A Button Calculation field has a multi-line box displayed while you are in the Form Editor into which you can enter a calculation, but is actually just displayed as a button when a user is looking at your form.<br/>
		This type of field enables you to perform mathematical calculations based on the values of your fields and to put the result of the calculation into another field when the user presses the button. You can refer to the fields in your form by name, just like variables in an equation.<br/>
		As an example, imagine we have two number fields, 'weight' and 'height', and we want to calculate the BMI value and put this into a third number field, called 'MyBMIResult'. A calculation for this could be:<br/>
		<br/>
		<code>MyBMIResult = weight/(height * height)</code>
		<br/> <br/>
		<a href="../help/calculations.html" title="Calculations" target="_blank">More information on Calculations</a>
		</p>
	</td>
</tr>
<tr>
	<td class="label"></td>
	<td class="input">
		<smvc:textarea rows="6" cols="30" path="formField.pattern" title="Enter a calculation to be executed when this button is pressed."/>
	</td>
</tr>
<tr>
	<td class="label">
	</td>
	<td class="input">
	<a id="showFields"><img src="../images/16x16/information.png" alt="Help" border="0"/> List fields on this form...</a>
	<div id="fieldsList" style="display: none;">
		<c:set var="cf" value="${formObjectForm.formField.parent.parent.parent}"/>
		<table style="width: 40em;">
			<tr>
				<th>Field name</th><th>Description</th>
			</tr>
		<c:forEach var="otherObj" items="${cf.toFlatList()}">
			<c:if test="${(otherObj.type eq 5)}">
				<tr>
					<td><c:out value="${otherObj.name}"/></td><td><c:out value="${otherObj.label}"/></td>
				</tr>
			</c:if>
		</c:forEach>
		</table>
	</div>
	</td>
</tr>
</c:if>
<c:if test="${formObjectForm.formField.fieldType eq 105}">
<tr>
	<td class="label">Choose a function</td>
	<td class="input">
		<smvc:select path="formField.pattern" title="Select the function to be executed when this button is pressed.">
			<smvc:option  value="appointmentsLookup">Chemo Appointments query</smvc:option >
			<smvc:option  value="anotherfunc">Testing, do not use</smvc:option >
		</smvc:select>
	</td>
</tr>
<tr>
	<td class="label"></td>
	<td class="input">
		<div><img src="../images/16x16/help.png" alt="Help" border="0"/> Select a system function to invoke when this button is clicked.<br/>
		</div>
	</td>
</tr>
</c:if>

	
<script type="text/javascript">
$("#showFields").click (function () {
	$("#fieldsList").toggle();
});
$("#showHelp").click (function () {
	$("#help").toggle();
});

</script>