<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles"%>
<%@ taglib prefix="peps" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@page import="java.util.Collection"%>
<%@page import="gov.va.med.pharmacy.peps.common.vo.ProductVo"%>
<%@page import="gov.va.med.pharmacy.peps.common.vo.RematchVo"%>

<link rel="stylesheet" type="text/css" href="css/fdbupdate.css" />

 <form:form id="unmatchedProductsRematch"
	name="unmatchedProductsRematch" modelAttribute="matchVo"
	action="/PRE/match.go" method="get"  onsubmit="return disableSubmit(this.id);">
      
   <div class="body-content">
   
        <div class="horizontalspacer"></div>
        <table border="0" width="100%"  cellpadding="0" cellspacing="0">
                               
            <tr>
	            <td style="vertical-align: top">
	               <div style="overflow:auto; height:400px; width:680px; ">
				        <table border="1" style="width:670px;"  cellpadding="0" cellspacing="0"  class="pendingTable" >
    			             <thead>
    			                 <tr>
                                    <th colspan="4" align="center">
                                        <h1 style="font-size:medium" align="center">Unmatched Product</h1>
                                    </th>
                                 </tr> 
	                             <tr>	                             	                                 
	                                 <th align="center" width="100px">VA Product Name</th>
	                                 <th align="center" width="50px">VA Product ID</th>	                                                                
	                             </tr>
	                         </thead>
				             <c:choose>
	                             <c:when test="${empty matchVo.productList}">
	                                 <tr>
	                                     <td colspan ="4">
	                                        <font size="4" color="red"><b>No Results Found</b></font>
	                                    </td>
	                                </tr>
	                             </c:when>
	                             <c:otherwise>
	                                <c:forEach var="result" items="${matchVo.productList}" begin="0" varStatus="status">
	                                     <tr class="${status.index % 2 == 0 ? 'even' : 'odd'}"> 
	                                     	<c:choose>
												<c:when test="${result.productName == null}">	
													<td align="center" valign="middle"><peps:text item="${result}" key="va.product.name"
																		value="" /></td>
												</c:when>
												<c:otherwise>
													<td align="center" valign="middle"><peps:text item="${result}" key="va.product.name"
																		value="${result.productName}" /></td>								
												</c:otherwise>
											</c:choose>
											<c:choose>
												<c:when test="${result.cmop == null}">
														<td align="center" valign="middle"><peps:text item="${result}" key="cmop.id"
																		value="" /></td>
												</c:when>
												<c:otherwise>
														<td align="center" valign="middle"><peps:text item="${result}" key="cmop.id"
																		value="${result.cmop}" /></td>
												</c:otherwise>
											</c:choose>                          
	                                     </tr>
	                                     <tr>
		                                     <td>
		                                        <input type="hidden" value="${result.id}" name="tableId"/>
		                                        <input type="hidden" value="${result.productId}" name="productId"/>
		                                     </td>
	                                     </tr>
	                                     
	                               </c:forEach>
	                             </c:otherwise>
	                         </c:choose>
				        </table>
			        </div>
		        </td>
		        <td style="vertical-align: top; align:top;">

				         <table border="1" style="width:565px;" cellpadding="0" cellspacing="0"  class="pendingTable">
				          <thead>
				                 <tr>
				                     <th colspan="7" align="center">
                                        <h1 style="font-size: medium" align="center">Possible Rematches</h1>
                                     </th>
                                 </tr>
                                 <tr>
                                     <th align="center" width="25%">VA Product Name</th>
                                     <th width="10%"  align="center">VA Product ID</th>                                     
                                     <th width="10%"  align="center">Suggestion</th>
                                     <th width="10%"  align="center">Automatic</th>
                                 </tr>
                             </thead>
				             <c:choose>
				                 <c:when test="${empty matchVo.rematchList}">
				                     <tr>
	                                     <td colspan="5">
	                                        <font size="4" color="red"><b>No Results Found</b></font>
	                                    </td>
	                                </tr>
				                 </c:when>
				                 <c:otherwise>
				                    <c:forEach var="productMatches" items="${matchVo.rematchList}" begin="0" varStatus="prod">
				                          <tr class="${prod.index % 2 == 0 ? 'even' : 'odd'}">	
				                          		<c:choose>
												<c:when test="${productMatches.matchedProductName == null}">	
													<td width="25%" align="center"><peps:text item="${productMatches}" key="va.product.name"
																		value="" /></td>
												</c:when>
												<c:otherwise>
													<td width="25%" align="center"><peps:text item="${productMatches}" key="va.product.name"
																		value="${productMatches.matchedProductName}" /></td>								
												</c:otherwise>
											</c:choose>
											<c:choose>
												<c:when test="${productMatches.matchedCmop == null}">
														<td width="10%" align="center"><peps:text item="${productMatches}" key="cmop.id"
																		value="" /></td>
												</c:when>
												<c:otherwise>
														<td width="10%" align="center"><peps:text item="${productMatches}" key="cmop.id"
																		value="${productMatches.matchedCmop}" /></td>
												</c:otherwise>
											</c:choose> 
											<c:choose>
												<c:when test="${matchVo.matchTypeFuture}">	
												    <td width="10%" align="center"><form:radiobutton cssClass="matchRadio" value="${productMatches.matchedProductId}" path="chosenMatch.suggestedMatch"/></td>
													<td width="10%" align="center"><form:radiobutton disabled = "true" cssClass="matchRadio" value="${productMatches.matchedProductId}" path="chosenMatch.autoMatch"/></td>
												</c:when>
												<c:otherwise>
													<td width="10%" align="center"><form:radiobutton cssClass="matchRadio" value="${productMatches.matchedProductId}" path="chosenMatch.suggestedMatch"/></td>
				                                	<td width="10%" align="center"><form:radiobutton cssClass="matchRadio" value="${productMatches.matchedProductId}" path="chosenMatch.autoMatch"/></td>						
											</c:otherwise>
											</c:choose>
				                         </tr>
			                         </c:forEach>			                          
				                 </c:otherwise>
				             </c:choose>
				         </table>
			     </td>
	        </tr>
        </table>
        <table width="1000px" cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td><br/><br/></td>  
            </tr>
            <tr>
                  <td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            
                  </td>
                  <c:if test="${nationalMgrOrSuperRole == true}">	
                  	<c:if test="${not empty matchVo.rematchList}"> 
	                        <td colspan="2" align="center">
	                        	<c:url value="/match.go" var="addMatchProductUrl"/>
	                      		<peps:submit key="button.add.to.product" action="${addMatchProductUrl}"/>
	                        </td> 
	                </c:if>
	              <td colspan="2" align="center">
	                  		<c:url value="/searchForExistingProductToRematch.go" var="associateProductUrl"/>
	                      	<peps:submit key="button.product.search" action="${associateProductUrl}" />
	                </td>
                  </c:if>                  
                  <td colspan="2" align="center">
                  	<c:url value="/cancelMatch.go" var="cancelUrl"/>
             		<peps:submit key="button.cancel" action="${cancelUrl}"/>
                  </td>
                  <td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  </td>
            </tr>
        </table>

    </div>
</form:form>
