<?php //session_start();?>
<div align="center">
<?php require('cfg/res.php');
$car1_sql='select *from tvir1 where enti="'.$_SESSION['user_vcrx_id'].'"';
//echo $car1_sql;
$car1_res=mysql_query($car1_sql,$link_vcrx);
$car1_idn=mysql_result($car1_res,0,'idnum1');

//$car2_sql='select *,(pvp1*cant)as sub,left(item,6) as item_img from tvir2 where idnum2="'.$car1_idn.'"';
$car2_sql='select *,(pvp1*cant)as sub,left(item,6) as item_img from tvir12 where idnum2="'.$car1_idn.'"';
$car2_res=mysql_query($car2_sql,$link_vcrx);


?>
<div class="c2">CARRITO</div>
<table border="0" cellpadding="4" width="100%" style="border-collapse:collapse;">
<!--
<tr>
    <th>IITEM</th>
    <th>CANT</th>
    <th>PRECIO</th>
    <th>SUB</th> 
</tr> -->
<?php while($car2_r=mysql_fetch_assoc($car2_res)){?>
<tr valign="top" id="filla_<?php echo $car2_r['idnum2'].$car2_r['iddet'].'1';?>">
<td width="8%">
<?php 
$img_sql='select *from imgi0 where left(imgi_item,6)="'.$car2_r['item_img'].'" and imgi_status!="X" order by imgi_defa desc limit 1';

$img_res=mysql_query($img_sql,$link_vcrx);

if(mysql_num_rows($img_res)!=0){
	if(file_exists('../gnya/imgi/'.mysql_result($img_res,0,'imgi_file'))){?> 
		<img class="cesto_img" src="<?php echo 'http://gnya.vcrxol.com/imgi/'.mysql_result($img_res,0,'imgi_file');?>"  />
	<?php } 
} ?></td>
<td width="92%">
<div align="center"><?php echo $car2_r['item_descri'].' ('.$car2_r['item'].')';?></div>
</td>
</tr>

<tr  valign="bottom"   colspan="2" id="filla_<?php echo $car2_r['idnum2'].$car2_r['iddet'].'2';?>" >
	<td colspan="2">
    <table><tr valign="bottom">	
    <td><input type="button" value="Eliminar" class="elitmina_btn" align="middle" onclick="_modifica('<?php echo $car2_r['idnum2']."','".$car2_r['iddet'];?>','d');" /></td>
    <td>
    	<div align="center">Cant</div>
    	<input type="text" class="txt_cant" value="<?php echo number_format($car2_r['cant'],0);?>" id="cant_<?php echo $car2_r['iddet'];?>" onClick="this.select();" onblur="_modifica('<?php echo $car2_r['idnum2']."','".$car2_r['iddet'];?>','');"  />
	</td>
    <td>
    	<div align="center">PvP</div>
    	<input type="text" class="txt_pvp"  value="<?php echo number_format($car2_r['pvp1'],2);?>" id="pvp_<?php echo $car2_r['iddet'];?>"  disabled="disabled" />
    </td>
    <td>
    	<div align="center">Subt</div>
    	<input type="text" class="txt_sub"  value="<?php echo number_format($car2_r['total'],2);?>" id="subt_<?php echo $car2_r['iddet'];?>"   disabled="disabled"   />
    </td>
    </tr></table>
</tr>

<!--    
<tr style="border-bottom:#000 solid 1px;">
	<td colspan="2"><input type="button" value="Eliminar" class="elitmina_btn" /></td>
	<td colspan="2"><input type="button" onclick="_agregar('<?php echo $car2_r['iddet'];?>')" value="Actualizar" class="agrega_btn" />	</td>
</tr>
-->
<tr style="border-bottom:#000 solid 1px;"  id="filla_<?php echo $car2_r['idnum2'].$car2_r['iddet'].'3';?>" >
	<td colspan="4"><div style="height:35px">&nbsp;</div><input type="hidden" class="txt_iva"  value="<?php echo $car2_r['iva'];?>"  /></td>
</tr>

<?php } 
$car2_sql='select sum(pvp1*cant)as subtotal from tvir2 where idnum2="'.$car1_idn.'"';
$car2_res=mysql_query($car2_sql,$link_vcrx);
$car2_subtotal=mysql_result($car2_res,0,'subtotal');
?>
<tr>
	
	<td align="right">Subtotal</td>
    <td align="right"><input type="text" id="subtotal" value="<?php echo number_format($car2_subtotal,2);?>" style="width:100%;" disabled="disabled" /></td>
    
</tr>

<tr>
	
	<td align="right">IVA</td>
    <td align="right">
    <?php 
	$car2_sql='select sum((pvp1*cant)*((iva/100)))as ivat from tvir2 where idnum2="'.$car1_idn.'"';
	$car2_res=mysql_query($car2_sql,$link_vcrx);
	$car2_ivat=mysql_result($car2_res,0,'ivat');
	$car2_total=$car2_subtotal+$car2_ivat;
	?>
    <input type="text" id="iva" value="<?php echo number_format($car2_ivat,2);?>" style="width:100%;" disabled="disabled" />
    </td>
    
</tr>
<tr>
	
	<td align="right">Total</td>
    <td align="right"><input type="text" id="total" value="<?php echo number_format($car2_total,2);?>" disabled="disabled" /></td>
    
</tr>

</table>
<div id="err_msg" style="height:30px;"></div>





<a href="index.php?opt=ces2m" style="text-decoration:none;"><div style="background:#09c; font-size:18px; font-weight:bolder;  color:#FFF; height:45px; padding-top:20px; box-sizing:border-box; box-sizing:content-box;">Proceder Orden</div></a>
</div>