<?
ini_set('display_errors','1');
/*
Autor: Lic. Carlos Alberto Vaca Coronado
Version: 3.2.0
*/

session_name('portal_absa');
session_start();


header('Content-Type: text/html; charset=utf-8');

require_once("libs/funciones.php");
require_once("conexion/conectar.php");
include_once("config.php");

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


if(@$_GET["modulo"] == "CONFIRMACORREO"){
	
				$_SESSION['RFC_RECEPTOR_PORTAL'] = @$_GET["rfcrec"];
}

if(isset($_SESSION['RFC_RECEPTOR_PORTAL']) && trim($_SESSION['RFC_RECEPTOR_PORTAL']) != ""){
	$query = "select tema_general,tema_menu,color_fondo,fondo_img,color_fondo_2,fondo_img_2,login_img,fondo_img_check,fondo_img_2_check,slide_superior_check,
	slide_centro_check,fondo_img_3,fondo_img_4,alineacion_slide_superior,banner_centro_check, fecha_sincronizacion_pagos
	 from configpagina where rfc_receptor='".$_SESSION['RFC_RECEPTOR_PORTAL']."'";


	$resultConfig = mysqli_query($conexion->CONEXION,$query);

	$temp=mysqli_fetch_array($resultConfig,MYSQLI_ASSOC);

	if(mysqli_num_rows($resultConfig) == 0){echo "<script>alert('No se encontro la configuración de la empresa.');window.location.href='principal.php'</script>";exit;}

	$_SESSION['tema_general'] = $temp['tema_general'];
	$_SESSION['tema_menu'] = $temp['tema_menu'];
	$_SESSION['color_fondo'] = $temp['color_fondo'];
	$_SESSION['fondo_img'] = $temp['fondo_img'];
	$_SESSION['color_fondo_2'] = $temp['color_fondo_2'];
	$_SESSION['fondo_img_2'] = $temp['fondo_img_2'];
	$_SESSION['login_img'] = $temp['login_img'];
	$_SESSION['fondo_img_check'] = $temp['fondo_img_check'];  //Fondo de Login Check
	$_SESSION['fondo_img_2_check'] = $temp['fondo_img_2_check'];  //Fondo General Check
	$_SESSION['slide_superior_check'] = $temp['slide_superior_check'];
	$_SESSION['slide_centro_check'] = $temp['slide_centro_check'];
	$_SESSION['banner_centro_check'] = $temp['banner_centro_check'];
	$_SESSION['fondo_img_3'] = $temp['fondo_img_3'];  //Fondo banner superior
	$_SESSION['fondo_img_4'] = $temp['fondo_img_4'];  //Fondo banner centro
	$_SESSION['alineacion_slide_superior'] = $temp['alineacion_slide_superior'];
	$_SESSION['fecha_sincronizacion_pagos'] = $temp['fecha_sincronizacion_pagos'];

	if(file_exists("config.ini")){
		$vlineas = file("config.ini");
		
		foreach ($vlineas as $sLinea) {
				if(substr($sLinea,0,17) == "AVISO_PRIVACIDAD=" && trim($sLinea) == "AVISO_PRIVACIDAD=SI"){
					$_SESSION["aviso"]="SI";
					break;
				}else{
					$_SESSION["aviso"]="NO";
				}
		}
	}else{
	$_SESSION["aviso"]=="NO";
	}

	$qRece = "select nombre from receptor where rfc='".$_SESSION['RFC_RECEPTOR_PORTAL']."' LIMIT 1";
	$rNombre = mysqli_query($conexion->CONEXION,$qRece);
	if(mysqli_num_rows($rNombre) > 0){
		$tNombre = mysqli_fetch_array($rNombre,MYSQLI_ASSOC);
		$_SESSION['nombre_receptor'] = $tNombre['nombre'];
	}
}else{
	header("location: index.php");exit;
}
	
if (!isset($_GET["pag"])) {$pagina = 1; $limite=0; $tampag=30;} // Por defecto, pagina 1
		if (isset($_GET["pag"])) {
		$pagina=@$_GET["pag"];
		$tampag = 30;
		$limite=($pagina-1) * $tampag;
		}

if(file_exists("config.ini")){
	$vlineas = file("config.ini");
	
		foreach ($vlineas as $sLinea) {
			if(substr($sLinea,0,17) == "ACTIVACION_ADMIN="){
				$_SESSION["activacion_admin"]=trim(substr($sLinea,17));
			}
		}
}

?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<title>Bienvenido::Recibe CFD</title>

<!--Versiones Jquery-->
<script language="javascript" src="libs/js/jquery.min1-3-2.js"></script>
<script type="text/javascript"	src="libs/js/jquery-ui.min.js"></script>
<script>
	var $j_3 = $.noConflict();
</script>
<script language="javascript" src="libs/js/jquery.form.js"></script>
<script language="javascript" src="libs/js/jquery.min1.6.2.js"></script>
<script>
	var $j_6 = $.noConflict();
</script>

<!--CSS General-->
<link href="CSS/super_css.css" rel="stylesheet" type="text/css" />
<!-- Funciones JavaScript -->
<script language="javascript" type="text/javascript" src="libs/js/funciones.js"></script>

<!--jqGrid-->
<!--CSS jqGrid-->
<link rel="stylesheet" type="text/css" media="screen" href="grids/jqgrid/src/css/<?=$_SESSION['tema_general']?>/jquery-ui-1.9.1.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="grids/jqgrid/src/css/ui.jqgrid.css" />
<link rel="stylesheet" type="text/css" media="screen" href="grids/jqgrid/src/css/ui.multiselect.css" />
<script src="grids/jqgrid/js/i18n/grid.locale-es.js" type="text/javascript"></script> 
<script src="grids/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script> 
<script src="grids/funcionesJQGrid.js" type="text/javascript"></script>

<!--SLIDE-->
<link rel="stylesheet" type="text/css" href="libs/slideshows/LofSlider/css/layout.css" />
<link rel="stylesheet" type="text/css" href="libs/slideshows/LofSlider/css/style.css" />
<script language="javascript" type="text/javascript" src="libs/slideshows/LofSlider/js/jquery.easing.js"></script>
<script language="javascript" type="text/javascript" src="libs/slideshows/LofSlider/js/script.js"></script>
</head>

<!--DatePicker-->
<!--<link rel="stylesheet" href="grids/jquery-ui-core/development-bundle/themes/redmond/jquery.ui.all.css">-->
<script src="grids/jquery-ui-core/development-bundle/ui/jquery.ui.core.js"></script>
<script src="grids/jquery-ui-core/development-bundle/ui/jquery.ui.widget.js"></script>
<script src="grids/jquery-ui-core/development-bundle/ui/jquery.ui.datepicker.js"></script>
<!--Mascara Input-->
<script src="libs/jQueryMasked/jquery.maskedinput-1.2.2.js"></script>

<!-- Jquery easy ui -->
<link rel="stylesheet" type="text/css" href="libs/jqueryEasy_1.2.5/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="libs/jqueryEasy_1.2.5/themes/icon.css">
<script type="text/javascript" src="libs/jqueryEasy_1.2.5/jquery.easyui.min.js"></script>

<!-- MSDropDown -->
<link rel="stylesheet" type="text/css" href="libs/msdropdown/dd.css" />
<script language="javascript" type="text/javascript" src="libs/msdropdown/jquery.dd.js"></script>

<!-- ColorPicker -->
<link rel="stylesheet" type="text/css" href="libs/colorpicker/css/colorpicker.css">
<script type="text/javascript" src="libs/colorpicker/js/colorpicker.js"></script>

<style>
.sombra{
behavior: url('CSS/ie-css3.htc');
box-shadow: -20px 20px 20px #333333;
-webkit-box-shadow: -20px 20px 20px #333333;
-moz-box-shadow: -20px 20px 20px #333333;

-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
padding-left : 5px; padding-right : 5px;
background-color: #FFFFFF
}
.headDiv{
behavior: url('CSS/ie-css3.htc');
box-shadow: -3px 3px 20px #333333;
-webkit-box-shadow: -3px 3px 20px #333333;
-moz-box-shadow: -3px 3px 20px #333333;
width:100%;
height: 30px;
border:0px;
background-color: #00263C;
font-size: 16px;
color: #CCCCCC;
z-index:200;
position:fixed;
}

.footer{
  padding: 5px 5px 5px 5px;
  left: 0;
  bottom: 0;
  width: 100%;
  background-color: #F9564C;
  color: white;
  text-align: center;
  vertical-align: center;
  font-size: 16;
}

.bannerDiv{
width:100%;
height: 150px;
border:0px;
position:fixed;
z-index: 199;
}

.sombraModal{
behavior: url('CSS/ie-css3.htc');
box-shadow: -10px 10px 20px #333333;
-webkit-box-shadow: -10px 10px 20px #333333;
-moz-box-shadow: -10px 10px 20px #333333;

-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
padding-left : 5px; padding-right : 5px;
background-color: #FFFFFF
}

.ventanaModal_{
background-color: #000000;
z-index:500;
position:fixed;
opacity:0.7;
filter: alpha(opacity=70);
}

.loadModal_{
background-color: #FFFFFF;
z-index:501;
position: absolute;
width: 500px;
height: 500px;
}

.close-window{
    padding: 5px 5px 5px 5px;
    margin-top:-15px;
}
.modal {
    display:    none;
    position:   fixed;
    z-index:    1000;
    top:        0;
    left:       0;
    height:     100%;
    width:      100%;
    background: rgba( 255, 255, 255, .8 ) 
                url('http://i.stack.imgur.com/FhHRx.gif') 
                50% 50% 
                no-repeat;
}

body.loading {
    overflow: hidden;   
}

body.loading .modal {
    display: block;
}
</style>
<!--
<!--[if IE]>
<style type="text/css">
.headDiv{
behavior: url('CSS/ie-css3.htc');
box-shadow: -3px 3px 20px #333333;
width:100%;
height: 30px;
border:0px;
background-color: #00263C;
font-size: 16px;
color: #CCCCCC;
z-index:200;
position: absolute;
left: expression( ( 0 + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );
top: expression( ( 0 + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
}

.bannerDiv{
width:100%;
height: 150px;
border:0px;
position: absolute;
left: expression( ( 0 + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );
top: expression( ( 0 + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
z-index: 199;
}

.ventanaModal_{
background-color: #000000;
z-index:500;
opacity:0.7;
filter: alpha(opacity=70);
position: absolute;
left: expression( ( 0 + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );
top: expression( ( 0 + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
}

</style>
<![EndIf]-->
<!--
<!--[if IE]>
<style>
.ventanaModal_{
background-color: #000000;
z-index:500;
opacity:0.7;
filter: alpha(opacity=70);
position: absolute;
left: expression( ( 0 + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );
top: expression( ( 0 + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
}

</style>
<![EndIf]-->
<?if(trim(@$_GET['modulo']) != "RECUERDAPASS"){?>
<script>
//Funciones para habilitar la ventana cuando se cierra el expediente virtual
var mipopup;
$j_6(document).ready(function() {
		$j_6("#closeModal").live('click',function () {
					$j_6('#loadModal').html('');
					$j_6('#loadModal-content').hide();
					$j_6('#ventanaModal').hide();
					$j_6('#loading').hide();
		});
});

function cerrarPopup(){
window.mipopup.close();
window.mipopup=null;
$j_6('body').removeClass();
}
function revisaForm(){
	return true;
}
function popupAbierto(){
	if(window.mipopup)
		window.mipopup.focus();
}
function cambiarDeEmpresa(){
	$j_6.messager.confirm("Confirmación","¿Desea cambiar de empresa?",function(r){
		if(r){
			$j_6.post("extras/cambiaEmpresa.php",{rfc_empresa_cambio: $j_6("#rfc_empresa_cambio").val()},function(data){
				$j_6("#result").html(data);
			});
		}else{
			return false;
		}
	});
	
}
//Termina funciones para habilitar la ventana cuando se cierra el expediente virtual
</script>

<?}
?>
<?include "menu.php";?>

</head>

<body>
	
<div class="headDiv">
Facturaci&oacute;n Electr&oacute;nica - Recibe CFD - <?=$_SESSION['nombre_receptor']?>
</div>

    <div class="bannerDiv" style="height: 100px">
        <br/>
        <table width="100%" height="105px" <?if($_SESSION['slide_superior_check'] != 1){?>style="background-image: url(Imagenes/imgBannerS/<?=$_SESSION['fondo_img_3']?>); background-repeat: no-repeat; background-size: 100%; -moz-background-size: 100%; -webkit-background-size: 100%;"<?}?> class="ui-accordion-header ui-helper-reset ui-state-default ui-accordion-header-active ui-state-active ui-accordion-icons">
                <tr>
                    <?if($_SESSION['slide_superior_check'] == 1){?><td width="70%"><? $divImgSlide="img1"; $tipoSlide="S"; $dirLoad = "imgBannerS"; include "imagenes.php";?></td><?}?>
                    
					<?if($_SESSION['slide_superior_check'] == 1){?>
						<td width="100%" align="right" valign="bottom">
					<?}else{?>
						<td width="30%" align="right" valign="bottom">
					<?}?>
					
                        <?if(isset($_GET['accion']) == "ACTIVACION" || isset($_SESSION['usuario_p_prov_absa']) && trim(@$_GET['modulo']) != "RECUERDAPASS"  && trim(@$_GET['modulo']) != "REGUSUARIOS"){?><font class="ui-widget-header"><strong>Bienvenido: </strong> <? echo $_SESSION['name_p_prov_absa']?></font>
                        <br/>
						<?if($_SESSION["MODULO_PAGOS"] == "1"){?>
							<font class="ui-widget-header"><strong>Información actualizada a: </strong> <? echo $_SESSION['fecha_sincronizacion_pagos']?></font>
						<?}?>
                        <br/>
                        <br/>
						<?if(trim(strtoupper($_SESSION['todo_RFC_p_prov_absa'])) == "SI"){
							if(trim($_SESSION["RES_RFC_REFERENCIA"]) == "SI"){
								$arrEmpresas = explode(",",$_SESSION['sesion_ref_rfc_receptor']);
							?>
								Empresa: <select id="rfc_empresa_cambio" name="rfc_empresa_cambio" style="width: 150px;border-color: #fbca93;">
										
										<?if(strtoupper(trim($_SESSION['usuario_p_prov_absa'])) == "ADMIN"){
											$query="select rfc from receptor";
											$resultado=mysqli_query($conexion->CONEXION,$query);
											while($temp=mysqli_fetch_array($resultado,MYSQLI_ASSOC)){?>
												<option value="<?=$temp["rfc"];?>" <? if($_SESSION['RFC_RECEPTOR_PORTAL'] == $temp["rfc"]){echo "selected";}?>><? echo $temp["rfc"];?></option>
										<?
											}
										}else{
											for($i=0; $i <= count($arrEmpresas); $i++){
												if(trim($arrEmpresas[$i]) == ""){continue;}?>
												<option value="<?=$arrEmpresas[$i]?>" <?if($_SESSION['RFC_RECEPTOR_PORTAL'] == $arrEmpresas[$i]){echo "selected";}?>><?=$arrEmpresas[$i]?></option>
										<?}
										}
										?>
								</select>
								<img src="Imagenes/change.png" style="cursor:pointer" onClick="cambiarDeEmpresa()" title="Cambiar de empresa" width="22" height="22" />
						<?	}
						}?>
						<img src="Imagenes/home.png" onClick="window.location.reload();" title="Recargar pagina" width="22" height="22" />
                        <img src="Imagenes/perfil.png" onClick="tools('editarPerfil.php?desde=menu');" title="Perfil" width="22" height="22" />
                        <img src="Imagenes/Help.png" onClick="tools('Acerca.htm')" title="Acerca de" width="22" height="22" />
                        <img src="Imagenes/modify_key.png" onClick="tools('CambiaPass.php');" title="Cambiar Contrase&ntilde;a" width="22" height="22" />
                        <img src="Imagenes/logout.png" onClick="window.location.href='logout.php'" title="Salir" width="22" height="22" />
                        <?}else{?>
                        <img src="Imagenes/Help.png" onClick="tools('Acerca.htm')" title="Acerca de" width="22" height="22" />
                        <img src="Imagenes/logout.png" onClick="window.location.href='logout.php'" title="Salir" width="22" height="22" />
                        <?}?>
                    </td>
                </tr>
            </table>
    </div>
<?if(isset($_SESSION['usuario_p_prov_absa'])){?>
    <div id="ventanaModal"></div>
    <div id="loadModal-content" style="position: fixed">
            <div id="closeModal-content" class="close-window" align="right"><img src="Imagenes/closeWindow.png" id="closeModal" style="cursor: pointer" title="Cerrar" width="20" height="20"/></div>
            <div id="loadModal" align="center" style="overflow:auto"></div>
    </div>
<?}?>
    <!--<br/><br/><br/><br/><br/><br/><br/><br/>-->
<?php if($PORTAL_TEST == 1){?>
<table width="100%" height="97%"   border="2" align="center" cellpadding="0" cellspacing="0" style="">
<?php }else{?>
<table width="100%" height="100%"   border="2" align="center" cellpadding="0" cellspacing="0" style="">	
<?php }?>

  <tr>
    <td width="100%" style="border:0px" height="100%">
    <table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
		<tr><td height="115px" style="border: none"></td></tr>
	  <tr>
		 <?if(isset($_GET['accion']) == "ACTIVACION" || isset($_SESSION['usuario_p_prov_absa']) && trim(@$_GET['modulo']) != "RECUERDAPASS" && trim(@$_GET['modulo']) != "REGUSUARIOS"){?>
		  <td height="100%" width="1%" valign="top" class="ui-accordion-header ui-helper-reset ui-state-default ui-accordion-header-active ui-state-active ui-accordion-icons">               
			  <div width="100%" style="margin-top: -15px"valign="top" class="collapse_left"><?  
						if(isset($_GET['accion']) == "ACTIVACION" || isset($_SESSION['usuario_p_prov_absa']) && trim(@$_GET['modulo']) != "RECUERDAPASS"){
							include("MenuPrincipal.php");
						}?>
			  </div>
		  </td>
		  
		  <td valign="center" width="1%" rowspan="7" align="right" class="ui-accordion-header ui-helper-reset ui-state-default ui-accordion-header-active ui-state-active ui-corner-top ui-accordion-icons"><img width="19" height="19" style="margin-left:-10px" src="Imagenes/showCollapse.png" id="collapse_left_hide" title="Ocultar Panel Izquierdo" onClick="collapseLeft(this,'collapse_left','','left','Izquierdo');"/></td>
		 <?}?>
		  
		  <td colspan="2" width="150%" valign="center" align="center" style="background: <?=$_SESSION['color_fondo_2']?>; <?if($_SESSION['fondo_img_2_check'] != 0 && trim($_SESSION['fondo_img_2']) != ""){?>background-image: url(Imagenes/imgFondo/<?=$_SESSION['fondo_img_2']?>);<?}?> background-size: cover; -moz-background-size: cover; -webkit-background-size: cover; background-attachment: fixed">
				<?if(isset($_SESSION['usuario_p_prov_absa'])){?>
				<div id="loading"><img src="Imagenes/loading.gif" width="28" height="25"></div>
				<?}?>
		<div id="cuerpo" style="text-align: middle; width: 100%; height: 100%;"><?
		if(isset($_GET['modulo']) && @$_GET['modulo'] == "REGUSUARIOS")
			include "regUsuarios.php";
		else if(isset($_GET['modulo']) && @$_GET['modulo'] == "RECUERDAPASS")		
			include "olvidoPass.php";
		else if(isset($_GET['modulo']) && @$_GET['modulo'] == "CONFIRMACORREO"){
			if(trim($_SESSION["activacion_admin"]) == "NO")
				include "activarCuentaXUsuarioCompleto.php";
			else
				include "activarCuentaXUsuario.php";
				
		}else if(isset($_GET['modulo']) && @$_GET['modulo'] == "ACTIVAUSUARIO")
			include "activarUsuario.php";
		else{
			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'])) && trim(strtoupper($_SESSION["URL_PORTAL"]."principal.php")) != trim(strtoupper($_SERVER['HTTP_REFERER'])) )){
				
				?><script>window.location.href="<?=$_SESSION["URL_PORTAL"]."index.php"?>"</script><?
				exit;
			}
			if($_SESSION['banner_centro_check'] == 0){
				if($_SESSION['slide_centro_check'] == 1){
					$divImgSlide="img2"; $tipoSlide=""; $dirLoad = "imgBannerC"; include "imagenes.php";
				}else{
					?><center><img src="Imagenes/imgBannerC/<?=$_SESSION['fondo_img_4']?>" /></center><?
				}
			}
		}
		
		?>
		
		</div>
			 
				<div id="result" style=""></div>
		
		</td>
		</tr>
    </table>
        
        
    </td>
  </tr>
  <tr>
    <td align="center" class="pie" style="background-color: #E9E9E9; border: 0px">Todos los derechos reservados para DisXII&reg; <a class="pie" href="http://www.disxii.com" target="_blank">www.disxii.com</a><br/>
	<?if($_SESSION["aviso"]=="SI"){include "aviso.php";}?></td>
  </tr>
</table>
<?php if($PORTAL_TEST == 1){?>
		<div class="footer">
			<span><?php echo $LEYENDA_FOOTER_TEST;?></span>
		</div>
	<?php }?>
<div id="eventosAjax"></div>
<div class="modal"></div>
</body>
<script>
$j_6('#loading').hide();
</script>

<?
	function caracteres_html($texto){ 
      $texto = htmlentities($texto); // Convertir caracteres especiales a entidades 
      $texto = htmlspecialchars_decode($texto, ENT_NOQUOTES); // Dejar <, & y > como estaban 
      return $texto;
  }
?>

</html>

