<?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');
$car1_adrs=mysql_result($car1_res,0,'adrs');

if(empty($car1_adrs)){die('<a href="index.php?opt=ces2m">Elija una direccion de envio</a>');}
//$car2_sql='select *,(pvp1*cant)as sub,left(item,6) as item_img from tvir2 where idnum2="'.$car1_idn.'"';
$car2_sql='select count(*)as total from tvir2 where idnum2="'.$car1_idn.'"';
$car2_res=mysql_query($car2_sql);
$car2_total=mysql_result($car2_res,0,'total');
if($car2_total==0){die('<a href="index.php?opt=catm">Su carrito esta vacio</a>');}
$car2_total=0;

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


?>
<div class="c2">CONFIRMACION DE PEDIDO</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></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'];?>" disabled="disabled" />
	</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;"  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>

<!-- **************** -->
<?php  require('cfg/res.php'); 
$adr_sql='select *from adrs00 where adrs_enti="'.$_SESSION['user_vcrx_id'].'" and adrs_codigo="'.$car1_adrs.'"';
//echo $adr_sql;
$adr_res=mysql_query($adr_sql,$link_vcrx);
if(mysql_num_rows($adr_res)!=0){?>
<div class="c2"></div>
	<div id="con_dir">
	
	<?php
	while($adr_r=mysql_fetch_assoc($adr_res)){?>
	
		<div align="left" class="dper_lbl">EMAIL:</div>
		<div align="left" class="dper_txt"><?php echo $adr_r['adrs_email'];?></div>
	
	
		<div align="left" class="dper_lbl">CALLE1-CDLA-EDIF:</div>
		<div align="left" class="dper_txt" ><?php echo $adr_r['adrs_calle1'];?></div>
	
	
		<div align="left" class="dper_lbl">CALLE2-MZ-PISO:</div>
		<div align="left" class="dper_txt" ><?php echo $adr_r['adrs_calle2'];?></div>
	
	
		<div align="left" class="dper_lbl">NUM.VILLA-DPTO:</div>
		<div align="left" class="dper_txt" ><?php echo $adr_r['adrs_callen'];?></div>
	
	
		<div align="left" class="dper_lbl">REFERENCIA:</div>
		<div align="left" class="dper_txt" ><?php echo $adr_r['adrs_calle3'];?></div>
	
	
		<div align="left" class="dper_lbl">TELEFONO:</div>
		<div align="left" class="dper_txt" ><?php echo $adr_r['adrs_tlfn'];?></div>
	
	
		<div align="left" class="dper_lbl">EXT:</div>
		<div align="left" class="dper_txt" ><?php echo $adr_r['adrs_ext'];?></div>
	
	
		<div align="left" class="dper_lbl">CIUDAD:</div>
		<div align="left" class="dper_txt"><?php echo $adr_r['prvc_descri'].'/'.$adr_r['cdad_descri'];?></div>
	
	
		<div align="left" class="dper_lbl">CONTACTO:</div>
		<div align="left" class="dper_txt" ><?php echo $adr_r['adrs_contacto'];?></div>
	

		
        <hr />
<?php } ?>
	
	</div>

<?php } ?>
<!-- **************** -->



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

<input type="button" onclick="_finalizar();" value="Finalizar Orden" style="background:#09c; font-size:18px; font-weight:bolder;  color:#FFF; height:45px; padding-top:20px; box-sizing:border-box; box-sizing:content-box;"  />
</div>