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

<script language="javascript">

function assignMeetingId(meetingId)
{
    document.getElementById('meetingId').value=meetingId;
}
</script>


<smvc:form name = "addToMyMdtForm" modelAttribute="patientInfo" method="post" onsubmit = "return submitTheForm();">
<input type="hidden" name="redirectParams" value="<c:out value="${requestScope['javax.servlet.forward.query_string']}" />" />
<smvc:hidden path="meetingId" id="meetingId" />
<smvc:hidden path="actionMethod" id="dispatchMethod"/>
     <c:set var="myErrorFlag" value=""/>
	 <table align="center">
        <spring:hasBindErrors name="patientInfo">
            <div class="error"><smvc:errors/>
            </div>
        <c:set var="myErrorFlag" value="0"></c:set>
        </spring:hasBindErrors>
        <c:choose>
            <c:when test="${errorMsg != null}">
                <tr>
                    <td>
                    <div class="error"><img src="../images/16x16/error.png"
                        alt="e" /><c:out value="${errorMsg}"/></div>
                    </td>
                </tr>
            </c:when>
            <c:otherwise>
                <c:if test="${myErrorFlag != 1}">
                    <tr>
                        <td>&nbsp;</td>
                    </tr>
                </c:if>
            </c:otherwise>
        </c:choose>
    </table>
	<table cellspacing="0" width="850" border="0" class="table">
		<tr>
			<td width="100%">
			<table border="0" width="100%" cellspacing="0" class="table">
				<tr>
					<td width="45%" class="nrlTableTitleBar">Add To My MDM</td>
					<td width="55%" class="nrlTableTitleBar"><input type="submit" id="submitBtn"
						 onclick="dispatch('ADD_TO_EMDT');" class="nrlgreenButton" value="OK" /></td>
				</tr>
				<tr>
				<td colspan="2">
					<!-- Patient Info table -->
                    <jsp:include page="../common/nrlPatientInfo.jsp"></jsp:include>
					<!-- End Patient Info table --></td>
				</tr>
				<tr>
					<td colspan="2">
					<table width="100%" class="table" border="0" cellspacing="0" style="border-top: 2px solid;">
						<tr style="border-top: 2px solid;" bgcolor="#E9DDE7">
						<td width="4%">&nbsp;</td>
						<td colspan="2" width="96%" style="font-weight: normal; font-size: 12pt;" class="nrlPDBTableCell" >Next Step</td>
						</tr>
						<tr style="border-top: 2px solid #a8abaf;">
                        <td width="4%">&nbsp;</td>
                        <td colspan="2" class="error">&nbsp;<smvc:errors path="notes"/></td>
						</tr>
						<tr>
                            <td width="4%">&nbsp;</td>
							<td width="16%" class="nrlTabBg">Your Notes</td>
							<td width="80%">&nbsp;</td>
						</tr>
						<tr>
						  <td width="4%">&nbsp;</td>
							<td width="96%" colspan="2" align="left"><smvc:textarea cssClass="txAreaBorder" rows="4" cols="120"
							  path="notes" /></td>
						</tr>
						<tr >
						<td colspan="3">&nbsp;</td>
						</tr>
					</table>
					</td>
				</tr>
				<tr style="border-top: 2px solid #a8abaf; border-bottom: 2px solid #a8abaf;" bgcolor="#E9DDE7">
					<td colspan="2">&nbsp;</td>
				</tr>
				</table>
					<table border="1" width="100%" cellspacing="0" class="table">
						<tr>
							<td class="tableTitleBar" colspan="6">My meetings</td>
						</tr>

						<tr class="tableHeader">
							<th class="tableColHeader" width="5%">Add To Meeting</th>
							<th class="tableColHeader" width="30%">Title</th>
							<th class="tableColHeader" width="10%">Date</th>
							<th class="tableColHeader" width="15%">Location</th>
							<th class="tableColHeader" width="10%">Patients For
							Discussion</th>
							<th class="tableColHeader" width="30%">Attendees</th>
						</tr>

						<c:forEach var="meeting" items="${patientInfo.meetings}"
							varStatus="s">
							<tr class='<c:out value="${s.index%2 == 0 ? 'even' : 'odd' }"/>Row <c:out value="${selMeeting }"/>'>
								<td width="5%" align="center">
								    <input type="submit" onclick="assignMeetingId('<c:out value="${meeting.id}"/>');dispatch('ADD_TO_EMDT_MEETINGS');" value="To" />  									
								</td>
								<td width="30%" align="center"><c:out value="${meeting.title}"></c:out></td>
									
								<td width="10%" align="center"><fmt:formatDate value="${meeting.date}" pattern="dd MMM yyyy - kk:mm"/></td>
								<td width="15%" align="center"><webapp:listValue domain="webapp" listName="location" key="${meeting.location }" /></td>
								<td width="10%" align="center"><c:out
									value="${fn:length(meeting.items)}"></c:out></td>
								<td width="30%" align="center">
									<c:forEach var="attendee"
										items="${meeting.attendees}" varStatus="sa">
										<c:out value="[${attendee.name}]"></c:out>&nbsp;
		                            </c:forEach>
	                            </td>
							</tr>

						</c:forEach>

					</table>
			</td>
		</tr>
	</table>
</smvc:form>