<?php

if(isset($_GET['save'])){
$ugid=$_GET['ugid'];
$dni=$_GET['dni'];
$pass=$_GET['pass'];
$apep=$_GET['apep'];
$apem=$_GET['apem'];
$nom=$_GET['nom'];
$direc=$_GET['direc'];
$fnac=$_GET['fnac'];
$ecivil=$_GET['ecivil'];
$mail=$_GET['mail'];
$telf1=$_GET['telf1'];
$telf2=$_GET['telf2'];
$cel1=$_GET['cel1'];
$cel2=$_GET['cel2'];
$celo=$_GET['celo'];
$nplan=$_GET['nplan'];
$ncol=$_GET['ncol'];
$nesp=$_GET['nesp'];

$uno=substr($fnac, 0, 2);
$dos=substr($fnac, 3, 2);
$tres=substr($fnac, 6, 4);
$fnac = ($tres."/".$dos."/".$uno);

$sqlupdate="update tb_usuasist set ua_dni='$dni', ua_password='$pass', ua_apepat=upper('$apep'), ua_apemat=upper('$apem'), ua_nom=upper('$nom'), ua_numplanilla='$nplan', ua_telef1='$telf1',";
$sqlupdate=$sqlupdate." ua_telf2='$telf2', ua_direc=upper('$direc'), ua_cel1='$cel1',ua_cel2='$cel2',ua_celotro='$celo', ua_mail='$mail', ua_fechanac='$fnac', ua_estcivil=upper('$ecivil'), ";
$sqlupdate=$sqlupdate." ua_numcoleg='$ncol', ua_numesp='$nesp' where ug_id='$ugid'";
//echo $sqlupdate;
$resulupdate = mysqli_query($conex,$sqlupdate);
echo "<input type='hidden' id='ugid' name='ugid' value='".$ugid."'>";
echo "<script type='text/javascript'>window.location.reload();</script>";
}

$ugid=$_GET['ugid'];
$idj=$_GET['idj'];
$ids=$_GET['ids'];
//$password=$_GET['pasw'];
//$dni1=42622645;
//$password="unidad";
//$ugid='SCPHU1';
$sqlpersonal="select a.ug_id as coduni, a.ua_dni as dni, a.ua_password as psw, a.ua_apepat as apepat, a.ua_apemat as apemat, a.ua_nom as nom, a.ua_numplanilla as numpla, a.ua_codprog as codprog, a.ua_telef1 as telef1,"; 
$sqlpersonal=$sqlpersonal."a.ua_telf2 as telf2, a.ua_cel1 as cel1, a.ua_cel2 as cel2, a.ua_celotro as celo, a.ua_direc as direc,(select d_desc from tb_distrito where d_id=a.d_id) as distrito, a.ua_mail as mail, date_format(a.ua_fechanac, '%d/%m/%Y') as fechanac, a.ua_estcivil as estcivil, a.ua_numcoleg as numcol, a.ua_numesp as numesp,";
$sqlpersonal=$sqlpersonal."b.ua_estado as estado, (select tc_abrev from tb_tipocont where tc_idcont=b.tc_idcont) as tcabrev, (select c_desc from tb_cargo where c_id=b.c_id) as cargo from tb_usuasist a inner join tb_usudep b on a.ug_id=b.ug_id where a.ug_id='$ugid'";
//$sqlpersonal=$sqlpersonal."inner join tb_cargo c on a.c_id=c.c_id where a.ua_dni='$dni1' and a.ua_password='$password'";
//echo $sqlpersonal;
$resultarea = mysqli_query($conex,$sqlpersonal);
while ($row= mysqli_fetch_array($resultarea)){
$coduni=$row['coduni'];
$dni=$row['dni'];
$pasw=$row['psw'];
$apepat=$row['apepat'];
$apemat=$row['apemat'];
$nom=$row['nom'];
$numpla=$row['numpla'];
$codprog=$row['codprog'];
$telef1=$row['telef1'];
$telef2=$row['telf2'];
$cel1=$row['cel1'];
$cel2=$row['cel2'];
$celo=$row['celo'];
$direc=$row['direc'];
$distrito=$row['distrito'];
$mail=$row['mail'];
$fechanac=$row['fechanac'];
if($fechanac=="00/00/0000"){
$fechanac="";
}
$estcivil=$row['estcivil'];
$numcol=$row['numcol'];
$numesp=$row['numesp'];
$estado=$row['estado'];
$tcabrev=$row['tcabrev'];
$cargo=$row['cargo'];
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles/Style.css">
<title>PROGRAMACION ASISTENCIAL</title>
<script type="text/javascript"> 
function ventanaClose(){ 
   //alert("hola mundo");
    window.close();
}
function editarpersonaldatos(){
 var ugid = document.getElementById("ugid").value;
 window.open("editarpersonal.php?ugid="+ugid,"","height=600,width=480,scrollbars=YES");
} 
</script> 
</head>
<body>
<form action='' >
<table align='center' class='FacetFormTABLE'>
<tr><td colspan='2'align='center' class='FacetFieldCaptionTD'><b><font color='blue'>DATOS DEL PERSONAL ASISTENCIAL</font></b></td></tr>
<?php
if(isset($_GET['error'])){
$error=$_GET['error'];
if($error !=""){
echo "<tr><td colspan='2'  align='center'><font color='red'>DATOS INCORRECTOS</font></td></tr>";
}
}
echo "<input type='hidden' id='ugid' name='ugid' value='".$ugid."'>";
?>
<br>
<tr><td colspan='2' align='center'>
<table align='center' class='FacetFormTABLE'>
<tr><td class='FacetFieldCaptionTD' width='110'>DNI</td><td width='250' ><?php echo $dni;?></td></tr>
</table>
<br>
<table align='center' class='FacetFormTABLE'>
<tr><td class='FacetFieldCaptionTD'width='110'>APE. PATERNO</td><td width='250'><?php echo $apepat;?></td></tr>
<tr><td class='FacetFieldCaptionTD'>APE. MATERNO</td><td><?php echo $apemat;?></td></tr>
<tr><td class='FacetFieldCaptionTD'>NOMBRES</td><td><?php echo $nom;?></td></tr>
</table>
<br>
<table align='center' class='FacetFormTABLE'>
<tr><td class='FacetFieldCaptionTD' width='110'>DIRECCION</td><td width='250'><?php echo $direc;?></td></tr>
<tr><td class='FacetFieldCaptionTD' width='110'>DISTRITO</td><td width='250'><?php echo $distrito;?></td></tr>
<tr><td class='FacetFieldCaptionTD'>FECHA DE NAC.</td><td><?php echo $fechanac;?></td></tr>
<tr><td class='FacetFieldCaptionTD'>ESTADO CIVIL</td><td><?php echo $estcivil;?></td></tr>
<tr><td class='FacetFieldCaptionTD'>CORREO</td><td><?php echo $mail;?></td></tr>
<tr><td class='FacetFieldCaptionTD'>TELEFONO 1</td><td><?php echo $telef1;?></td></tr>
<tr><td class='FacetFieldCaptionTD'>TELEFONO 2</td><td><?php echo $telef2;?></td></tr>
<tr><td class='FacetFieldCaptionTD'>CELULAR 1</td><td><?php echo $cel1;?></td></tr>
<tr><td class='FacetFieldCaptionTD'>CELULAR 2</td><td><?php echo $cel2;?></td></tr>
<tr><td class='FacetFieldCaptionTD'>OTRO CEL</td><td><?php echo $celo;?></td></tr>
</table><br>
<table align='center' class='FacetFormTABLE'>
<tr><td class='FacetFieldCaptionTD'>CARGO</td><td><?php echo $cargo;?></td></tr>
<tr><td class='FacetFieldCaptionTD' width='110'>NUM PLANILLA</td><td width='250'><?php echo $numpla;?></td></tr>
<tr><td class='FacetFieldCaptionTD'>NUM COLEGIATURA</td><td><?php echo $numcol;?></td></tr>
<tr><td class='FacetFieldCaptionTD'>NUM ESPECIALIDAD</td><td><?php echo $numesp;?></td></tr>
<tr><td class='FacetFieldCaptionTD'>TIPO DE CONTRATO</td><td><?php echo $tcabrev;?></td></tr>
</table>
</td></tr>
<tr><td align='center'> </td><td align='center'><input type='button' value='Editar' id='edit' class='FacetButton' onClick='editarpersonaldatos()'></td></tr>
</table>
</form>
</body>
</html>