<%@ page import="java.util.Hashtable"%>
<%@ page import="java.util.Enumeration"%>
<%@ page import="com.fenalco.entities.User"%>
<%@ page import="com.fenalco.entities.DataAccess"%>
<%@ page import="com.fenalco.utilities.lists.ListView"%>
<%@ page import="com.fenalco.entities.Community"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<html>
<head>
<link rel='stylesheet' style='text/css' href='../css/tablas.css'>
<title>Informaci&oacute;n de la comunidad</title>
</head>
<!-- 
	Esta página le permite al proveedor agregar una nueva comunidad
	Para ello debe ingresar como datos de registro el nombre y
	la descripción de la comunidad.
	
-->
<script language="JavaScript" type="text/javascript">

    function submitCombo(comboName){
            document.community.combo.value=comboName;
            document.community.submit();
            document.community.operationType.value="view";
            return true;
    }

</script>
<body bgcolor="#ffffff" background="../images/supplier/general/fondo.jpg" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<%
	String helpId = "56";
%>
<table border="0" cellpadding="0" cellspacing="0" width="760">
    <%@ include file="encabezado.jsp" %>
</table>

<table width="760" border='0' align='left'>
    
    <tr>
        <td width="152" valign='top'>
			<%@ include file="menuproveedor.jsp" %>
	</td>
        <td valign='top'>
            <%
                String tittle = "Comunidad";
            %>
            <%@ include file="/titulo.jsp" %>

			<table width="100%">
                                <%
                                    Community communityData = (Community)request.getAttribute("community");
                               %>
                                <tr><td align="center"><%=(String)request.getAttribute("message")%></td></tr>
				<tr>
                                    <form name="community" method="post" action="">
                                        <table align="center" width='90%' border='0'>
                                                <tr>
                                                    <td align='right' width='25%'><strong>Nombre</td>
                                                    <td align='left'><input type='text' name='name' size='41' maxlength='40' value='<%=communityData.getName()%>' readonly></td>
                                                    <td align='center'><input type='submit' name='escalas' value='Administrar Escalas' onClick="document.community.action='/proveedor/productoescalas'"></td>
                                                
                                                </tr>
                                                <tr><td colspan="5" align="center">&nbsp;</td></tr>
                                                <!--
                                                <tr>
                                                    <td colspan='1' align='right'>B&uacute;squeda por<br>Minorista</td>
                                                    <td colspan="1" align="left">
                                                          <select name='shopKeeperId' onchange='submitCombo(this.name);'>
                                                            <option value='-1'>Todos</option>
                                                          </select>
                                                    </td>
                                                    <input type='hidden' name='combo' value=''>
                                                    <td align='left' colspan='3'><a href='#'><img name='stores' alt='Ver detalle minorista' src='' height='20' width='20' onClick=""></a></td>
                                                </tr>-->
                                                <tr>
                                                    <input type='hidden' name='shopKeeperId' value='-1'>
                                                    <input type='hidden' name='communityId' value='<%=communityData.getId()%>'>
                                                </tr> 
                                        </table>
                                        <table align="center" width='100%' border='0'>
                                                <tr><td colspan="5" align="center">&nbsp;</td></tr>
                                                <tr class="tableheader">
                                                    <td align='left' width='25%'><strong>Nombre Minorista</td>
                                                    <td align='left' width='35%'><strong>Nombre Establecimiento</td>
                                                    <td align='left' width='25%'><strong>Direcci&oacute;n</td>
                                                    <td align='center'>Eliminar</td>
                                                </tr>
                                                 <% 
                                                    ListView view = (ListView)request.getAttribute("view");
                                                        String data;
                                                        int count = 0;
                                                        while(view.move())
                                                        {
                                                        	count++;
                                                                int i=0;
                                                                String id="";
                                                                String status="";
                                                    %>
                                                                <tr>
                                                                <% while((data=(String)view.nextElement()) != null){
                                                                        if(i==1){%>
                                                                                <td><%= data %></td>
                                                                      <%}else{ 
                                                                                i=1; 
                                                                                id=data;
                                                                        }%>
                                                                <%}%>
                                                                    <!--
                                                                    Columnas para las opciones
                                                                    --> 
                                                                    <td align='center'><input type='checkbox' name='item' value='<%=id%>'></td>
                                                                </tr>  

                                                    <%
                                                    }
                                                    if( count == 0 )
                                                    {
                                                    	%>
														<tr>
															<td align='center' colspan='4'>
																<strong>No se han adicionado establecimientos a esta comunidad</strong>
															</td>
														</tr>
														<%
                                                    }
                                                    %>
                                                <tr><td colspan="5" align="center">&nbsp;</td></tr>
                                                <tr>
                                                        <td colspan="3" align="center"><input type="submit" name="agregar" value="Agregar Establecimiento" onClick="document.community.operationType.value='add';document.community.action='/proveedor/establecimientos';"></td>
                                                        <%if( count > 0 ){%><td align="center"><input type="submit" name="eliminar" value="Eliminar" onClick="document.community.operationType.value='delete';document.community.action='/proveedor/administrarcomunidad'"></td><%}%>
                                                        <!-- 
                                                        El evento onClick inicia la verificación del formulario llamando a la función
                                                        validateForm().
                                                        -->
                                                </tr>
                                                
                                                <input type='hidden' name='operationType' value=''>
                                        </table>		
                                </form>
				</tr>
	</td>
    </tr>
	
</table>
</body>
</html>
