<%@ page import="com.fenalco.utilities.lists.ListView"%>
<%@ page import="com.fenalco.entities.User"%>
<%@ page import="com.fenalco.entities.DataAccess"%>
<%@ page import="com.fenalco.utilities.MessageBuilder"%>
<%@ page import="com.fenalco.entities.StoreList"%>
<%@ page import="com.fenalco.entities.SuperOffer"%>
<%@ page import="java.util.Enumeration"%>
<%@ page import="java.util.Vector"%>
<%@ page import="java.util.Hashtable"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel='stylesheet' style='text/css' href='../css/tablas.css'>
<title>P&aacute;gina principal minorista</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#ffffff" background="../images/shopkeeper/general/fondo.jpg" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- 
-->
<%
	String helpId = "30";
%>
<table border="0" cellpadding="0" cellspacing="0" width="780">
    <%@ include file="encabezado.jsp" %>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0">
    
    <tr>
        <td width="155" valign="top">
			<%@ include file="menuminorista.jsp" %>
	</td>
        <td width='505' valign="top">
                         <%
                            String tittle = "P&aacute;gina principal";
                         %>
                         <%@ include file="/titulo.jsp" %>
			<table width="100%">
				<tr>
                                    <td align="center" >
				    <%String message = ( String )request.getAttribute("message");
                                        if( message != null )
                                        {
                                            %>
                                            <%=message%>
                                            <%
                                        }      
                                    %>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    <!-- esta es la tabla que contiene las superofertas -->
                                    <%
                                        Vector view = (Vector)request.getAttribute("view");
                                    %>
                                    <table>
                                        <!-- combo de establecimientos -->
                                        <tr>
                                          <%Hashtable stores = (Hashtable)request.getAttribute("stores");
                                          Enumeration en = stores.keys();
                                            if(stores.size()>0)
                                           {%>
                                                  
                                            <td valign='top'>
                                                    <strong>Seleccione su establecimiento</strong>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <form name='stores' method='post' action='/minorista/minorista'>
                                                    <select name="storeId" onchange='stores.submit();'>
                                                                <%
                                                                String selected = "";
                                                                Integer temp = (Integer) request.getAttribute("storeId");

                                                                for(int i = 0 ; i < stores.size() ; i++){
                                                                    Object key = en.nextElement();
                                                                    Integer temp2 = (Integer) key;
                                                                    if(temp.intValue() == temp2.intValue()){
                                                                        selected = "selected";
                                                                    }
                                                                    else{
                                                                        selected = "";
                                                                    }
                                                                %>
                                                                    <option value="<%=key%>" <%=selected%>><%=stores.get(key)%> </option>
                                                                <%
                                                                }
                                                                %>

                                                    </select>
                                                    </form>
                                            </td>
                                            <td>
                                            </td>
                                            <%}
                                            else{%>
                                            <td>
                                                <b>USTED AUN NO HA DEFINIDO NINGUN ESTABLECIMIENTO</b>
                                            </td>
                                            <%}%>    
                                        </tr>
                                        <!-- -->
                                        <tr>
                                            <td colspan='3'><b>SUPEROFERTAS</b></td>
                                        </tr>
                                        <tr>
                                            <td colspan='3'><hr></td>
                                        </tr>
                                        <tr>
                                            <%
                                             if(view.size()==0){%>
                                                <td>
                                                    <b>EN ESTE MOMENTO NO HAY SUPEROFERTAS DISPONIBLES<br>
                                                       DE SUS PROVEEDORES </b>
                                                    
                                                </td>
                                             <%}
                                             else{
                                              
                                                for(int i = 0 ; i < view.size(); i++){
                                                    SuperOffer temp2 = (SuperOffer)view.elementAt(i);
                                            %>
                                            <td>
                                               <table>
                                                    <tr>
                                                        <td><a href="#"><img src="<%=temp2.getImageUrl()%>" width="200" height="250" onclick="window.open('/minorista/versuperoferta?id=<%=temp2.getId()%>','','WIDTH=500,HEIGHT=250');" alt='<%=temp2.getProductName()%>'></a></td>
                                                    </tr>
                                                    <tr>
                                                        <td ><b>Precio <%=DataAccess.getCurrency(temp2.getPrice())%></b></td>

                                                    </tr>   

                                                </table>
                                            </td>
                                            <td width='40'></td>
                                                <%}
                                            %>
                                            
                                        </tr>
                                        <tr>
                                            <td>
                                            <% double totalPages = ((Double)request.getAttribute("totalPages")).doubleValue();
                                                for (int j = 0 ; j < totalPages;j++){%>
                                                 <a href="/minorista/minorista?page=<%=j%>"> <%=j+1%></a>
                                            <%}
                                            }%>
                                            </td>
                                        </tr>
                                        </table>
                                    </td>   
                                </tr>
                            </table>
                       
            </td>            
    </tr>
</table>
<table width="760">
	<tr>
		<td><%@ include file="/piepagina.jsp" %></td>
	</tr>
</table>
</body>
</html>