<?php
session_start();
include('../_cfg/config.php');
include ('php_gene1.php');
include ('php_session.php');

$docu=$_GET['docu'];
$fecha1=$_GET['fecha1'];
$fecha2=$_GET['fecha2'];
$enti=$_GET['enti'];
$order=$_GET['order'];

if($docu==''){$docu=$_POST['docu'];}
if($fecha1==''){$fecha1=$_POST['fecha1'];}
if($fecha2==''){$fecha2=$_POST['fecha2'];}
if($enti==''){$enti=$_POST['enti'];}
if($order==''){$order=$_POST['order'];}

if($fecha1==''){$fecha1=date('Y-m-1');}
if($fecha2==''){$fecha2=date('Y-m-d');}


$sql_docu='select * from docu0 where docu_codigo like "'.substr($docu,0,2).'%" order by docu_codigo';
$res_docu=mysql_query($sql_docu,$link_vcrx);
$tabla =mysql_result($res_docu,0,'docu_tabla');


$sql_docu ='select * from '.$tabla.'1 left join enti0 on enti=enti_codigo ';
$sql_docu.=' where docu like "'.substr($docu,0,2).'%"';
$sql_docu.=' and enti like "'.substr($enti,0,10).'%"';
$sql_docu.=' and fecha>="'.$fecha1.'"';
$sql_docu.=' and fecha<="'.$fecha2.'"';
if($order=='E'){$sql_docu.=' order by enti_descri,numero';}
if($order=='F'){$sql_docu.=' order by fecha,enti_descri,numero';}
if($order=='N'){$sql_docu.=' order by numero,idnum1';}
$res_docu=mysql_query($sql_docu,$link_vcrx);


?>

<?php ob_start(); ?>

<?php
$xride='';
while($aso_docu=mysql_fetch_assoc($res_docu))
{
  $xdocu=$aso_docu['docu'];
  $ride=prnt_docu0($xdocu,$aso_docu['idnum1']);
  
  $ride =substr($ride,strpos($ride,'<body>'+0));
  $ride =substr($ride,0,strpos($ride,'</body>')+7);
  
  if(mb_stristr('RC',substr($xdocu,0,2)))
  {$ride = str_replace('<recibe>','<recibe style="display:none;">',$ride);}
  
  echo '<div';
  if(mb_stristr('RC',substr($xdocu,0,2))){echo ' style="height:148.5mm;"';}
  echo '>';
  echo $ride;
  echo '</div>';
}
?>

<?php
$docuhtml = ob_get_clean(); 
$docuhtml=alltrim($docuhtml);
echo $docuhtml;	
return;  
?>
