<div class="container">
  <div class="row">
    <div class="col-lg-12">
      <div class="card shadow-lg p-3 mb-5 bg-white ">
        <div class="card-header"> <h2>Trasladar Producción al Inventario</h2> </div>
        <div class="card-body">
          <!-- COMIENZO DEL FORMULARIO -->
         <div class="container-fluid">
            
             <div class="form-row">           
                     <div class="col-md-3 mb-3">
                        <button id="btnCrear" class="btn btn-primary"  onclick="ejecutarconsulta(0)"  >Procesar</button>
                     </div>
                        
             </div>
                    
<div class="form-row">
            <div >
               <table id="tabla123" class="cell-border" style="width:100%">
                   <thead>
                          <tr>
                            <th></th>  
                            <th>ID</th>
                            <th>Fecha</th>
                            <th>Turno</th>
                            <th>Area</th>
                            <th>Supervisor</th>      
                          </tr>                     
                   </thead>
                   <tbody>
                   </tbody>
               </table>
           </div>
</div>                    
          </div>
        </div>
      </div>
    </div>
  </div>

<script src= "/jquery/dist/jquery.js"  ></script> 

<script>

    $(document).ready(function() {   

        var url1 = "/links/Listaturnoscerrados";

          $('#tabla123').DataTable({     
                'columnDefs': [
                    {
                        'targets': 0,
                        'checkboxes': {
                        'selectRow': true
                        }
                    }
                ],
                'select': {
                    'style': 'multi'
                },
                  "ajax" : {
                  "url" : url1,
                  "dataSrc":"",
                  "type" : "GET"                  
              },
              "columns":[
                  {"data": "comodin", "width": "5%", "title": ""  },
                  {"data": "id_produccion", "width": "5%", "title": "ID"  },
                  {"data": "Fecha", "width": "25%", "title": "Fecha"   },
                  {"data": "turno", "width": "25%", "title":  "Turno",  className: "text-center" },
			      {"data": "Area", "width": "10%", "title": "Area"  }, 
                  {"data": "supervisor", "width": "50%", "title": "Supervisor"  },
             ],
             pageLength : 10,
             lengthMenu: [[5, 10, 20, -1], [5, 10, 20, 'Todos']],
            "scrollY": 400,
            "scrollX": true         
              });
    });

</script>

<script>

function ejecutarconsulta(value) {
  var table = $('#tabla123').DataTable();
  var selectedRows = table.rows('.selected').data().length
  var   rowData = table.rows( { selected: true } ).data().toArray();
  if (rowData.length > 0 ) {
      var json = JSON.stringify (rowData);
      var url1 = "/links/ejecutarsaint/" + json;

        $.ajax({
            type: "GET",
            url: url1,
            datatype: "json",
            traditional: true
            })
        .done(function (data) {
                });
  }


  //alert(json[0].id_produccion) 
} // fin



</script>


</div>

