<?

require "../checa1.php";

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<DIV id=popCal 
style="BORDER-RIGHT: 2px ridge; BORDER-TOP: 2px ridge; Z-INDEX: 100; VISIBILITY: hidden; BORDER-LEFT: 2px ridge; WIDTH: 10px; BORDER-BOTTOM: 2px ridge; POSITION: absolute" 
onclick=event.cancelBubble=true>

<IFRAME name=popFrame id=popFrame 
src="popcjs.htm" 
frameBorder=0 width=183 scrolling=no height=188></IFRAME></DIV>

<script type="text/javascript" src="../../../js/autocomplete/jquery.js"></script>
<link rel="stylesheet" type="text/css" href="../../../js/windowfiles_2/dhtmlwindow.css">
<script type="text/javascript" src="../../../js/windowfiles_2/dhtmlwindow.js"></script>
<SCRIPT type="text/javascript" src="../../../js/dhtmlgoodies_calendar_1/dhtmlgoodies_calendar.js?random=20060118"></script>
<link type="text/css" rel="stylesheet" href="../../../js/dhtmlgoodies_calendar_1/dhtmlgoodies_calendar.css" media="screen"></LINK>

<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( $("#Exportar_a_Excel").eq(0).clone()).html());
		$("#FormularioExportacion").submit();
});
});
</script>
<style type="text/css">
.botonExcel{cursor:pointer;}
</style>

<script type="text/javascript" src="../../../js/autocomplete/jquery.autocomplete.js"></script>
<link rel="stylesheet" type="text/css" href="../../../js/autocomplete/jquery.autocomplete.css" media="all" />
<script>
$().ready(function() {
 $("#txtnaviera").autocomplete("navieras.php", {
		width: 320,
		matchContains: true,
		selectFirst: false,
		max:150
	});
$("#txtnaviera").result(function(event, data, formatted) {
		$("#txtnaviera").val(data[1]);
});

$("#txtagente_aduanal").autocomplete("agentes_aduanales.php", {
		width: 320,
		matchContains: true,
		selectFirst: false,
		max:150
	});
$("#txtagente_aduanal").result(function(event, data, formatted) {
		$("#txtagente_aduanal").val(data[1]);
});


$("#txtbuque").autocomplete("buques.php", {
		width: 320,
		matchContains: true,
		selectFirst: false,
		max:150
	});
$("#txtbuque").result(function(event, data, formatted) {
		$("#txtbuque").val(data[0]);
})

$("#txtpuerto").autocomplete("lista_de_pol.php", {
		width: 320,
		matchContains: true,
		selectFirst: false,
		max:150
	});
$("#txtpuerto").result(function(event, data, formatted) {
		$("#txtpuerto").val(data[0]);
})

$("#txtcliente").autocomplete("clientes.php", {
		width: 320,
		matchContains: true,
		selectFirst: false,
		max:150
	});
$("#txtcliente").result(function(event, data, formatted) {
		$("#txtcliente").val(data[0]);
})
});
</script>

 
<!--<script type="text/javascript" src="../../../js/jQueryExcel/jquery-1.3.2.min.js"></script>-->
<script src="../../../js/funciones.js" type="text/javascript"></script>

<style type="text/css">
.botonExcel{cursor:pointer;}
</style>
<SCRIPT event=onclick() 
for=document>document.getElementById('popCal').style.visibility = "hidden";</SCRIPT>


<script>
function seleccionar(conexion){
	parent.document.getElementById('txtvessel').value=conexion
	parent.document.getElementById('VesselsBox').close()
}


function checainco()
{

vas1=this.document.form1.txtmaster_bl.value;
vas2=this.document.form1.txtfecha_registro.value;
vas3=this.document.form1.txtcliente.value;
vas4=this.document.form1.txtbuque.value;
vas5=this.document.form1.txtnaviera.value;
vas6=this.document.form1.txtpuerto.value;
vas7=this.document.form1.txtid.value;


if ( vas1.length==0 || vas2.length==0 || vas3.length==0 || vas4.length==0 || vas5.length==0 || vas6.length==0 || vas7.length==0 )

{

alert ("Por favor complete todos los datos de bl master");

return;

}

 this.document.form1.submit();

}



function checacontainer()

{
if(document.getElementById('txtmaster_bl').value==''){
	alert ("Ingrese el master bl al que pertenece este contenedor");
	return;
}


vas1=this.document.form2.txtmarcas.value;
 

if ( vas1.length==0)

{

alert ("Complete las marcas del contenedor");

return;

}




this.document.form2.submit();

}


function checapantainer()

{

vas1=this.document.form3.txtnopantainer.value;
//vas2=this.document.form3.txtimportador.value;

if(document.getElementById('txtmaster_bl').value==''){
	alert ("Ingrese el master bl al que pertenece este contenedor");
	document.getElementById('txtmaster_bl').focus()
	return;
}

if(document.getElementById('txtmarcas').value==''){
	alert ("Ingrese el contenedor al que pertenece el pantainer (marcas)");
	document.getElementById('txtmarcas').focus()
	return;
}

if ( vas1.length==0)
{
alert ("Complete el numero de pantainer");
document.getElementById('txtnopantainer').focus()
return;
}
/*
if ( vas2.length==0)
{
alert ("Complete el importador del pantainer");
document.getElementById('txtimportador').focus()
return;
}*/
this.document.form3.submit();

}

</script>

<script language="Javascript">

function preguntar(inst1,dato){

eliminar=confirm("Do you really want to delete it ? ");

if (eliminar)

window.location.href = inst1; 

//else

//alert('No se ha podido eliminar el registro...')

}

</script>

<html>

<head>
 

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
<!--
body,td,th {
	font-family: Verdana, Geneva, sans-serif;
	font-size: 12px;
}
-->
</style></head>



<body background="../EXPORTACIONES/mundo.jpg">

<? echo "<div align=\"center\"><strong><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">BIENVENIDO " . $_SESSION['name'] . "</font><BR><BR>
REPORTE DE FECHAS DE ENTREGA DE VACIOS</strong>
</div>";?>


<br>
<form name="form1" id="form1" method="post" action="guardamasterbl.php">
 
  <table width="471" border="0" align="center">
    <tr bordercolor="#666666" >
      <td colspan="3" bgcolor="#CCFFFF"><b>B&uacute;squeda por Master BL</b></td>
    </tr>
    <tr bordercolor="#FFFFFF">
      <td>No referencia (*)</td>
      <td colspan="2" align="left"><input type="text" name="txtid" id="txtid" size="40" 
      value="<? //=$_POST[txtid]?>" ></td>
    </tr>
    <tr bordercolor="#FFFFFF">
      <td>BL No (*)</td>
      <td colspan="2" align="left"><!--onBlur="document.getElementById('form1').action='manage.php';document.getElementById('form1').submit()-->
      <input type="text" name="txtmaster_bl" id="txtmaster_bl" size="40" 
      value="<?=($_POST[txtmaster_bl]=='' ? $_GET[txtmaster_bl] : $_POST[txtmaster_bl]) ?>" ></td>
    </tr>
    
    <tr bordercolor="#FFFFFF">
      <td colspan="3" align="left"><i>(*) Son criterios de b&uacute;squeda</i></td>
    </tr>
    <tr bordercolor="#FFFFFF">
      <td colspan="3" align="left"><input type="button" name="Submit2sb" value="Buscar" onClick="document.getElementById('form1').action='vacios.php';document.getElementById('form1').submit()"></td>
    </tr>
    
</table>
</form>
    
<form name="form2" id="form2" method="post" >
<input type="hidden" id="contenedor_txtmaster_bl" name="contenedor_txtmaster_bl">
<input type="hidden" id="txtidcontenedor" name="txtidcontenedor">
  <table width="508" border="0" align="center">
    <tr bordercolor="#FFFFFF" bgcolor="#FF9933">
      <td colspan="2" align="left"><b>B&uacute;squeda por  contenedor</b></td>
    </tr>
    <tr bordercolor="#FFFFFF">
      <td width="197" align="left">Marcas</td>
      <td width="301" align="left"><input type="text" name="txtmarcas" id="txtmarcas" size="40" value="<?=$_GET[txtmarcas]?>"></td>
    </tr>
    <tr bordercolor="#FFFFFF">
      <td align="left">Fecha de entrega Vac&iacute;o Desde</td>
      <td align="left"><input type="text" name="txtfecha_entrega_vacio" id="txtfecha_entrega_vacio" size="40" readonly onClick="displayCalendar(document.getElementById('txtfecha_entrega_vacio'),'yyyy-mm-dd',this)" >
      <!--<INPUT onClick="popFrame.fPopCalendar(txtfecha_entrega_vacio,txtfecha_entrega_vacio,popCal);return false" type=button value=V>--></td>
    </tr>
    <tr bordercolor="#FFFFFF">
      <td align="left">Fecha de entrega Vac&iacute;o Hasta</td>
      <td align="left"><input type="text" name="txtfecha_entrega_vacio2" id="txtfecha_entrega_vacio2" size="40" readonly onClick="displayCalendar(document.getElementById('txtfecha_entrega_vacio2'),'yyyy-mm-dd',this)" ></td>
    </tr>
    <tr bordercolor="#FFFFFF">
      <td colspan="2" align="left"><input type="button" name="Submit2sb2" value="Buscar" onClick="document.getElementById('form2').action='vacios.php';document.getElementById('form2').submit()"></td>
    </tr>
  </table>
  </form>
 <!-- master_bl
  contenedor_pantainer
  pantainer
  -->
<form name="form3" id="form3" method="post" action="guarda_pantainer.php" style="display:none">
  <input type="hidden" id="pantainer_txtmaster_bl" name="pantainer_txtmaster_bl">
  <input type="hidden" id="pantainer_txtmarcas" name="pantainer_txtmarcas">
  <input type="hidden" id="txtidpantainer" name="txtidpantainer">
  <table width="445" border="0" align="center">
    <tr bordercolor="#FFFFFF" bgcolor="#66FF00">
      <td colspan="2" align="left"><b>B&uacute;squeda por  pantainer</b></td>
    </tr>
    <tr bordercolor="#FFFFFF">
      <td align="left">No. Pantainer</td>
      <td align="left"><input type="text" name="txtnopantainer" id="txtnopantainer" size="40" ></td>
    </tr>
    <tr bordercolor="#FFFFFF">
      <td align="left"><input type="button" value="Guardar Pantainer" onClick="
      document.getElementById('pantainer_txtmarcas').value=document.getElementById('txtmarcas').value;
      document.getElementById('pantainer_txtmaster_bl').value=document.getElementById('txtmaster_bl').value;
      checapantainer()">
      </td>
      <td colspan="2" align="left">&nbsp;</td>
    </tr>
    <tr bordercolor="#FFFFFF">
      <td align="left">&nbsp;</td>
      <td colspan="2" align="left">&nbsp;</td>
    </tr>
    <tr bordercolor="#FFFFFF">
      <td colspan="3" align="center"><a class="botonExcel" style="color:#009; text-decoration:underline"><span style="font-family:Verdana, Geneva, sans-serif; font-size:11px">Exportar a Excel</span></a>
      </td>
    </tr>
  </table>
  </form>
  <p> 

    <?php 



	include("../coneximpo.php"); 

//	include("paginacion.php"); 

   	$link = Conectarseimpo() ;

$txtmaster_bl= $_POST['txtmaster_bl'];

$page= $_GET['page'];

if ($page == "")

$page=1;

$page2i=0  + 30 * ($page-1);

$page2f=30;





	

$page= $_GET['page'];

if ($page == "")

$page=1;

$registrosm=30;

$page2i=0  + $registrosm * ($page-1);

$page2f=$registrosm;

$sqlpag="SELECT * FROM master_bl  order by fecha_registro desc";

$paf="vacios.php";
if($_POST[txtfecha_entrega_vacio]!=''){
			$result = mysqli_query("SELECT * FROM master_bl where master_bl in (select master_bl from contenedor_pantainer where 
			fecha_entrega_vacio >= '".$_POST[txtfecha_entrega_vacio]."' and fecha_entrega_vacio <= '".$_POST[txtfecha_entrega_vacio2]."') 
			order by referencia*1 desc limit $page2i,$page2f",$link); 
			$titulo = 'Entregas de vacio desde: '.$_POST[txtfecha_entrega_vacio].' hasta: '.$_POST[txtfecha_entrega_vacio2];
			
}else{
if($_POST[txtmarcas]!=''){ //HLXU 805008-3
			$result = mysqli_query("SELECT * FROM master_bl where master_bl in (select master_bl from contenedor_pantainer where 
			marcas = '".$_POST[txtmarcas]."') order by referencia*1 desc limit $page2i,$page2f",$link); 
			$titulo = 'Entregas de vacio de marcas: '.$_POST[txtmarcas];
			
}else{
		if($_POST[txtid]!=''){
					$titulo = 'Entregas de vacio de la Referencia: '.$_POST[txtid];
				
					$result = mysqli_query("SELECT * FROM master_bl where referencia like '%".$_POST[txtid]."%' order by referencia*1 
					desc limit $page2i,$page2f",$link);
		}else{
			if($_POST[txtmaster_bl]!=''){
					$titulo = 'Entregas de vacio de Master bl: '.$_POST[txtmaster_bl];
			
					$result = mysqli_query("SELECT * FROM master_bl where master_bl like '%".$_POST[txtmaster_bl]."%' 
					order by referencia*1 desc limit $page2i,$page2f",$link); 
			}else{
					echo '<div align="center">Ingrese su criterio de búsqueda. Nota: la selección de periodos grandes de consulta hace que el 
					reporte se demore en su descarga</div>';
					return;
			}
		}
}
}
if(mysqli_num_rows($result)==0){
	echo '<div align="center">No se encontraron resultados</div>';
	return;
}
?>

<p align="center" 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="vacios_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?> 
  FECHA DE LISTADO: <?=date("Y/m/d")?>" />
</form>
  
</p>


<?
if ($row = mysqli_fetch_array($result)){ 

?>
<table border = '1' align="center"  bordercolorlight="#0000FF" bgcolor="#CCFFFF" id="Exportar_a_Excel" >

<?

$i=0;

?>
<tr>
<td colspan="10"><strong><font size="2" face="Arial, Helvetica, sans-serif">
<?=$titulo?> 
 * FECHA DE LISTADO: <?=date("Y/m/d")?>
 </font></strong>
 </td>
</tr>

<TR>

  <TD width="77" ><strong><font size="1" face="Arial, Helvetica, sans-serif">Referencia No</font></strong></TD>
	   <TD width="32"><strong><font size="1" face="Arial, Helvetica, sans-serif">BL No</font></strong></TD>
	   <TD width="141"><strong><font size="1" face="Arial, Helvetica, sans-serif">Fecha de recepción</font></strong></TD>
	   <TD width="157"><strong><font size="1" face="Arial, Helvetica, sans-serif">Cliente</font></strong></TD>
	   <TD width="68"><strong><font size="1" face="Arial, Helvetica, sans-serif">Buque</font></strong></TD>
	   <TD width="74"><strong><font size="1" face="Arial, Helvetica, sans-serif">Naviera</font></strong></TD>
	   <TD width="86"><strong><font size="1" face="Arial, Helvetica, sans-serif">Puerto</font></strong></TD>
	   <TD width="143"><strong><font size="1" face="Arial, Helvetica, sans-serif">Fecha reval naviera</font></strong></TD>
	   <TD width="88"><strong><font size="1" face="Arial, Helvetica, sans-serif">Agente aduanal</font></strong></TD>
	   <TD width="88"><strong><font size="1" face="Arial, Helvetica, sans-serif">Fecha Reval Agente aduanal</font></strong></TD>
	   </TR>
<?       

do {

	$i=$i+1; 
 
?>
<TR>
  <TD><font size="1" face="Arial, Helvetica, sans-serif"><?=$row["referencia"]?></font></TD>
<TD><font size="1" face="Arial, Helvetica, sans-serif"><?=$row["master_bl"]?></font></TD>
<TD><font size="1" face="Arial, Helvetica, sans-serif"><?=$row["fecha_registro"]?></font></TD>
<TD><font size="1" face="Arial, Helvetica, sans-serif"><?=$row["cliente"]?></font></TD>
<TD><font size="1" face="Arial, Helvetica, sans-serif"><?=$row["buque"]?></font></TD>
<TD><font size="1" face="Arial, Helvetica, sans-serif"><?=$row["naviera"]?></font></TD>
<TD><font size="1" face="Arial, Helvetica, sans-serif"><?=$row["puerto"]?></font></TD>
<TD><font size="1" face="Arial, Helvetica, sans-serif"><?=$row["fecha_reval_naviera"]?></font></TD>
<TD><font size="1" face="Arial, Helvetica, sans-serif"><?=$row["agente_aduanal"]?></font></TD>
<TD><font size="1" face="Arial, Helvetica, sans-serif"><?=$row["fecha_reval_aa"]?></font></TD>
</TR> 

<?
 
$queryCont = mysqli_query("select * from contenedor_pantainer where master_bl = '".$row["master_bl"]."'",$link);

if(mysqli_num_rows($queryCont)>0){
	?>
<?	   
}
while($rCont=mysqli_fetch_array($queryCont)){
?>
<TR bgcolor="#FF9933">
<TD colspan="3">&nbsp;&nbsp;
</TD>
<TD ><font size="1" face="Arial, Helvetica, sans-serif">Tipo: <?=$rCont["tipo"]?></font></TD>
<TD colspan="3"><font size="1" face="Arial, Helvetica, sans-serif">
<? if($_POST[txtmarcas]==$rCont["marcas"]){ echo '<b><i>';}?>
Marcas: <?=$rCont["marcas"]?>
<? if($_POST[txtmarcas]==$rCont["marcas"]){ echo '</i></b>';}?>
</font>
</TD>
<TD colspan="3">
<font size="1" face="Arial, Helvetica, sans-serif">
Entrega vac&iacute;o: <?=$rCont["fecha_entrega_vacio"]?>
</font>
</TD>
</TR>

 

<?
 
$queryPant = mysqli_query("select * from pantainer where master_bl = '".$row["master_bl"]."' and marcas = '".$rCont["marcas"]."' ",$link);
 
if(mysqli_num_rows($queryPant)>0){
	?>
<?	   
}
while($rPant=mysqli_fetch_array($queryPant)){
?>
<TR bgcolor="#66FF00">
  <TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD >&nbsp;</TD>
<TD colspan="3"><font size="1" face="Arial, Helvetica, sans-serif">Pantainer no:&nbsp;<?=$rPant["nombre_pantainer"]?></font></TD>
<TD colspan="3"></TD>
</TR>
<? } ?>
<? } ?>
 

<?

   } while ($row = mysqli_fetch_array($result)); 

?></table>
<?
}
?>

  </p>

</body>

</html>

