<?php session_start();?>
<?php include('../_cfg/config.php');?>
<?php include('php_gene1.php'); ?>
<?php include('php_session.php');?>

<?php $orient=$_POST['orient']; ?>
<?php $pant=$_POST['pant']; ?>
<?php $nombre=$_POST['nombre']; ?>
<?php $seudonimo=$_POST['seudonimo']; ?>
<?php $email=$_POST['email']; ?>
<?php $celular=$_POST['celular']; ?>
<?php $wsapp=$_POST['wsapp']; ?>
<?php $telefono=$_POST['telefono']; ?>
<?php $cedula=$_POST['cedula']; ?>
<?php $pais=$_POST['pais']; ?>
<?php $provincia=$_POST['provincia']; ?>
<?php $ciudad=$_POST['ciudad']; ?>
<?php $calle1=$_POST['calle1']; ?>
<?php $calle2=$_POST['calle2']; ?>
<?php $calle3=$_POST['calle3']; ?>
<?php $callen=$_POST['callen']; ?>
<?php $postal=$_POST['postal']; ?>
<?php $referidox=$_POST['referidox']; ?>
<?php //die(); ?>

<?php foreach($_POST as $campo => $valor){${$campo}=$valor;} ?>



<?php $seudonimo=nospace($seudonimo,'_')?>

<?php
  
//   echo '*/*/*/*/';
if($cfg_empr=='gnya')
{
	$sql_updt ='update user0 left join enti0 on left(user_cedula,10)=left(enti_codigo,10) ';
	$sql_updt.=' set user_referidox=enti_referidox ';
	$sql_updt.=' where (user_referidox="" or user_referidox is null or user_referidox="'.$cfg_ruc.'")';
	$sql_updt.=' and enti_referidox!="" and enti_referidox is not null ';
	$sql_updt.=' and user_email="'.$user_email.'"';
	$res_updt=msql_query($sql_updt,$link_vcrx);
// 	echo msql_error();
}

?>


<?php
if(empty($pant)){$pant='pant1';}
// if ($email!='' and $confirm!=''){$regis=2;}
// if ($email!='' and $recover!=''){$regis=6;}
$xfontsize=12;
if($mobile=='true' and $orient=='V'){$xfontsize=30;}


?>

<?php ob_start(); ?>
<resultado>
	
<?php if ($pant=='pant1'){?>	
<pant1>
<?php	val_usercodigo(); ?>
	
<div width="100%" style="overflow:auto; display:none;">
<?php if($mobile=='true'){?>	
<br>
<?php } ?>
	
<?php $classtab='filtro'; ?>
<?php $classcol=$classtab.'_coligua'; ?>
<table id="filtro" cellpadding="2" width="100%" border="0" class="<?php echo $classtab?>"
			Xonclick="resizeTab('<?php echo $classtab?>','<?php echo $classcol; ?>');" Xonmouseover="this.onclick();"
			style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse;  ">
	<tr>
	<td width="10%">
		<?php $pidtxt='f_nuevo';  $pcaption='NUEVO USUARIO'; $psize=$xfontsize;
		$ponclick='{location.href="?regis=nuevo&"}';
		include('vrbutton.php'); ?>
	</td>
	<td width="10%">
		<?php $pidtxt='f_confirmar';  $pcaption='CONFIRMA REGIST.'; $psize=$xfontsize;
		$ponclick='{location.href="?regis=confirma&"}';
		include('vrbutton.php'); ?>
	</td>
	<td width="10%">
		<?php $pidtxt='f_recuperar';  $pcaption='RESTAURA CLAVE'; $psize=$xfontsize;
		$ponclick='{location.href="?regis=confirma&"}';
		include('vrbutton.php'); ?>
	</td>
	<td width="90%"></td>
	</tr>
</table>	
<?php if($mobile=='true'){?>	
<br>
<?php } ?>
</div>

<?php
//   $user_codigo=637;                       
	$sql_user='select * from user0 where user_codigo="'.$user_codigo.'"';
	$res_user=msql_query($sql_user,$link_vcrx);
?>	
	
<!-- <script src='https://www.google.com/recaptcha/api.js'></script> -->
<?php if($datos='datos'){ ?>
<!-- <form> -->
	<table id="tpant0" cellpadding="2" width="100%" border="0"
				style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse;  ">

			<tr style="font-size:<?php echo $xfontsize+6;?>; font-weight:bold;">
				<td align="center" colspan="2">
					<?php $pcaption= 'USUARIO '.''.strtoupper(msql_result($res_user,0,'user_tipo')); 
						$psize=$xfontsize;
					include('vrbutton.php'); ?>
				</td>
				<?php if($mobile=='false') {?>
				<td width="50%"></td>
				<?php } ?>
			</tr>

			<tr>
				<?php $pidtxt='codigo'; $pcaption='CODIGO'; $psize=$xfontsize; 
					$pdefa=msql_result($res_user,0,'user_codigo'); 
					$pcodigo=msql_result($res_user,0,'user_codigo');
          $ptabla='user'; $pcolu='codigo'; 
          $pdisab=1; $ptabla='user';
 					include('vrsaycod.php'); ?>
			</tr>

			<tr>
				<?php
//                       $pidtxt='codigo'; $pcaption='nick'; $psize=$xfontsize; 
// 					$pcodigo=msql_result($res_user,0,'user_codigo'); 
//           $pdisab=0; $ptabla='user'; $pcolu='nickname';
// 					include('vrsaycod.php'); 
        ?>
			</tr>

			<tr>
				<?php $pidtxt='nombre'; $pcaption='Nombre'; $psize=$xfontsize; $plong=25;
					$pdefa=msql_result($res_user,0,'user_descri'); 
					include('vrgettxt.php'); ?>
			</tr>

			<tr>
				<?php $pidtxt='email'; $pcaption='e-mail'; $psize=$xfontsize; $plong=20;
					$pdefa=msql_result($res_user,0,'user_email'); 
					include('vrgettxt.php'); 
				?>
			</tr>

		
			<tr>
				<?php $pidtxt='seudonimo'; $pcaption='Seudónimo'; $psize=$xfontsize; $plong=20;
					$pdefa=msql_result($res_user,0,'user_nickname'); 
					include('vrgettxt.php'); ?>
			</tr>

    
		<tr>
				<?php $pidtxt='cedula'; $pcaption='Cédula / ID'; $psize=$xfontsize;
					$ptabla='enti'; $pexact=1;
					$pdefa=msql_result($res_user,0,'user_cedula'); 
				//	include('vrgetcod.php'); 
      ?>
			</tr>

		<tr>
				<?php $pidtxt='cedula'; $pcaption='Num.IDENT.'; $psize=$xfontsize;
					$ptabla='enti'; $pexact=1; $plong=10;
					$pdefa=msql_result($res_user,0,'user_cedula'); 
					include('vrgetnum.php'); 
// 					include('vrgetcod.php'); 
      ?>
			</tr>
    
			<tr>
				<?php $pidtxt='telefono'; $pcaption='Telf.Fijo'; $psize=$xfontsize; $plong=10;
					$pdefa=msql_result($res_user,0,'user_telefono'); 
					include('vrgetnum.php'); ?>
			</tr>

			<tr>
				<?php $pidtxt='celular'; $pcaption='Celular'; $psize=$xfontsize; $plong=10;
					$pdefa=msql_result($res_user,0,'user_celular'); 
					include('vrgetnum.php'); ?>
			</tr>

			<tr>
				<?php $pidtxt='wsapp'; $pcaption='WhatsApp'; $psize=$xfontsize; $plong=10;
					$pdefa=msql_result($res_user,0,'user_wsapp'); 
					include('vrgetnum.php'); ?>
			</tr>


			<?php //if($cfg_empr=='gnya'){ ?>
			<?php if(mb_stristr('gnya.gmny',$cfg_empr)){ ?>
			<tr>
				<?php $pidtxt='referidox'; $pcaption='Referido X:'; $psize=$xfontsize;
					$ptabla='user'; $pexact=1;
// 					$ptabla='enti'; $pexact=1;
					$pdefa=msql_result($res_user,0,'user_referidox'); 
					if(!empty($pdefa)){$preado=1;}
                                               
          if($pdefa!=msql_result($res_user,0,'user_codigo') and $pdefa!=""){$pdisab=1;}
					include('vrgetcod.php'); ?>
			</tr>
			<?php } ?>

		
		
		<tr>
			<td><br></td>
		</tr>
		<tr>
				<?php $pidtxt='pais'; $pcaption='Pais'; $psize=$xfontsize;
					$ptabla='pais'; 
					$pdefa=msql_result($res_user,0,'user_pais'); 
					if($pdefa==''){$pdefa="ECUA";}
					include('vrselopt.php');
				?>
			</tr>

		<tr>
				<?php $pidtxt='provincia'; $pcaption='Provincia'; $psize=$xfontsize; $plong=30;
					$pdocu='enti'; $pcolu='enti_provincia'; 
					$pdefa=@msql_result($res_user,0,'user_provincia'); 
					if($pdefa==''){$pdefa="GUAYAS";}
					include('vrgettxt.php');
				?>
			</tr>

		<tr>
				<?php $pidtxt='ciudad'; $pcaption='Ciudad'; $psize=$xfontsize; $plong=30;
					$pdocu='enti'; $pcolu='enti_ciudad'; 
					$pdefa=msql_result($res_user,0,'user_ciudad'); 
					if($pdefa==''){$pdefa="GUAYAQUIL";}
					include('vrgettxt.php');
				?>
			</tr>

		<tr>
				<?php $pidtxt='postal'; $pcaption='Cod.Postal'; $psize=$xfontsize; $plong=10; 
					$pdocu='enti'; $pcolu='enti_postal';
					$pdefa=msql_result($res_user,0,'user_postal'); 
					include('vrgettxt.php');
				?>
			</tr>


		<tr>
			<td><br></td>
		</tr>



		<tr>
				<?php $pidtxt='calle1'; $pcaption='Calle 1 / Cdla.'; $psize=$xfontsize;
					 $plong=30; $pdocu='enti'; $pcolu='enti_calle1';
					$pdefa=msql_result($res_user,0,'user_calle1'); 
					include('vrgettxt.php'); ?>
			</tr>

		<tr>
				<?php $pidtxt='calle2'; $pcaption='Calle 2 / Mz. '; $psize=$xfontsize;
					 $plong=30; $pdocu='enti'; $pcolu='enti_calle2';
					$pdefa=msql_result($res_user,0,'user_calle2'); 
					include('vrgettxt.php'); ?>
			</tr>

		<tr>
				<?php $pidtxt='callen'; $pcaption='Número / Dpto.'; $psize=$xfontsize;
					 $plong=10; 
					$pdefa=msql_result($res_user,0,'user_callen'); 
					include('vrgettxt.php'); ?>
			</tr>

		<tr>
				<?php $pidtxt='calle3'; $pcaption='Referencia'; $psize=$xfontsize;
					 $plong=30;
					$pdefa=msql_result($res_user,0,'user_calle3'); 
					include('vrgettxt.php'); ?>
			</tr>

		<tr>
				<td></td>
				<td align="left">
				<?php $pidtxt='grabar'; $pcaption='GRABAR'; $psize=$xfontsize; 
					$ponclick="user_dato('grabar')";
					include('vrbutton.php'); ?>
				</td>
		</tr>


	</table>

<!-- </form>	 -->
<?php } ?>

</pant1>
<?php } ?>	

<?php if ($pant=='grabar'){?>	
<graba1>
<?php
	
	$sql_user='update user0 set user_descri="'.$nombre.'" where user_codigo="'.$user_codigo.'"';
	$res_user=msql_query($sql_user,$link_vcrx);

// 	$sql_user='update user0 set user_descri="'.$nombre.'" where user_codigo="'.$user_codigo.'"';
// 	$res_user=msql_query($sql_user,$link_vcrx);
	
	$sql_user='update user0 set user_cedula="'.$cedula.'" where user_codigo="'.$user_codigo.'"';
	$sql_user.=' and (user_cedula is null or user_cedula="")';
	$res_user=msql_query($sql_user,$link_vcrx);
	
	$sql_user='update user0 set user_nickname="'.$seudonimo.'" where user_codigo="'.$user_codigo.'"';
	$res_user=msql_query($sql_user,$link_vcrx);
	
	$sql_user='update user0 set user_referidox="'.$referidox.'" where user_codigo="'.$user_codigo.'"';
	$sql_user.='and (user_referidox=user_codigo or user_referidox="" or user_referidox is null)';
	$res_user=msql_query($sql_user,$link_vcrx);
	
	$sql_user='update user0 set user_telefono="'.$telefono.'" where user_codigo="'.$user_codigo.'"';
	$res_user=msql_query($sql_user,$link_vcrx);
	
	$sql_user='update user0 set user_celular="'.$celular.'" where user_codigo="'.$user_codigo.'"';
	$res_user=msql_query($sql_user,$link_vcrx);
	
	$sql_user='update user0 set user_wsapp="'.$wsapp.'" where user_codigo="'.$user_codigo.'"';
	$res_user=msql_query($sql_user,$link_vcrx);
	
	$sql_user='update user0 set user_postal="'.$postal.'" where user_codigo="'.$user_codigo.'"';
	$res_user=msql_query($sql_user,$link_vcrx);
	
	$sql_user='update user0 set user_calle1="'.$calle1.'" where user_codigo="'.$user_codigo.'"';
	$res_user=msql_query($sql_user,$link_vcrx);
	
	$sql_user='update user0 set user_calle2="'.$calle2.'" where user_codigo="'.$user_codigo.'"';
	$res_user=msql_query($sql_user,$link_vcrx);
	
	$sql_user='update user0 set user_calle3="'.$calle3.'" where user_codigo="'.$user_codigo.'"';
	$res_user=msql_query($sql_user,$link_vcrx);
	
	$sql_user='update user0 set user_callen="'.$callen.'" where user_codigo="'.$user_codigo.'"';
	$res_user=msql_query($sql_user,$link_vcrx);
	
	$sql_user='update user0 set user_pais="'.$pais.'" where user_codigo="'.$user_codigo.'"';
	$res_user=msql_query($sql_user,$link_vcrx);
	
	$sql_user='update user0 set user_provincia="'.$provincia.'" where user_codigo="'.$user_codigo.'"';
	$res_user=msql_query($sql_user,$link_vcrx);
	
	$sql_user='update user0 set user_ciudad="'.$ciudad.'" where user_codigo="'.$user_codigo.'"';
	$res_user=msql_query($sql_user,$link_vcrx);
	
	$sql_user='update user0 set user_descri="'.$nombre.'" where user_codigo="'.$user_codigo.'"';
	$res_user=msql_query($sql_user,$link_vcrx);
	
	// actualiza la cedula del carrito
	$sql_user='update carr1 set enti="'.$cedula.'" where iuser="'.$user_codigo.'"';
	$res_user=msql_query($sql_user,$link_vcrx);
	
 	updt_userenti($cedula,1);
?>	
</graba1>	
<?php } ?>	
	
</resultado>
<?php $obstart = ob_get_clean(); ?>
<?php $obstart = alltrim($obstart) ?>
<?php echo $obstart;	?>

		