<?
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;
}
include "../../conexion/conectar.php";
require "../../libs/funciones.php";

$conexion = new CONDB();
$conexion->conectar();
$q="select * from correos_proveedores where rfc='".$_REQUEST["rfc"]."' and rfc_receptor='".$_SESSION['RFC_RECEPTOR_PORTAL']."'";
if(!$result = mysqli_query($conexion->CONEXION,$q)){
	?><script>$j_6.messager.alert("Error","Ocurrio un error al consultar los correos.","error");</script><?exit;
}
if(mysqli_num_rows($result) <= 0){
	?><center><font style="color: red; font-size: 20px">No hay correos dados de alta</font></center><?exit;
}
?>
<script>
function eliminaCorreoProveedor(id){
	$j_6.messager.confirm("Confirmar","<?=utf8_encode("¿")?>Esta seguro de eliminar el correo?",function(r){
		if(r){
			$j_6.post("formularios/extras/elimina_correo_proveedor.php",{id: id},function(data){
				$j_6("#result").html(data);
			});
		}else{
			return false;
		}
	});
}
</script>

<table width="100%" style="border: 2px solid #DDDDDD">
	<tr style="background-color: black; color: white; border: 2px solid #DDDDDD">
		<th>Nombre</th>
		<th>Correo</th>
		<th width="50px"></th>
	</tr>
<?
$con=0;
while($tmp=mysqli_fetch_array($result,MYSQLI_ASSOC)){
		$con++;
		$res = $con%2;
		$trEstilo="";
		if($res == 0){
			$trEstilo = "style='background-color: #DDDDDD; border: 2px solid #DDDDDD'";
		}else{
			$trEstilo = "style='background-color: white; border: 2px solid #DDDDDD'";
		}
	?>
	<tr <?=$trEstilo?>>
		<td ><?=$tmp["nombre"]?></td>
		<td><?=$tmp["correo"]?></td>
		<td style="text-align: center"><img style="cursor:pointer" src="Imagenes/remove_24.png" width="24" height="24" onClick="eliminaCorreoProveedor(<?=$tmp["id"]?>)"></td>
	</tr>
	<?
}
?>
</table>