<?php
session_start();
require('../cfg/res.php');
$sql_clie1='select *from '.$_POST['tabla'].'11 where idnum1='.$_POST['indx'];
$res_clie1=mysql_query($sql_clie1,$link_vcrx);

$xdocu=mysql_result($res_clie1,0,'docu');
$xptoe=mysql_result($res_clie1,0,'ptoe');
$xnumero=mysql_result($res_clie1,0,'numero');

?>



<div style=" max-height:500px; overflow-y:scroll; margin-top:5px;">


<?php
if (mb_stristr('vtas.clie.comp.prov.clte',$_POST['tabla']))
{
$xtdcto=mysql_result($res_clie1,0,'tdcto');
$xtice=mysql_result($res_clie1,0,'tice');
$xtiva=mysql_result($res_clie1,0,'tiva');
$xtirbp=mysql_result($res_clie1,0,'tirbp');
?>
<table id="verdoc2" width="100%" border="0" cellspacing="0" cellpadding="2" style="border-collapse:collapse;font-size:12px; ">
<?php
$sql_clie2='select *from '.$_POST['tabla'].'12 where idnum2='.$_POST['indx'];
$res_clie2=mysql_query($sql_clie2,$link_vcrx);
//echo $sql_clie2;

if(mysql_num_rows($res_clie2)==0)
{
?>
	<span>
	<strong> DOCUMENTO SIN DETALLE
	</span>
<?php
}
?>
<tr align="center" style="background: #F7F7F7; border-top:solid 1px#000;border-bottom:solid 1px#000">
    <th>ITEM</th>
    <th>DESCRI.</th>
    <th>CANT.</th>
    <th>P.UNI</th>
    <th>SUBT.</th>
    <?php if ($xtdcto!=0) { ?> <th>DCTO.</th> <?php } ?>
    <?php if ($xtice!=0) { ?> <th>ICE</th> <?php } ?>
    <?php if ($xtiva!=0) { ?> <th>IVA</th> <?php } ?>
    <?php if ($xtirbp!=0) { ?> <th>IRBP</th> <?php } ?>
    <th>TOTAL</th>
    <th>DETALLE</th>
    </tr>
<?php
}
?>

<?php
if (mb_stristr('caja.bcos.cjte',$_POST['tabla']))
{
?>

<table id="verdoc2" width="100%" border="0" cellspacing="0" cellpadding="2" style="border-collapse:collapse;font-size:12px; ">

<?php
$sql_clie2='select *from '.$_POST['tabla'].'12 where idnum2='.$_POST['indx'];
$res_clie2=mysql_query($sql_clie2,$link_vcrx);
if(mysql_num_rows($res_clie2)==0)
{
?>
<span>
<strong> DOCUMENTO SIN DETALLE
</span>
<?php
}
?>
<tr align="center" style="background: #F7F7F7; border-top:solid 1px#000;border-bottom:solid 1px#000">
    <th>DOCUMENTO</th>
    <th>DOCU</th>
    <th>NUMERO</th>
    <th>CANT.</th>
    </tr>
<?php
}
?>



<?php
if (mb_stristr('cxco.cxpa',$_POST['tabla']))
{
?>
<table id="verdoc2" width="50%" border="0" cellspacing="0" cellpadding="2" style="border-collapse:collapse;font-size:14px; ">
<?php
$sql_clie2='select *from '.$_POST['tabla'].'22 where docum="'.$xdocu.'" and ptoem="'.$xptoe.'" and numer="'.$xnumero.'"';
$res_clie2=mysql_query($sql_clie2,$link_vcrx);
if(mysql_num_rows($res_clie2)==0)
{
?>
<span>
<strong> DOCUMENTO SIN DETALLE
</span>
<?php
}
?>
<tr align="center" style="background: #F7F7F7; border-top:solid 1px#000;border-bottom:solid 1px#000">
    <th>FECHA</th>
    <th>DOCUMENTO</th>
    <th>DOCU</th>
    <th>NUMERO</th>
    <th>CANT.</th>
    </tr>
<?php
}
?>




<?php
if (mb_stristr('inve.prod',$_POST['tabla']))
{
?>
<table id="verdoc2" width="100%" border="0" cellspacing="0" cellpadding="2" style="border-collapse:collapse;font-size:12px; ">
<?php
$sql_clie2='select *from '.$_POST['tabla'].'12 where idnum2='.$_POST['indx'];
$res_clie2=mysql_query($sql_clie2,$link_vcrx);


if(mysql_num_rows($res_clie2)==0)
{
?>
<span>
<strong> DOCUMENTO SIN DETALLE
</span>
<?php
}
?>
<tr align="center" style="background: #F7F7F7; border-top:solid 1px#000;border-bottom:solid 1px#000">
    <th>ITEM</th>
    <th>DESCRI.</th>
    <th>CANT.</th>
    <th>P.UNI</th>
    <th>SUBT.</th>
    <th>TOTAL</th>
    <th>N.SERIE</th>
    <th>DETALLE</th>
    </tr>
<?php
}
?>






<?php
$filax=0;
?>

<?php
if (mb_stristr('vtas.clie.comp.prov.clte',$_POST['tabla']))
{
while($r_clie2=mysql_fetch_assoc($res_clie2))
{
$duni=$r_clie2['item_duni'];
?>

<tr style=" <?php if($filax!=3){$filax++;}else{echo 'border-bottom:dotted 1px #000000;'; $filax=0;}?> ">

    <td align="center"><?php echo $r_clie2['item'];?></td>
    <td><div style="word-wrap:break-word;"><?php echo $r_clie2['item_descri'];?></div></td>
    <td align="right"><?php echo number_format($r_clie2['tcant'],$duni);?></td>
    <td align="right"><?php echo number_format($r_clie2['puni'],2);?></td>
    <td align="right"><?php echo number_format($r_clie2['tsubt'],2);?></td>
    <?php if ($xtdcto!=0) { ?>
    <td align="right"><?php echo '<span title="'.$r_clie2['dcto'].'%">'.number_format($r_clie2['tdcto'],2).'</span>';?></td>
    <?php } ?>
    <?php if ($xtice!=0) { ?>
    <td align="right"><?php echo '<span title="'.$r_clie2['ice'].'%">'.number_format($r_clie2['tice'],2).'</span>';?></td>
    <?php } ?>
    <?php if ($xtiva!=0) { ?>
    <td align="right"><?php echo '<span title="'.$r_clie2['iva'].'%">'.number_format($r_clie2['tiva'],2).'</span>';?></td>
    <?php } ?>
    <?php if ($xtirbp!=0) { ?>
    <td align="right"><?php echo '<span title="'.$r_clie2['irbp'].'%">'.number_format($r_clie2['tirbp'],2).'</span>';?></td>
    <?php } ?>
    <td align="right"><?php echo number_format($r_clie2['total'],2);?></td>
    <td align="left">

    <?php 
    if(mb_stristr('clte.clie',$_POST['tabla']))
    if (mb_stristr('admi',substr($_SESSION['user_vcrx_tipo'],0,4)))
    {
    {
    ?>
	<td align="center">
       	<input type="image" id="e_pedido" src="http://vcrxol.com/_img/ico_eliminar.png" width="25" title="Eliminar"  onclick="anular_pedido('<?php echo $_POST['tabla'] ;?>','<?php echo $r_clie2['idnum1'];?>','<?php echo $r_clie2['iddet'];?>','X')" />
	</td>
    <?php
    }}
    else
    {
	echo $r_clie2['detalle'];
    }
    ?>
    </td>

    </tr>

	
<?php	
}
?>
<?php
}
?>


<?php
if (mb_stristr('caja.bcos.cjte',$_POST['tabla']))
{
while($r_clie2=mysql_fetch_assoc($res_clie2))
{
$duni=$r_clie2['item_duni'];
?>
<tr style=" <?php if($filax!=3){$filax++;}else{echo 'border-bottom:dotted 1px #000000;'; $filax=0;}?> ">
    <td><div style="max-width:200px; word-wrap:break-word;"><?php echo $r_clie2['docum_descri'];?></div></td>
    <td align="center"><?php echo $r_clie2['docum'];?></td>
    <td align="center"><?php echo $r_clie2['ptonumer'];?></td>
    <td align="right"><?php echo number_format($r_clie2['tcant'],2);?></td>
    </tr>
	
<?php	
}
?>
<?php
}
?>



<?php
if (mb_stristr('cxco.cxpa',$_POST['tabla']))
{
while($r_clie2=mysql_fetch_assoc($res_clie2))
{
$duni=$r_clie2['item_duni'];
?>
<tr style=" <?php if($filax!=3){$filax++;}else{echo 'border-bottom:dotted 1px #000000;'; $filax=0;}?> ">
    <td align="center"><?php echo $r_clie2['fechadmy'];?></td>
    <td><div style="max-width:200px; word-wrap:break-word;"><?php echo $r_clie2['docu_descri'];?></div></td>
    <td align="center"><?php echo $r_clie2['docu'];?></td>
    <td align="center"><?php echo $r_clie2['ptonumero'];?></td>
    <td align="right"><?php echo number_format($r_clie2['tcant'],2);?></td>
    </tr>
	
<?php	
}
?>
<?php
}
?>



<?php
if (mb_stristr('inve.prod',$_POST['tabla']))
{
while($r_clie2=mysql_fetch_assoc($res_clie2))
{
$duni=$r_clie2['item_duni'];
?>

<tr style=" <?php if($filax!=3){$filax++;}else{echo 'border-bottom:dotted 1px #000000;'; $filax=0;}?> ">

    <td align="center"><?php echo $r_clie2['item'];?></td>
    <td><div style="word-wrap:break-word;"><?php echo $r_clie2['item_descri'];?></div></td>
    <td align="right"><?php echo number_format($r_clie2['tcant'],$duni);?></td>
    <td align="right"><?php echo number_format($r_clie2['puni'],2);?></td>
    <td align="right"><?php echo number_format($r_clie2['tsubt'],2);?></td>
    <td align="right"><?php echo number_format($r_clie2['total'],2);?></td>
    <td><div style="word-wrap:break-word;"><?php echo $r_clie2['numserie'];?></div></td>
    <td align="left">

    <?php 
    if(mb_stristr('clte.clie',$_POST['tabla']))
    if (mb_stristr('admi',substr($_SESSION['user_vcrx_tipo'],0,4)))
    {
    {
    ?>
	<td align="center">
       	<input type="image" id="e_pedido" src="http://vcrxol.com/_img/ico_eliminar.png" width="25" title="Eliminar"  onclick="anular_pedido('<?php echo $_POST['tabla'] ;?>','<?php echo $r_clie2['idnum1'];?>','<?php echo $r_clie2['iddet'];?>','X')" />
	</td>
    <?php
    }}
    else
    {
	echo $r_clie2['detalle'];
    }
    ?>
    </td>

    </tr>
<?php	
}
?>
<?php
}
?>





</table>

<br>

<div>

