<?php  

include 'index.php';

if(isset($_SESSION['estado_user'])=='ACTIVO' AND $_SESSION['tipo_user']){

	if(isset($_POST['editarP'])){
		$id_per=$_POST['id_per'];
		$numDoc_per=$_POST['numDoc_per'];
		$expeditoDoc_per=$_POST['expeditoDoc_per'];
		$nom_per=$_POST['nom_per'];
		$primerAp_per=$_POST['primerAp_per'];
		$segundoAp_per=$_POST['segundoAp_per'];
		$fechaNac_per=$_POST['fechaNac_per'];
		$correo_per=$_POST['correo_per'];
		$numCelu_per=$_POST['numCelu_per'];
		$id_dir=$_POST['id_dir'];
		$nom_dir=$_POST['nom_dir'];
		$id_uni=$_POST['id_uni'];
		$nom_uni=$_POST['nom_uni'];
		$cargo=$_POST['cargo'];
		$gradoAcad_per=$_POST['gradoAcad_per'];

	?>

		<script type="text/javascript">
			$( document ).ready(function() {
			    $('#myModal').modal('toggle')
			});
		</script>

		<div class="modal fade " id="myModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
			<div class="modal-dialog modal-lg">
				<div class="modal-content row">
					<div class="row">
			            <div class="col-md-12">
			                <div class="card mb-4">
			                    <div class="card-header" style="background: #BDBDBD;">
			                        <div class="row">
			                            <div class="col-md-11">
			                                <i class="fas fa-list"></i>
			                                Editar datos del personal del GAM-PV
			                            </div>
			                            <div class="col-md-1">
			                                <a href="index.php" class="btn btn-outline-dark"><i class="far fa-window-close"></i></a>
			                            </div>
			                        </div>
			                    </div>
			                    <div class="card-body">
			                        <form name="" action="index.php" method="POST"> 
			                        	<input type="hidden" name="id_per" value="<?php print $id_per; ?>">
			                        	<div class="form-row">
			                        		<div class="col-md-4">
			                        			<label>Nº de Documento (CI)</label>
			                        			<input type="text" name="numDoc_per" class="form-control" value="<?php print $numDoc_per; ?>" onKeyPress="return soloNumeros(event)">
			                        		</div>
			                        		<div class="col-md-2">
			                        			<label>Expedito</label>
			                        			<select name="expeditoDoc_per" class="form-control">
			                        				<option value="<?php print $expeditoDoc_per; ?>"><?php print $expeditoDoc_per; ?></option>
			                        				<option value="CH">CH</option>
		                                            <option value="LP">LP</option>
		                                            <option value="CB">CB</option>
		                                            <option value="OR">OR</option>
		                                            <option value="PT">PT</option>
		                                            <option value="TJ">TJ</option>
		                                            <option value="SC">SC</option>
		                                            <option value="BE">BE</option>
		                                            <option value="PD">PD</option>
		                                            <option value="OTRO">OTRO</option>
			                        			</select>
			                        		</div>
			                        		<div class="col-md-6">
			                        			<label>Nombre</label>
			                        			<input type="text" name="nom_per" class="form-control" value="<?php print $nom_per; ?>" onkeypress="return soloLetras(event)" onkeyup="aMays(event, this)">
			                        		</div>
			                        	</div>
			                        	<div class="form-row">
			                        		<div class="col-md-6">
			                        			<label>Primer apellido</label>
			                        			<input type="text" name="primerAp_per" class="form-control" value="<?php print $primerAp_per; ?>" onkeypress="return soloLetras(event)" onkeyup="aMays(event, this)">
			                        		</div>
			                        		<div class="col-md-6">
			                        			<label>Segundo Apellido</label>
			                        			<input type="text" name="segundoAp_per" class="form-control" value="<?php print $segundoAp_per; ?>" onkeypress="return soloLetras(event)" onkeyup="aMays(event, this)">
			                        		</div>
			                        	</div>
			                        	<div class="form-row">
			                        		<div class="col-md-6">
			                        			<label>Fecha Nacimiento</label>
			                        			<input type="date" name="fechaNac_per" class="form-control" value="<?php print $fechaNac_per; ?>">
			                        		</div>
			                        		<div class="col-md-6">
			                        			<label>Nº de Celular</label>
			                        			<input type="text" name="numCelu_per" class="form-control" value="<?php print $numCelu_per; ?>" onKeyPress="return soloNumeros(event)">
			                        		</div>
			                        	</div>
			                        	<div class="form-row">
			                        		<div class="col-md-12">
			                        			<label>Correo Electrónico</label>
			                        			<input type="text" name="correo_per" class="form-control" value="<?php print $correo_per; ?>">
			                        		</div>
			                        	</div>
			                        	<script type="text/javascript">
			                                $(document).ready(function(){
			                                    $("#cbx_direccion").change(function(){

			                                        $("#cbx_direccion option:selected").each(function(){
			                                            id_dir=$(this).val();
			                                            $.post("Controller/unidadController.php",{id_dir:id_dir}, function(data){
			                                                $("#cbx_unidad").html(data);
			                                            })
			                                        })

			                                    })
			                                })
			                            </script>
			                        	<div class="form-row">
			                        		<div class="col-md-6">
			                        			<label>Dirección</label>
			                        			<select name="id_dir" id="cbx_direccion" class="form-control">
		                                            <option value="<?php print $id_dir; ?>"><?php print $nom_dir; ?></option>
		                                            <?php  
		                                            include "Model/direccionModel.php";
		                                            include "Controller/direccionController.php";
		                                            ?>
		                                            
		                                        </select>
			                        		</div>
			                        		<div class="col-md-6">
			                        			<label>Unidad</label>
			                        			<select name="id_uni" id="cbx_unidad" class="form-control">
		                                            <option value="<?php print $id_uni; ?>"><?php print $nom_uni; ?></option>
		                                        </select>
			                        		</div>
			                        	</div>
			                        	<div class="form-row">
			                        		<div class="col-md-3">
			                        			<label>Grado académico</label>
			                        			<select name="gradoAcad_per" class="form-control">
			                        				<option value="<?php print $gradoAcad_per; ?>"><?php print $gradoAcad_per; ?></option>
		                                            <option value="ING">ING</option>
		                                            <option value="ARQ">ARQ</option>
		                                            <option value="LIC">LIC</option>
		                                            <option value="ABG">ABG</option>
		                                            <option value="TEC">TEC</option>
		                                            <option value="OTRO">OTRO</option>
		                                        </select>
			                        		</div>
			                        		<div class="col-md-9">
			                        			<label>Cargo</label>
			                        			<input type="text" name="cargo" class="form-control" value="<?php print $cargo; ?>"  onkeyup="aMays(event, this)">
			                        		</div>
			                        	</div>
			                        	<div class="form-group mt-4 mb-0"> <button type="submit" name="actualizarPer" class="btn btn-primary btn-block">Guardar los Cambios</button> </div>
			                        </form>
			                    </div>
			                </div>
			            </div>
			        </div>
			    </div>
			</div>
		</div>  

	<?php 
	}else{
		header('location:personalGAMPV.php');
	}


	

}else{
    header('location:../../index.php');
}
?>