<script language="javascript" src="../scripts/ESR-Script.js"></script>
<%@ taglib uri="/tags/authz" prefix="auth"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/tags/fw" prefix="fw"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/struts-bean-el" prefix="bean-el"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html-el"%>
<%@ taglib uri="/tags/esr-core" prefix="esrcore"%>
<%@ page import='gov.va.med.esr.common.model.lookup.Capability' %>

<c:set var="modifyHandbookReleaseCtl" value="false"/>
<auth:authorize ifAnyGranted="<%=Capability.MODIFY_HANDBOOK_RELEASE_NUM.getName()%>">
 	<c:set var="modifyHandbookReleaseCtl" value="true"/>
</auth:authorize>
<auth:authorize ifAnyGranted="<%=Capability.MANAGE_HANDBOOK_BATCH.getName()%>">
 	<c:set var="mangeHandBook" value="true"/>
</auth:authorize>
							

<c:set var="requiredText">
	<bean-el:message key="label.required" />
</c:set>
  <c:set var="GROUP_1" value="1" />
<c:set var="GROUP_2" value="2" />
<c:set var="GROUP_3" value="3" />
<c:set var="GROUP_4" value="4" />
<c:set var="GROUP_5" value="5" />
<c:set var="GROUP_6" value="6" />
<c:set var="GROUP_7" value="7" />
<c:set var="GROUP_7a" value="7,1" />
<c:set var="GROUP_7b" value="7,2" />
<c:set var="GROUP_7c" value="7,3" />
<c:set var="GROUP_7d" value="7,4" />
<c:set var="GROUP_7e" value="7,5" />
<c:set var="GROUP_7g" value="7,7" />
<c:set var="GROUP_8" value="8" />
<c:set var="GROUP_8a" value="8,1" />
<c:set var="GROUP_8b" value="8,2" />
<c:set var="GROUP_8c" value="8,3" />
<c:set var="GROUP_8d" value="8,4" />
<c:set var="GROUP_8e" value="8,5" />
<c:set var="GROUP_8g" value="8,7" />
 <c:set var="GROUP_all" value="all" /> 

<c:set var="GROUP_1_Dec" value="PG1 (Service-connected 50% to 100%)"/>
<c:set var="GROUP_2_Dec" value="PG2 (Service-connected 30% to 40%) and above"/>
<c:set var="GROUP_3_Dec" value="PG3 (Service-connected 10% to 20%, Prisoner of War (POW), Purple Heart, or Medal of Honor) and above"/>
<c:set var="GROUP_4_Dec" value="PG4 (Catastrophically Disabled or Aid & Attendance or Housebound) and above"/>
<c:set var="GROUP_5_Dec" value="PG5 (VA Pension, Eligible for Medicaid, or Means Test Copay Exempt) and above"/>
<c:set var="GROUP_6_Dec" value="PG6 (SC 0% Compensable, Radiation or Agent Orange Exposure, SHAD, SW Asia Conditions, Combat Veteran) and above" />
<c:set var="GROUP_7a_Dec" value="PG7a (SC 0% Non-compensable and GMT Copay Required) and above" />
<c:set var="GROUP_7c_Dec" value="PG7c (NSC and GMT Copay Required) and above" />
<c:set var="GROUP_8a_Dec" value="PG8a (SC 0% Non-compensable and continuously enrolled) and above" />
<c:set var="GROUP_8b_Dec" value="PG8b (SC 0% Non-compensable and enrolled under Priority Group 8 Relaxation Percentage) and above" />
<c:set var="GROUP_8c_Dec" value="PG8c (NSC and continuously enrolled) and above" />
<c:set var="GROUP_8d_Dec" value="PG8d (NSC and enrolled under Priority Group 8 Relaxation Percentage) and above" />


<script type="text/javascript">
	
var singleSelect = true;  
var sortSelect = true;  
var sortPick = true;  
function addSelectedItems(sourceId,targetId)
{
  var sourceList = document.getElementById(sourceId);
    var selectedIndex = sourceList.selectedIndex;
    var selectedOptions = sourceList.options;
    var targetList = document.getElementById(targetId);
    var targetOptions = targetList.options;
    var targetOLength = targetOptions.length;

    while (selectedIndex > -1)
    {
       if((sourceList[selectedIndex].text.substr(0,4))=="VISN")
        {
           i=selectedIndex;
           j=selectedIndex;
            while(i !=-1)
         	{
                  sourceList[j].selected = true;
                  selectedOptions = sourceList.options;
         		 targetOptions[targetOLength] = new Option(sourceList[j].text);
       			 targetOptions[targetOLength].value = sourceList[j].value;
       			 
       			 selectedOptions[j] = null;
       			 i=i+1;
         		 if((sourceList[j].text.substr(0,4)=="VISN"))
         		{
         			i=-1;
         		}
         		targetOLength=targetOLength+1;
         	}
         }else{
        	targetOptions[targetOLength] = new Option(sourceList[selectedIndex].text);
        	targetOptions[targetOLength].value = sourceList[selectedIndex].value;
            selectedOptions[selectedIndex] = null;
        
        	
       		 targetOLength = targetOptions.length;
        
       		 }
    selectedIndex = sourceList.selectedIndex;
 }  
    if (selectedOptions[0] != null)
    {
      selectedOptions[0].selected = true;
    }
}

function sortSelectItems(selectList)
{
    if(selectList != null) {
    var options = selectList.options;
      var length = options.length;
    var index = 0;
    while(index < length-1)
    {
      if(options[index].value > options[index+1].value) {
          var tempText = options[index].text;
          var tempValue = options[index].value;

          options[index].text = options[index+1].text;
          options[index].value = options[index+1].value;

          options[index+1].text = tempText;
          options[index+1].value = tempValue;
      }
      index = index + 1;
    }
    }
}
		
function selectAllOptions(selectBoxName) {
		
    var selectBox = document.getElementById(selectBoxName)
    
   
    if(selectBox != null && selectBox.options.length != null) {
	for (var i=0; i<selectBox.options.length; i++) {
	   if((selectBox.options[i].text.substr(0,4))!="VISN"){
	    selectBox.options[i].selected = true;
	    }
	}
    }
}
function setReleaseCtl(){
if( handBookBatchRequestForm.defaultReleaseCtl.value != handBookBatchRequestForm.releaseCtl.value){
    var message = "You want to change default release control number value?";
	if(confirm(message)){
	   
	handBookBatchRequestForm.updateReleaseCtl.value =true;
    
	   return true;								   
	}
	}
}
</script>

<table width="100%" border="1" cellpadding="0" cellspacing="0"
	class="moduleShell" role="presentation">
	<html:form action="/handBookBatchRequest" method="post">
	  <%@ include file="/admin/csrfgentoken.jsp" %>
	  <html-el:hidden property="defaultReleaseCtl" />
	  <html-el:hidden property="updateReleaseCtl" />
		<tr>
			<td>
			<table width="100%" border="0" cellpadding="0" cellspacing="0"
				class="moduleShellTable" role="presentation">
				<tr>
					<td>
					<table width="100%" border="0" cellpadding="0" cellspacing="0"
						class="moduleShellTableHead" role="presentation">
						<tr>
							<td class="moduleBlueBox"><img alt=""
								src="../images/spacer.gif" width="28" height="23" /></td>
							<td  class="moduleHeadline"><bean-el:message
								key="label.handBookBatchRequest" /></td>
							<td width="100%"><img alt="" src="../images/spacer.gif" /></td>
							<td nowrap class="moduleBlueLink" style="padding: 1 8 1 8">
							 <c:if test="${mangeHandBook == true}">		
									
							<fw:link
								action="/handBookBatchRequest.do?methodName=list" module="/admin">
								<bean-el:message
									key="label.handBookBatchRequest.viewHistoricalBatchRequest" />
							</fw:link>
							</c:if>
							</td>
						</tr>
					</table>
					</td>
				</tr>
				<tr>
					<td>
					<table width="100%" border="0" cellspacing="0" cellpadding="0"
						class="moduleShellTableBody" role="presentation">
                        <tr>
                            <td colspan="2">
                              <%@ include file="/tiles/common/instructionalText.jsp" %>
                            </td>
                        </tr>
						<tr>
							<td style="padding: 10 20 10 10">
							<table width="100%" border="0" cellspacing="0" cellpadding="0" role="presentation">
								<tr>
									<td width="45%" class="moduleLabel"><fw:label 
										required="true" property="releaseDate" forId="txtReleaseDate">
										<bean-el:message key="label.handBookBatchRequest.releaseDate" />:</fw:label></td>
									<td width="55%" class="moduleValue"><c:set var="nameText">
										<bean-el:message key="label.handBookBatchRequest.releaseDate" />
									</c:set> <html-el:text title="${requiredText}, ${nameText}"
										property="releaseDate" styleId="txtReleaseDate" styleClass="moduleEdit initfocus" size="30"
										maxlength="25" /></td>
								</tr>

								<tr>
									<td class="moduleLabel"><fw:label required="true"
										property="visnVamc" forId="visnVamcSource">
										<bean-el:message key="label.handBookBatchRequest.facilities" />:</fw:label></td>
								</tr>
								<c:set var="selectedVisnVamc"
									value="${handBookBatchRequestForm.visnVamc}" />
								<esrcore:setLookup var="visnVamcSource"
									className="gov.va.med.esr.ui.common.beans.VISNParentFacility"
									removeCollection="selectedVisnVamc" />
								<esrcore:setLookup var="visnVamcTarget"
									className="gov.va.med.esr.ui.common.beans.VISNParentFacility"
									removeCollection="visnVamcSource" />
								<tr id="facilityParam">
									<td colspan="3" align="center">
									<table border="0" cellpadding="0" cellspacing="0" role="presentation">
										<tr>
											<td class="moduleValue"><bean-el:message
												key="label.available" /></td>
											<td class="moduleValue">&nbsp;</td>
											<td class="moduleValue"><bean-el:message
												key="label.selected" /></td>
										</tr>
										<tr>
											<td class="moduleLabel"><c:set var="availableText">
										<bean-el:message key="label.available" />
									</c:set><html-el:select
												title="${availableText}" styleId="visnVamcSource"
												styleClass="moduleEdit" style="width:350px;"
												property="dummySelect" multiple="true" size="8">
												<c:if
													test="${handBookBatchRequestForm.allVisnVamcSelected == false}">
													<html-el:option styleClass="moduleEdit" value="allVAMCs">
														<bean-el:message key="label.handBookBatchRequest.allVISNs" />
													</html-el:option>
												</c:if>
												<esrcore:options styleClass="moduleEdit"
													collection="visnVamcSource" property="code"
													labelProperty="facilityName" />
											</html-el:select></td>
											<td class="moduleValue">
											<fw:label forId="addSelectionId" property="button"><span style="display:none">addSelection</span></fw:label>
											<input
												id="addSelectionId"												
												title="<bean-el:message key="label.addSelections" />"
												name="button"
												onclick="addSelectedItems('visnVamcSource','visnVamcTarget')"
												type="button"
												value="<bean-el:message key="button.rightArrow" />"><br>
											<fw:label forId="removeSelectionId" property="button"><span style="display:none">removeSelection</span></fw:label>											
											<input
											    id="removeSelectionId"
												title="<bean-el:message key="label.removeSelections" />"
												name="button"
												onclick="addSelectedItems('visnVamcTarget','visnVamcSource')"
												type="button"
												value="<bean-el:message key="button.leftArrow" />">
											</td>
											<td class="moduleValue">
											<c:set var="selectedText">
										<bean-el:message key="label.selected" />
									</c:set>
									<fw:label forId="visnVamcTarget" property="visnVamc"><span style="display:none">visnVamcTarget</span></fw:label>
									<html-el:select
												title="${requiredText}, ${selectedText}" styleId="visnVamcTarget"
												styleClass="moduleEdit" style="width:350px;"
												property="visnVamc" multiple="true" size="8">
												<c:if test="${reportInfoForm.allVisnVamcSelected == true}">
													<html-el:option styleClass="moduleEdit" value="allVAMCs">
														<bean-el:message key="label.hadBookBatchRequest.allVISNs" />
													</html-el:option>
												</c:if>
												<esrcore:options styleClass="moduleEdit"
													collection="visnVamcTarget" property="code"
													labelProperty="facilityName" />
											</html-el:select></td>
										</tr>
									</table>
									</td>
								</tr>
								<esrcore:setLookup var="EnrollmentPriorityGroupAndSubGroupList"
									className="gov.va.med.esr.ui.common.beans.EnrollmentPriorityGroupAndSubGroup" />
								<tr>
									<td colspan="3">&nbsp;</td>
								</tr>
								<tr>
									<td class="moduleLabel" style="vertical-align: top"><bean-el:message key="label.required.prefix" />&nbsp;
										<bean-el:message
											key="label.handBookBatchRequest.priorityGroup" />:</td>
									<td class="moduleValue" colspan="2">
									<table border="0" cellpadding="0" cellspacing="0" role="presentation">

											<c:set var="priorityGroupAllText">
											<bean-el:message key="label.required" />,&nbsp;<bean-el:message
												key="label.handBookBatchRequest.priorityGroup" />&nbsp;(<bean-el:message
												key="label.handBookBatchRequest.allPriorityGroups" />)</c:set>
										<tr>
											<td><html-el:radio title="${priorityGroupAllText}"
												property="priorityGroup" styleId="priorityGroup_${GROUP_all}" value="${GROUP_all}" /></td>
											<td colspan="2" class="moduleValue"><fw:label
												property="priorityGroup" forId="priorityGroup_${GROUP_all}"><bean-el:message
												key="label.handBookBatchRequest.allPriorityGroups" /></fw:label></td>
										</tr>
							
										<c:forEach var="item"
											items="${EnrollmentPriorityGroupAndSubGroupList}">
											<c:set var="priorityGroupText">
												<bean-el:message key="label.required" />,&nbsp;<bean-el:message
													key="label.handBookBatchRequest.priorityGroup" />&nbsp;(<c:out
													value="${item.description}" />)</c:set>
											<c:if test="${item.code !=GROUP_8 && item.code !=GROUP_7 && item.code !=GROUP_7e && item.code !=GROUP_7g
											  && item.code !=GROUP_8e && item.code !=GROUP_8g && item.code !=GROUP_7b && item.code !=GROUP_7d}">




											<tr>
												<td width="1%">&nbsp;&nbsp;</td>
													
												<c:if test="${item.code ==GROUP_1}">
												<tr>
												<td width="1%">&nbsp;&nbsp;</td>
															<td><html-el:radio title="${GROUP_1_Dec}"
																property="priorityGroup" styleId="priorityGroup_${item.code}" value="${item.code}" /></td>


															<td class="moduleValue" width="99%"><fw:label
															property="priorityGroup" forId="priorityGroup_${item.code}"><c:out
															value="${GROUP_1_Dec}" /></fw:label></td>
												</tr>
												</c:if>
												<c:if test="${item.code ==GROUP_2}">
												<tr>
												<td width="1%">&nbsp;&nbsp;</td>
															<td><html-el:radio title="${GROUP_2_Dec}"
																property="priorityGroup" styleId="priorityGroup_${item.code}" value="${item.code}" /></td>


															<td class="moduleValue" width="99%"><fw:label
															property="priorityGroup" forId="priorityGroup_${item.code}"><c:out
															value="${GROUP_2_Dec}" /></fw:label></td>
												</tr>
												</c:if>
												<c:if test="${item.code ==GROUP_3}">
												<tr>
												<td width="1%">&nbsp;&nbsp;</td>
															<td><html-el:radio title="${GROUP_3_Dec}"
																property="priorityGroup" styleId="priorityGroup_${item.code}" value="${item.code}" /></td>


															<td class="moduleValue" width="99%"><fw:label
															property="priorityGroup" forId="priorityGroup_${item.code}"><c:out
															value="${GROUP_3_Dec}" /></fw:label></td>
												</tr>
										        </c:if>
										        <c:if test="${item.code ==GROUP_4}">
												<tr>
												<td width="1%">&nbsp;&nbsp;</td>
															<td><html-el:radio title="${GROUP_4_Dec}"
																property="priorityGroup" styleId="priorityGroup_${item.code}" value="${item.code}" /></td>


															<td class="moduleValue" width="99%"><fw:label
															property="priorityGroup" forId="priorityGroup_${item.code}"><c:out
															value="${GROUP_4_Dec}" /></fw:label></td>
												</tr>
										        </c:if>
										        <c:if test="${item.code ==GROUP_5}">
												<tr>
												<td width="1%">&nbsp;&nbsp;</td>
															<td><html-el:radio title="${GROUP_5_Dec}"
																property="priorityGroup" styleId="priorityGroup_${item.code}" value="${item.code}" /></td>


															<td class="moduleValue" width="99%"><fw:label
															property="priorityGroup" forId="priorityGroup_${item.code}"><c:out
															value="${GROUP_5_Dec}" /></fw:label></td>
												</tr>
										        </c:if>
												<c:if test="${item.code ==GROUP_6}">
												<tr>
												<td width="1%">&nbsp;&nbsp;</td>
															<td><html-el:radio title="${GROUP_6_Dec}"
																property="priorityGroup" styleId="priorityGroup_${item.code}" value="${item.code}" /></td>


															<td class="moduleValue" width="99%"><fw:label
															property="priorityGroup" forId="priorityGroup_${item.code}"><c:out
															value="${GROUP_6_Dec}" /></fw:label></td>
										        </c:if>
										        </tr>
												<c:if test="${item.code ==GROUP_7a}">
												<tr>
												<td width="1%">&nbsp;&nbsp;</td>
															<td><html-el:radio title="${GROUP_7a_Dec}"
																property="priorityGroup" styleId="priorityGroup_${item.code}" value="${item.code}" /></td>


															<td class="moduleValue" width="99%"><fw:label
															property="priorityGroup" forId="priorityGroup_${item.code}"><c:out
															value="${GROUP_7a_Dec}" /></fw:label></td>
															</tr>
										        </c:if>
										        <c:if test="${item.code ==GROUP_7c}">
										        <tr>
												<td width="1%">&nbsp;&nbsp;</td>
															<td><html-el:radio title="${GROUP_7c_Dec}"
																property="priorityGroup" styleId="priorityGroup_${item.code}" value="${item.code}" /></td>


															<td class="moduleValue" width="99%"><fw:label
															property="priorityGroup" forId="priorityGroup_${item.code}"><c:out
															value="${GROUP_7c_Dec}" /></fw:label></td>
												</tr>
										        </c:if>
										        <c:if test="${item.code ==GROUP_8a}">
										             <tr>
												<td width="1%">&nbsp;&nbsp;</td>
															<td><html-el:radio title="${GROUP_8a_Dec}"
																property="priorityGroup" styleId="priorityGroup_${item.code}" value="${item.code}" /></td>


															<td class="moduleValue" width="99%"><fw:label
															property="priorityGroup" forId="priorityGroup_${item.code}"><c:out
															value="${GROUP_8a_Dec}" /></fw:label></td>
															</tr>
										        </c:if>
										        <c:if test="${item.code ==GROUP_8b}">
										        <tr>
												<td width="1%">&nbsp;&nbsp;</td>
															<td><html-el:radio title="${GROUP_8b_Dec}"
																property="priorityGroup" styleId="priorityGroup_${item.code}" value="${item.code}" /></td>


															<td class="moduleValue" width="99%"><fw:label
															property="priorityGroup" forId="priorityGroup_${item.code}"><c:out
															value="${GROUP_8b_Dec}" /></fw:label></td>
															</tr>
										        </c:if>
										        <c:if test="${item.code ==GROUP_8c}">
										            <tr>
												<td width="1%">&nbsp;&nbsp;</td>
															<td><html-el:radio title="${GROUP_8c_Dec}"
																property="priorityGroup" styleId="priorityGroup_${item.code}" value="${item.code}" /></td>


															<td class="moduleValue" width="99%"><fw:label
															property="priorityGroup" forId="priorityGroup_${item.code}"><c:out
															value="${GROUP_8c_Dec}" /></fw:label></td>
															</tr>
										        </c:if>
										        <c:if test="${item.code ==GROUP_8d}">
										        
										           <tr>
												<td width="1%">&nbsp;&nbsp;</td>
															<td><html-el:radio title="${GROUP_8d_Dec}"
																property="priorityGroup" styleId="priorityGroup_${item.code}" value="${item.code}" /></td>


															<td class="moduleValue" width="99%"><fw:label
															property="priorityGroup" forId="priorityGroup_${item.code}"><c:out
															value="${GROUP_8d_Dec}" /></fw:label></td>
															</tr>
										        </c:if>	
												
											</c:if>
										</c:forEach>
									</table>
									</td>
								</tr>

								
								<tr>
									<c:set var="maxRecordLabel">
										<bean-el:message key="label.handBookBatchRequest.maxRecord" />
									</c:set>
									<td width="45%" class="moduleLabel"><fw:label
										required="true" property="maxRecord" forId="txtMaxRecord">
										<bean-el:message key="label.handBookBatchRequest.maxRecord" />:</fw:label></td>
									<td width="55%" class="moduleValue"><html-el:text
										title="${requiredText}, ${maxRecordLabel}"
										property="maxRecord" styleId="txtMaxRecord" size="25" maxlength="30" tabindex="2" /></td>
								</tr>
								<tr>
									<c:set var="releaseCtlLabel">
										<bean-el:message key="label.handBookBatchRequest.releaseCtl" />
									</c:set>
									<td width="45%" class="moduleLabel"><fw:label
										property="releaseCtl" forId="rpValueInput">
										<bean-el:message key="label.handBookBatchRequest.releaseCtl" />:</fw:label></td>
									 <c:if test="${modifyHandbookReleaseCtl == true}">		
										
												<td><html-el:select title="${releaseCtlLabel}" styleClass="moduleEdit" property="releaseCtl" styleId="rpValueInput" >
   													  <html-el:option value=""><bean-el:message key="label.select"/></html-el:option>
   														   <esrcore:options collection="gov.va.med.esr.ui.common.beans.HandBookReleaseControl" property="code" labelProperty="code"/>






   											 </html-el:select>
 												 </td>
											
									</c:if>	
									 <c:if test="${modifyHandbookReleaseCtl == false}">	
											
									<td width="55%" class="moduleValue"><html-el:text
										styleId="rpValueInput" title="${requiredText}"
										property="releaseCtl" size="25" maxlength="30"  disabled="true" tabindex="2" /></td>
										</c:if>
								</tr>
								<tr>
									<c:set var="setDescriptionLabel">
										<bean-el:message key="label.handBookBatchRequest.releaseNote" />
									</c:set>
									<th width="45%" class="moduleLabel"><fw:label
										property="releaseNote" forId="txtReleaseNote">
										<bean-el:message key="label.handBookBatchRequest.releaseNote" />:</fw:label></th>
									<td width="55%" class="moduleValue"><html-el:textarea
										title="${setDescriptionLabel}" property="releaseNote"
										styleId="txtReleaseNote" cols="50" rows="3" /></td>
								</tr>
								<tr>
									<td>&nbsp;</td>
								</tr>
								<tr>
									<td colspan=2>
									<table border="0" align="center" cellspacing="3"
										cellpadding="0" role="presentation">
										<tr>
												<td><img alt="" src="../images/buttonEndLeft.gif" /><html-el:submit
												property="methodName" style="width:80; vertical-align: top;"
												onclick="selectAllOptions('visnVamcTarget');setReleaseCtl()"
												styleClass="buttonText">
												<bean-el:message key="button.handBookBatchRequest.add" />
											</html-el:submit><img alt="" src="../images/buttonEndRight.gif" /></td>

											<td><img alt="" src="../images/buttonEndLeft.gif" /><html-el:submit
												property="methodName" style="width:50; vertical-align: top;"
												styleClass="buttonText">
												<bean-el:message key="button.handBookBatchRequest.reset" />
											</html-el:submit><img alt="" src="../images/buttonEndRight.gif" /></td>
											<td><img alt="" src="../images/buttonEndLeft.gif" /><html-el:submit
												property="methodName" style="width:50; vertical-align: top;"
												styleClass="buttonText">
												<bean-el:message key="button.handBookBatchRequest.cancel" />
											</html-el:submit><img alt="" src="../images/buttonEndRight.gif" /></td>

										</tr>
									</table>
									</td>
								</tr>
							</table>
							</td>
						</tr>
					</table>
					</td>
				</tr>

			</table>
			</td>
		</tr>

	</html:form>
</table>
