<?php 
header("Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; name='excel'");
header("Content-Disposition: filename=descarga_exportacion_pagos_".date("Y-m-d").".xls");
header("Pragma: no-cache");
header("Expires: 0");
session_start();
include("../comun/coneximpo.php");
$link=Conectarse();
 
 
$result = mysqli_query($link,"SELECT modifico_atd,booking_interteam,customer,atd,no_aplica_confirmacion_pago,creo_atd,files,
reviso_pago_no_aplica,fecha_reviso_pago_no_aplica,etafinaldest from bookingexpint FORCE INDEX (i_atd)
where no_aplica_confirmacion_pago<>''  and no_aplica_confirmacion_pago<>'NO APLICA. BL COLLECT.'
 and (ofwmpp='PP' or ofminpp='PP' or bllppp='PP' or imcopp='PP' or precarrpp='PP' or custclpp='PP' or other1pp='PP' or other2pp='PP' or fumpp='PP' or cfspp='PP')
   
 ".
($_SESSION['tipo']=='AIRE' ? " and booking_interteam like '%EXITMEX%' " : " and booking_interteam not like '%EXITMEX%' " )."

order by $forder "); //limit 200
 
 

if (mysqli_num_rows($result)>0){

?>	
	
<table border = '1' id='Exportar_a_Excel' class="sortable" width="60%"  cellpadding="1" cellspacing="1" align="center"  bordercolorlight="#FFFFFF"  > 
<thead>
<?
$i=0;$j=1;
?>
<TR>
<TH nowrap><h3><font size="1" face="Arial, Helvetica, sans-serif">#</font></h3></TH> 
<TH nowrap><h3><font size="1" face="Arial, Helvetica, sans-serif">BOOKING</font></h3></TH>
<TH nowrap><font size="1" face="Arial, Helvetica, sans-serif">TIPO DE CARGA</font></TH> 
<TH nowrap><h3><font size="1" face="Arial, Helvetica, sans-serif">ATD</font></h3></TH>
<TH nowrap><font size="1" face="Arial, Helvetica, sans-serif">ETA F.D.</font></TH>
<TH nowrap><font size="1" face="Arial, Helvetica, sans-serif">USUARIO GUARDO ATD</font></TH>
<TH nowrap><h3><font size="1" face="Arial, Helvetica, sans-serif">CONDICION DE PAGO</font></h3></TH> 
<TH nowrap><h3><font size="1" face="Arial, Helvetica, sans-serif">CLIENTE</font></h3></TH> 
<TH nowrap><h3><font size="1" face="Arial, Helvetica, sans-serif">NO APLICA</font></h3></TH>
<TH nowrap><h3><font size="1" face="Arial, Helvetica, sans-serif">USUARIO GUARDO </font></h3></TH>
<TH nowrap><font size="1" face="Arial, Helvetica, sans-serif">REVISADO</font></TH>
<TH nowrap><font size="1" face="Arial, Helvetica, sans-serif">USUARIO QUE REVISO</font></TH>
</TR>
</thead>
<tbody>

<?

//fpeso_volumen1($rqury[bl_house],$referencia);

 
while ($row = mysqli_fetch_array($result)) {
 
$result1 = mysqli_query($link,"SELECT credito from customerexpint_n where socialreason = '".$row["customer"]."'");	 
$row1 = mysqli_fetch_array($result1);	 
$result2 = mysqli_query($link,"SELECT service from datosexpint where files = '".$row["files"]."'");	 
$row2 = mysqli_fetch_array($result2);
?>
<TR>
<TD nowrap ><font size="1" face="Arial, Helvetica, sans-serif"><?= ($j) ?></font></TD><? $j++;?>
<TD nowrap ><font size="1" face="Arial, Helvetica, sans-serif"><?=$row["booking_interteam"]?></font></TD>
<TD nowrap ><font size="1" face="Arial, Helvetica, sans-serif">
  <?=$row2["service"]?>
</font></TD> 
<TD nowrap <?=$row["fec"]==date("Y-m-d") ? 'style="background-color:#3FF"' : ''?>><font size="1" face="Arial, Helvetica, sans-serif"><?=$row["atd"]?></font></TD>
<TD nowrap <?=$row["fec"]==date("Y-m-d") ? 'style="background-color:#3FF"' : ''?>><font size="1" face="Arial, Helvetica, sans-serif">
  <?=$row["etafinaldest"]?>
</font></TD>
<TD nowrap  <?=$row["fec"]==date("Y-m-d") ? 'style="background-color:#3FF"' : ''?>><font size="1" face="Arial, Helvetica, sans-serif">
  <?=str_replace('-exporta','',($row["creo_atd"]=='' ? $row["modifico_atd"] : $row["creo_atd"]))?>
</font></TD>
<TD nowrap  <?=$row["fec"]==date("Y-m-d") ? 'style="background-color:#3FF"' : ''?>><font size="1" face="Arial, Helvetica, sans-serif">
<?= $row1[credito]==1 ? 'CREDITO' : 'CONTADO'?> 
</font></TD> 
<TD nowrap ><font size="1" face="Arial, Helvetica, sans-serif"><?=utf8_decode($row["customer"])?></font></TD> 
<TD nowrap ><font size="1" face="Arial, Helvetica, sans-serif"><?=$row["no_aplica_confirmacion_pago"]?></font></TD>
<TD nowrap ><font size="1" face="Arial, Helvetica, sans-serif"><?=$row["usuario_guardo_no_aplica"]?></font></TD>
<TD nowrap ><font size="1" face="Arial, Helvetica, sans-serif">
  <?=$row["fecha_reviso_pago_no_aplica"]?>
</font></TD>
<TD nowrap ><font size="1" face="Arial, Helvetica, sans-serif">
  <?=$row["reviso_pago_no_aplica"]?>
</font></TD>
</TR>
<?
 
   } 
?>
</tbody>
</table>
<?
 
   } 
?>