<%@ page import="com.fenalco.utilities.lists.ListView"%>
<%@ page import="com.fenalco.entities.User"%>
<%@ page import="com.fenalco.entities.DataAccess"%>
<%
    
    //ListView shopKeepers = ( ListView )request.getAttribute( "shopKeepers" );
    ListView view = ( ListView )request.getAttribute( "view" );
    
    String firstRow = ( String )request.getAttribute( "firstRow" );
    String lastRow = ( String )request.getAttribute( "lastRow" );
    String total = ( String )request.getAttribute( "total" );
    String page1 = ( String )request.getAttribute( "page" );
    String pages = ( String )request.getAttribute( "pages" );
    int pageResults = Integer.valueOf(request.getAttribute( "pageResults" ).toString()).intValue();
    
    //String companyType = ( String )request.getAttribute( "companyType" );
    //int supplier = ( ( Integer )request.getAttribute( "supplier" ) ).intValue();
    //int shopKeeper = ( ( Integer )request.getAttribute( "shopKeeper" ) ).intValue();
    int order = ( ( Integer )request.getAttribute( "order" ) ).intValue();
    
    String date = ( String )request.getAttribute( "date" );
    String startDate = ( String )request.getAttribute( "startDate" );
    String endDate = ( String )request.getAttribute( "endDate" );
    
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel='stylesheet' style='text/css' href='../css/tablas.css'>
<link rel='stylesheet' style='text/css' href='../css/fuentes.css'>
<title>Listado de Pedidos</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<%
	String helpId = "61";
%>
<table border="0" cellpadding="0" cellspacing="0" width="760">
    <%@ include file="encabezado.jsp" %>
</table>
<table width="760" border='0'>
   
    <tr>
        <td width="152" valign='top'>
			<%@ include file="menuproveedor.jsp" %>
	</td>
        <td valign='top'>
            <%
                String tittle = "Buscador";
            %>
            <%@ include file="/titulo.jsp" %>
            <form action="/proveedor/ordenesdecompra" method="post" name="buscador" id="buscador">
              <table width="70%" border="0" cellpadding="0" cellspacing="0" bgcolor="#E8E8F4" align="center">
                <tr>
                    <td width="16" align="left" valign="top"><img src="/proveedor/images/bus1.gif" width="16" height="14"></td>
                    <td colspan='6'>&nbsp;</td>
                    <td width="15" align="right" valign="top"><img src="/proveedor/images/bus3.gif" width="15" height="14"></td>
                </tr>
                <tr align='right'>
                    <td>&nbsp;</td>
                    <td align="left" colspan='3'>
                        <input name="date" type="radio" value="1" <%if( date.equals("1") ){%>checked<%}%>>Hoy
                    </td>
                    <td align="left" colspan='3'><input name="date" type="radio" value="2" <%if( date.equals("2") ){%>checked<%}%>>&Uacute;ltimos ocho d&iacute;as
                    </td>
                    <td>&nbsp;</td>
                </tr>
                <tr align='right'>
                    <td>&nbsp;</td>
                    <td align="left" colspan='3'><input name="date" type="radio" value="3" <%if( date.equals("3") ){%>checked<%}%>>Este Mes</td>
                    <td align="left" colspan='3'><input name="date" type="radio" value="4" <%if( date.equals("4") ){%>checked<%}%>>Este Año</td>
                    <td>&nbsp;</td>
                </tr>    
                <tr><td colspan='4'>&nbsp;</td></tr>
                <tr>
                    <td>&nbsp;</td>
                    <td>Fecha inicial</td>
                    <td><input type="text" name='startDate' value='<%=startDate%>' size='10' ></td><td><a href="javascript:cal_startDate.popup()"><img src="../images/pages/cal.gif" width='20' height='20'></a></td>
                        <script type='text/javascript' language='javascript' src='../js/calendar1.js'></script>
                        <script>
                            var cal_startDate = new calendar1(document.buscador.startDate);
                        </script>
                    <td>Fecha final</td>
                    <td><input type="text" name='endDate' value='<%=endDate%>' size='10' ></td><td><a href="javascript:cal_endDate.popup()"><img src="../images/pages/cal.gif" width='20' height='20'></a></td>
                        <script>
                            var cal_endDate = new calendar1(document.buscador.endDate);
                        </script>
                    <td>&nbsp;</td>    
                </tr>
                <tr><td colspan='4'>&nbsp;</td></tr>
                <tr>
                  <td>&nbsp;</td>  
                  <td><div align="right">Ordenar por: </div></td>
                  <td><select name="order">
                    <!--<option value="1" <%if( order == 1 ){%>selected<%}%>>Empresa</option>-->
                    <option value="2" <%if( order == 2 ){%>selected<%}%>>Fecha</option>
                    <!--<option value="3" <%if( order == 3 ){%>selected<%}%>>Valor</option>-->
                    <option value="4" <%if( order == 4 ){%>selected<%}%>>Estado</option>
                  </select></td> 
                  <td colspan='2' align="center">
                      <input type="submit" value=' Buscar ' name='Buscar' id='Buscar'>
                  </td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                    <td align="left" valign="bottom"><img src="/proveedor/images/bus2.gif" width="16" height="15"></td>
                    <td colspan='6'>&nbsp;</td>
                    <td align="right" valign="bottom"><img src="/proveedor/images/bus4.gif" width="15" height="15"></td>
                </tr>
              </table>
              <table align="center">
                <tr>
                    <td>
                        <jsp:include page="/general/paginador.jsp" flush="true">
                            <jsp:param name="page" value="<%=page1%>" />
                            <jsp:param name="pages" value="<%=pages%>" />
                            <jsp:param name="pageResults" value="<%=pageResults%>" />
                        </jsp:include>
                    </td>
                </tr>
                <tr>
                    <td>
                        <jsp:include page="/general/resultados.jsp" flush="true">
                            <jsp:param name="firstRow" value="<%=firstRow%>" />
                            <jsp:param name="lastRow" value="<%=lastRow%>" />
                            <jsp:param name="total" value="<%=total%>" />
                        </jsp:include>
                    </td>
                </tr>
            </table>
            </form>
            <%
                tittle = "&Oacute;rdenes de Compra";
            %>
            <%@ include file="/titulo.jsp" %>
            <table border="0" align="center" width='90%' >
              <tr class='tableheader' align="center">
                <td><strong>Id Pedido</strong></td>
                <td width='20%'><strong>Nombre Comercial</strong></td>
                <td width='20%'><strong>Establecimiento</strong></td>
                <td><strong>Fecha</strong></td>
                <td><strong>Valor</strong></td>
                <td align='center'><strong>Estado</strong></td>
                <td align='center'><strong>Super<br>Oferta</strong></td>
                <td align='center'><strong>Ver</strong></td>
              </tr>
                <%
                    int cont = 0;
                    int countRows = 0;
                    String color = "";
                    while( view.move() ){
                        if( countRows % 2 == 0 )
                        {
                                color = "FFFFF0";
                        }
                        else
                        {
                                color = "EFEFEF";
                        }
                        countRows++;
                        cont++;
                        int id = Integer.parseInt( ( String )view.nextElement() );
                        String data="";
                        view.nextElement();
                %>
                        <tr bgcolor='<%=color%>'>
                            <td><%=id%></td>
                     <%
                        int i=1;
                        while((data=(String)view.nextElement())!=null){
                            if(i==6){
                                String checked = "";
                                if( new Integer(data).intValue() > 0){
                                    checked = "checked";
                                }
                            %>
                                <td align="center"><input type="checkbox" <%=checked%> disabled></td>
                            <%
                            }else{
                            %>
                                <td><%=data%></td>
                            <% i++;
                            }
                     %>

                     <% }
                     %>
                            <td align="center"><a href="/proveedor/verordencompra?key=<%= id %>"><img alt="Detalle Pedido" name="view" src='/images/buttons/supplier/detalle.gif'  border='0'></a></td>
                        </tr>
                <%
                    }
                if(cont == 0){%>
                   <tr>
                        <td colspan='6'>
                            <b >NINGUNA ORDEN DE COMPRA HA SIDO GENERADA POR SUS CLIENTES</b>
                        </td>
                   </tr>
                <%}%>
            </table>
            <table align="center">
                <tr>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td align="rigth"><font size='2'><b>Sumatoria Total Pedidos:</b> <%=request.getAttribute("sumTotal").toString()%></font></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>
                        <jsp:include page="/general/resultados.jsp" flush="true">
                            <jsp:param name="firstRow" value="<%=firstRow%>" />
                            <jsp:param name="lastRow" value="<%=lastRow%>" />
                            <jsp:param name="total" value="<%=total%>" />
                        </jsp:include>
                    </td>
                </tr>
            </table>
<!-- -->
  </td>
</td>
</table>
<table width="760">
	<tr>
		<td><%@ include file="/piepagina.jsp" %></td>
	</tr>
</table>
</body>
</html>
// “Copyright (C) <2008> Multilateral Investment Fund of the Inter-American Development Bank.
// Este archivo es parte de <ICT4BUS-PVL>
// < ICT4BUS-PVL > es software libre: usted puede redistribuirlo y/o modificarlo bajo los términos de la Licencia Pública General GNU publicada por la Fundación para el Software Libre, ya sea la versión 3 de la Licencia, o (a su elección) cualquier versión posterior.
// < ICT4BUS-PVL > se distribuye con la esperanza de que sea útil, pero SIN GARANTÍA ALGUNA; ni siquiera la garantía implícita MERCANTIL o de APTITUD PARA UN PROPÓSITO DETERMINADO. 
// Consulte los detalles de la Licencia Pública General GNU para obtener una información más detallada. 
// Debería haber recibido una copia de la Licencia Pública General GNU junto a este programa. En caso contrario, consulte http://www.gnu.org/licenses/.”