<?php 
session_start();

if(isset($_SESSION['estado_user'])=='ACTIVO' AND $_SESSION['tipo_user']){
include 'incluciones/header.php';

include 'incluciones/Db.php';
include 'Model/personalModel.php';

include 'controller/personalController.php';
?>


<main>
    <div class="container-fluid"> <BR>
        <div class="row justify-content-center h-100">
            <div class="col-xl-7">
                <div class="card mb-4">
                    <div class="card-header" style="background: #BDBDBD;color: ;">
                        <div class="row">
                            <div class="col-md-11">
                                <i class="fas fa-file-signature"></i>
                                Registrar personal de GAM-PV
                            </div>
                            <div class="col-md-1">
                                <!--<a href="" class="btn btn-primary"><i class="far fa-edit"></i></a>-->
                            </div>
                        </div>
                    </div>
                    <div class="card-body">
                        <form name="" action="" method="POST">
                            <div class="form-row">
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="small mb-1" for="inputFirstName">Nº de Documentación ( C.I.)</label>
                                        <input type="text" name="numDoc_per" id="inputFirstName" class="form-control"  required="required" placeholder="Ingrese Nº Documentación" onKeyPress="return soloNumeros(event)" />
                                    </div>
                                </div>
                                <div class="col-md-2">
                                    <div class="form-group">
                                        <label class="small mb-1" for="inputFirstName">Expedito (Doc.)</label>
                                        <select name="expeditoDoc_per" class="form-control">
                                            <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>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="small mb-1" for="inputLastName">Nombre del personal</label>
                                        <input type="text" name="nom_per" id="inputLastName" class="form-control" required="required"  placeholder="Ingrese el nombre" onkeypress="return soloLetras(event)" onkeyup="aMays(event, this)" />
                                    </div>
                                </div>
                            </div>
                            <div class="form-row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="small mb-1" for="inputFirstName">Primer apellido </label>
                                        <input type="text" name="primerAp_per" id="inputFirstName" class="form-control" required="required"   placeholder="Ingrese primer apellido" onkeypress="return soloLetras(event)" onkeyup="aMays(event, this)" />
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="small mb-1" for="inputLastName">Segundo apellido</label>
                                        <input type="text" name="segundoAp_per" id="inputLastName" class="form-control" required="required"  placeholder="Ingrese segundo apellido" onkeypress="return soloLetras(event)" onkeyup="aMays(event, this)" />
                                    </div>
                                </div>
                            </div>
                            <div class="form-row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="small mb-1" for="inputLastName" required >Fecha de nacimiento</label>
                                        <input type="date" name="fechaNac_per" id="inputLastName" class="form-control"  />
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="small mb-1" for="inputFirstName">Nº de Celular</label>
                                        <input type="text" name="numCelu_per" id="inputFirstName" class="form-control"  placeholder="Ingrese Nº celular" onKeyPress="return soloNumeros(event)" />
                                    </div>
                                </div>
                            </div>
                            <div class="form-row">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="small mb-1" for="inputFirstName">Correo Electrónico</label>
                                        <input type="text" name="correo_per" id="inputFirstName" class="form-control"  placeholder="Ingrese correo electrónico" />
                                    </div>
                                </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">
                                    <div class="form-group">
                                        <label class="small mb-1" for="inputFirstName">Dirección</label>
                                        <select name="id_dir" id="cbx_direccion" class="form-control">
                                            <option> Seleccione Dirección</option>
                                            <?php  
                                            include "Model/direccionModel.php";
                                            include "Controller/direccionController.php";
                                            ?>
                                            
                                        </select>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="small mb-1" for="inputLastName">Unidad</label>
                                        <select name="id_uni" id="cbx_unidad" class="form-control">
                                            <option value="0"> Seleccione Unidad</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            

                            <div class="form-row">
                                <div class="col-md-3">
                                    <div class="form-group">
                                        <label class="small mb-1" for="inputLastName">Grado académico</label>
                                        <select name="gradoAcad_per" class="form-control">
                                            <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>
                                <div class="col-md-9">
                                    <div class="form-group">
                                        <label class="small mb-1" for="inputLastName">Cargo</label>
                                        <input type="text" name="cargo" id="inputLastName" class="form-control"  placeholder="Ingrese el cargo del personal" onkeyup="aMays(event, this)"  />
                                    </div>
                                </div>
                            </div>
                            <div class="form-group mt-4 mb-0"> <button type="submit" name="regPer" class="btn btn-primary btn-block">Guardar</button> </div>
                        </form>
                    </div>
                    <div class="card-footer text-center">
                        <div class="small"><a href="https://www.facebook.com/profile.php?id=100063951547418" target="_blank">Link</a></div>
                    </div>
                    <!--<div class="card-body"><canvas id="myAreaChart" width="100%" height="40"></canvas></div>-->
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xl-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>
                                Personal del GAM-PV
                            </div>
                            <div class="col-md-1">
                                <a href="index.php" class="btn btn-primary" style="float: right;"><i class="far fa-edit"></i></a>
                            </div>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0" style="font-size: 12px;">
                                <thead>
                                    <tr>
                                        <th>Nº</th>
                                        <th>Nº CI</th>
                                        <th>Nombre</th>
                                        <th>Celular</th>
                                        <th>Dirección</th>
                                        <th>Unidad</th>
                                        <th>Cargo</th>
                                    </tr>
                                </thead>
                                <tfoot>
                                    <tr>
                                        <th>Nº</th>
                                        <th>Nº CI</th>
                                        <th>Nombre</th>
                                        <th>Nº Celular</th>
                                        <th>Dirección</th>
                                        <th>Unidad</th>
                                        <th>Cargo</th>
                                    </tr>
                                </tfoot>
                                <tbody>
                                    <?php
                                    
                                    $trabajador = new Personal;
                                    $result=$trabajador->mostrar();

                                    foreach ($result as $fila ) {
                                        ?>
                                        <tr>
                                            <td><?php print $fila['id_per']; ?></td>
                                            <td><?php print $fila['numDoc_per']." ".$fila['expeditoDoc_per']; ?></td>
                                            <td><?php print $fila['gradoAcad_per']." ".$fila['nom_per']." ".$fila['primerAp_per']." ".$fila['segundoAp_per']; ?></td>
                                            <td><?php print $fila['numCelu_per']; ?></td>
                                            <td><?php print $fila['nom_dir']; ?></td>
                                            <td><?php print $fila['nom_uni']; ?></td>
                                            <td><?php print $fila['cargo']; ?></td>
                                        </tr>
                                        <?php 
                                    }
                                    ?>
                                </tbody>
                            </table>
                        </div>
                        
                    </div>
                </div>
            </div>
        </div>
        
    </div>
</main>

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