<%@ include file="/includes.jsp"%>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<script>
	function update() {
		var res=confirm("Please confirm that you want to send the emails");
		if(res){
			document.getElementById('action').value="Send emails";
			document.getElementById('emailsForm').submit();
		}
		return res;
	}
	function selectAllAttendees() {
		var totAttendees, mbox;
		totAttendees = document.getElementById('totAttendees').value;
		for (index = 0; index < totAttendees; index++) {
			mbox = "multibox[" + index + "]";
			document.getElementById(mbox).checked = true;
		}
	}
</script>

<br />

<div> <%@include file="meetingHeadingPanel.jsp" %></div>


<table width="100%">
	<tr>
		<td align="center">
			<c:set var="timeNow" value="<%=new java.util.Date() %>"/>
			<c:if test="${timeNow.before(emdt.currentMeeting.date) }"><span class="warning">The date of this meeting is in the future</span></c:if>
		</td>
	</tr>
	<tr>
		<td valign="top" align="center"><br /> <smvc:form
				modelAttribute="followupEmailsForm" id="emailsForm" action="../meetings/editMeetingFollowupMails.form">
				<input type="hidden" name="redirectParams" value="<c:out value="${requestScope['javax.servlet.forward.query_string']}" />" />
				<input type="hidden" name="page" value="FollowupMails" />
				<input type="hidden" id="totAttendees" value="<c:out value="${sendFollowupEmailForm.meeting.totAttendees}"/>" />
				<table cellpadding="0" cellspacing="0" width="400">
					<tr>
						<td><br /> <tags:dialogBox title="Meeting Follow-up Email">
								<table cellpadding="4">
									<tr>
										<td colspan="3">Select which meeting attendees should receive this follow-up email:<br/></td>
									</tr>
									<tr>
										<th>Send Email?</th>
										<th>Attendee name</th>
										<th>Email Address</th>
									</tr>
									<c:forEach var="attendee"
										items="${followupEmailsForm.meeting.attendees }" varStatus="s">
										<tr>
											<td class="input" style="border: 0px solid;" align="center"
												title="Check to include attendee"><smvc:checkbox
													path="selected" value="${attendee.id}"
													id="multibox[${s.index}]" cssClass="allNonInvert"/></td>
											<td class="input"><c:out value="${attendee.user.fullName}"/></td>
											<td class="input"><c:out value="${attendee.user.email}"/></td>
										</tr>
									</c:forEach>
									<tr>
										<td align="center">
											<a href="javascript:select('all')">all</a> | <a href="javascript:select('none')">none</a> | <a href="javascript:select('invert')">invert</a>
										</td>
										<td></td>
										<td></td>
									</tr>
									
									
									
									
								</table>
							</tags:dialogBox> <br> <tags:dialogBox title="Email Contents:">
								<table cellpadding="4">

									<tr>
										<td>Message:</td>
										<td><smvc:textarea path="meeting.emailMessage" cols="80"
												rows="10" />
										</td>
									</tr>

									<tr>
										<td>Include&nbsp;Patient&nbsp;Summary:</td>
										<td><smvc:select path="meeting.patientSummaryId">
												<smvc:option value="">-- no summary selected --</smvc:option>
												<c:forEach var="summary" items="${emdt.patientSummaries}">
													<smvc:option value="${summary.id}"><c:out value="${summary.title}"/></smvc:option>
												</c:forEach>
											</smvc:select></td>
									</tr>
									<tr >
										<td>Include a link the meeting within the email:<smvc:checkbox
												path="includelink" /></td>
												
										<td>Include patient summary to email:<smvc:checkbox
												path="includePatientDetails" />
										</td>
									</tr>
								</table>
							</tags:dialogBox></td>
					</tr>
					<tr>
						<td align="center">
							<c:if test="${message ne null}">
								<span class="info"><c:out value="${message}"/></span>
								<br/>
							</c:if>
						</td>
					</tr>
				</table>
			<smvc:hidden path="action" id="action"/>
   			 <input type="button" value="Send emails" onclick="return update()"/>

			</smvc:form>
		</td>
		<td width=5%></td>
	</tr>

	<tr>
	<td align="center">
		<br/>

		<div class="meetingNavigationPanel" style="width:300px;">
		
			<c:if test="${emdt.currentMeeting != null}">
				<a href="resumeMeeting.form">Return to Current Meeting <img src="../images/16x16/arrow_undo.png" /> </a> <br/>
			</c:if>
			 <br/>
			<a href="setMeetingFilter.form?filterId=0">Select Another Meeting <img src="../images/16x16/bullet_go.png" /> </a> 
			<br/>
			
		</div>
		<br/>
		
		<br/>
	</td>
	</tr>

</table>
