<?

require "../checa1.php";

?>
<? 
//include("../../../header_subnivel3.php");
include("../../js/comun/funciones.php");
?>

<link rel="stylesheet" href="../sorter/style.css" />

<link type="text/css" rel="stylesheet" href="../../../../js/dhtmlgoodies_calendar_1/dhtmlgoodies_calendar.css" media="screen"></LINK>
<SCRIPT type="text/javascript" src="../../../../js/dhtmlgoodies_calendar_1/dhtmlgoodies_calendar.js"></script>

<!--<link rel="stylesheet" type="text/css" href="../style.css" media="all" />-->
 
<script type="text/javascript" src="../../../../js/jQueryExcel/jquery-1.3.2.min.js"></script>
<script language="javascript">
$(document).ready(function() {
	$(".botonExcel").click(function(event) {
		$("#datos_a_enviar").val( $("<div>").append( $("#table").eq(0).clone()).html());
		$("#FormularioExportacion").submit();
});
});
</script>
<style type="text/css">
.botonExcel{cursor:pointer;}
.texto {
	font-family: Verdana, Geneva, sans-serif;
	font-size: 11px;
}
</style>

<div align="justify" style="line-height:18px;margin-top:-44px; position:absolute;width: 1500px; height:100%;background:url(../../../images/mundo.jpg) ">
<br />
 
<br>

<form name="form1" id="form1" method="post" action="vacios.php">
  <table width="66%" border="0" align="left" style="line-height:25px">

    <tr bordercolor="#FFFFFF"> 

      <td width="9%" class="texto"  >Desde fecha</td>

      <td width="17%" align="left"> 
      <input type="text" name="txtvacios_date" id="txtvacios_date" readonly="readonly" value="<?=$_POST[txtvacios_date]?>"  onclick="displayCalendar(document.getElementById('txtvacios_date'),'yyyy-mm-dd',this)"></td>
      <td width="9%" class="texto">Hasta fecha</td>
      <td width="65%" align="left"><input type="text" name="txtvacios_date_till" id="txtvacios_date_till" readonly="readonly" value="<?=$_POST[txtvacios_date_till]?>"  onclick="displayCalendar(document.getElementById('txtvacios_date_till'),'yyyy-mm-dd',this)" /></td>

    </tr>
 
    <tr bordercolor="#FFFFFF">
      <td class="texto" >Referencia</td>
      <td align="left"><input type="text" name="txtreferencia" id="txtreferencia" value="<?=$_POST[txtreferencia]?>" /></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr bordercolor="#FFFFFF">
      <td  class="texto">Marcas</td>
      <td colspan="3" align="left" class="texto"><input type="text" name="txtmarcas" id="txtmarcas"  /></td>
    </tr>
    <tr bordercolor="#FFFFFF">
      <td  class="texto">Pantainer</td>
      <td colspan="3" align="left" class="texto"><input type="text" name="txtpantainer" id="txtpantainer"  /></td>
    </tr>
    <tr bordercolor="#FFFFFF">
      <td  class="texto">Listar        &nbsp;</td>
      <td colspan="3" align="left" class="texto"><input name="top_limit" type="text" id="top_limit" size="5" value="<?=$_POST[top_limit]=='' ? 50 : $_POST[top_limit]?>" />
      filas</td>
    </tr>
    <tr bordercolor="#FFFFFF">
      <td  ><input type="submit" name="Submit2sb" value="Buscar" >
	  </td>
      <td colspan="3">&nbsp;</td>
    </tr>
    
  </table>
   
 
<?php 
include("../coneximpo.php"); 
$link = Conectarseimpo() ;
$condicion='';
$titulo='BUSQUEDA DE VACIOS PENDIENTES DE ENTREGA SEGUN FILTRO: ';
if($_POST[txtvacios_date_till]==''){
	$_POST[txtvacios_date_till]=$_POST[txtvacios_date];
}

$condicion.= ($_POST[txtvacios_date]!='' ? ($condicion!='' ? " AND " : '') . " (fecha_entrega_vacio between '".$_POST[txtvacios_date]."' AND '".$_POST[txtvacios_date_till]."') " : '' );
$condicion.= ($_POST[txtreferencia]!='' ? ($condicion!='' ? " AND " : '') . " txtreferencia like '%".$_POST[txtreferencia]."%' " : '' );

$titulo.= ($_POST[txtvacios_date]!='' ? ($condicion!='' ? " * " : '') . " Desde fecha = ".$_POST[txtvacios_date]." " : '' );
$titulo.= ($_POST[txtvacios_date_till]!='' ? ($condicion!='' ? " * " : '') . " Hasta fecha = ".$_POST[txtvacios_date_till]." " : '' );
$titulo.= ($_POST[txtreferencia]!='' ? ($condicion!='' ? " * " : '') . " de la referencia = ".$_POST[txtreferencia]." " : '' );
$titulo.= ($_POST[txtpantainer]!='' ? ($condicion!='' ? " * " : '') . " del pantainer no = ".$_POST[txtpantainer]." " : '' );
$titulo.= ($_POST[txtmarcas]!='' ? ($condicion!='' ? " * " : '') . " que son de las marcas = ".$_POST[txtmarcas]." " : '' );
 
$page2f = ($_POST[top_limit]=='' ? 50 : $_POST[top_limit]);

if($condicion==''){
	$result = mysql_query("SELECT * FROM contenedor_pantainer ORDER BY fecha_entrega_vacio desc limit 0,$page2f");
}else{
	$result = mysql_query("SELECT * FROM contenedor_pantainer WHERE $condicion ORDER BY fecha_entrega_vacio desc limit 0,$page2f");
	//echo "SELECT * FROM bookingexpint WHERE $condicion ORDER BY pickupdate desc limit 0,$page2f";
}


if ($row = mysql_fetch_array($result)){ 

$titulo.= ($_POST[txtfile]!='' ? ($condicion!='' ? " * " : '') . " File = ".$row[files]." " : '' );
?>

<!-- class="tablas_con_bordes_"-->		
<br /><br /><br /><br /><br /><br />
<p align="left" style="font-family:Arial, Helvetica, sans-serif; font-size:11px">&nbsp;</p>
</form>

 <p align="left" style="font-family:Arial, Helvetica, sans-serif; font-size:11px">
 <a class="botonExcel" style="color:#009; text-decoration:underline"><span style="font-family:Arial, Helvetica, sans-serif; font-size:11px">Exportar a Excel</span></a>
 <form action="searches_pick_up_date_exc.php" method="post" target="_blank" id="FormularioExportacion">

<input type="hidden" id="datos_a_enviar" name="datos_a_enviar" />
<input type="hidden" id="titulo" name="titulo" value="<?=$titulo=='BUSQUEDA DE VACIOS PENDIENTES DE ENTREGA SEGUN FILTRO: ' ? '' : $titulo?> 
  FECHA DE LISTADO: <?=date("Y/m/d")?>" />
</form>
<span class="texto">
  <?=$titulo=='BUSQUEDA DE VACIOS PENDIENTES DE ENTREGA SEGUN FILTRO: ' ? '' : $titulo?>
* FECHA DE LISTADO:

 <?=date("Y/m/d")?>
 </span>
</p>

	
<table border = '1' align="left"  id="table" class='sortable' style="font-family:Arial, Helvetica, sans-serif; font-size:11px" >

			  <? $i=0; ?>
			  <thead>
              
              <tr>
				<th align="left">#</th>
                <th align="left"><h3>REFERENCIA NO</h3></th>
                <th align="left"><h3>BL NO</h3></th>
                <th align="left" width="130PX"><h3>FECHA DE RECEPCION</h3></th>
                <th align="left"><h3>CLIENTE</h3></th>
                <th align="left"><h3>BUQUE</h3></th>
                <th align="left"><h3>NAVIERA</h3></th>
                <th align="left"><h3>PUERTO</h3></th>
                <th align="left" width="140PX"><h3>FECHA REVAL NAVIERA</h3></th>
                <th align="left"><h3>AGENTE ADUANAL</h3></th>
                <th align="left" width="120PX"><h3>FECHA REVAL AA</h3></th>
                </tr>
</thead>
			  <?
			do {
			$i=$i+1; 
			?>
			  <tr class='comun'>
				<td align="left"><font size="1" face="Arial, Helvetica, sans-serif">
				  <?=$i?></font>
                </td>
                <td align="left"><font size="1" face="Arial, Helvetica, sans-serif">
				  <?=$row["transportcompany"]?></td>
				<td align="left"><font size="1" face="Arial, Helvetica, sans-serif">
			    <?=$row["booking_interteam"]?></td>
                 <td align="left"><font size="1" face="Arial, Helvetica, sans-serif">
			    <?=$row["pickupdate"]?></td> 
                <td align="left"><font size="1" face="Arial, Helvetica, sans-serif">
				  <?=$row["customer"]?></td>
				<td align="left"><font size="1" face="Arial, Helvetica, sans-serif">
			    <?=$row["pickupplace"]?></td>
                 <td align="left"><font size="1" face="Arial, Helvetica, sans-serif">
			    <?=$row["pickupcity"]?></td> 
                <td align="left"><font size="1" face="Arial, Helvetica, sans-serif">
				  <?=$row["pickupstate"]?></td>
                <?  $dat=data("select pol,pol_country,pod,pod_country from datosexpint where files = '".$row[files]."'");
				$pol=$dat[pol];$pol_country=$dat[pol_country];$pod=$dat[pod];$pod_country=$dat[pod_country];
				?>
				
                
                <? 
				$tipo='';
				$typeQ=mysql_query("select type from detailcargaexpint where files = '".$row[files]."' 
				and bookingno='".$row[booking]."' ");	
				while($rT=mysql_fetch_array($typeQ)){
					$tipo.=$rT[type].'<br>';
				}
				
				$bulks=busquedaB("select sum(bulk) as suma from detailcargaexpint where files = '".$row[files]."' 
				and bookingno='".$row[booking]."' ",'suma');	
				
				$measurement=busquedaB("select sum(measurement) as suma from detailcargaexpint where files = '".$row[files]."' 
				and bookingno='".$row[booking]."' ",'suma');	
				
				//echo "select sum(measurement) as suma from detailcargaexpint where files = '".$row[files]."' 
				//and bookingno='".$row[booking]."' ";
	 			$weight=busquedaB("select sum(weight) as suma from detailcargaexpint where files = '".$row[files]."' 
				and bookingno='".$row[booking]."' ",'suma');
     			?>
                <td align="right"><font size="1" face="Arial, Helvetica, sans-serif"><?=$bulks?></font></td>
                
                <td align="right"><font size="1" face="Arial, Helvetica, sans-serif"><?=$tipo?></font></td>
                
                <td align="right"><font size="1" face="Arial, Helvetica, sans-serif">
                <?=number_format($weight,2)?></font></td>
              </tr>
			  <?
			} while ($row = mysql_fetch_array($result)); 
			
			?>
  </table>

 
  <?
  }?>
 

<p>&nbsp;</p><p>&nbsp;</p>
<p>&nbsp;</p><p>&nbsp;</p> <br />
 
</div>
<script type="text/javascript"  src="../sorter/script.js"></script>
<script type="text/javascript">
  if(document.getElementById('table')) {
  var sorter = new TINY.table.sorter("sorter");
	sorter.head = "head";
	sorter.asc = "asc";
	sorter.desc = "desc";
	sorter.even = "evenrow";
	sorter.odd = "oddrow";
	sorter.evensel = "evenselected";
	sorter.oddsel = "oddselected";
	sorter.paginate = true;
	sorter.currentid = "currentpage";
	sorter.limitid = "pagelimit";
	sorter.init("table",0);
  }
  </script>
