<%@ include file="/includes.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>
<c:set var="namedLists" value="${dbListForm.databaseNamedLists}"/>

<head>
<title>Edit Database List Row</title>
<link rel="stylesheet" href="../webapp.css" type="text/css" />
<script src="../js/webapp.js" type="text/javascript"></script>
<script>
		//<!--
			var requiresUpdate = false;
		
			function moveItem(id, amount) {
				
				document.getElementById("dispatchMethod").value = "move";
				document.getElementById("moveId").value = id;
				document.getElementById("moveAmount").value = amount
				document.getElementById("form").submit();
			}
			
			function doUpdate() {
				if(requiresUpdate) {
					updateParent();
				}
			}
			
			function doDelete() {
				requiresUpdate = true; 
				if(confirmAndDispatch('delete', 'Are you sure you wish to remove the selected items?')) {
					document.getElementById("form").submit();
				}
				return false;
			}
			function doSave()
            {
                document.getElementById("dispatchMethod").value = "save";
                return false;
            }
			function doCancel()
			{
				history.go(-1)
				return false;
			}
		//-->
		</script>
<style type="text/css">
.sortable {
	background-color: #eee;
	font-size: 16pt;
}

.odd {
	background-color: #ddd;
}

.even {
	background-color: #eee;
}
.pageLinks  {
	color: green;
}
.pageLinks a {
	color: orange;
}

.pageBanner  {
	color: blue;
	display:	block;
}
td	{
	padding: 5 5 5 5;
	background-color: #eee;
}
.title	{
	font-size:	14pt;
	font-weight:	bold;
}


</style>




</head>
<body style="margin: 0 0 0 0" onload="window.focus()">
	
<smvc:form action="/admin/editDBListItem.form?domain=${dbListForm.namedList.domain}&name=${dbListForm.namedList.name }" id="form">
	 	<input type="hidden" name="redirectParams" value="<c:out value="${requestScope['javax.servlet.forward.query_string']}" />" />
	 <center>
    	<br />
            <div class="title">Editing list :  <c:out value="${dbListForm.name}"/></div>
    
			<smvc:hidden path="domain" />
			<smvc:hidden path="name" />
			<smvc:hidden path="mode" />
			<input type="hidden" name="method" value="filter" id="dispatchMethod" />
			<c:if test="${errorMsg!=null}">
				<div class="error"><br/><c:out value="${errorMsg}"/></div><br>
			</c:if>
			<div class="info"><c:out value="${succesMsg}"/></div><br>
			<c:set var="primKey" value="${dbListForm.keyFieldName}"/>
			<br />
			<table border="1">
                <c:forEach var="colName" items="${dbListForm.columnNames}" varStatus="status" >
                <tr>
			       <td><c:out value="${colName}"/> </td> 
			       <td>
			       <c:choose>
			       	 <c:when test="${dbListForm.namedList.autoflag eq 1 and primKey ne null and primKey eq colName }">
			       	 	<c:out value="(read-only)"></c:out>
			       	 	<c:if test="${dbListForm.mode ne null and dbListForm.mode eq 'edit'}">
			       	 		<input type="hidden" name="<c:out value="${dbListForm.columnNames[status.count-1]}"/>" value="<c:out value="${dbListForm.columnValues[status.count-1]}"/>"/>
			       	 	</c:if>
			       	 </c:when>
			       	 <c:otherwise>
			       	 	<input type="text" name="${dbListForm.columnNames[status.count-1]}"/>" value="<c:out value="${dbListForm.columnValues[status.count-1]}"/>"/>
			       	 </c:otherwise>
			       </c:choose>
			      
			       
			       
			       </td>
                </tr>
			    </c:forEach>

			    <tr>
		            <td colspan="2" align="center">
		            <input type="submit" value="Save" onclick="doSave()"/>
		            <input type="submit" value="Cancel" />
		            </td>
	            </tr>
			</table>
    </center>

    <br/>
    <br/>
	<c:if test=" ${dbListForm.errors  ne null}">
    <br />
    <smvc:errors >
	</smvc:errors></c:if>
</smvc:form>
	
</body>
