<?php
/*
Autor: Lic. Carlos Alberto Vaca Coronado
Version: 3.2.0
*/

session_name('portal_absa');
session_start();
require_once "conexion/conectar.php";
require_once "libs/funciones.php";

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

	$idReceptor="";
	$rfc="";
	$nombre="";
	$calle="";
	$noExterior="";
	$noInterior="";
	$colonia="";
	$ciudad="";
	$estado="";
	$pais="";
	$codigoPostal="";
	$cerPass="";
	$cerB64="";
	$keyB64="";
	
if(isset($_POST["id"]))
{
	$completaSelect = "";
	if($_SESSION["MODULO_PENDIENTES_CANCELAR"] === "1"){
		$completaSelect = ",cerPass,cerB64,keyB64";
	}
	
	$query="Select idReceptor,rfc,nombre,calle,noexterior,nointerior,colonia,ciudad,estado,pais,codigopostal $completaSelect from receptor where idReceptor='".$_POST["id"]."' LIMIT 1";
	
	$rquery=mysqli_query($conexion->CONEXION,$query);
	
	if(mysqli_num_rows($rquery) == 1)
	{
		$temp=mysqli_fetch_assoc($rquery);

		$idReceptor=$_POST['idReceptor'];
		$rfc=$temp["rfc"];
		$nombre=$temp["nombre"];
		$calle=$temp["calle"];
		$noExterior=$temp["noexterior"];
		$noInterior=$temp["nointerior"];
		$colonia=$temp["colonia"];
		$ciudad=$temp["ciudad"];
		$estado=$temp["estado"];
		$pais=$temp["pais"];
		$codigoPostal=$temp["codigopostal"];
		$cerPass=Encripta($temp["cerPass"]);
		$cerB64=$temp["cerB64"];
		$keyB64=$temp["keyB64"];

	}
}
?>
<script language="javascript" src="libs/Vanadium/vanadium.js"></script>
<script>
$j_6.noConflict();
$j_6(document).ready(function() {
	$j_6('#loading').hide();
    $j_6().ajaxStart(function() {
        $j_6('#loading').show();
        $j_6('#result').hide();
    }).ajaxStop(function() {
        $j_6('#result').fadeIn('slow');
		$j_6('#loading').hide();
    });
	
	/*$j_3('#formRFC').ajaxForm(function(data) {
					if(data.indexOf('ERROR:') == -1){
						document.getElementById('rfc').readOnly=true;
					}
					$j_3('#result').html(data);
					$j_3('#loading').hide();
	});*/
	
	var opciones= {
                               beforeSubmit: beforeSub, //funcion que se ejecuta antes de enviar el form
                               success: mostrarRespuesta //funcion que se ejecuta una vez enviado el formulario
            };
		
		$j_3('#formRFC').ajaxForm(opciones);
        function beforeSub(){
            $j_6('body').addClass("loading");
        }
	function mostrarRespuesta (data){
		$j_6('#result').html(data);
		$j_6('body').removeClass("loading");
        };
	
	/*$j_6('#form, #fat, #formRFC').submit(function() {
        $j_6.ajax({
            type: 'POST',
            url: $j_6(this).attr('action'),
            data: $j_6(this).serialize(),
            success: function(data) {
					if(data.indexOf('ERROR:') == -1){
						document.getElementById('rfc').readOnly=true;
					}
					$j_6('#result').html(data);
					$j_6('#loading').hide();
            }
        })
        
        return false;
    });*/
	
   $j_6("#rfc").change(function () {
   		$j_6("#rfc").each(function () {
				var rfcAnt='<?=$rfc?>';
				var rfc=$j_6(this).val();
				<?if(isset($_POST['idReceptor'])){?>
				if(rfcAnt==rfc)
					return false;
				<?}?>
				$j_6.post("regresaRFC.php", { rfc: rfc, rfcBD: rfcAnt },function(data){
					$j_6('#result').html(data);
			});			
        });
   });
   
});
function maximo(campo,limite){
if(campo.value.length>=limite){
campo.value=campo.value.substring(0,limite);
 }
}
function pulsar(e) {
  tecla = (document.all) ? e.keyCode : e.which;
  return (tecla != 13);
}
</script>
<table>
		<tr>
		<td valign="top" class="txt_logindat" width="800" height="35"><div id="result"></div></td>
		</tr>
</table>
<table bgcolor="#FFFFFF">
		<tr>
			<td valign="top" class="txt_logindat" align="center"><center><h2>CONFIGURACI&Oacute;N DE RECEPTOR</h2></center></td>
		</tr>
</table>
        <form action="altaRFC.php" method="post" name="formRFC" id="formRFC" onkeypress = "return pulsar(event)" enctype="multipart/form-data">
        <INPUT TYPE="hidden" NAME="reloadGridAfterSave" id="reloadGridAfterSave" value="<?=$_POST['reloadGridAfterSave']?>">
		<INPUT TYPE="hidden" NAME="valLiga" id="valLiga" value="<?=$_GET['valLiga']?>">
		<table class="td_general" bgcolor="#FFFFFF">
		<tr>
		<td valign="top" class="txt_logindat">
		<strong>R.F.C. Receptor: * :</strong>
		<input type="hidden" value="<?=$idReceptor?>" name="idReceptor">
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" size="23" maxlength="13" name="rfc" id="rfc" class=":required Logers" value="<?=$rfc?>"/>
        </td>
        <td valign="top" class="txt_logindat">
        <strong>Raz&oacute;n Social * :</strong>
        </td>
        <td valign="top" class="txt_logindat">
        <input type="text" maxlength="100" size="30" name="nombre" id="nombre" class=":required Logers" value="<?=$nombre?>" maxlength="100">
        <br><br>
        </td>
        </tr>
        <tr>
		<td valign="top" class="txt_logindat" colspan="3">
		<table>
		<tr>
        <td valign="top" class="txt_logindat" width="100">
        <strong>Calle :</strong>
		</td>
		<td valign="top" class="txt_logindat" colspan="2">
		<input type="text" maxlength="100" size="60" name="calle" id="calle" class="Logers" value="<?=$calle?>"/><br /><br />
		</td>
		</tr>
		<tr>
        <td valign="top" class="txt_logindat" width="75">
        <strong>No. Exterior :</strong>
		</td>
		<td valign="top" class="txt_logindat" colspan="2">
		<input type="text" maxlength="20" size="60" name="noExterior" id="noExterior" class="Logers" value="<?=$noExterior?>"/><br /><br />
		</td>
		</tr>
		<tr>
        <td valign="top" class="txt_logindat" width="75">
        <strong>No. Interior :</strong>
		</td>
		<td valign="top" class="txt_logindat" colspan="2">
		<input type="text" maxlength="20" size="60" name="noInterior" id="noInterior" class="Logers" value="<?=$noInterior?>"/><br /><br />
		</td>
		</tr>
		<tr>
        <tr>
        <td valign="top" class="txt_logindat" width="75">
        <strong>Colonia :</strong>
		</td>
		<td valign="top" class="txt_logindat" colspan="2">
		<input type="text" maxlength="50" size="60" name="colonia" id="colonia" class="Logers" value="<?=$colonia?>"/><br /><br />
		</td>
		</tr>
		<tr>
		<tr>
        <td valign="top" class="txt_logindat" width="75">
        <strong>Ciudad :</strong>
		</td>
		<td valign="top" class="txt_logindat" colspan="2">
		<input type="text" maxlength="50" size="60" name="ciudad" id="ciudad" class="Logers" value="<?=$ciudad?>"/><br /><br />
		</td>
		</tr>
		<tr>
        <td valign="top" class="txt_logindat" width="75">
        <strong>Estado :</strong>
		</td>
		<td valign="top" class="txt_logindat" colspan="2">
		<input type="text" maxlength="50" size="60" name="estado" id="estado" class="Logers" value="<?=$estado?>"/><br /><br />
		</td>
		</tr>
		<tr>
        <td valign="top" class="txt_logindat" width="75">
        <strong>Pa&iacute;s :</strong>
		</td>
		<td valign="top" class="txt_logindat" colspan="2">
		<input type="text" maxlength="50" size="60" name="pais" id="pais" class="Logers" value="<?=$pais?>"/><br /><br />
		</td>
		</tr>
		<tr>
        <td valign="top" class="txt_logindat" width="75">
        <strong>C. P. :</strong>
		</td>
		<td valign="top" class="txt_logindat" colspan="2">
		<input type="text" maxlength="5" size="60" name="codigoPostal" id="codigoPostal" class="Logers" value="<?=$codigoPostal?>"/><br /><br />
		</td>
		</tr>
		<?if($_SESSION["MODULO_PENDIENTES_CANCELAR"] === "1"){?>
			<tr>
			<td valign="top" class="txt_logindat" width="75">
			<strong>Certificado :</strong>
			</td>
			<td valign="top" class="txt_logindat" colspan="2">
				<input type="file" name="cer" id="cer" accept=".cer"/><?if(trim($cerB64) !== ""){?><img title="Certificado cargado" src="Imagenes/accept.png" width="12" height="12"/><?}?>
			</td>
			</tr>
			<tr>
			<td valign="top" class="txt_logindat" width="75">
			<strong>Llave :</strong>
			</td>
			<td valign="top" class="txt_logindat" colspan="2">
				<input type="file" name="key" id="key" accept=".key"/><?if(trim($keyB64) !== ""){?><img title="Llave cargada" src="Imagenes/accept.png" width="12" height="12"/><?}?>
			</td>
			</tr>
			<tr>
			<td valign="top" class="txt_logindat" width="75">
			<strong>Contraseña :</strong>
			</td>
			<td valign="top" class="txt_logindat" colspan="2">
				<input type="password" maxlength="20" size="60" name="cerPass" id="cerPass" value="<?=$cerPass?>"/>
			</td>
			</tr>
		<?}?>
		</table>
		</td>
        </tr>
        <tr>
        <td>
        <? echo btnNavegacion('');?>
        </td>
        </tr>
		</table>
        </form>
<?
function btnNavegacion($url)
{
?>	
		<input type="submit" class="estilo_btn" value="GUARDAR"/>
<?
}
?>