<%@ include file="/includes.jsp"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.GregorianCalendar"%>
<script language="javascript">

function validate() {
//Check occurences of '/' symbol
        var checkOK = "0123456789/";
        var checkStr = document.meetingtrackingReportForm.sel1.value;    
        if(checkStr.length>0){
	        var allValid_f = true;                                                    
	
	        for (i = 0; i < checkStr.length; i++) { 
	       		ch = checkStr.charAt(i); 
	               for (j = 0; j < checkOK.length; j++)
	                if (ch == checkOK.charAt(j))
	                break;
	                if (j == checkOK.length){ 
		               	allValid_f = false; 
		               	break; 
	               } 
	        }
	        
	         if (!allValid_f){ 
	                alert("Invalid Date.\nFormat accepted is dd/mm/yyyy.");
	                document.meetingtrackingReportForm.sel1.focus();
	                return (false); 
	        } 
	        
	        var k;
	        var l=0;
	        
	        for(k = 0; k < checkStr.length; k++) { 
	        		ch = checkStr.charAt(k); if(ch=='/') l++;}
	            	if (l!=2){ 
	                    alert("Invalid  Date.\nFormat accepted is dd/mm/yyyy.");
	                    document.meetingtrackingReportForm.sel1.select();
	                    document.meetingtrackingReportForm.sel1.focus();
	                    return (false); 
	                 } 
	                 
	                 //Checks for Invalid Date formats
			        a=document.meetingtrackingReportForm.sel1.value.indexOf('/')
			        b=document.meetingtrackingReportForm.sel1.value.indexOf('/',a+1)
			        fs_date=document.meetingtrackingReportForm.sel1.value.substring(0,a)
			        fs_month=document.meetingtrackingReportForm.sel1.value.substring(a+1,b)
			        fs_year=document.meetingtrackingReportForm.sel1.value.substring(b+1,10)
	
	        
		        	if(document.meetingtrackingReportForm.sel1.value.substring(b+1,10).length !=4){
						alert("Invalid Date.\nFormat accepted is dd/mm/yyyy.");
		                document.meetingtrackingReportForm.sel1.select();
		                document.meetingtrackingReportForm.sel1.focus();
		                return (false); 
		            }
	
			        if((document.meetingtrackingReportForm.sel1.value.substring(a+1,b).length < 1) || (document.meetingtrackingReportForm.sel1.value.substring(a+1,b).length > 2)){
		                alert("Invalid From Date.\nFormat accepted is dd/mm/yyyy.");
		                document.meetingtrackingReportForm.sel1.select();
		                document.meetingtrackingReportForm.sel1.focus();
		                return (false); 
			        }
	        
			        if((document.meetingtrackingReportForm.sel1.value.substring(0,a).length < 1) || (document.meetingtrackingReportForm.sel1.value.substring(0,a).length > 2)){
			                alert("Invalid From Date.\nFormat accepted is dd/mm/yyyy.");
			                document.meetingtrackingReportForm.sel1.select();
			                document.meetingtrackingReportForm.sel1.focus();
			                return (false); 
			        }
	        
			        if(fs_month>12 || fs_month<1){
			                alert("Invalid From Date in month.");
			                 document.meetingtrackingReportForm.sel1.select();
			                document.meetingtrackingReportForm.sel1.focus();
			                return (false); 
			         }
	         
		          	if(fs_date>31 || fs_date<1){
		                alert("Invalid From Date in days.");
		                document.meetingtrackingReportForm.sel1.select();
		                document.meetingtrackingReportForm.sel1.focus();
		                return (false); 
		        	}
	        
	        		if(fs_month==4 || fs_month==6 || fs_month==9 || fs_month==11)
	        			if(fs_date>30){
			                alert("Invalid From Date.");
			                 document.meetingtrackingReportForm.sel1.select();
			                document.meetingtrackingReportForm.sel1.focus();
			                return (false); 
	  					}
	        
	         		if(fs_month==2)
	        			if(fs_date>29){
			                alert("Invalid From Date .");
			                document.meetingtrackingReportForm.sel1.select();
			                document.meetingtrackingReportForm.sel1.focus();
			                return (false); 
	        			}
	        
	        		if((fs_year%4)!=0)
	        			if(fs_month==2)
	        				if(fs_date>28){
	                		alert("Invalid From Date.");
	                 		document.meetingtrackingReportForm.sel1.select();
	                		document.meetingtrackingReportForm.sel1.focus();
	                		return (false); 
	        			}
        	}          
                showPleaseWait();
}
</script>

<div class="breadcrumb">
You are here: <a href="../emdt/emdtHome.form"><img src="../emdt/images/16x16/icon.png" style="vertical-align: top;"/> eMDT</a> &gt; <a href="../emdt/reportMenu.jsp">Reports</a> &gt; <a class="selected">Patient Meeting Tracking report</a>
</div>

<sec:authorize access="hasAnyRole('EMDT')">
<form name="meetingtrackingReportForm" id="meetingtrackingReportForm" method="post"
	action="../emdt/meetingtrackingReport.form?${_csrf.parameterName}=${_csrf.token}" onsubmit="return validate();">
<table width="60%" border="2" cellpadding="0" cellspacing="0" align="center">
	<tbody>
		<tr>
			<td>
			<table class="dialogBox" width="100%" border="0"
				cellpadding="0" cellspacing="0">
				<tbody>
					<tr>
						<td class="dialogTitle"><b>Patient Meeting Tracking report</b></td>
					</tr>
					<tr>
						<td>
						<table width="100%" border="0" cellpadding="10" cellspacing="0">

							<tbody>
								<tr>
									<td>
									<table border="0" cellpadding="0" cellspacing="0" width="90%">
										<tbody>
											<tr>
												<td class="label"><b>Speciality:</b></td>
												<td><webapp:selectAndEditList path="selectedSpeciality" domain="EMDT" list="speciality" includeEmpty="true"  />
												</td>
											</tr>
											<tr><td><br/></td></tr>
											<tr>
												<td class="label"><b>Primary Clinician:</b></td>
												<td><select name="selectedClinician" id="selectedClinician">
														<option value=""> Any </option>
														<c:forEach var="usersByHospitalMap" items="${webapp.usersByHospitalIdMap}">
							                   				<optgroup label="<c:out value="${webapp.hospMap[usersByHospitalMap.key]}"/>">
																<c:forEach var="userId" items="${usersByHospitalMap.value}">
																	<option value="<c:out value="${userId}"/>" ><c:out value="${webapp.userIdUsernameMap[userId]}"/> [${webapp.userIdNameMap[userId]}"/>]</option>
																</c:forEach>
															</optgroup>
														</c:forEach>
													</select>
												</td>
											</tr>
											<tr><td><br/></td></tr>
											<tr>
												<td class="label"><b>Date Added:</b></td>
												<td >&nbsp;<input name="addedDate"
													maxlength="10" size="12"  id="sel1"
													type="text" placeholder="dd/mm/yyyy" ><img title='Click to choose date' style='cursor: pointer' src='../images/16x16/date.png' id='sel1_DateTrigger'/>
												</td>
											</tr>
											<tr><td><br/></td></tr>
											<tr>
												<td></td>
												<td class="input" align="right"><input value="Cancel" type="button" onclick="document.location.href ='../emdt/reportMenu.jsp'" > &nbsp;&nbsp;
												<input value="Continue" type="submit"></td>
											</tr>
										</tbody>
									</table>
									<br/>
									<br/>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td colspan="2" class="dialogSpacer"></td>
					</tr>
					<tr>
						<td colspan="2" class="dialogFooter"></td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
	</tbody>
</table>
</form></sec:authorize>


