 <div class="container col d-flex justify-content-center">
   <div class="row">
      <div class="col-lg-12">
         <div class="card shadow-lg p-3 mb-5 bg-white ">
            <div class="card-header">
               <h3> Trabajadores </h3>
            </div>
            <div class="card-body">
               <!-- COMIENZO DEL FORMULARIO -->
               <form id="createform" action="/links/create-trabajadores" method="POST"   class="needs-validation" novalidate>
                  <div class="form-row">
                    <div class="col-md-2 mb-3">
                      <label class="font-weight-bold" for="desformula">Codigo</label> 
                      <div class="input-group">
                        <input class="form-control" type="text"  id="id-area"    name="codigo"     >                     
                      </div>
                    </div>


                    <div class="col-md-4 mb-3">
                      <label class="font-weight-bold" for="desformula">Nombres</label> 
                      <div class="input-group">
                        <input class="form-control" type="text"  id="idnombres"   name="nombres"  value = ""  required>                     
                      </div>
                    </div>

                    <div class="col-md-4 mb-3">
                      <label class="font-weight-bold" for="desformula">Apellidos</label> 
                      <div class="input-group">
                        <input class="form-control" type="text"  id="idapellidos"   name="apellidos"  value = ""  required>                     
                      </div>
                    </div>

                    <div class="col-md-2 mb-3">
                      <label class="font-weight-bold" for="desformula">Cédula</label> 
                      <div class="input-group">
                        <input class="form-control" type="number"  id="idcedula"   name="cedula"  value = ""  required>                     
                      </div>
                    </div>


                      <div class="input-group">
                        <input type="hidden"  class="form-control"  name="tipo_de_submit"  value=0 >
                      </div>

                  </div> <!-- FIN DE LABELS E INPUTS DEL LA PRIMERA FILA  -->
                   <div class="form-row">
                        <div class="col-md-3 mb-3">
                            <label class="font-weight-bold" for="fecha">Fecha Ingreso</label>
                            <input name="fecha_ingreso" type="date" class="form-control" id="id-fecha" value={{ eldia }}>
                        </div>

                       <div class="col-md-3 mb-3">
                           <label class="font-weight-bold"  for="cargo">Cargo</label>
                           <select name="cargo" class="custom-select"     >
                              {{#each lista}}
                              {{#each lista_cargos}}
                                <option value="{{id_cargo}}"   selected="selected">{{descripcion}}</option>
                              {{/each}}
                              {{/each}}
                           </select>
                        </div>

                       <div class="col-md-3 mb-3">
                           <label class="font-weight-bold"  for="status">Status</label>
                           <select name="status" class="custom-select"     >
                                <option value="Activo"   selected="selected">Activo</option>
                                <option value="Vacaciones"   >Vacaciones</option>
                                <option value="Inactivo"   >Inactivo</option>
                           </select>
                        </div>



                   </div> <!-- FIN DE LABELS E INPUTS DEL LA SEGUNDA FILA  -->
                  <div class="form-row">
                     <!-- COMIENZO DE la CUARTA linea ROW-->
                            <div class="col-md-8 mb-3">
                              <div class="input-group">                               

                              </div>
                            </div>
                            <div class="col-md-2 mb-3">
                              <div class="input-group">                               
                               <button class="btn btn-success"  onclick= "cambiarstatus(0)"  type="submit">Save</button>
                              </div>
                            </div>
                            <div class="col-md-2 mb-3">
                              <div class="input-group">                               
                                <button id="btnCrear"    class="btn btn-danger" onclick= "cambiarstatus(1)"  >Close</button>
                              </div>
                            </div>
                  </div>


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

<script>
   function cambiarstatus(valor) {
      document.getElementsByName('tipo_de_submit')[0].value = valor;
   }
</script>

<script>

   (function () {
      'use strict';
      window.addEventListener('load', function () {
         // Fetch all the forms we want to apply custom Bootstrap validation styles to
         var forms = document.getElementsByClassName('needs-validation');
         // Loop over them and prevent submission
         var validation = Array.prototype.filter.call(forms, function (form) {
            form.addEventListener('submit', function (event) {
               if (form.checkValidity() === false) {
                  if (parseInt(document.getElementsByName('tipo_de_submit')[0].value) <= 0) {
                      event.preventDefault();
                      event.stopPropagation();
                  }
               }
               form.classList.add('was-validated');
            }, false);
         });
      }, false);
   });


</script>
