<? 
include("../../../header_subnivel3.php");
//include("../../../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;}
</style>

<div align="justify" style="line-height:18px;margin-top:-44px; position:absolute;width: 1500px; height:100%;background:url(../../../images/mundo.jpg) ">
<br />
<span style="color:#00AF4B">Rolled booking search  &raquo;</span>
<br><br>

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

    <tr bordercolor="#FFFFFF"> 

      <td width="18%" bgcolor="#00E1A9">Desde Fecha</td>

      <td width="26%"> 
      <input type="text" name="txtfecha_desde" id="txtfecha_desde" readonly="readonly" value="<?=$_POST[txtfecha_desde]?>"  onclick="displayCalendar(document.forms[0].txtfecha_desde,'yyyy-mm-dd',this)"></td>
      <td width="15%">Hasta Fecha</td>
      <td width="41%"><input type="text" name="txtfecha_hasta" id="txtfecha_hasta" readonly="readonly" value="<?=$_POST[txtfecha_hasta]?>"  onclick="displayCalendar(document.forms[0].txtfecha_hasta,'yyyy-mm-dd',this)" /></td>

    </tr>
 
    <tr bordercolor="#FFFFFF">
      <td bgcolor="#00E1A9">File desde</td>
      <td><input type="text" name="txtfile" id="txtfile" value="<?=$_POST[txtfile]?>" /></td>
      <td>File hasta</td>
      <td><div align="left">
        <input type="text" name="txtfile_hasta" id="txtfile_hasta" value="<?=$_POST[txtfile_hasta]?>" />
      </div></td>
    </tr>
    <tr bordercolor="#FFFFFF">
      <td bgcolor="#00E1A9">Booking interteam</td>
      <td colspan="3"><input type="text" name="txtbooking_interteam" id="txtbooking_interteam" value="<?=$_POST[txtbooking_interteam]?>" /></td>
    </tr>
    <tr bordercolor="#FFFFFF">
      <td bgcolor="#00E1A9">Listar        &nbsp;</td>
      <td colspan="3"><input name="top_limit" type="text" id="top_limit" size="5" value="<?=$_POST[top_limit]=='' ? 30 : $_POST[top_limit]?>" />
      filas</td>
    </tr>
    <tr bordercolor="#FFFFFF">
      <td bgcolor="#00E1A9"><input type="submit" name="Submit2sb" value="Buscar" >
	  </td>
      <td colspan="3">&nbsp;</td>
    </tr>
    
  </table>
   
 
<?php 
 
include("../../../comun/conexion3.php");



$condicion='';
$titulo='BOOKINGS ROLLED SEGUN FILTRO: ';
if($_POST[txtfecha_hasta]==''){
	$_POST[txtfecha_hasta]=$_POST[txtfecha_desde];
}

$condicion.= ($_POST[txtfecha_desde]!='' ? ($condicion!='' ? " AND " : '') . " ( fecha_rolled between '".$_POST[txtfecha_desde]."' AND '".$_POST[txtfecha_hasta]."') " : '' );
$condicion.= ($_POST[txtfile]!='' ? ($condicion!='' ? " AND " : '') . " files_desde like '%".$_POST[txtfile]."%' " : '' );
$condicion.= ($_POST[txtfile_hasta]!='' ? ($condicion!='' ? " AND " : '') . " files_hasta like '%".$_POST[txtfile_hasta]."%' " : '' );
$condicion.= ($_POST[txthbl_desde]!='' ? ($condicion!='' ? " AND " : '') . " hbl_desde like '%".$_POST[txthbl_desde]."%' " : '' );
$condicion.= ($_POST[txtbooking_interteam]!='' ? ($condicion!='' ? " AND " : '') . " booking_interteam like '%".$_POST[txtbooking_interteam]."%' " : '' );

$titulo.= ($_POST[txtfecha_desde]!='' ? ($condicion!='' ? " * " : '') . " Desde fecha = ".$_POST[txtfecha_desde]." " : '' );
$titulo.= ($_POST[txtfecha_hasta]!='' ? ($condicion!='' ? " * " : '') . " Hasta fecha = ".$_POST[txtfecha_hasta]." " : '' );


 
$page2f = ($_POST[top_limit]=='' ? 30 : $_POST[top_limit]);

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


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

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

<!-- class="tablas_con_bordes_"-->		
<br /><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_rolled_booking_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=='BOOKINGS ROLLED SEGUN FILTRO: ' ? '' : $titulo?> 
  FECHA DE LISTADO: <?=date("Y/m/d")?>" />
</form>
  <?=$titulo=='BOOKINGS ROLLED SEGUN FILTRO: ' ? '' : $titulo?> 
 * FECHA DE LISTADO: <?=date("Y/m/d")?>
</p>

	
<table border = '1' align="left" width="100%"  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>DESDE FILE</h3></th>
                <th align="left"><h3>HASTA FILE</h3></th>
                <th align="left"><h3>BOOKING </h3></th>
                <th align="left"><h3>HBL </h3></th>
                <th align="left"><h3>FECHA DE ROLL OVER</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["files_desde"]?></td>
                <td align="left"><font size="1" face="Arial, Helvetica, sans-serif">
				  <?=$row["files_hasta"]?></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["hbl_desde"]?></td>
                 <td align="left"><font size="1" face="Arial, Helvetica, sans-serif">
			    <?=$row["fecha_rolled"]?>
                </td> 
			  </tr>
			  <?
			} while ($row = mysqli_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>
