Commit 1f31a56b by Billy Larru

usando handsontable

parent 636fe850
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package asistencia.servlets;
import java.util.HashMap;
import java.util.List;
import static java.util.stream.Collectors.toList;
import org.json.JSONArray;
import org.json.JSONObject;
public class NewClass {
public static void main(String[] args) {
JSONArray arr = new JSONArray();
JSONObject obj = new JSONObject();
obj.put("nombre", "billy");
obj.put("apellido", "larru");
arr.put(obj);
JSONObject obj2 = new JSONObject();
obj2.put("nombre", "felipe");
obj2.put("apellido", "escala");
arr.put(obj2);
JSONObject obj3 = new JSONObject();
obj3.put("nombre", "");
obj3.put("apellido", "escala");
arr.put(obj3);
System.out.println(arr.toList().get(0).getClass().getTypeName());
List<HashMap> list = arr.toList().stream().filter(HashMap.class::isInstance).map(HashMap.class::cast).collect(toList());
List<HashMap<String, String>> list2 = (List<HashMap<String, String>>)(Object)list;
// list.stream().filter(h -> h.entrySet().stream().filter(e -> e.g) );
// HashMap<String, String> map = list.get(0);
// map.entrySet().stream().filter(e -> e.get)
// list2.forEach(h -> h.entrySet().stream().filter(e -> e.getKey().equals("nombre") &&!e.getValue().isEmpty()).forEach(e -> System.out.println("e="+e.getKey()+ " "+e.getValue())));
System.out.println(list);
List<HashMap<String, String>> listmap = (List<HashMap<String, String>>)(Object)arr.toList();
listmap.forEach(
h -> h.entrySet().stream()
.filter(e -> e.getKey().equals("nombre") && !e.getValue().isEmpty())
.forEach(e -> System.out.println("k="+e.getKey()+", v="+e.getValue()))
);
}
}
let data = []; let data = [];
let sedes = [];
function initializeData() { function initializeData() {
data.push({"numero": 1, "nombres": "DELGADO CHOZO JUAN FRANCISCO", "sede": "CANTA CALLAO 2", "horario": "07:00 - 17:00", "tipo_horario": "REGULAR", data.push({"dni": "12345678", "nombres": "DELGADO CHOZO JUAN FRANCISCO", "sede": "CANTA CALLAO 2", "horario": "07:00 - 17:00", "tipo_horario": "REGULAR",
"fecha_entrada": "2018-06-15", "marcacion_entrada": "06:59", "marcacion_salida": "00:00", "fecha_salida": "2018-06-15"}); "fecha_entrada": "15/06/2018", "marcacion_entrada": "06:59", "marcacion_salida": "00:00", "fecha_salida": "2018-06-15"});
data.push({"dni": "12345678", "nombres": "DELGADO CHOZO JUAN FRANCISCO", "sede": "CANTA CALLAO 2", "horario": "07:00 - 17:00", "tipo_horario": "REGULAR",
data.push({"numero": 2, "nombres": "DELGADO CHOZO JUAN FRANCISCO", "sede": "CANTA CALLAO 2", "horario": "07:00 - 17:00", "tipo_horario": "REGULAR", "fecha_entrada": "16/06/2018", "marcacion_entrada": "06:59", "marcacion_salida": "00:00", "fecha_salida": "2018-06-16"});
"fecha_entrada": "2018-06-16", "marcacion_entrada": "06:59", "marcacion_salida": "00:00", "fecha_salida": "2018-06-16"}); data.push({"dni": "12345678", "nombres": "DELGADO CHOZO JUAN FRANCISCO", "sede": "CANTA CALLAO 2", "horario": "07:00 - 17:00", "tipo_horario": "REGULAR",
"fecha_entrada": "17/06/2018", "marcacion_entrada": "06:59", "marcacion_salida": "00:00", "fecha_salida": "2018-06-17"});
data.push({"numero": 3, "nombres": "DELGADO CHOZO JUAN FRANCISCO", "sede": "CANTA CALLAO 2", "horario": "07:00 - 17:00", "tipo_horario": "REGULAR",
"fecha_entrada": "2018-06-17", "marcacion_entrada": "06:59", "marcacion_salida": "00:00", "fecha_salida": "2018-06-17"});
sedes = ["LINCE", "MONTESORI", "AREQUIPA", "ARENALES", "CUBA", "COCALENOS", "BELISARIO", "BERTONELLI", "VILLA EL SALVADOR"];
data.push({"numero": 4, "nombres": "APONTE JAIME SEGUNDO FRANCISCO", "sede": "CUBA", "horario": "07:00 - 17:00", "tipo_horario": "REGULAR",
"fecha_entrada": "2018-06-15", "marcacion_entrada": "06:59", "marcacion_salida": "00:00", "fecha_salida": "2018-06-15"});
data.push({"numero": 5, "nombres": "APONTE JAIME SEGUNDO FRANCISCO", "sede": "CUBA", "horario": "07:00 - 17:00", "tipo_horario": "REGULAR",
"fecha_entrada": "2018-06-17", "marcacion_entrada": "06:59", "marcacion_salida": "00:00", "fecha_salida": "2018-06-17"});
data.push({"numero": 6, "nombres": "GARCIA TORRES DAVID", "sede": "CUBA", "horario": "07:00 - 17:00", "tipo_horario": "REGULAR",
"fecha_entrada": "2018-06-15", "marcacion_entrada": "06:59", "marcacion_salida": "00:00", "fecha_salida": "2018-06-15"});
data.push({"numero": 7, "nombres": "VERA GUEVARA HUGO", "sede": "CUBA", "horario": "07:00 - 17:00", "tipo_horario": "REGULAR",
"fecha_entrada": "2018-06-15", "marcacion_entrada": "06:59", "marcacion_salida": "00:00", "fecha_salida": "2018-06-15"});
data.push({"numero": 8, "nombres": "MENDOZA RAMIREZ JORGE", "sede": "CUBA", "horario": "07:00 - 17:00", "tipo_horario": "REGULAR",
"fecha_entrada": "2018-06-15", "marcacion_entrada": "06:59", "marcacion_salida": "00:00", "fecha_salida": "2018-06-15"});
data.push({"numero": 9, "nombres": "MENDOZA RAMIREZ JORGE", "sede": "CUBA", "horario": "07:00 - 17:00", "tipo_horario": "REGULAR",
"fecha_entrada": "2018-06-15", "marcacion_entrada": "06:59", "marcacion_salida": "00:00", "fecha_salida": "2018-06-15"});
data.push({"numero": 10, "nombres": "GUERRERO VELASCO LUIS SEGUNDO", "sede": "CUBA", "horario": "07:00 - 17:00", "tipo_horario": "REGULAR",
"fecha_entrada": "2018-06-15", "marcacion_entrada": "06:59", "marcacion_salida": "00:00", "fecha_salida": "2018-06-15"});
data.push({"numero": 11, "nombres": "GUERRERO VELASCO LUIS SEGUNDO", "sede": "CUBA", "horario": "07:00 - 17:00", "tipo_horario": "REGULAR",
"fecha_entrada": "2018-06-15", "marcacion_entrada": "06:59", "marcacion_salida": "00:00", "fecha_salida": "2018-06-15"});
data.push({"numero": 12, "nombres": "GUERRERO VELASCO LUIS SEGUNDO", "sede": "CUBA", "horario": "07:00 - 17:00", "tipo_horario": "REGULAR",
"fecha_entrada": "2018-06-15", "marcacion_entrada": "06:59", "marcacion_salida": "00:00", "fecha_salida": "2018-06-15"});
} }
function mostrarVistaPrevia() { function mostrarVistaPrevia() {
console.log("vista previa"); let container = document.getElementById("tblProyectado");
console.log(data); handsonTable = new Handsontable(container, {
$("#tblAsistenciaPolicias").DataTable().destroy();
$("#tblAsistenciaPolicias").DataTable({
"language": {
"lengthMenu": "Mostrar: _MENU_",
"zeroRecords": "&nbsp;&nbsp;&nbsp; No se encontraron resultados",
"info": "&nbsp;&nbsp;&nbsp; Mostrando del _START_ al _END_ de un total de _TOTAL_ registros",
"infoEmpty": "&nbsp;&nbsp;&nbsp; Mostrando 0 de 0 registros",
"search": "Filtrar:",
"loadingRecords": "Cargando...",
"processing": '<span style="width:100%;"><img src="http://www.snacklocal.com/images/ajaxload.gif"></span>',
"paginate": {
"first": "First",
"last": "Last",
"next": "Siguiente",
"previous": "Anterior"
}
},
"bSort": false,
"bFilter": false,
"aaSorting": [],
"ordering": false,
"bLengthChange": false,
"bInfo": true,
"paging": true,
iDisplayLength: 50,
bStateSave: false,
autoWidth: false,
responsive: true,
stateSave: true,
columnDefs: [
{orderable: false, width: '5%', targets: 0, className: "text-center"},
{orderable: false, width: '15%', targets: 1},
{orderable: false, width: '10%', targets: 2, className: "text-center"},
{orderable: false, width: '7%', targets: 3, className: "text-center"},
{orderable: false, width: '7%', targets: 4, className: "text-center"},
{orderable: false, width: '10%', targets: 5, className: "text-center"},
{orderable: false, width: '8%', targets: 6, className: "text-center"},
{orderable: false, width: '8%', targets: 7, className: "text-center"}
],
dom: '<"datatable-header"fl><"datatable-scroll-wrap"t><"datatable-footer"ip>',
"processing": true,
data: data, data: data,
"columns": [ stretchH: 'all',
rowHeaders: true,
colHeaders: ['DNI', 'Apellidos y Nombres', 'Sede', 'Horario', 'Rol', 'Fecha Entrada', 'Hora entrada', 'Hora Salida', 'Fecha Salida'],
columns: [
{
data: "dni",
className: 'text-center',
readOnly: true
},
{ {
"data": "numero", "data": "nombres",
"className": "text-center" readOnly: true
}, },
{"data": "nombres"},
{ {
"data": "sede", "data": "sede",
"className": "text-center" "className": "text-center",
// editor: 'select',
// selectOptions: sedes,
source: sedes,
strict: true,
type: 'autocomplete',
allowInvalid: false
}, },
{ {
"data": "horario", "data": "horario",
"className": "text-center" "className": "text-center",
readOnly: true
}, },
{ {
"data": "tipo_horario", "data": "tipo_horario",
"className": "text-center", "className": "text-center",
render: (data) => { readOnly: true,
let label = ''; // render: (data) => {
// let label = '';
switch (data) { //
case "REGULAR": // switch (data) {
label = `label bg-slate border-slate-700`; // case "REGULAR":
break; // label = `label bg-slate border-slate-700`;
} // break;
// }
return `<span class="${label}">${data}</span>`; //
} // return `<span class="${label}">${data}</span>`;
// }
}, },
{ {
"data": "fecha_entrada", "data": "fecha_entrada",
"className": 'text-center' "className": 'text-center',
type: 'date',
dateFormat: 'DD/MM/YYYY'
}, },
{ {
"data": "marcacion_entrada", data: "marcacion_entrada",
"className": 'text-center' className: 'text-center',
type: 'time',
timeFormat: 'HH:mm',
correctFormat: true,
allowInvalid: false
}, },
{ {
"data": "marcacion_salida", data: "marcacion_salida",
"className": 'text-center' className: 'text-center',
type: 'time',
timeFormat: 'HH:mm',
correctFormat: true,
allowInvalid: true
}, },
{ {
"data": "fecha_salida", data: "fecha_salida",
"className": 'text-center' className: 'text-center',
}, type: 'date',
], dateFormat: 'DD/MM/YYYY'
rowsGroup: [1, 2, 3, 4], }
fnInitComplete: function (settings, data) { ]
$('th').removeClass('sorting_asc');
console.log(data);
}
}); });
} }
...@@ -153,7 +109,6 @@ $(function () { ...@@ -153,7 +109,6 @@ $(function () {
} }
}); });
$("#dpFechaInicio").datepicker('setDate', 'now'); $("#dpFechaInicio").datepicker('setDate', 'now');
$("#dpFechaFin").datepicker({ $("#dpFechaFin").datepicker({
minDate: new Date(2000, 1 - 1, 1), maxDate: new Date(), minDate: new Date(2000, 1 - 1, 1), maxDate: new Date(),
dateFormat: 'dd/mm/yy', dateFormat: 'dd/mm/yy',
...@@ -166,7 +121,6 @@ $(function () { ...@@ -166,7 +121,6 @@ $(function () {
} }
}); });
$("#dpFechaFin").datepicker('setDate', 'now'); $("#dpFechaFin").datepicker('setDate', 'now');
// defaultConfigDataTable(); // defaultConfigDataTable();
initializeData(); initializeData();
$("#btnVistaPrevia").click(mostrarVistaPrevia); $("#btnVistaPrevia").click(mostrarVistaPrevia);
......
...@@ -51,8 +51,8 @@ ...@@ -51,8 +51,8 @@
<div class="panel-heading"> <div class="panel-heading">
<h6 class="panel-title" style="font-size: 15px; font-family: inherit"><i class="icon icon-search4"></i>&nbsp;ASISTENCIAS PROYECTADAS</h6> <h6 class="panel-title" style="font-size: 15px; font-family: inherit"><i class="icon icon-search4"></i>&nbsp;ASISTENCIAS PROYECTADAS</h6>
</div> </div>
<div> <div id="tblProyectado">
<table class="table table-responsive dataTable table-striped table-sm table-bordered" id="tblAsistenciaPolicias"> <!-- <table class="table table-responsive dataTable table-striped table-sm table-bordered" id="tblAsistenciaPolicias">
<thead> <thead>
<tr> <tr>
<th class="text-center">N°</th> <th class="text-center">N°</th>
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
<tbody> <tbody>
</tbody> </tbody>
</table> </table>-->
</div> </div>
</div> </div>
</div> </div>
...@@ -83,11 +83,12 @@ ...@@ -83,11 +83,12 @@
<%@include file="templates/footer-body.jsp"%> <%@include file="templates/footer-body.jsp"%>
<!--js de la pagina--> <!--js de la pagina-->
<script src="../plantilla/assets/js/plugins/ui/moment/moment.min.js" type="text/javascript"></script>
<script type="text/javascript" src="../plantilla/assets/js/plugins/pickers/daterangepicker.js"></script> <script type="text/javascript" src="../plantilla/assets/js/plugins/pickers/daterangepicker.js"></script>
<script type="text/javascript" src="../plantilla/assets/js/core/libraries/jquery_ui/widgets.min.js"></script> <script type="text/javascript" src="../plantilla/assets/js/core/libraries/jquery_ui/widgets.min.js"></script>
<script src="../plantilla/assets/js/plugins/tables/datatables/datatables.min.js" type="text/javascript"></script> <script src="../plantilla/assets/js/plugins/tables/datatables/datatables.min.js" type="text/javascript"></script>
<script src="../js/lib/dataTables.rowsGroup.js" type="text/javascript"></script> <script src="../js/lib/dataTables.rowsGroup.js" type="text/javascript"></script>
<script type="text/javascript" src="../plantilla/assets/js/plugins/tables/handsontable/handsontable.min.js"></script>
<script src="../js/pages/proyectar_asistencia_policias.js" type="text/javascript"></script> <script src="../js/pages/proyectar_asistencia_policias.js" type="text/javascript"></script>
<!--js--> <!--js-->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment