<?php session_start();
if(empty($_SESSION['user_vcrx_id'])){die ('<resultado><error>No ha iniciado sesion</error></resultado>');}
$adrs_sql='insert into adrs0 (
adrs_email,
adrs_calle1,
adrs_calle2,
adrs_callen,
adrs_calle3,
adrs_tlfn,
adrs_ext,
adrs_contacto,
adrs_cdad,
adrs_enti,
adrs_iuser,
adrs_idate
)
values(
"'.$_POST['email'].'",
"'.$_POST['calle1'].'",
"'.$_POST['calle2'].'",
"'.$_POST['callen'].'",
"'.$_POST['calle3'].'",
"'.$_POST['tlfn'].'",
"'.$_POST['ext'].'",
"'.$_POST['contacto'].'",
"'.$_POST['ciudad'].'",
"'.$_SESSION['user_vcrx_id'].'",
"'.$_SESSION['user_vcrx_id'].'",
NOW()
)
';
require('../cfg/res.php');
if($_POST['idx']!='0' && $_POST['action']!='X'){
	$adrs_sql='update adrs0 set adrs_defa="0"  where  adrs_enti="'.$_SESSION['user_vcrx_id'].'"';
	mysql_query($adrs_sql,$link_vcrx);
	$adrs_sql='update adrs0 set adrs_defa="1"  where adrs_codigo="'.$_POST['idx'].'" and adrs_enti="'.$_SESSION['user_vcrx_id'].'"';
}

if($_POST['idx']!='0' && $_POST['action']=='X'){
	$adrs_sql='update adrs0 set adrs_status="X"  where adrs_codigo="'.$_POST['idx'].'" and adrs_enti="'.$_SESSION['user_vcrx_id'].'"';
}


echo '<resultado>';
if(mysql_query($adrs_sql,$link_vcrx)){echo '<error>Se realizo con exito</error>';}
else{echo '<error>Error al registrar </error>';}
echo '</resultado>';
?>