<?php if(file_exists('../_cfg/config.php')){include('../_cfg/config.php');} ?>

<?php
// require('../cfg/res.php');
// require('../cfg/cfg.php');
require('../../_lib/vrdocu0.php');
include ('php_session.php');
include ('php_gene1.php');

$docu=strtoupper($_POST['docu']);
$ptoe=$_POST['ptoe'];
$ptov=$_POST['ptov'];
$caja=$_POST['caja'];
$ctab=$_POST['ctab'];
$bode=$_POST['bode'];
$enti=$_POST['enti'];
$numeror=$_POST['numero'];
$numeror=str_replace('-','',$numeror);
$numeror=str_pad($numeror,9,"0",STR_PAD_LEFT);

$tdocu=substr($docu,0,2);


$docur=new vrdocu0('../cfg/res.php',$_POST['docu']);

$sql_cab='select idnum1,stfin from '.$docur->tabla.'1 where ';
$sql_cab.=' docu="'.$docu.'"';

if(mb_stristr('fp.nc.rc.rp.gr',$tdocu)){$sql_cab.=' and ptoe="'.$ptoe.'"';}

if(mb_stristr('fc.nv',$tdocu))
{
     $ptov_sql='select *from ptov0 where ptov_codigo="'.$ptov.'"';
     $ptov_res=mysql_query($ptov_sql,$link_vcrx);
     if(mysql_num_rows($ptov_res)==0)
     {$ptoe='001001';}
     else
     {$ptoe=mysql_result($ptov_res,0,'ptov_ptoe');}
     $sql_cab.=' and ptoe="'.$ptoe.'"';
     $sql_cab.=' and ptov="'.$ptov.'"';
}

if(mb_stristr('ib.eb',$tdocu))
{
     $bode_sql='select *from bode0 where bode_codigo="'.$bode.'"';
     $bode_res=mysql_query($bode_sql,$link_vcrx);
     if(mysql_num_rows($bode_res)==0)
     {$ptoe='001001';}
     else
     {$ptoe=mysql_result($bode_res,0,'bode_ptoe');}
     $sql_cab.=' and ptoe="'.$ptoe.'"';
     $sql_cab.=' and bode="'.$bode.'"';
}

if(mb_stristr('ie.iv',$tdocu)){$sql_cab.=' and caja="'.$caja.'"';}

if(mb_stristr('ch.dc.db.dp',$tdocu)){$sql_cab.=' and ctab="'.$ctab.'"';}

if(mb_stristr('fp.rc',$tdocu)){$sql_cab.=' and enti="'.$enti.'"';}

if(mb_stristr('no.ro',$tdocu))
{
// 	$sql_cab.=' and enti="'.$enti.'"';
	$sql_cab=str_replace('1 where','12 where',$sql_cab);
	$sql_cab.=' and enti2!="" and enti2 is not null';
// 	$sql_cab.=' and enti2 like "'.substr($enti,0,10).'%"';
	$sql_cab.=' and status!="X"';
	$sql_cab.=' and status!="O"';
// 	$sql_cab.=' and fecha2<=now()';
// 	$sql_cab.=' order by fecha desc,idnum1 ';
// 	$sql_cab.=' order by fecha2 desc,idnum1 ';
}

if(mb_stristr('nm',$tdocu))
{
// 	$sql_cab.=' and enti="'.$enti.'"';
	$sql_cab=str_replace('1 where','12 where',$sql_cab);
	$sql_cab.=' and enti2!="" and enti2 is not null';
	$sql_cab.=' and enti2 like "'.substr($enti,0,10).'%"';
	$sql_cab.=' and status!="X"';
	$sql_cab.=' and status!="O"';
	$sql_cab.=' and fecha2<=now()';
// 	$sql_cab.=' order by fecha desc,idnum1 ';
	$sql_cab.=' order by fecha2 desc,idnum1 ';
}
else
{	
$sql_cab.=' and numero="'.$numeror.'"';
$sql_cab.=' and status!="X"';
}

// echo '<span>'.$sql_cab.'</span>';


$res_cab=mysql_query($sql_cab,$link_vcrx);
//  echo '*****'.$sql_cab.'******';
//if(($res_cab)!=0)
if(mysql_num_rows($res_cab)!=0)
{
	$idnumx=mysql_result($res_cab,0,'idnum1');
	$stfin=mysql_result($res_cab,0,'stfin');
	$_POST['idnumx']=$idnumx;
// 	echo $_POST['idnumx'];
}
else
{
	$_POST['idnumx']=0;
	die('<span>NO HAY DETALLE. -->.</span> ');
}

// $sql_tota='select * from '.$docur->tabla.'11 where idnum2='.$_POST['idnumx'].' order by iddet desc';
// $res_tota=mysql_query($sql_tota,$link_vcrx);

$sql_deta='select * from '.$docur->tabla.'12 where idnum2='.$_POST['idnumx'].' order by iddet ';

// if(mb_stristr('nomi', strtolower($docur->tabla)))
// {
// 	$sql_deta='select * from '.$docur->tabla.'12 where idnum2='.$_POST['idnumx'].' order by fecha2 desc ';
// }

if(mb_stristr('nomi', strtolower($docur->tabla)))
{
	$sql_deta ='select * from '.$docur->tabla.'12 ';
	$sql_deta.=' where idnum2='.$_POST['idnumx'].'';
	$sql_deta.=' order by fecha2 desc, enti_descri, enti ';
}

if(mb_stristr('nvdd', strtolower($docur->tabla)))
{
	$sql_deta ='select * from '.$docur->tabla.'12 ';
	$sql_deta.=' where idnum2='.$_POST['idnumx'].'';
// 	$sql_deta.=' order by fecha2 desc, enti_descri, enti ';
	$sql_deta.=' order by fecha desc, enti_descri, enti, nvdd_tipo, nvdd ';
}

// echo '********************************';
// echo $sql_deta;
// echo '<span>'.$sql_deta.'</span>';

// if($_SESSION['user_vcrx_empr']=='ecgl')
if($empr_codigo=='ecgl')
{$sql_deta=str_replace('order by iddet','order by itnum,iddet',$sql_deta);}
// echo '-*-*-'.$empr_codigo;
// echo '*/*/'.$sql_deta;
$res_deta=mysql_query($sql_deta,$link_vcrx);



$sql_error='';
$sql_error= mysql_error($link_vcrx);
$sql_error=trim($sql_error);

//echo '<span>'.$sql_error.'</span>';
$filax=1;

if(empty($sql_error))
{
if(mysql_num_rows($res_deta)!=0  )
{

// 	$tcant=mysql_result($res_tota,0,'tcant');

	$tdcto=0;
	$tice=0;
	$tiva=0;
	$tirbp=0;
	
// 	$total=mysql_result($res_tota,0,'total');
	
	if(mb_stristr('vtas.clie.comp.prov.dxco.dxpa', strtolower($docur->tabla)))
	{
  $sql_tota ='select max(dcto)as tdcto,max(ice) as tice,max(prop) as tprop, max(iva) as tiva ';
  $sql_tota.='from '.$docur->tabla.'2 where idnum2='.$_POST['idnumx'];
  $res_tota=mysql_query($sql_tota,$link_vcrx);
//   explain_sql($sql_tota);
//     echo $sql_tota;
//     echo mysql_error();
	$tdcto=@mysql_result($res_tota,0,'tdcto');
	$tice=@mysql_result($res_tota,0,'tice');
	$tiva=@mysql_result($res_tota,0,'tiva');
// 	$total=mysql_result($res_tota,0,'total');
	}

// 	$xstat=mysql_result($res_tota,0,'status');



$xfec1 = date('Y-m-j');
$xfec1 = strtotime ( '-10 day' , strtotime ( $xfec1 ) ) ;
$xfec1 = date ( 'Y-m-j' , $xfec1 );

// $xfec2 = mysql_result($res_tota,0,'fecha');
// $xfec2 = mysql_result($res_tota,0,'idate');
// $xstat = mysql_result($res_tota,0,'status');

$xmodif = 0;
if ($xfec2>=$xfec1 && $xstat=="-")
{$xmodif=1;}

$xmodif = 1;
//$stfin  = '-';


?>








<?php
	if(mb_stristr('cont', strtolower($docur->tabla)))
	{
?>
<table width="100%" border="1" cellpadding="2" cellspacing="0" class="tablitita"   style="border-collapse:collapse; font-size:14px;">
   <tr style="border-bottom:solid 2px;" align="center">
   <th>#</th>
   <th>Cuenta</th>
   <th>Contable</th>
   <th>Debito</th>
   <th>Credito</th>
   <th>Centro</th>
   <th>Detalle</th>
   </tr>

<?php	
	$num_fila=0;
   while($row_deta=mysql_fetch_assoc($res_deta))
   {
   $duni=2;
   $dval=2;
   ?>
   <tr id="numrow_<?php echo $num_fila;?>" style=" <?php if($filax==3){echo 'border-bottom:solid 1px #000;';$filax=1;}else{echo'border-bottom:thin dotted  #000;';$filax++;} ?>" >
	    <td align="center"><div id="num_id_<?php echo $row_deta['iddet'];?>"><?php echo $row_deta['iddet'];?></div></td>
	    <td><?php echo $row_deta['ctas'];?></td>
    	    <td><?php echo $row_deta['ctas_descri'];?></td>
	    <td align="right"><?php echo number_format($row_deta['tdebito'],$dval);?></td>
	    <td align="right"><?php echo number_format($row_deta['tcredito'],$dval);?></td>
   	    <td><?php echo $row_deta['csub_descri'];?></td>
   	    <td><?php echo $row_deta['detalle'];?></td>

	
	    <?php if ($xmodif==1 && $stfin!='1') { ?>
	    <td>
	    <input class="e_detab" type="image" id="e_deta" src="http://vcrxol.com/_img/ico_minus.png" width="25" title="Eliminar linea #<?php echo $row_deta['iddet'];?>-<?php echo $row_deta['cant'];?>"  onclick="deledeta('<?php echo strtolower($docur->tabla);?>','<?php echo $row_deta['idnum1'];?>','<?php echo $row_deta['iddet'];?>','numrow_<?php echo $num_fila;?>');"  />
	    </td>
	    <?php  } ?>
	
	
	</tr>

<?php $num_fila++; }?>
</table>
<?php
	}
?>


<?php
	if(mb_stristr('vtas.clie.guia', strtolower($docur->tabla)))
	{
?>
<table width="100%" border="1" cellpadding="2" cellspacing="0" class="tablitita"   style="border-collapse:collapse;font-size:14px;">
   <tr style="border-bottom:solid 2px;" align="center">
   <th>#</th>
   <th>Item</th>
   <th>Descrip</th>
		 
	<?php if($empr_codigo=='ecgl'){ ?>
		<th width="1%">Laminas</th>
		<th width="1%">Largo</th>
		<th width="1%">Ancho</th>
	<?php } ?>

	<th>Cant</th>
	 
   <th>P.Unit.</th>

   <?php if ($tdcto!=0){ ?>
   <th>Dcto</th>
   <?php }?>
   <?php if ($tice!=0){ ?>
   <th>ICE</th>
   <?php }?>
   <?php if ($tiva!=0){ ?>
   <th>IVA</th>
   <?php }?>
   <?php if ($tirbp!=0){ ?>
   <th>IRBP</th>
   <?php }?>
   <th>SubTot</th>
   <th>Detalle</th>
   <th></th>
	<th></th>
   </tr>

<?php	
	 		$xfinve="2000-01-01";
		 if ($docur->vstock==1)
		 {
     $finve_sql='select * from empr0';
     $finve_res=mysql_query($finve_sql,$link_vcrx);
     if(mysql_num_rows($finve_res)>0)
     {$xfinve=mysql_result($finve_res,0,'empr_finve');}
		 } 
   $num_fila=0;
   while($row_deta=mysql_fetch_assoc($res_deta))
   {
   $duni=$row_deta['item_duni'];
   $dval=$row_deta['item_dval'];
   $dval=2;
   ?>
   <tr id="numrow_<?php echo $num_fila;?>" 
       style="
              <?php if($filax==3){echo 'border-bottom:solid 1px #000;';$filax=1;}else{echo'border-bottom:thin dotted  #000;';$filax++;} ?>
            	<?php if($empr_codigo=='ecgl' and mb_stristr('clie.vtas',$docur->tabla) and substr($row_deta['item_descri'],0,5)=='VIDRI'){echo 'background:#f7f7f7;';} ?>
              " >
	    <td align="center"><small><div id="num_id_<?php echo $row_deta['iddet'];?>"> 
        <?php $iddet= $row_deta['iddet'];?>
      	<?php if($empr_codigo=='ecgl' and mb_stristr('clie.vtas',$docur->tabla)){ ?>
        <?php $iddet=$row_deta['itnum'];?>
        <?php}else{?>
        <?php //echo $row_deta['iddet'];?>
        <?php}?>
        <?php echo $iddet; ?>
      </div></small></td>
	    <td><?php echo $row_deta['item'];?></td>
    	    <td><?php echo $row_deta['item_descri'];?></td>
        
			<?php if($empr_codigo=='ecgl'){ ?>
        <td align="right"><?php echo number_format($row_deta['lmns'],0);?></td>
        <td align="right"><?php echo number_format($row_deta['mm_l'],0);?></td>
        <td align="right"><?php echo number_format($row_deta['mm_a'],0);?></td>
			<?php } ?>

	    <td align="right"><?php echo number_format($row_deta['cant'],$duni);?></td>
        
	    <td align="right"><?php echo '<span title="'.$row_deta['puni'].'">'.number_format($row_deta['puni'],$dval).'</span>';?></td>
	    <?php if ($tdcto!=0){ ?>
	    <td align="right"><?php echo '<span title="'.number_format(abs($row_deta['dcto']),2).'%">'.number_format(abs($row_deta['tdcto']),2).'</span>';?></td>
	    <?php }?>
	    <?php if ($tice!=0){ ?>
	    <td align="right"><?php echo '<span title="'.number_format(abs($row_deta['ice']),0).'%">'.number_format(abs($row_deta['tice']),2).'</span>';?></td>
	    <?php }?>
	    <?php if ($tiva!=0){ ?>
	    <td align="right"><?php echo '<span title="'.number_format(abs($row_deta['iva']),0).'%">'.number_format(abs($row_deta['tiva']),2).'</span>';?></td>
	    <?php }?>
	    <?php if ($tirbp!=0){ ?>
	    <td align="right"><?php echo '<span title="'.number_format(abs($row_deta['irbp']),4).'">'.number_format(abs($row_deta['tirbp']),2).'</span>';?></td>
	    <?php }?>
	    <td align="right"><?php echo number_format(abs($row_deta['total']),2);?></td>
   	  <td>
      <?php echo $row_deta['detalle'];?>
      <?php if($cfg_empr=='ecgl' and mb_stristr('clie.vtas',$docur->tabla)){?>
   	  <?php echo $row_deta['perfor1'];?>
   	  <?php echo $row_deta['saques1'];?>
      <?php } ?>
      </td>

     
      <?php if($cfg_empr=='pcs1'){ ?>
      <?php if($row_deta['cntn']!=''){ ?>
        <td align="center"><?php echo $row_deta['cntn'];?></td>
        <td align="center"><?php echo date('d/M/y',strtotime($row_deta['cntnf1']));?></td>
        <td align="center"><?php echo date('d/M/y',strtotime($row_deta['cntnf2']));?></td>
      <?php } ?>
      <?php } ?>

      <?php if($cfg_empr=='tgck'){ ?>
        <td align="center"><?php echo $row_deta['vhcl'];?></td>
        <td align="left"><?php echo r_fiel('vhcl',$row_deta['vhcl']);?></td>
      <?php } ?>

     
     <?php if($xmodif==1 && $stfin!='1'){ ?>
	    <td>
	    <input class="e_detab" type="image" id="e_deta" src="http://vcrxol.com/_img/ico_minus.png" width="25" title="Eliminar linea #<?php echo $row_deta['iddet'];?>-<?php echo $row_deta['cant'];?>"  onclick="deledeta('<?php echo strtolower($docur->tabla);?>','<?php echo $row_deta['idnum1'];?>','<?php echo $row_deta['iddet'];?>','numrow_<?php echo $num_fila;?>');"  />
	    </td>
	    <?php } ?>
		 <td align="right">
	    <?php	    
		 if ($docur->vstock==1)
		 {
		 $xdispo=0;
     $dispo_sql='select item,sum(tcant) as dispo from inve12 where item like "'.$row_deta['item'].'" and fecha>="'.$xfinve.'"';
     $dispo_res=mysql_query($dispo_sql,$link_vcrx);
     if(mysql_num_rows($dispo_res)>0)
     {$xdispo=mysql_result($dispo_res,0,'dispo');}
		 echo number_format($xdispo,$duni);
		 }
			?>
		 </td>
    </tr>
<?php $num_fila++; }?>
</table>
<?php } ?>


<?php
	if(mb_stristr('comp.prov', strtolower($docur->tabla)))
	{
?>
<table width="100%" border="1" cellpadding="2" cellspacing="0" class="tablitita"  style="border-collapse:collapse;font-size:14px;">
   <tr style="border-bottom:solid 2px;" align="center">
   <th>#</th>
   <th>Item</th>
   <th>Descrip</th>
   <th>Cant</th>
   <th>P.Unit.</th>
   <?php if ($tdcto!=0){ ?><th>Dcto</th><?php }?>
   <?php if ($tice!=0){ ?><th>ICE</th><?php }?>
   <?php if ($tiva!=0){ ?><th>IVA</th><?php }?>
   <?php if ($tirbp!=0){ ?><th>IRBP</th><?php }?>
   <th>SubTot</th>
   <th>Detalle</th>
    <?php
      if(mb_stristr('comp.', strtolower($docur->tabla)))
      {
    ?>
   <th>CAIR</th>
   <th>Cuenta</th>
   <th></th>
    <?php } ?>
   </tr>

<?php	
   $num_fila=0;
   while($row_deta=mysql_fetch_assoc($res_deta))
   {
   $duni=$row_deta['item_duni'];
   $dval=$row_deta['item_dval'];
   $dval=2;
   ?>
   <tr id="numrow_<?php echo $num_fila;?>" style=" <?php if($filax==3){echo 'border-bottom:solid 1px #000;';$filax=1;}else{echo'border-bottom:thin dotted  #000;';$filax++;} ?>" >
	    <td align="center"><div id="num_id_<?php echo $row_deta['iddet'];?>"> <?php echo $row_deta['iddet'];?></div></td>
	    <td><?php echo $row_deta['item'];?></td>
    	    <td><small><?php echo $row_deta['item_descri'];?></small></td>
	    <td align="right"><?php echo number_format($row_deta['cant'],$duni);?></td>
	    <td align="right"><?php echo '<span title="'.$row_deta['puni'].'">'.number_format($row_deta['puni'],$dval).'</span>';?></td>
	    <?php if ($tdcto!=0){ ?>
	    <td align="right"><small><?php echo '<span title="'.$row_deta['dcto'].'%">'.number_format($row_deta['tdcto'],2).'</span>';?></small></td>
	    <?php }?>
	    <?php if ($tice!=0){ ?>
	    <td align="right"><small><?php echo '<span title="'.$row_deta['ice'].'%">'.number_format($row_deta['tice'],2).'</span>';?></small></td>
	    <?php }?>
	    <?php if ($tiva!=0){ ?>
	    <td align="right"><small><?php echo '<span title="'.$row_deta['iva'].'%">'.number_format($row_deta['tiva'],2).'</span>';?></small></td>
	    <?php }?>
	    <?php if ($tirbp!=0){ ?>
	    <td align="right"><small><?php echo '<span title="'.$row_deta['irbp'].'">'.number_format($row_deta['tirbp'],2).'</span>';?></small></td>
	    <?php }?>
	    <td align="right"><b><?php echo number_format($row_deta['total'],2);?></b></td>
   	    <td><?php echo $row_deta['detalle'];?></td>
    <?php
      if(mb_stristr('comp.', strtolower($docur->tabla)))
      {
    ?>
     
	    <td align="center"><?php echo $row_deta['cair'];?></td>
	    <td align="left"><?php echo $row_deta['ctas'].' -'. $row_deta['ctas_descri'];?></td>
    <?php } ?>
	    <?php if($xmodif==1 && $stfin!='1'){ ?>
	    <td>
	    <input type="image" class="e_detab" id="e_deta" src="http://vcrxol.com/_img/ico_minus.png" width="25" title="Eliminar linea #<?php echo $row_deta['iddet'];?>-<?php echo $row_deta['cant'];?>"  onclick="deledeta('<?php echo strtolower($docur->tabla);?>','<?php echo $row_deta['idnum1'];?>','<?php echo $row_deta['iddet'];?>','numrow_<?php echo $num_fila;?>');"  />
	    </td>
	    <?php } ?>
    </tr>
<?php $num_fila++; }?>
</table>
<?php } ?>


<?php
	if(mb_stristr('inve', strtolower($docur->tabla)))
	{
?>
<table width="100%" border="1" cellpadding="2" cellspacing="0" class="tablitita"   style="border-collapse:collapse;font-size:12px;">
   <tr style="border-bottom:solid 2px;" align="center">
   <th>#</th>
   <th>Item</th>
   <th>Descrip</th>
   <th>Cant</th>
   <th>P.Unit.</th>
   <th>SubTot</th>
   <th>NumSerie</th>
   <th>Detalle</th>
   <th></th>
   </tr>

<?php	
$num_fila=0;
   while($row_deta=mysql_fetch_assoc($res_deta))
   {
   $duni=$row_deta['item_duni'];
   $dval=$row_deta['item_dval'];
   $dval=2;
// 		$duni=2;
   ?>
   
		
   <tr id="numrow_<?php echo $num_fila;?>" style=" <?php if($filax==3){echo 'border-bottom:solid 1px #000;';$filax=1;}else{echo'border-bottom:thin dotted  #000;';$filax++;} ?>" >
    
	    <td align="center"><div id="num_id_<?php echo $row_deta['iddet'];?>"> <?php echo $row_deta['iddet'];?></div></td>
			
	    <td><?php echo $row_deta['item'];?></td>
    	    <td><?php echo $row_deta['item_descri'];?></td>
	    <td align="right"><?php echo number_format($row_deta['cant'],$duni);?></td>
	    <td align="right"><?php echo '<span title="'.$row_deta['puni'].'">'.number_format($row_deta['tsubt'],$dval).'</span>';?></td>
	    <td align="right"><?php echo number_format($row_deta['total'],2);?></td>
        <td align="right"><?php echo $row_deta['numserie'];//numero de serie ?></td>
   	    <td><?php echo $row_deta['detalle'];?></td>
	    <?php if($xmodif==1 && $stfin!='1'){ ?>
	    <td>
	    <input type="image" class="e_detab" id="e_deta" src="http://vcrxol.com/_img/ico_minus.png" width="25" title="Eliminar linea #<?php echo $row_deta['iddet'];?>-<?php echo $row_deta['cant'];?>"  onclick="deledeta('<?php echo strtolower($docur->tabla);?>','<?php echo $row_deta['idnum1'];?>','<?php echo $row_deta['iddet'];?>','numrow_<?php echo $num_fila;?>');"  />
	    </td>
      <?php } ?>

   
   
	
    </tr>

<?php $num_fila++; }?>
</table>
<?php
	}
?>


<?php
	if(mb_stristr('nomi', strtolower($docur->tabla)))
	{
?>
<table width="100%" border="1" cellpadding="2" cellspacing="0" class="tablitita"   style="border-collapse:collapse;font-size:12px;">
   <tr style="border-bottom:solid 2px;" align="center">
   <th>#</th>
   <th>Fecha</th>
   <th>Sueldo</th>
   <th>% Anti.</th>
   <th>Antic.</th>
<!--    <th>IESS</th> -->
   <th>Reloj</th>
   <th>Atraso</th>
   <th>Falta</th>
   <th>H 25%</th>
   <th>H 50%</th>
   <th>H 100%</th>
   <th>D 13</th>
   <th>D 14</th>
   <th>Fon.Res.</th>
   <th>Cargo</th>
   <th></th>
   </tr>

<?php	
$num_fila=0;
   while($row_deta=mysql_fetch_assoc($res_deta))
   {
   $duni=$row_deta['item_duni'];
   $dval=$row_deta['item_dval'];
   $dval=2;
   ?>
   
		
   <tr id="numrow_<?php echo $num_fila;?>" style=" <?php if($filax==3){echo 'border-bottom:solid 1px #000;';$filax=1;}else{echo'border-bottom:thin dotted  #000;';$filax++;} ?>" >
    
	    <td align="center"><div id="num_id_<?php echo $row_deta['iddet'];?>"> <?php echo $row_deta['iddet'];?></div></td>
			
	    <td align="center"><?php echo $row_deta['fecha2'];?></td>
	    <td align="right"><?php echo number_format($row_deta['sueldo'],$dval);?></td>
	    <td align="center"><?php echo number_format($row_deta['poranti'],0).'%';?></td>
	    <td align="right"><?php echo number_format($row_deta['valanti'],$dval);?></td>
<!-- 	    <td align="center"><?php if($row_deta['iess']==1){echo 'Si';}else{echo '-';};?></td> -->
	    <td align="center"><?php if($row_deta['reloj']==1){echo 'Si';}else{echo '-';};?></td>
	    <td align="center"><?php if($row_deta['atraso']==1){echo 'Si';}else{echo '-';};?></td>
	    <td align="center"><?php if($row_deta['falta']==1){echo 'Si';}else{echo '-';};?></td>
	    <td align="center"><?php if($row_deta['h025']==1){echo 'Si';}else{echo '-';};?></td>
	    <td align="center"><?php if($row_deta['h050']==1){echo 'Si';}else{echo '-';};?></td>
	    <td align="center"><?php if($row_deta['h100']==1){echo 'Si';}else{echo '-';};?></td>
	    <td align="center"><?php if($row_deta['de13']==1){echo 'Anual';}else{echo 'Mensual';};?></td>
	    <td align="center"><?php if($row_deta['de14']==1){echo 'Anual';}else{echo 'Mensual';};?></td>
	    <td align="center"><?php if($row_deta['fres']==1){echo 'Anual';}else{echo 'Mensual';};?></td>
	    <td align="center"><?php echo $row_deta['cargo'] ;?></td>
	    <?php //if($xmodif==1 && $stfin!='1'){ ?>
	    <?php if($xmodif==1 && $row_deta['fecha2']>=date('Y-m-d',strtotime('-60 days'))){ ?>
	    <td>
	    <input type="image" class="e_detab" id="e_deta" src="http://vcrxol.com/_img/ico_minus.png" width="25" title="Eliminar linea #<?php echo $row_deta['iddet'];?>-<?php echo $row_deta['cant'];?>"  onclick="deledeta('<?php echo strtolower($docur->tabla);?>','<?php echo $row_deta['idnum1'];?>','<?php echo $row_deta['iddet'];?>','numrow_<?php echo $num_fila;?>');"  />
	    </td>
      <?php } ?>

   
   
	
    </tr>

<?php $num_fila++; }?>
</table>
<?php
	}
?>


<?php
	if(mb_stristr('rolp.nvdd', strtolower($docur->tabla)))
	{
?>
<table width="100%" border="1" cellpadding="2" cellspacing="0" class="tablitita"   style="border-collapse:collapse;font-size:12px;">
   <tr style="border-bottom:solid 2px;" align="center">
   <th>#</th>
   <th>Emplado</th>
   <th>Nombre</th>
   <th>Novedad</th>
   <th>Descrip.</th>
   <th>Cant.</th>
   <th>V.Unit.</th>
   <th>Ingreso</th>
   <th>Descto.</th>
   <th>Provis.</th>
   <th>Centro.Sub</th>
   <th>Detalle</th>
   <th></th>
   </tr>

<?php	
$num_fila=0;
   while($row_deta=mysql_fetch_assoc($res_deta))
   {
   $duni=$row_deta['item_duni'];
   $dval=$row_deta['item_dval'];
   $dval=2;
   ?>
   
		
   <tr id="numrow_<?php echo $num_fila;?>" style=" <?php if($filax==3){echo 'border-bottom:solid 1px #000;';$filax=1;}else{echo'border-bottom:thin dotted  #000;';$filax++;} ?>" >
    
	    <td align="center"><div id="num_id_<?php echo $row_deta['iddet'];?>"> <?php echo $row_deta['iddet'];?></div></td>
			
	    <td><?php echo $row_deta['enti2'];?></td>
    	<td><?php echo $row_deta['enti_descri'];?></td>
	    <td><?php echo $row_deta['nvdd'];?></td>
    	<td><?php echo $row_deta['nvdd_descri'];?></td>
	    <td align="right"><?php echo number_format($row_deta['cant'],2);?></td>
	    <td align="right"><?php echo '<span title="'.$row_deta['puni'].'">'.number_format($row_deta['puni'],$dval).'</span>';?></td>
	    <td align="right"><?php echo number_format($row_deta['tingreso'],2);?></td>
	    <td align="right"><?php echo number_format($row_deta['tegreso'],2);?></td>
	    <td align="right"><?php echo number_format($row_deta['tprovi1']+$row_deta['tprovi2'],2);?></td>
        <td align="right"><?php echo $row_deta['csub_descri']; ?></td>
   	    <td><?php echo $row_deta['detalle'];?></td>
      <?php if( $stfin!='1'){?>
	    <td>
	    <input type="image" class="e_detab" id="e_deta" src="http://vcrxol.com/_img/ico_minus.png" width="25" title="Eliminar linea #<?php echo $row_deta['iddet'];?>-<?php echo $row_deta['cant'];?>"  onclick="deledeta('<?php echo strtolower($docur->tabla);?>','<?php echo $row_deta['idnum1'];?>','<?php echo $row_deta['iddet'];?>','numrow_<?php echo $num_fila;?>');"  />
	    </td>
      <?php } ?>

   
   
	
    </tr>

<?php $num_fila++; }?>
</table>
<?php
	}
?>





<?php
	if(mb_stristr('caja.bcos.cjte.', strtolower($docur->tabla)))
	{
?>
<table width="100%" border="1" cellpadding="2" cellspacing="0" class="tablitita"   style="border-collapse:collapse;">
   <tr style="border-bottom:solid 2px;" align="center">
   <th>#</th>
   <th width="50px">Docum</th>
   <th>Descrip</th>
   <th width="180px">Numero</th>
   <th width="110px">Cantidad</th>
   <th width="150px">Cuenta</th>
   <th>Contable</th>
   <th>Detalle</th>
   </tr>

<?php	
   $num_fila=0;
   while($row_deta=mysql_fetch_assoc($res_deta))
   {
   $duni=2;
   $dval=2;
   ?>
		
   <tr  id="numrow_<?php echo $num_fila;?>" style=" <?php if($filax==3){echo 'border-bottom:solid 1px #000;';$filax=1;}else{echo'border-bottom:thin dotted  #000;';$filax++;} ?>" >
	    <td align="center"><div id="num_id_<?php echo $row_deta['iddet'];?>"> <?php echo $row_deta['iddet'];?></div></td>
	    <td align="center"><?php echo $row_deta['docum'];?></td>
    	<td><?php echo $row_deta['docum_descri'];?></td>
    	<td align="center"><?php echo $row_deta['ptonumer'];?></td>
	    <td align="right"><?php echo number_format($row_deta['cant'],$dval);?></td>
	    <td align="center"><?php echo $row_deta['ctas'];?></td>
	    <td align="left"><?php echo $row_deta['ctas_descri'];?></td>
   	    <td><?php echo $row_deta['detalle'];?></td>

	    <?php if($xmodif==1 && $stfin!='1'){ ?>
	    <td>
	    <input type="image" class="e_detab" id="e_deta" src="http://vcrxol.com/_img/ico_minus.png" width="25" title="Eliminar linea #<?php echo $row_deta['iddet'];?>-<?php echo $row_deta['cant'];?>"  onclick="deledeta('<?php echo strtolower($docur->tabla);?>','<?php echo $row_deta['idnum1'];?>','<?php echo $row_deta['iddet'];?>','numrow_<?php echo $num_fila;?>');"  />
	    </td>
	    <?php } ?>
    </tr>

<?php $num_fila++; }
?>
</table>
<?php } ?>



<?php
	if(mb_stristr('dxco.dxpa', strtolower($docur->tabla)))
	{
?>
<table width="100%" border="1" cellpadding="2" cellspacing="0" class="tablitita"   style="border-collapse:collapse;">
   <tr style="border-bottom:solid 2px;" align="center">
   <th>#</th>
   <th width="50px">Docum</th>
   <th>Descrip</th>
   <th width="180px">Numero</th>
   <th width="110px">Cantidad</th>
   <th width="110px">P.Unit</th>
   <th width="150px">Cuenta</th>
   <th>Contable</th>
   <th>Detalle</th>
   </tr>

<?php	
   $num_fila=0;
   while($row_deta=mysql_fetch_assoc($res_deta))
   {
   $duni=2;
   $dval=2;
   ?>
		
   <tr  id="numrow_<?php echo $num_fila;?>" style=" <?php if($filax==3){echo 'border-bottom:solid 1px #000;';$filax=1;}else{echo'border-bottom:thin dotted  #000;';$filax++;} ?>" >
	    <td align="center"><div id="num_id_<?php echo $row_deta['iddet'];?>"> <?php echo $row_deta['iddet'];?></div></td>
	    <td align="center"><?php echo $row_deta['docum'];?></td>
    	<td><?php echo $row_deta['docum_descri'];?></td>
    	<td align="center"><?php echo $row_deta['ptonumer'];?></td>
	    <td align="right"><?php echo number_format($row_deta['cant'],$dval);?></td>
	    <td align="right"><?php echo number_format($row_deta['puni'],$dval);?></td>
	    <td align="center"><?php echo $row_deta['ctas'];?></td>
	    <td align="left"><?php echo $row_deta['ctas_descri'];?></td>
   	    <td><?php echo $row_deta['detalle'];?></td>

	    <?php if($xmodif==1 && $stfin!='1'){ ?>
	    <td>
	    <input type="image" class="e_detab" id="e_deta" src="http://vcrxol.com/_img/ico_minus.png" width="25" title="Eliminar linea #<?php echo $row_deta['iddet'];?>-<?php echo $row_deta['cant'];?>"  onclick="deledeta('<?php echo strtolower($docur->tabla);?>','<?php echo $row_deta['idnum1'];?>','<?php echo $row_deta['iddet'];?>','numrow_<?php echo $num_fila;?>');"  />
	    </td>
	    <?php } ?>
    </tr>

<?php $num_fila++; }
?>
</table>
<?php } ?>



<?php
	if(mb_stristr('retc.retp', strtolower($docur->tabla)))
	{
?>
<table width="100%" border="1" cellpadding="2" cellspacing="0" class="tablitita"   style="border-collapse:collapse;">
   <tr style="border-bottom:solid 2px;" align="center">
   <th>#</th>
   <th width="50px">Docum</th>
   <th>Descrip</th>
   <th width="180px">Numero</th>
   <th>CAIR</th>
   <th>Base</th>
   <th width="50px">%</th>
   <th>Valor</th>
   <th>Detalle</th>
   </tr>

<?php	
   $num_fila=0;
   while($row_deta=mysql_fetch_assoc($res_deta))
   {
   $duni=2;
   $dval=2;
   ?>
		
   <tr  id="numrow_<?php echo $num_fila;?>" style=" <?php if($filax==3){echo 'border-bottom:solid 1px #000;';$filax=1;}else{echo'border-bottom:thin dotted  #000;';$filax++;} ?>" >
	    <td align="center"><div id="num_id_<?php echo $row_deta['iddet'];?>"> <?php echo $row_deta['iddet'];?></div></td>
	    <td align="center"><?php echo $row_deta['docum'];?></td>
    	<td><?php echo $row_deta['docum_descri'];?></td>
    	<td align="center"><?php echo $row_deta['ptonumer'];?></td>
    	<td align="center"><?php echo $row_deta['cair'];?></td>
	    <td align="right"><?php echo number_format($row_deta['cant'],$dval);?></td>
	    <td align="center"><?php echo number_format($row_deta['puni'],2);?></td>
	    <td align="right"><?php echo number_format(abs($row_deta['total']),$dval);?></td>
   	    <td><?php echo $row_deta['detalle'];?></td>

	    <?php if($xmodif==1 && $stfin!='1'){ ?>
	    <td>
	    <input type="image" class="e_detab" id="e_deta" src="http://vcrxol.com/_img/ico_minus.png" width="25" title="Eliminar linea #<?php echo $row_deta['iddet'];?>-<?php echo $row_deta['cant'];?>"  onclick="deledeta('<?php echo strtolower($docur->tabla);?>','<?php echo $row_deta['idnum1'];?>','<?php echo $row_deta['iddet'];?>','numrow_<?php echo $num_fila;?>');"  />
	    </td>
	    <?php } ?>
    </tr>

<?php $num_fila++; }?>
</table>
<?php	}?>

<?php if(mb_stristr('prod', strtolower($docur->tabla))) {?>
<table width="100%" border="1" cellpadding="2" cellspacing="0" class="tablitita"   style="border-collapse:collapse;font-size:14px;">
   <tr style="border-bottom:solid 2px;" align="center">
   <th>#</th>
   <th>Item</th>
   <th>Descrip</th>
   <th>Cant</th>
   <th>P.Unit.</th>
   <th>SubTot</th>
   <th>NumSerie</th>
   <th>Detalle</th>
   <th></th>
   </tr>

<?php	
$num_fila=0;
   while($row_deta=mysql_fetch_assoc($res_deta))
   {
   $duni=$row_deta['item_duni'];
   $dval=$row_deta['item_dval'];
   $dval=2;
   ?>
   
		
   <tr id="numrow_<?php echo $num_fila;?>" style=" <?php if($filax==3){echo 'border-bottom:solid 1px #000;';$filax=1;}else{echo'border-bottom:thin dotted  #000;';$filax++;} ?>" >
    
	    <td align="center"><div id="num_id_<?php echo $row_deta['iddet'];?>"> <?php echo $row_deta['iddet'];?></div></td>
			
	    <td><?php echo $row_deta['item'];?></td>
    	    <td><?php echo $row_deta['item_descri'];?></td>
	    <td align="right"><?php echo number_format($row_deta['cant'],$duni);?></td>
	    <td align="right"><?php echo '<span title="'.$row_deta['puni'].'">'.number_format($row_deta['puni'],$dval).'</span>';?></td>
	    <td align="right"><?php echo abs(number_format($row_deta['total'],2));?></td>
        <td align="right"><?php echo $row_deta['numserie'];//numero de serie ?></td>
   	    <td><?php echo $row_deta['detalle'];?></td>
      <?php if( $stfin!='1'){?>
	    <td>
	       <input type="image" class="e_detab" id="e_deta" src="http://vcrxol.com/_img/ico_minus.png" width="25" title="Eliminar linea #<?php echo $row_deta['iddet'];?>-<?php echo $row_deta['cant'];?>"  onclick="deledeta('<?php echo strtolower($docur->tabla);?>','<?php echo $row_deta['idnum1'];?>','<?php echo $row_deta['iddet'];?>','numrow_<?php echo $num_fila;?>');"  />
	    </td>
      <?php } ?>

   
   
	
    </tr>

<?php $num_fila++; }?>
</table>
<?php	} ?>



	
	
<?php
}
else
{echo '<span>NO HAY DETALLE! -->!</span> ';}

}
?>
<resultado>
	<error><?php echo $sql_error;?></error>
</resultado>
<input type="hidden" id="hdd_car_det_err" value="<?php echo $sql_error;?>" />