<?
session_name('portal_absa');
session_start();
require("../../conexion/conectar.php");

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

mysqli_query($conexion->CONEXION,"delete from proveedores where rfc_receptor='".$_SESSION['RFC_RECEPTOR_PORTAL']."'");

$ban=false;

for($i=0; $i < count($_POST['checkRFC']); $i++){
	if(mysqli_query($conexion->CONEXION,"insert into proveedores set rfc='".$_POST['checkRFC'][$i]."', rfc_receptor='".$_SESSION['RFC_RECEPTOR_PORTAL']."'")){
		$ban=true;
	}
}

$result = mysqli_query($conexion->CONEXION,"select * from proveedores where rfc='".$_SESSION['RFC_RECEPTOR_PORTAL']."' and rfc_receptor='".$_SESSION['RFC_RECEPTOR_PORTAL']."' LIMIT 1");
if(mysqli_num_rows($result) <= 0){
	mysqli_query($conexion->CONEXION,"insert into proveedores set rfc='".$_SESSION['RFC_RECEPTOR_PORTAL']."', rfc_receptor='".$_SESSION['RFC_RECEPTOR_PORTAL']."'");
}

if($ban){
?><script>alert("Se han guardado las referencias correctamente");</script><?
}

?>