Commit bed0d075 by Billy Larru

mostrando mensaje de registro de asistencia de policias

parent ded43277
let asistencias = [], sedes = [];
let htmlSedes;
function getColumns() {
let columns = [
{
title: `N°`,
data: `id`,
className: 'text-center'
},
{
title: `APELLIDOS Y NOMBRES`,
data: `policia_nombres`
},
{
title: `SEDE`,
data: `sede_descripcion`,
className: 'text-center'
},
{
title: `HORARIO`,
data: `horario`,
className: 'text-center'
},
{
title: `TIPO`,
data: `tiporol_descripcion`,
className: 'text-center'
},
{
title: `FRECUENCIA`,
data: `frecuencia_descripcion`,
className: 'text-center'
},
{
title: `FECHA ENTRADA`,
data: `fecha_entrada`,
className: 'text-center'
},
{
title: `MARC. ENTRADA`,
data: null,
className: 'text-center',
render: data => {
let label = "";
if (data.estado == 3 || data.estado == 4 || data.estado == 9) {
return `-`;
}
function listarAsistencias(objParams = {}) {
axios.get(URI_POLICIAS_ASISTENCIA, objParams).then((response) => {
response.data = formatResponse(response);
let columns = [
{
title: `N°`,
data: `id`,
className: 'text-center'
},
{
title: `APELLIDOS Y NOMBRES`,
data: `policia_nombres`
},
{
title: `SEDE`,
data: `sede_descripcion`,
className: 'text-center'
},
{
title: `HORARIO`,
data: `horario`,
className: 'text-center'
},
{
title: `TIPO`,
data: `tiporol_descripcion`,
className: 'text-center'
},
{
title: `FRECUENCIA`,
data: `frecuencia_descripcion`,
className: 'text-center'
},
{
title: `FECHA ENTRADA`,
data: `fecha_entrada`,
className: 'text-center'
},
{
title: `MARC. ENTRADA`,
data: null,
className: 'text-center',
render: data => {
let label = "";
if (data.estado == 3 || data.estado == 4 || data.estado == 9) {
return `-`;
}
if (data.marcacion_entrada === null) {
return null;
}
if (data.huella_entrada === 1) {
label = "text-migration font-weight-bold";
} else if (data.huella_entrada === 0) {
label = "text-default";
}
return `<span class="${label}">${data.marcacion_entrada}</span>`;
if (data.marcacion_entrada === null) {
return null;
}
},
{
title: `MARC. SALIDA`,
data: null,
className: 'text-center',
render: (data) => {
let label = "";
if (data.estado == 3 || data.estado == 4 || data.estado == 9) {
return `-`;
}
if (data.marcacion_salida === null) {
return null;
}
if (data.huella_salida === 1) {
label = "text-migration font-weight-bold";
} else if (data.huella_salida === 0) {
label = "text-default";
}
return `<span class="${label}">${data.marcacion_salida}</span>`;
if (data.huella_entrada === 1) {
label = "text-migration font-weight-bold";
} else if (data.huella_entrada === 0) {
label = "text-default";
}
},
{
title: `FECHA SALIDA`,
data: `fecha_salida`,
className: 'text-center'
},
{
title: `ESTADO`,
data: null,
className: 'text-center',
render: (data) => {
let label = "";
let estado = "";
switch (data.estado) {
case 1:
label = "label label-success";
estado = "TEMPRANO";
break;
case 2:
label = "label label-warning";
estado = "TARDANZA";
break;
case 3:
label = "label label-danger";
estado = "FCA";
break;
case 4:
label = "label label-danger";
estado = "FSA";
break;
case 5:
label = "label label-default";
estado = "NO MARCÓ";
break;
case 9:
label = "label label-info";
estado = "LSGH";
break;
case 10:
label = "label bg-purple";
estado = "ENTRADA PENDIENTE";
break;
case 11:
label = "label bg-purple";
estado = "SALIDA PENDIENTE";
break;
case null:
label = "label bg-purple";
estado = "PENDIENTE";
break;
}
return `<span class="${label}">${estado}</span>`;
return `<span class="${label}">${data.marcacion_entrada}</span>`;
}
},
{
title: `MARC. SALIDA`,
data: null,
className: 'text-center',
render: (data) => {
let label = "";
if (data.estado == 3 || data.estado == 4 || data.estado == 9) {
return `-`;
}
if (data.marcacion_salida === null) {
return null;
}
if (data.huella_salida === 1) {
label = "text-migration font-weight-bold";
} else if (data.huella_salida === 0) {
label = "text-default";
}
return `<span class="${label}">${data.marcacion_salida}</span>`;
}
},
{
title: `FECHA SALIDA`,
data: `fecha_salida`,
className: 'text-center'
},
{
title: `ESTADO`,
data: null,
className: 'text-center',
render: (data) => {
let label = "";
let estado = "";
switch (data.estado) {
case 1:
label = "label label-success";
estado = "TEMPRANO";
break;
case 2:
label = "label label-warning";
estado = "TARDANZA";
break;
case 3:
label = "label label-danger";
estado = "FCA";
break;
case 4:
label = "label label-danger";
estado = "FSA";
break;
case 5:
label = "label label-default";
estado = "NO MARCÓ";
break;
case 9:
label = "label label-info";
estado = "LSGH";
break;
case 10:
label = "label bg-purple";
estado = "ENTRADA PENDIENTE";
break;
case 11:
label = "label bg-purple";
estado = "SALIDA PENDIENTE";
break;
case null:
label = "label bg-purple";
estado = "PENDIENTE";
break;
}
},
{
title: `ACCIONES`,
data: null,
render: (data) => {
let acciones = "";
switch (data.estado) {
case 10:
case 11:
case null:
acciones = `<span data-toggle="tooltip" data-placement="left" title="Editar" style="cursor: pointer"> <i class='registrar icon-plus-circle2 text-success-700'></i>&nbsp;&nbsp; </span>
return `<span class="${label}">${estado}</span>`;
}
},
{
title: `ACCIONES`,
data: null,
render: (data) => {
let acciones = "";
switch (data.estado) {
case 10:
case 11:
case null:
acciones = `<span data-toggle="tooltip" data-placement="left" title="Editar" style="cursor: pointer"> <i class='registrar icon-plus-circle2 text-success-700'></i>&nbsp;&nbsp; </span>
<span data-toggle="tooltip" data-placement="left" title="Editar" style="cursor: pointer"> <i class='editar icon-pencil text-slate-800'></i>&nbsp;&nbsp; </span>
<span data-toggle="tooltip" data-placement="left" title="Aprobar" style="cursor: pointer"> <i class='aprobar icon-checkmark-circle text-success-700'></i>&nbsp;&nbsp; </span>
<span data-toggle="tooltip" data-placement="left" title="Anular" style="cursor: pointer"> <i class='anular icon-cancel-circle2 text-danger-700'></i>&nbsp;&nbsp; </span>`;
break;
}
return acciones;
break;
}
return acciones;
}
];
let columnDefs = [
{orderable: false, width: '5%', targets: 0, className: "text-center"},
{orderable: false, width: '5%', targets: 1},
{orderable: false, width: '30%', 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"},
{orderable: false, width: '8%', targets: 8, className: "text-center"},
{orderable: false, width: '8%', targets: 9, className: "text-center"},
{orderable: false, width: '8%', targets: 10, className: "text-center"},
{orderable: false, width: '8%', targets: 11, className: "text-center"},
{orderable: false, width: '8%', targets: 12, className: "text-center"}
];
}
];
return columns;
}
function getColumnDefs() {
let columnDefs = [
{orderable: false, width: '5%', targets: 0, className: "text-center"},
{orderable: false, width: '5%', targets: 1},
{orderable: false, width: '30%', 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"},
{orderable: false, width: '8%', targets: 8, className: "text-center"},
{orderable: false, width: '8%', targets: 9, className: "text-center"},
{orderable: false, width: '8%', targets: 10, className: "text-center"},
{orderable: false, width: '8%', targets: 11, className: "text-center"},
{orderable: false, width: '8%', targets: 12, className: "text-center"}
];
return columnDefs;
}
function inicializarInputsModal(data = {}){
$("#spanNombres").html(data.policia_nombres);
$("#dpAsistencia").datepicker({
minDate: new Date(2000, 1 - 1, 1), maxDate: new Date(),
dateFormat: 'dd/mm/yy',
setDate: 'now',
changeMonth: true,
changeYear: true,
yearRange: '-18:+0',
onSelect: function () {
// $(this).valid();
}
});
$("#dpAsistencia").datepicker('setDate', data.fecha_entrada);
$("#cboTipoRegistro").change(cambioTipoRegistro);
}
function mostrarMensajeResultadoModal(result = {}) {
if (result.value) {
swal({
type: 'success',
title: '¡Asistencia registrada!',
showConfirmButton: false,
timer: 1500
})
}
}
function mostrarModalRegistroAsistencia(data = {}) {
axios.get("modals/policias/controlAsistencia/registrarAsistencia.jsp").then((response) => {
swal({
title: '<strong>Registrar Asistencia</strong>',
html: response.data,
showCloseButton: true,
showCancelButton: true,
focusConfirm: false,
confirmButtonText: '<i class="fa fa-thumbs-up"></i> Registrar asistencia',
confirmButtonAriaLabel: 'Thumbs up, great!',
cancelButtonText: 'Cancelar',
cancelButtonAriaLabel: 'Thumbs down',
width: '30%',
onOpen: () => {
inicializarInputsModal(data);
}
}).then((result) => {
mostrarMensajeResultadoModal(result);
});
});
}
function listarAsistencias(objParams = {}) {
axios.get(URI_POLICIAS_ASISTENCIA, objParams).then((response) => {
response.data = formatResponse(response);
let columns = getColumns();
let columnDefs = getColumnDefs();
let wrapsNameDatatable = `divAsistencias`;
let classNameForDatatable = `display table table-bordered`;
let footer = false;
makeDatatable(
{
data: response.data.data,
columns: columns,
columnDefs: columnDefs,
wrapsNameDatatable: wrapsNameDatatable,
classNameForDatatable: classNameForDatatable,
footer: footer
columns,
columnDefs,
wrapsNameDatatable,
classNameForDatatable,
footer
}
).then((datatable) => {
$(datatable).on("click", ".registrar", function () {
let data = $(datatable).DataTable().row($(this).parents("tr")).data();
console.log(data);
axios.get("modals/policias/controlAsistencia/registrarAsistencia.jsp").then((response) => {
swal({
title: '<strong>Registrar Asistencia</strong>',
html: response.data,
showCloseButton: true,
showCancelButton: true,
focusConfirm: false,
confirmButtonText: '<i class="fa fa-thumbs-up"></i> Registrar asistencia',
confirmButtonAriaLabel: 'Thumbs up, great!',
cancelButtonText: 'Cancelar',
cancelButtonAriaLabel: 'Thumbs down',
width: '30%',
onOpen: () => {
$("#spanNombres").html(data.policia_nombres);
$("#dpAsistencia").datepicker({
minDate: new Date(2000, 1 - 1, 1), maxDate: new Date(),
dateFormat: 'dd/mm/yy',
setDate: 'now',
changeMonth: true,
changeYear: true,
yearRange: '-18:+0',
onSelect: function () {
// $(this).valid();
}
});
$("#dpAsistencia").datepicker('setDate', data.fecha_entrada);
$("#cboTipoRegistro").change(cambioTipoRegistro);
}
});
});
mostrarModalRegistroAsistencia(data);
});
});
});
}
......
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