<%@ include file="/includes.jsp"%>
<link rel="stylesheet" href="../js/jquery/datatables.min.css"
	type="text/css" />
<script src="../js/jquery/datatables.min.js"> </script>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<script type="text/javascript">
function processEditDelete(id) {
	var isProceed  = confirm("Are you sure you want to delete this Configuration?");
	if (isProceed) {
	    document.location.href="../admin/configuration.form?actionRequired=delete&meetingScheduleId="+id;
    }else{
        return false;
     }
}
function saveProperties(){
	document.getElementById('action').value="";
	document.getElementById('configurationForm').submit();
}
</script>

<smvc:form id="configurationForm" action="../admin/configuration.form"
	modelAttribute="emdtProperties" method="post">
	<input type="hidden" name="redirectParams"
		value="<c:out value="${requestScope['javax.servlet.forward.query_string']}"/>" />
	<smvc:hidden path="id" />
	<smvc:hidden path="action" id="action" />
	<c:if test="${not empty successMsg}">
		<div class="message">
			<img src="../images/16x16/information.png" alt="i" />
			<c:out value="${successMsg}" />
		</div>
	</c:if>
	<fieldset class="nobg">
		<legend>Configurations</legend>
		<fieldset>
			<c:choose>
				<c:when
					test="${emdtPropertiesList!=null and fn:length(emdtPropertiesList)>0}">
					<table>
						<tr>
							<td colspan="9"><B>List of Configurations</B></td>
						</tr>
						<tr>
							<td colspan="9">&#160;</td>
						</tr>
					</table>


					<table id="usersTable" width="100%" class="display">
						<thead>
							<tr>
								<th align="left">Key</th>
								<th align="left">Value</th>
								<th align="left">Description</th>
								<th align="left">Edit</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach var="emdtProperties" items="${emdtPropertiesList}">
								<tr>
									<td><c:out value="${emdtProperties.key}" /></td>
									<td><c:out value="${emdtProperties.value}" /></td>
									<td><c:out value="${emdtProperties.description}" /></td>
									<td><a
										href="../admin/configuration.form?actionRequired=edit&id=<c:out value="${emdtProperties.id}"/>"
										title="Edit configuration"
										onmouseover="this.style.cursor = cursorPointer; "> <img
											src="../images/page_white_edit.png" border="0" alt="Edit" /></a></td>
								</tr>
							</c:forEach>
						<tbody>
					</table>
				</c:when>
				<c:otherwise>
					<table width="100%" cellspacing="0" cellpadding="4">
						<tr>
							<th>-- No Configurations defined --</th>
						</tr>
					</table>
				</c:otherwise>
			</c:choose>
		</fieldset>
		<c:if test="${emdtProperties.id ne null}">
			<fieldset>
				<table width="100%" cellspacing="0" cellpadding="4">
					<tr>
						<td align="right"><input type="button"
							value="Add New Configuration.."
							onclick="document.location.href='../admin/configuration.form'" />
						</td>
					</tr>
				</table>
			</fieldset>
		</c:if>
	</fieldset>


	<c:if test="${not empty errMsg}">
		<div class="error">
			<img src="../images/16x16/error.png" alt="!" border="0" />&nbsp;&nbsp;
			<c:out value="${errMsg}" />
		</div>
	</c:if>
	<table width="500">
		<tr>
			<td>
				<fieldset class="dialogBox">
					<table class="dialogTitle" width="100%">
						<tr>
							<th><c:choose>
									<c:when test="${emdtProperties.id ne null}">
										<div>Edit Configuration</div>
									</c:when>
									<c:otherwise>
										<div>Create New Configuration</div>
									</c:otherwise>
								</c:choose></th>
						</tr>
					</table>
					<br /> <br />

					<table id="editConfigurationTable" width="100%">
						<tr>
							<td>Key:</td>
							<td><smvc:input path="key" /></td>
						</tr>
						<tr>
							<td>Value:</td>
							<td><smvc:input path="value" /></td>
						</tr>
						<tr>
							<td>Description:</td>
							<td><smvc:input path="description" /></td>
						</tr>
						<tr>
							<td height="25"></td>
						</tr>
					</table>
					<table width="100%"
						style="background: #DFE5EB; height: 40px; padding: 2px 5px 2px 10px;">
						<tr>
							<td width="65%"><c:if test="${emdtProperties.id ne null}">
									<input type="button"
										onclick="processEditDelete(<c:out value="${emdtProperties.id}"/>);return false;"
										value="Delete" />
								</c:if></td>
							<td style="text-align: right;"><input type="button"
								value="Save" onclick="saveProperties();return false;" />
							</td>
						</tr>
					</table>
				</fieldset> <br /> <br />
			</td>
		</tr>
	</table>

</smvc:form>
