<?
session_name('portal_absa');
session_start();
if(!isset($_SESSION['usuario_p_prov_absa']) || trim($_SESSION['usuario_p_prov_absa']) == "" || trim(strtoupper($_SESSION["URL_PORTAL"]."admin.php")) != trim(strtoupper($_SERVER['HTTP_REFERER']))){
	?><script>window.location.href="<?=$_SESSION["URL_PORTAL"]."index.php"?>"</script><?
	exit;
}
require("../../conexion/conectar.php");

$conexion = new CONDB();
$conexion->conectar();

$rfc = $_POST['rfc'];
$check = $_POST['check'];

if($check=="false"){
	mysqli_query($conexion->CONEXION,"delete from proveedores where rfc_receptor='".$_SESSION['RFC_RECEPTOR_PORTAL']."' and rfc='$rfc'");
}else{
	$rExiste = mysqli_query($conexion->CONEXION,"select * from proveedores where rfc_receptor='".$_SESSION['RFC_RECEPTOR_PORTAL']."' and rfc='$rfc' LIMIT 1");
	if(mysqli_num_rows($rExiste) != 1)
		mysqli_query($conexion->CONEXION,"insert into proveedores set rfc='$rfc', rfc_receptor='".$_SESSION['RFC_RECEPTOR_PORTAL']."'");	
}

?>