<?php session_start();
if(empty($_SESSION['user_vcrx_id'])){die('Su sesion expiro');}
require('../cfg/res.php');
$car_sql='delete from car2 where idnum2="'.$_POST['idn'].'" and iddet="'.$_POST['idd'].'"';

echo '<resultado>';
if(mysql_query($car_sql)){echo '<error>0</error>';}
else{echo '<error>Ocurrio error al eliminar</error>';}

$car1_sql='select *from car1 where enti="'.$_SESSION['user_vcrx_id'].'"';
$car1_res=mysql_query($car1_sql,$link_vcrx);
$car1_idn=mysql_result($car1_res,0,'idnum1');


$car2_sql='select sum(pvp1*cant)as subtotal from car2 where idnum2="'.$car1_idn.'"';
$car2_res=mysql_query($car2_sql,$link_vcrx);
$car2_subtot=mysql_result($car2_res,0,'subtotal');
echo '<subtotal>'.number_format($car2_subtot,2).'</subtotal>';

$car2_sql='select sum((pvp1*cant)*((iva/100)))as ivat from car2 where idnum2="'.$car1_idn.'"';
$car2_res=mysql_query($car2_sql,$link_vcrx);
$car2_ivat=mysql_result($car2_res,0,'ivat');
$car2_total=$car2_tot+$car2_ivat;
echo '<ivat>'.number_format($car2_ivat,2).'</ivat>';
echo '<total>'.number_format($car2_total,2).'</total>';
echo '<sql>'.$car_sql.'</sql>';
echo '</resultado>';

?>