<%@ include file="/includes.jsp"%>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>
<script type="text/javascript">
function loadNote(o,formId) {
	disablePopup('noteModifiedPopupId','noteModifiedPopupTable');
    fullScreenPleaseWait();
	document.location = "consultationNote.form?conNoteId="+o+"&filterFormId="+formId;
}
function overrideAndSaveNote(formId) {
	disablePopup('noteModifiedPopupId','noteModifiedPopupTable');
    document.getElementById('redirectParams').value="filterFormId="+formId;
    document.getElementById('overrideModifications').value='yes';
    document.getElementById("actionRequired").value = "save";
	fullScreenPleaseWait();
	preSubmit();
	document.getElementById("consultationNote").submit();
  }
</script>
<style type="text/css">
.contentPopup {
	display: none;
	position: relative;
	height: auto;
	width: 1000px;
	border: 2px solid #668B8B;
	z-index: 2;
	font-size: 13px;
	background-color: #e0e5eb;
	padding: 10px;
}

.closeContainer {
	background: darkgray;
	text-align: center;
}
#noteModifiedPopupTable tr th	{
	text-align: left;
	border: 1px grey solid;
}
#noteModifiedPopupTable tr td	{
	border: 1px grey solid;
	padding: 4px;
}
	.field {
	}
	.theirs	{
		background: lightgrey;
	}
	.yours	{
		background: whitesmoke;
	}

</style>
<div id="noteModifiedPopupId" class="contentPopup"><span class="warning">Caution! <br/>This form has been changed by another user since you opened it.</span>
	<table id="noteModifiedPopupTable">
		<thead>
			<tr>
				<th class="dialogTitle">Modified by</th><td  class="dialogTitle" colspan="2"><c:out value="${noteModifiedByOtherUserName}"/>, at <fmt:formatDate value="${noteModifiedByOtherDate}" pattern="dd MMM yyyy HH:mm" /></td>
			</tr>
			<tr>
				<th class="field">Field</th>
				<th class="theirs">Their values:</th>
				<th class="yours">Your values:</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach var="modifications" items="${modificationsMap}">
				<tr>
					<th class="field"><c:out value="${modifications.key}"/></th>
					<td class="theirs"><c:out value="${modifications.value}"/></td>
					<td class="yours"><c:out value="${consultationNoteForm.view.note.values[modifications.key]}"/></td>
				</tr>
			</c:forEach>
		</tbody>
		<tfoot>
		<tr>
			<td>&nbsp;</td>
			<td class="closeContainer"><button type="button" onclick="loadNote('<c:out value="${consultationNoteForm.view.note.guid}"/>','<c:out value="${consultationNoteForm.view.form.id}"/>');" class="popupContactClose">Use <c:out value="${noteModifiedByOtherUserName}"/>'s changes, discard your changes</button></td>
			<td class="closeContainer"><button type="button" onclick="overrideAndSaveNote('<c:out value="${consultationNoteForm.view.form.id}"/>');" class="popupContactClose">Save your changes, and overwrite theirs</button></td>
		</tr>
		</tfoot>
	</table>
</div>