<?php

if($_SESSION["perfil"] == "Invitado"){

  echo '<script>

    window.location = "inicio";

  </script>';

  return;

}

?>

<div class="content-wrapper">

  <section class="content-header">
    
    <h1>
      
      Ventana de alta de alumnos-Ventas
    
    </h1>

    <ol class="breadcrumb">
      
      <li><a href="inicio"><i class="fa fa-dashboard"></i> Inicio</a></li>
      
      <li class="active">Administrar vista ventas</li>
    
    </ol>

  </section>

  <section class="content">

    <div class="box">

      <div class="box-header with-border">
  
        <button class="btn btn-primary" data-toggle="modal" data-target="#modalAgregarPersona">
          
          Nuevo Alumno

        </button>

      </div>

      <div class="box-body">
        
       <table id="tablaPersonas" class="table table-bordered table-striped dt-responsive" width="100%">
         
        <thead>
         
         <tr>
           
           <th style="width:10px">#</th> 
           <th>ID</th>          
           <th>NOMBRE</th>
           <th>MATRICULA</th>  
           <th>ESTATUS</th>    
           <th>CORREO</th>   
           <th>TELEFONO</th> 
           <th>DIPLOMADO</th>
           <th>BLOQUE</th> 
           <th>Acciones</th>

         </tr> 

        </thead>
        <tbody>

        </tbody>

       </table>

      </div>

    </div>

  </section>

</div>

<!--=====================================
MODAL AGREGAR CLIENTE
======================================-->

<div id="modalAgregarPersona" class="modal fade" role="dialog">
  
  <div class="modal-dialog">

    <div class="modal-content">

      <form role="form" method="post">

        <!--=====================================
        CABEZA DEL MODAL
        ======================================-->

        <div class="modal-header" style="background:#3c8dbc; color:white">

          <button type="button" class="close" data-dismiss="modal">&times;</button>

          <h4 class="modal-title">Agregar cliente</h4>

        </div>

        <!--=====================================
        CUERPO DEL MODAL
        ======================================-->

        <div class="modal-body" style="padding:0px">

          <div class="box-body" style="padding:0px">

                  <!-- ENTRADA PARA EL NOMBRE -->

                  <div class="form-row">
                  
                    <div class="form-group col-md-12">
                      <label for="inputCity">NOMBRE:</label>
                      <div class="input-group col-12">
                        <span class="input-group-addon"><i class="fa fa-address-card"></i></span>
                        <input type="text" class="form-control" name="nuevoNombres" placeholder="Nombres" required>
                      </div>
                    </div>
                  </div>         
                  <div class="form-row">
                    <div class="form-group col-md-6">
                        <label for="inputCity">ID DE ALUMNO:</label>
                        <div class="input-group">
                          <span class="input-group-addon"><i class="fa fa-drivers-license-o"></i></span>              
                          <input type="text" class="form-control" id="codigo" name="codigo" placeholder="ID DE ALUMNO" required>
                        </div>
                    </div>

                    <div class="form-group col-md-6">
                        <label for="inputCity">MATRICULA:</label>
                        <div class="input-group">
                          <span class="input-group-addon"><i class="fa fa-drivers-license-o"></i></span>              
                          <input type="text" class="form-control" id="nuevoDocumento" name="nuevoDocumento" placeholder="N° MATRICULA">
                        </div>
                    </div>
                    
                    <div class="form-group col-md-6">
                      <label for="inputCity">UNIVERSIDAD:</label>
                      <div class="input-group">
                        <span class="input-group-addon"><i class="fa fa-volume-control-phone"></i></span>
                        <input type="text" class="form-control" id="universidad" name="universidad" placeholder="UNIVERSIDAD">
                      </div>
                    </div>
                    <div class="form-group col-md-6">
                      <label for="inputCity">TELEFONO:</label>
                      <div class="input-group">
                        <span class="input-group-addon"><i class="fa fa-volume-control-phone"></i></span>
                        <input type="number" min="0" class="form-control" name="nuevoTelefono" placeholder="Teléfono">
                      </div>
                    </div>
                                          
                    <div class="form-group col-md-6">
                      <label for="inputCity">FECHA DE NACIMIENTO:</label>
                      <div class="input-group">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input type="text" class="form-control" name="nuevoFechaNacimiento" placeholder="Fecha nacimiento" data-inputmask="'alias': 'yyyy/mm/dd'" data-mask>
                      </div>
                    </div>
                  </div>
                  <div class="form-row">    
                    
                    <div class="form-group col-md-6">
                      <label for="inputCity">BLOQUE:</label>
                      <div class="input-group">
                      <span class="input-group-addon"><i class="fa fa-flag-checkered"></i></span>
                      <select class="form-control" id="nuevoZona" name="nuevoZona" required>
                              <option value="">Seleccione</option>
                              <?php 
                              $direccion = ControladorDirecciones::ctrMostrarZona();
                              foreach($direccion as $dir){
                               ?>                              
                              <option value="<?= $dir['idzona'] ?>"><?= $dir['nombre_zona'] ?></option>
                             <?php } ?>
                                              
                            </select>  
                      </div>
                    </div>

                    <div class="form-group col-md-6">
                      <label for="inputCity">ESTATUS ESCOLAR:</label>
                        <div class="">
                            <label>                                         
                              <input type="radio" class="minimal porcentaje" name="sexo" id="sexo" value="M" checked="checked">
                              ALUMNO                         
                            </label>
                          
                            <label>                                          
                              <input type="radio" class="minimal porcentaje" name="sexo" id="sexo" value="F">
                              EX ALUMNO                           
                            </label>
                        </div>

                    </div>

                  </div>


                  <div class="form-row">                     
                    
                    <div class="form-group col-md-12">
                        <label for="diplomado">DIPLOMADO:</label>
                        <div class="input-group">
                            <span class="input-group-addon"><i class="fa fa-graduation-cap"></i></span>
                            <select class="form-control" id="nuevaDireccion" name="nuevaDireccion">
                                <option value="">Seleccione diplomado</option>
                                <option value="LEAN MANUFACTURING">LEAN MANUFACTURING</option>
                                <option value="SAP BUSINESS ONE">ERP'S SAP BUSINESS ONE</option>
                                <option value="CALIDAD AUTOMOTRIZ IATF 16949">CALIDAD AUTOMOTRIZ</option>
                                <option value="LOGISTICA INTERNACIONAL">LOGISTICA INTERNACIONAL</option>
                                <option value="SISTEMAS DE GESTION INTEGRAL">SISTEMAS DE GESTION INTEGRAL</option>
                                <option value="GD&T">GD&T</option>
                                <option value="AUTOMATIZACION INDUSTRIAL">AUTOMATIZACION INDUSTRIAL</option>
                                <option value="ROBOTICA INDUSTRIAL">ROBOTICA INDUSTRIAL</option>
                                <option value="LEAN SIX SIGMA">LEAN SIX SIGMA</option>
                                <option value="PROJECT MANAGEMENT">PROJECT MANAGEMENT</option>
                            </select>
                        </div>
                    </div>
                      
                    <div class="form-group col-md-12">
                      <label for="inputCity">CORREO:</label>
                      <div class="input-group">
                        <span class="input-group-addon"><i class="fa fa-envelope-o"></i></span>
                        <input type="email" class="form-control" name="nuevoEmail" placeholder="E-mail">
                        
                      </div>
                    </div>

                  </div>
  
        </div>
    </div>

        <!--=====================================
        PIE DEL MODAL
        ======================================-->

        <div class="modal-footer">

          <button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-arrow-circle-left"></i> Cancelar</button>

          <button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> Guardar</button>

        </div>

      </form>

      <?php

        $crearPersona = new ControladorPersonas();
        $crearPersona -> ctrCrearPersona();

      ?>

    </div>

  </div>

</div>

<!--=====================================
MODAL EDITAR CLIENTE
======================================-->
<div id="modalEditarPersona" class="modal fade" role="dialog">
  
  <div class="modal-dialog">

    <div class="modal-content">

      <form role="form" method="post">

        <!--=====================================
        CABEZA DEL MODAL
        ======================================-->

        <div class="modal-header" style="background:#3c8dbc; color:white">

          <button type="button" class="close" data-dismiss="modal">&times;</button>

          <h4 class="modal-title">Editar cliente</h4>

        </div>

        <!--=====================================
        CUERPO DEL MODAL
        ======================================-->

        <div class="modal-body" style="padding:0px">

          <div class="box-body" style="padding:0px">

                  <!-- ENTRADA PARA EL NOMBRE -->

                  <div class="form-row">

                    <div class="form-group col-md-12">
                      <label for="inputCity">nombre:</label>
                      <div class="input-group">
                        <span class="input-group-addon"><i class="fa fa-address-card"></i></span>
                        
                        <input type="hidden" min="0" class="form-control" id="idpersona" name="idpersona">
                        <input type="text" class="form-control" id="editarNombres" name="editarNombres" placeholder="Nombres" required>
                      </div>
                    </div>
                  

                  </div>

                  <div class="form-row"> 

                    <div class="form-group col-md-6">
                        <label for="inputCity">id:</label>
                        <div class="input-group">
                          <span class="input-group-addon"><i class="fa fa-drivers-license-o"></i></span>              
                          <input type="text" class="form-control" id="editarCodigo" name="editarCodigo" placeholder="Codigo" required>
                        </div>
                    </div>                    
                    
                    <div class="form-group col-md-6">
                      <label for="inputCity">matricula:</label>
                      <div class="input-group">
                        <span class="input-group-addon"><i class="fa fa-drivers-license-o"></i></span>              
                        <input required class="form-control" id="editarDocumento" name="editarDocumento" placeholder="N° de Cédula" required>
                      </div>
                    </div>

                  </div>

                  <div class="form-row">
                     

                     <div class="form-group col-md-6">
                      <label for="inputCity">Teléfono:</label>
                      <div class="input-group">
                        <span class="input-group-addon"><i class="fa fa-volume-control-phone"></i></span>
                        <input type="number" min="0" class="form-control" id="editarTelefono" name="editarTelefono" placeholder="Teléfono" required>
                      </div>
                    </div>           

               </div>   

                <div class="form-row">  

                <div class="form-group col-md-6">
                      <label for="inputCity">Fecha de Nacimiento:</label>
                      <div class="input-group">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input type="text" class="form-control" id="editarFechaNacimiento" name="editarFechaNacimiento" placeholder="Fecha nacimiento" data-inputmask="'alias': 'yyyy/mm/dd'" data-mask>
                      </div>
                    </div>                        
                    
                    
                    <div class="form-group col-md-6">
                      <label for="inputCity">BLOQUE:</label>
                      <div class="input-group">
                      <span class="input-group-addon"><i class="fa fa-flag-checkered"></i></span>
                      <select class="form-control" id="editarZona" name="editarZona" required>
                              <option value="">Seleccione</option>
                              <?php $direccion = ControladorDirecciones::ctrMostrarZona();
                              foreach($direccion as $dir){
                               ?>                              
                              <option value="<?= $dir['idzona'] ?>"><?= $dir['nombre_zona'] ?></option>
                             <?php } ?>
                                              
                            </select>  
                      </div>
                    </div>

                    <div class="form-group col-md-6">

                      <label for="inputCity">estatus:</label>

                        <div class="">

                          
                            <label>                                         
                              <input type="radio" class="minimal porcentaje" name="editarSexo" id="editarSexoM" value="M">
                              Alumno                        
                            </label>
                          
                            <label>                                          
                              <input type="radio" class="minimal porcentaje" name="editarSexo" id="editarSexoF" value="F">
                             Ex-Alumno                           
                            </label>
                          

                        </div>

                    </div> 

                  </div>


                  <div class="form-row">                     
                    
                  <div class="form-group col-md-12">
                      <label for="inputCity">DIPLOMADO:</label>
                      <div class="input-group">
                        <span class="input-group-addon"><i class="fa fa-map-marker"></i></span>
                        <input type="text" class="form-control" id="editarDireccion" name="editarDireccion" placeholder="dirección">                      
                      </div>
                    </div>
                      
                    <div class="form-group col-md-12">
                      <label for="inputCity">Correo:</label>
                      <div class="input-group">
                        <span class="input-group-addon"><i class="fa fa-envelope-o"></i></span>
                        <input type="email" class="form-control" id="editarEmail" name="editarEmail" placeholder="E-mail">
                        
                      </div>
                    </div>

                  </div>          

            
  
        </div>
    </div>

        <!--=====================================
        PIE DEL MODAL
        ======================================-->

        <div class="modal-footer">

          <button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-arrow-circle-left"></i> Cancelar</button>

          <button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> Guardar cambios</button>

        </div>

      </form>

        <?php

        $editarPersona = new ControladorPersonas();
        $editarPersona -> ctrEditarPersona();

      ?>

 

    </div>

  </div>

</div>

<?php

  $eliminarPersona = new ControladorPersonas();
  $eliminarPersona -> ctrEliminarPersona();

?>

<script>

$("#tablaPersonas").DataTable({

"language": {

  "sProcessing":     "Procesando...",
  "sLengthMenu":     "Mostrar _MENU_ registros",
  "sZeroRecords":    "No se encontraron resultados",
  "sEmptyTable":     "Ningún dato disponible en esta tabla",
  "sInfo":           "Mostrando registros del _START_ al _END_ de un total de _TOTAL_",
  "sInfoEmpty":      "Mostrando registros del 0 al 0 de un total de 0",
  "sInfoFiltered":   "(filtrado de un total de _MAX_ registros)",
  "sInfoPostFix":    "",
  "sSearch":         "Buscar:",
  "sUrl":            "",
  "sInfoThousands":  ",",
  "sLoadingRecords": "Cargando...",
  "oPaginate": {
  "sFirst":    "Primero",
  "sLast":     "Último",
  "sNext":     "Siguiente",
  "sPrevious": "Anterior"
  },
  "oAria": {
    "sSortAscending":  ": Activar para ordenar la columna de manera ascendente",
    "sSortDescending": ": Activar para ordenar la columna de manera descendente"
  }

},
"ajax": {
        "url": "ajax/personas.ajax.php",
        "data" : { 'consultarPersonas': "consultar" },
        "type" : 'post'
      },
      "columns": [
      {"data":"idpersona"},
      {"data":"codigo"},
      {"data":"nombres"},
      {"data":"documento"},
      {"data": "estado",
       "render": function(data, type, JsonResultRow, meta){
         var estado = '<td><button class="btn btn-danger btn-xs btnActivar" idPersona="'+JsonResultRow.idpersona+'" estadoPersona="activo">Desactivado</button></td>';
         if(JsonResultRow.estado == "activo"){
            estado = '<td><button class="btn btn-success btn-xs btnActivar" idPersona="'+JsonResultRow.idpersona+'" estadoPersona="inactivo">Activado</button></td>';
         } 
         return estado;
       }
      },
      {"data":"email"},
      {"data":"telefono"},
      {"data":"direccion"},
      {"data":"nombre_zona"},
      {"data": "idpersona",
        "render": function(data, type, JsonResultRow, meta){
          var accion;
          accion = '<button class="btn btn-warning btnEditarPersona" data-toggle="modal" data-target="#modalEditarPersona" idPersona="'+JsonResultRow.idpersona+'"><i class="fa fa-pencil"></i></button>';
          <?php
          if($_SESSION["perfil"] == "Administrador"){ ?>
                          accion += ' <button class="btn btn-danger btnEliminarPersona" idPersona="'+JsonResultRow.idpersona+'"><i class="fa fa-trash"></i></button>';
            <?php
          }?>
         
          return accion;
        }
      }
      ],  

});

/*=============================================
ACTIVAR PERSONA
=============================================*/


</script>



