<%@ include file="/includes.jsp" %>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>

<script language="javascript">
	function updateSelection() {
		dispatch("updateSelection");
		return document.getElementById("form").submit();
	}
</script>
<style>
	.invTitle {
		padding:	8px;
	}
	
	.invGo {
		text-align: right;
	}
</style>
<br/>
<sec:authorize access="hasRole('ADMIN')">
<smvc:form action="../admin/inventorySelection.form" id="form" modelAttribute="inventorySelectionForm">
	<input type="hidden" name="redirectParams" value="<c:out value="${requestScope['javax.servlet.forward.query_string']}" />" />
	<input type="hidden" name="method" value="formInventory" id="dispatchMethod"/>
	<table width="700">
		<tr>
			<td>
			<div class="dialogBox">
			<div class="dialogTitle">Select Inventory..</div>
				<div class="dialogContent">

					<table width="100%">
						<tr>
							<td class="invTitle">Form Inventory</td>
							<td class="invOptions">
								Form Group:&nbsp;
								<smvc:select path="fiGroup" onchange="return updateSelection()">
									<smvc:option value="">All</smvc:option>
									<c:forEach var="group" items="${inventorySelectionForm.formGroups}">
										<smvc:option value="${group.path}"><c:out value="${group.label}"/></smvc:option>
									</c:forEach>
								</smvc:select>&nbsp;
								Forms:&nbsp;
								<smvc:select path="fiForm">
									<smvc:option value="">All</smvc:option>
									<c:forEach var="def" items="${inventorySelectionForm.forms}">
										<smvc:option value="${def.path}"><c:out value="${def.label}"/></smvc:option>
									</c:forEach>
								</smvc:select>
							</td>
							<td class="invGo">
								<input type="submit" value="Go" onclick="return dispatch('formInventory')"/>
							</td>
						</tr>
						<tr>
							<td class="invTitle" colspan="2">
								Fields with missing lists
							</td>
							<td class="invGo">
								<input type="submit" value="Go" onclick="return dispatch('noListDefined')"/>
							</td>
						</tr>
						<tr>
							<td class="invTitle" colspan="2">
								Fields with empty lists
							</td>
							<td class="invGo">
								<input type="submit" value="Go" onclick="return dispatch('emptyList')"/>
							</td>
						</tr>
						<tr>
							<td class="invTitle" colspan="2">
								List usage
							</td>
							<td class="invGo">
								<input type="submit" value="Go" onclick="return dispatch('listUsage')"/>
							</td>
						</tr>
                        <tr>
                            <td class="invTitle" colspan="2">
                                Form Usage
                            </td>
                            <td class="invGo">
                                <input type="submit" value="Go" onclick="return dispatch('formUsage')"/>
                            </td>
                        </tr>
					</table>
				</div>
				</div>
			</td>
		</tr>
	</table>
</smvc:form></sec:authorize>