<?php session_start();
require('../cfg/cfg.php');
require('../cfg/res.php');
$pagina_descri='DATOS PERSONALES';
$pagina_nivel;
$pagina_tipo;


require('../cfg/res.php');
require('../../_lib/select.php');
$sql_enti='select *from enti0 where enti_codigo="'.$_SESSION['user_vcrx_id'].'"';



$res_enti=mysql_query($sql_enti,$link_vcrx);

	$n1='';
	$n2='';
	$a1='';
	$a2='';
	$fn='';
	$nik='';
	$c1='';
	$c2='';
	$c3='';
	$c4='';
	$cn='';
	$e1='';
	$t1='';
	$t2='';
	$ref='';
	$pais='';
	$ciu='';
	$ci='';
	$razsoc='';
	$nomcom='';
	$struc='';
	

if(mysql_num_rows($res_enti)!=0)
{
$n1=mysql_result($res_enti,0,'enti_nom1');
$n2=mysql_result($res_enti,0,'enti_nom2');
$a1=mysql_result($res_enti,0,'enti_ape1');
$a2=mysql_result($res_enti,0,'enti_ape2');
$fn=mysql_result($res_enti,0,'enti_fechanac');
$nik=mysql_result($res_enti,0,'enti_nickname');
$c1=mysql_result($res_enti,0,'enti_calle1');
$c2=mysql_result($res_enti,0,'enti_calle2');
$c3=mysql_result($res_enti,0,'enti_calle3');
$c4=mysql_result($res_enti,0,'enti_callen');
$cn=mysql_result($res_enti,0,'enti_callen');
$e1=mysql_result($res_enti,0,'enti_email');
$t1=mysql_result($res_enti,0,'enti_telefono');
$ref=mysql_result($res_enti,0,'enti_referidox');
$pais=mysql_result($res_enti,0,'enti_pais');
$ciudad=mysql_result($res_enti,0,'enti_cdad');
$ci=mysql_result($res_enti,0,'enti_codigo');
$razsoc=mysql_result($res_enti,0,'enti_razsoc');
$nomcom=mysql_result($res_enti,0,'enti_nomcom');
$struc=mysql_result($res_enti,0,'enti_struc');

if(!empty($ref))
{
	$ref_sql='select enti_descri from enti0 where enti_codigo="'.$ref.'"';
	$ref_res=mysql_query($ref_sql,$link_vcrx);
	if(mysql_num_rows($ref_res)!=0)
	{
		$res_descri=mysql_result($ref_res,0,'enti_descri');
	}
}

}



?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $empr_nombre.'-'.$_SESSION['user_vcrx_id'];?> - Datos Personales </title>
<link rel="stylesheet" href="http://vcrxol.com/_css/comun.css" type="text/css" />
<link rel="stylesheet" href="../css/comun2.css" type="text/css" />
<style>
body{ font-size:12px;}
</style>
<script type="text/javascript" src="../js/jquery-1.11.1.js"></script>
<script type="text/javascript">
<?php include('../../_js/busca_maes3.js');?>
<?php include('../../_js/lista_maes3.js');?>
<?php include('../../_js/fecha_format.js');?>

function guarda_dper()
{ 

  	var ci=document.getElementById('ci').value;
	var n1=document.getElementById('n1').value;
	
	var n2=document.getElementById('n2').value;
	var a1=document.getElementById('a1').value;
	var a2=document.getElementById('a2').value;
	var razsoc=document.getElementById('razsoc').value;
	var nomcom=document.getElementById('nomcom').value;
	
	var c1=document.getElementById('c1').value;
 	var c2=document.getElementById('c2').value;
	var c3=document.getElementById('c3').value;
	var cn=document.getElementById('cn').value;
	var e1=document.getElementById('e1').value;
 	var t1=document.getElementById('t1').value;
	var ref=document.getElementById('ref').value;
 	var ciudad=document.getElementById('ciudad').value;
	var pais=document.getElementById('pais').value;
 	var nik=document.getElementById('nik').value;
	var fn=document.getElementById('fn').value;
	
	var descri='';
 	
	var struc=document.getElementById('struc').value;
	
	n1=n1.trim();
	a1=a1.trim();
	c1=c1.trim();
	c2=c2.trim();
	c3=c3.trim();
	e1=e1.trim();
	t1=t1.trim();
	nik=nik.trim();
	ref=ref.trim();
	


	
	fn=fecha_format(fn);
	if(n1.length<2 && ci.length<13)
	{
		document.getElementById('n1_descri').innerHTML='*Obligatorio';
		return false;
	}
	else
	{
		document.getElementById('n1_descri').innerHTML='';
	}

	
	if(a1.length<2  && ci.length<13)
	{
		document.getElementById('a1_descri').innerHTML='*Obligatorio';
		return false;
	}
	else
	{
		document.getElementById('a1_descri').innerHTML='';
	}

	
	if(c1.length<2)
	{
		document.getElementById('c1_descri').innerHTML='*Obligatorio';

		return false;
	}
	else
	{
		document.getElementById('c1_descri').innerHTML='';
	}

	
	if(c2.length<1)
	{
		//document.getElementById('dper_err_c2').innerHTML='*Obligatorio';
		//return false;
	}
	else
	{
		//document.getElementById('dper_err_c2').innerHTML='';
	}

	
	if(c3.length<1)
	{
		//document.getElementById('dper_err_c3').innerHTML='*Obligatorio';
		//return false;
	}
	else
	{
		//document.getElementById('dper_err_c3').innerHTML='';
	}

	if(t1.length<2)
	{
		document.getElementById('t1_descri').innerHTML='*Obligatorio';
		return false;
	}
	else
	{
		document.getElementById('e1_descri').innerHTML='';
	}
	
	
	if(nik.length==0)
	{
	}


	if(ci.length==13 && razsoc.length<2)
	{
		document.getElementById('razsoc_descri').innerHTML='*Razcon Social Obligatoria';
		return false;
	}
	else
	{
		document.getElementById('razsoc_descri').innerHTML='';
	}


	if(ci.length==13 && nomcom.length<2)
	{
		document.getElementById('nomcom_descri').innerHTML='*Nombre Comercial Obligatoria';
		return false;
	}
	else
	{
		document.getElementById('nomcom_descri').innerHTML='';
	}

	if(ci.length<13)
	{
		descri=a1 + ' ' + a2 + ' ' + n1 + ' ' + n2;		
		razsoc=descri;
		nomcom=descri;
	}
	else
	{
		descri=razsoc;
	}

	n1=n1.toUpperCase();
	n2=n2.toUpperCase();
	a1=a1.toUpperCase();
	a2=a2.toUpperCase();
	c1=c1.toUpperCase();
	c2=c2.toUpperCase();
	c3=c3.toUpperCase();
	cn=cn.toUpperCase();
	e1=e1.toUpperCase();
	t1=t1.toUpperCase();
	nik=nik.toUpperCase();
	razsoc=razsoc.toUpperCase();
	nomcom=nomcom.toUpperCase();
	descri=descri.toUpperCase();
	console.log(descri);

	$.ajax({
		cache:false,
		url:'dper2.php',
		type:'POST',
		async:false,
		data:{n1:n1,n2:n2,a1:a1,a2:a2,c1:c1,c2:c2,cn:cn,c3:c3,e1:e1,t1:t1,ref:ref,pais:pais,ciudad:ciudad,nik:nik,fn:fn,struc:struc,descri:descri},
	   	beforeSend: function(jqXHR, textStatus){}, 
		success:function(dato)
		{
			
			document.getElementById('dper_btn').disabled=false;
			document.body.style.cursor='auto';
			if($(dato).find("error").text()=='0')
			{
				alert('Datos Personales Actualizados');
			}
			else
			{
				alert('Ocurrio un Error al actualizar datos');
				console.log($(dato).find("error").text());
			}
		}, 
		error:function(jqXHR,textStatus,errorThrown )
		{
           if (jqXHR.status === 0) {
              console.log('Not connect: Verify Network.');
           } else if (jqXHR.status == 404) {
               console.log('Requested page not found [404]');
           } else if (jqXHR.status == 500) {
               console.log('Internal Server Error [500].');
           } else if (exception === 'parsererror') {
               console.log('Requested JSON parse failed.');
           } else if (exception === 'timeout') {
               //console.log('Time out error.');
			   alert('Servidor no Responde');
           } else if (exception === 'abort') {
               console.log('Ajax request aborted.');
           } else {
               console.log('Uncaught Error: ' + jqXHR.responseText);
           }

		}, 
	    complete:function(jqXHR, textStatus){},
		timeout:30000

	});


}
 
</script>

</head>
<body style="padding:0px; margin:0px;">
	<div style="height:5px; margin:-1px 0px 0px 0px; padding:0px;"><div id="barra_azul" style=" background:#06F; height:5px;"></div></div>
	<div align="center" >
	<div align="center"><?php include('../../_lib/cabecera2.php');?></div>
	<div align="center">
<!--+++++ -->
<table border="0" cellpadding="2" cellspacing="0" width="70%" style=" font-size:12px; font-weight:bolder;">


<tr>
	<td>CI/RUC:</td>
    <td><input type="text" id="ci" class="dper_txt" maxlength="45"  value="<?php echo $_SESSION['user_vcrx_id'];?>" disabled="disabled" title="CI" /></td>
    <td></td>
</tr>

<tr align="left">
	<td><span>PRIMER NOMBRE:</span></td>
    <td><input type="text" id="n1" class="dper_txt" maxlength="20" value="<?php echo $n1;?>" /></td>
    <td ><span id="n1_descri" class="dper_err"></span></td>
</tr>
<tr>
	<td>SEGUNDO NOMBRE:</td>
    <td><input type="text" id="n2" class="dper_txt" maxlength="20" value="<?php echo $n2;?>"  /></td>
    <td><span id="n2_descri" class="dper_err"></span></td>
</tr>
<tr>
	<td>APELLIDO PATERNO:</td>
    <td><input type="text" id="a1" class="dper_txt" maxlength="20" value="<?php echo $a1;?>"  /></td>
    <td><span id="a1_descri" class="dper_err"></span></td>
</tr>
<tr>
	<td>APELLIDO MATERNO:</td>
    <td><input type="text" id="a2" class="dper_txt" maxlength="20" value="<?php echo $a2;?>"  /></td>
    <td><span id="a2_descri" class="dper_err"></span></td>
</tr>

<tr>
	<td>RAZON SOCIAL:</td>
    <td><input type="text" id="razsoc" class="dper_txt" maxlength="20" value="<?php echo $razsoc;?>"  /></td>
    <td><span id="razsoc_descri" class="dper_err"></span></td>
</tr>

<tr>
	<td>NOMBRE COMERCIAL:</td>
    <td><input type="text" id="nomcom" class="dper_txt" maxlength="20" value="<?php echo $nomcom;?>"  /></td>
    <td><span id="nomcom_descri" class="dper_err"></span></td>
</tr>


<tr>
	<td>FECHA DE NACIMIENTO:</td>
    <td><input type="date" id="fn" class="dper_txt" maxlength="20" value="<?php echo $fn;?>"  /></td>
    <td><span id="fn_descri" class="dper_err"></span></td>
</tr>

<tr>
	<td>PSEUDONIMO (NICK):</td>
    <td><input type="text" id="nik" class="dper_txt" maxlength="20" value="<?php echo $nik;?>"  /></td>
    <td><span id="nik_descri" class="dper_err"></span></td>
</tr>




<tr>
	<td>ESTATUS RUC:</td>
    <td>
		<select id="struc">
        	<option value="-" <?php if($struc!='A' && $struc!='S'){ echo 'selected="selected"';} ?> >N/A</option>
            <option value="A" <?php if($struc=='A'){ echo 'selected="selected"';} ?> >Activo</option>
            <option value="S" <?php if($struc=='S'){ echo 'selected="selected"';} ?> >Suspendido</option>
        </select>
		
    </td>
    <td><span id="struc_descri" class="dper_err"></span></td>
</tr>


<tr>
	<td>PAIS:</td>
    <td>
    	<select id="pais" name=";pais"  style="font-size:10px;border: #535353 solid 1px; width:100%;">
        	<?php $pais_sql='select *from pais0';
				$pais_res=mysql_query($pais_sql,$link_vcrx);
				while($pais_r=mysql_fetch_assoc($pais_res)){?>
            		<option value="<?php echo $pais_r['pais_codigo'];?>" <?php if($pais==$pais_r['pais_codigo']){echo 'selected="selected"';}?> ><?php echo $pais_r['pais_descri'];?></option>
             <?php } ?>
        </select>
     </td>
    <td></td>
</tr>
<tr>
	<td>PROV /CIUDAD:</td>
    <td>
        <select id="ciudad" name="ciudad"  style="font-size:10px;border: #535353 solid 1px; width:100%">
        	<?php $ciudad_sql='select *from cdad0';
				$ciudad_res=mysql_query($ciudad_sql,$link_vcrx);
				while($ciudad_r=mysql_fetch_assoc($ciudad_res)){?>
            		<option value="<?php echo $ciudad_r['cdad_codigo'];?>" <?php if($ciudad==$ciudad_r['cdad_codigo']){echo 'selected="selected"';}?> ><?php echo $ciudad_r['cdad_descri'];?></option>
             <?php } ?>


        </select>
     </td>
    <td></td>
</tr>

<tr>
	<td>CALLE 1 /CDLA. /EDIF.</td>
    <td><input type="text" id="c1" class="dper_txt" maxlength="20" value="<?php echo $c1;?>"   /></td>
    <td><span id="c1_descri" class="dper_err"></span></td>
</tr>
<tr>
	<td>CALLE 2 /MZ /PISO </td>
    <td><input type="text" id="c2" class="dper_txt" maxlength="20" value="<?php echo $c2;?>"   /></td>
    <td><span id="c2_descri" class="dper_err"></span></td>
</tr>

<tr>
	<td>NUM. /VILLA /DPTO</td>
    <td><input type="text" id="cn" class="dper_txt" maxlength="20" value="<?php echo $cn;?>"   /></td>
    <td><span id="cn_descri" class="dper_err"></span></td>
</tr>

<tr>
	<td>REFERENCIA(casa):</td>
    <td><input type="text" id="c3" class="dper_txt" maxlength="20" value="<?php echo $c3;?>"   /></td>
    <td><span id="c3_descri" class="dper_err"></span></td>
</tr>

<tr>
	<td>EMAIL:</td>
    <td><input type="text" id="e1" class="dper_txt" maxlength="45"  value="<?php echo $e1;?>"  /></td>
    <td><span id="e1_descri" class="dper_err"></span></td>
</tr>

<tr>
	<td>TEL. CONVENCIONAL:</td>
    <td><input type="text" id="t1" class="dper_txt" maxlength="20"  value="<?php echo $t1;?>"  /></td>
    <td><span id="t1_descri" class="dper_err"></span></td>
</tr>

<tr style=" <?php if($empr_codigo!='gnya' && $empr_codigo!='demo'){echo "display:none;";}?>">
	<td width="24%">DIRECTOR:</td>
    <td width="19%"><input type="text"   onKeyDown="_ref(event);"   id="ref" class="dper_txt" maxlength="45"  value="<?php if(empty($ref)){echo $empr_ruc;}else{echo $ref;}?>" <?php if(!empty($ref)){echo 'disabled="disabled"';}?> title="Nombre director /CI /email /" /></td>
    <td width="57%"><span id="ref_descri" class="dper_err"><?php if(empty($ref)){echo $empr_nombre;}else{ echo $res_descri;}?></span></td>
</tr>


</table>

	</div>
	<div><input type="button" value="Guardar" onClick="guarda_dper();" id="dper_btn"/></div>
	</div>

</body>
</html>