<%-- 
    Document   : resultat
    Created on : 4 mars 2018, 20:29:48
    Author     : faycal
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Resultat</title>
    </head>
    <body>
        <%@include file="header.jsp" %>
        
        <c:choose>
            <c:when test="${error != null}">
                <h1>${error}</h1>
            </c:when>
            <c:otherwise>
                <table border="1" cellpadding="10">
                    <TR>
                        <c:forEach items="${colonnes}" var="col">
                        <TD>${col}</TD> 
                        </c:forEach>
                    </TR>

                    <c:forEach items="${results}" var="values" varStatus="row" >
                    <TR>
                        <c:forEach items="${values}" var="v" varStatus="vStatus" >
                            <c:choose>
                                <c:when test="${relation != null && relation.get(colonnes[vStatus.index]) != null}">
                                    <TD>
                                        <form name="Detail" action="detail.htm"  method="POST">
                                            <input hidden type="text" name="type"  value="${relation.get(colonnes[vStatus.index])}"/>
                                            <input hidden name="num"  value="${v}"/>
                                            <input type=submit  value="${v}"  />
                                        </form>
                                    </TD>
                                </c:when>
                                <c:otherwise>
                                    <TD>${v}</TD>
                                </c:otherwise>
                            </c:choose>
                        </c:forEach>
                        <TD>
                            <form name="Detail" action="detail.htm"  method="POST">
                                <input hidden type="text" name="type"  value="${type}"/>
                                <input hidden name="num"  value="${values[0]}"/>
                                <input type=submit  value="Détail"  />
                            </form>
                        </TD>
                    </TR>
                </c:forEach>
                </table>
            </c:otherwise>
        </c:choose>
    </body>
</html>