<%@ 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" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel='stylesheet' style='text/css' href='../css/tablas.css'>
<title>Listado de Sectores</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#ffffff" background="../images/sysmanager/general/fondo.jpg" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- 
-->

<script type='text/javascript' language='javascript' src='../js/library.js'></script>
<script>

 function validateForm(formName){

            var message = "Han ocurrido los siguientes errores:\n";
            var flag = true;
            if(isEmpty(formName.name)){
                    message = message + "- El campo nombre está vacío.\n";
                    flag = false;
            }
            
            if(!flag){
                    window.alert(message);
            }
                        
            return flag;
    }
	
</script>
            
<table border="0" cellpadding="0" cellspacing="0" width="780">
        <%
            String helpId = "0";
        %>
        <%@ include file="encabezado.jsp" %>
</table>
<table width="760">
	<tr>
		<td width="152" valign='top'>
			<%@ include file="menuadministrador.jsp" %>
		</td>
		<td valign='top'>
            <%
                String tittle = "Sectores Econ&oacute;micos";
            %>
            <%@ include file="/titulo.jsp" %>

			<table width="603">
				<tr><td align="center"><%= request.getAttribute("message")%></td></tr>
				<tr><td height='10'></td></tr>
				<tr>
				<form name="sectorList" method="post" action="/administrador/administrarsectores" >
				<table align="center">
					<tr class='tableheader'>
						<!-- Encabezado del listado -->
						<td align="center">Nombre</td>
						<td align="center">Modificar</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="";
				%>
						<% while((data=(String)view.nextElement()) != null){
							if(i>0){
						%>
                                                            <td><input type="text" name="<%= "name"+id%>" maxlength="30" size='20' value="<%=data%>"></td>
                                                    <%  }else if(i==0){ 
                                                            id=data;
                                                        }
                                                        i++;
                                                     %>
                                                <% }
						%>
							<!-- Columnas para las opciones -->
							<td align="center"><a href="#"><img  name="update" src="/images/buttons/sysmanager/actualizar.gif"  border="0" onclick="operationType.value='update';sectorList.action='/administrador/administrarsectores?key=<%=id%>'; return sectorList.submit();"></a></td>
							<td align="center"><input name="item" type="checkbox" value="<%= id %>"></td> 
						</tr>
					<%
                                        }
                                        if( count == 0 )
                                        {
                                            %>
                                            <tr>
                                                <td align="center" colspan='3'>
                                                    <strong>No se han definido Sectores Económicos</strong  >
                                                </td>
                                            </tr>
                                            <%
                                        }
                                        else
                                        {
                                        %>
        					<tr>
                                                    <td colspan='2'></td>
                                                    <td align="center"><input name="delete" type="submit" value="Eliminar" onClick="operationType.value='delete';return window.confirm('Está a punto de eliminar registros del sistema, desea continuar?');"><td>
                                                </tr>
                                        <%
                                        }
                                        %>
                                                <tr><td><br></td></tr>
                                </table>
                                <table align="center">
						 <tr>
                                                    <td>Nuevo sector</td>
                                                    <td><input type="text" name='name' size='12'></td>
						 </tr>
						 <tr><td><br></td></tr>                                                
						 <tr>
                                                    <td align="center" colspan='2'><input name="new" type="submit" value="Agregar" onClick="operationType.value='new';return validateForm(document.sectorList)"><td> 
						 </tr>
                                                 </table>
				</table>
				<input name="operationType" type="hidden" value="">
				</form>
			</tr>
			</table>
		</td>
	</tr>
	
</table>
<table width="760">
	<tr>
		<td><%@ include file="/piepagina.jsp" %></td>
	</tr>
</table>

</body>
</html>







