<?php 
 include('../_cfg/config.php');
 include('php_gene1.php');
 include('php_session.php');
?>
<?php $xenti=$_POST['enti']; ?>
<?php $xdocu=$_POST['docu']; ?>

<resultado>
  
<?php $valor0=1/100; ?>  
<?php $xsaldo=0; ?>
<?php if(mb_stristr('IB.EB',substr($xdocu,0,2))){$valor0=-1;} ?>  
  
<!--   <dl_cxco> -->
  <?php 
  if(mb_stristr('IE.IC.DC.IV.EB',substr($xdocu,0,2)) or $xdocu=='')
  {
      $dltag='dl_cxco';
      $tabla='vtas';
      $xdocu2='FC';
  }
  ?>
<!--   </dl_cxco> -->
<!--   <dl_cxpa> -->
  <?php 
  if(mb_stristr('EE.CH.DP.EV.IB',substr($xdocu,0,2)) or $xdocu=='')
  {
      $dltag='dl_cxpa';
      $tabla='comp';
      $xdocu2='FP';
  }  
  ?>

<?php 
  if(mb_stristr('IB.EB',substr($xdocu,0,2)))
  {$dltag='dl_numfac';}
?>  
  
<?php
      $sql_docu ='select idnum1,docu,ptoe,numero,fecha,status ';
      $sql_docu.='from '.$tabla.'1 ';
      $sql_docu.='where enti like "'.substr($xenti,0,10).'%" ';
      $sql_docu.='and docu like "'.$xdocu2.'%"';
      $sql_docu.='and status!="O" and status!="X" ';
      $sql_docu.='order by fecha desc ';
      $sql_docu.='limit 10';
      $res_docu=msql_query($sql_docu,$link_vcrx);
   
//       echo '<msgalert>';
//          echo ''.$sql_docu;
//       echo '</msgalert>';
?>  
  
  

  
  
<?php
    
      echo '<'.$dltag.'>'; 
   
      if(msql_num_rows($res_docu)==0)
      {
         $xvalue=0;
         $xoption='NO FAC';
          $option ='';
          $option.='<option value="'.$xvalue.'">';
          $option.=$xoption;
          $option.='</option>';
          echo $option;
         
      }
 
      while($aso_docu=msql_fetch_assoc($res_docu))
      {
        if(!mb_stristr('IB.EB',substr($xdocu,0,2)))
        {$xsaldo=sal_docu($aso_docu['docu'],$aso_docu['idnum1']);}

        if(abs($xsaldo)>$valor0)
        {
          $xvalue =$aso_docu['numero'];
          
          $xoption =$aso_docu['docu'];
          $xoption.='/'.$aso_docu['ptoe'];
          $xoption.='-'.$aso_docu['numero'];
          $xoption.='=>'. number_format($xsaldo,2);
          
          if(mb_stristr('IB.EB',substr($xdocu,0,2)))
          {
            $xoption ='';
            $xoption.=$aso_docu['numero'];
          }
          
          $xvalue=$xoption;
          
          $option ='';
          $option.='<option value="'.$xvalue.'">';
          $option.=$xoption;
          $option.='</option>';
          echo $option;
        }
      }
    
      echo '</'.$dltag.'>'; 
    
?>    
    
<!--   </datalist> -->
<!--   </dl_cxpa> -->

</resultado>


