Commit 2d2ff29f by Billy Larru

editar tolerancias individuales

Se mueve el sweetalert al footer-body,
se agrega una nueva clase en el general.css para evitar el centrado en el body del modal.
parent 183bdf0a
......@@ -268,4 +268,8 @@ table.display tbody tr:hover td {
.col-centered{
float: none;
margin: 0 auto;
}
.align-auto {
text-align: -webkit-auto;
}
\ No newline at end of file
......@@ -40,6 +40,11 @@ const URI_ADMINISTRATIVOS_ESTADO_TOLERANCIA_INDIVIDUAL = "estadoTolerancias";
//</editor-fold>
swal.mixin({
buttonsStyling: false,
confirmButtonClass: 'btn btn-primary mr-5 ml-5',
cancelButtonClass: 'btn btn-secondary mr-5 ml-5'
});
$.extend($.fn.dataTable.defaults, {
// bSort: false,
......@@ -176,18 +181,18 @@ let getClosest = (elem, selector) => {
// Element.matches() polyfill
if (!Element.prototype.matches) {
Element.prototype.matches =
Element.prototype.matchesSelector ||
Element.prototype.mozMatchesSelector ||
Element.prototype.msMatchesSelector ||
Element.prototype.oMatchesSelector ||
Element.prototype.webkitMatchesSelector ||
function (s) {
var matches = (this.document || this.ownerDocument).querySelectorAll(s),
i = matches.length
while (--i >= 0 && matches.item(i) !== this) {
}
return i > -1
}
Element.prototype.matchesSelector ||
Element.prototype.mozMatchesSelector ||
Element.prototype.msMatchesSelector ||
Element.prototype.oMatchesSelector ||
Element.prototype.webkitMatchesSelector ||
function (s) {
var matches = (this.document || this.ownerDocument).querySelectorAll(s),
i = matches.length
while (--i >= 0 && matches.item(i) !== this) {
}
return i > -1
}
}
// Get closest match
for (; elem && elem !== document; elem = elem.parentNode) {
......@@ -302,15 +307,15 @@ function primeraLetraMayuscula(str) {
const makeDatatable = (
wrapName = ``,
forDatatable = {
data: [],
columns: [],
footerFilter: false,
footer: false
},
className = ``,
) => {
wrapName = ``,
forDatatable = {
data: [],
columns: [],
footerFilter: false,
footer: false
},
className = ``,
) => {
if (!wrapName) {
return {
message: `{wrapName} is empty`,
......@@ -385,7 +390,7 @@ const makeDatatable = (
}
$(`#${nameDatatable}`)
.DataTable(forDatatable);
.DataTable(forDatatable);
if (forDatatable.footerFilter) {
// DataTable
......@@ -397,8 +402,8 @@ const makeDatatable = (
$('input', this.footer()).on('keyup change', function () {
if (that.search() !== this.value) {
that
.search(this.value)
.draw();
.search(this.value)
.draw();
}
});
});
......@@ -461,7 +466,7 @@ const initSelect2 = (nodeIdentifier, URI, {title, subtitle} = {}) => {
page: params.page
};
},
processResults: function (data, params) {
processResults: function (data, params) {
// parse the results into the format expected by Select2
// since we are using custom formatting functions we do not need to
// alter the remote JSON data, except to indicate that infinite
......@@ -528,4 +533,6 @@ const generarFechas = (desde, hasta) => {
diaActual.add(1, 'days');
}
return fechas;
}
\ No newline at end of file
}
......@@ -68,9 +68,15 @@ function getColumns() {
let editar = "";
let eliminar = "";
if (data.estado === 1) {
eliminar = `<span style="cursor: pointer"><i class="eliminar fa fa-power-off text-danger-700"></i>&nbsp;&nbsp;</span>`;
} else {
eliminar = `<span style="cursor: pointer"><i class="eliminar fa fa-power-off text-success-700"></i>&nbsp;&nbsp;</span>`;
}
verdetalle = `<span style="cursor: pointer"><i class="verdetalle icon-list text-primary-700"></i>&nbsp;&nbsp;</span>`;
editar = `<span style="cursor: pointer"><i class="editar icon-pencil text-slate-800"></i>&nbsp;&nbsp;</span>`;
eliminar = `<span style="cursor: pointer"><i class="eliminar fa fa-power-off text-danger-700"></i>&nbsp;&nbsp;</span>`;
......@@ -183,28 +189,28 @@ const registrarNuevaTolerancia = () => {
};
ajaxWebService.post(URI_ADMINISTRATIVOS_TOLERANCIA_INDIVIDUAL, params)
.then((response) => {
debugger;
if (response.status) {
swal({
type: 'success',
title: '¡Tolerancia registrada exitosamente!',
showConfirmButton: false,
timer: 1500
})
listarToleranciasIndividuales();
} else {
swal({
type: 'success',
title: '¡No ha sido posible registrar la tolerancia!',
showConfirmButton: false,
timer: 1500
})
}
})
.catch((error) => {
console.log(error);
});
.then((response) => {
debugger;
if (response.status) {
swal({
type: 'success',
title: '¡Tolerancia registrada exitosamente!',
showConfirmButton: false,
timer: 1500
})
listarToleranciasIndividuales();
} else {
swal({
type: 'success',
title: '¡No ha sido posible registrar la tolerancia!',
showConfirmButton: false,
timer: 1500
})
}
})
.catch((error) => {
console.log(error);
});
};
......@@ -270,6 +276,106 @@ function addMinutes(time, minsToAdd) {
return D(mins % (24 * 60) / 60 | 0) + ':' + D(mins % 60);
}
const mostrarModalVerDetalleTolerancia = (data) => {
};
const mostrarModalEditarTolerancia = (data) => {
ajaxModal.get("administrativos/tolerancia/individual/editarTolerancia.jsp").then((response) => {
swal({
title: '<strong>Editar Tolerancia</strong>',
// type: 'info',
html: response.data,
showCloseButton: true,
showCancelButton: true,
focusConfirm: false,
confirmButtonText: '<i class="icon-checkmark2"></i> Editar tolerancia',
confirmButtonAriaLabel: 'Editar tolerancia',
cancelButtonText: '<i class="icon-cross3"></i>Cancelar',
cancelButtonAriaLabel: 'Thumbs down',
width: '30%',
customClass: 'swal2-overflow',
onOpen: () => {
inicializarInputsModalEditarTolerancia(data);
}
}).then((result) => {
if (result.value) {
editarTolerancia();
}
});
});
};
const mostrarModalEliminarTolerancia = (data) => {
let {id, estado} = data;
let titulo = "";
let textoConfirmacion = ""
let tituloOperacion = "";
if (estado == 1) {
titulo = 'Está seguro de eliminar la tolerancia?';
textoConfirmacion = 'Sí, eliminar!';
tituloOperacion = '¡Eliminado exitosamente!';
estado = 4;
} else {
titulo = 'Está seguro de activar?';
textoConfirmacion = 'Sí, activar!';
tituloOperacion = '¡Activado exitosamente!';
estado = 1;
}
swal({
title: titulo,
text: "",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: textoConfirmacion
}).then((result) => {
if (result.value) {
ajaxWebService.patch(`${URI_ADMINISTRATIVOS_TOLERANCIA_INDIVIDUAL}/${id}`, {estado}).then((response) => {
if (response.status) {
swal({
type: 'success',
title: tituloOperacion,
showConfirmButton: false,
timer: 1500
});
listarToleranciasIndividuales();
}
});
}
});
};
const editarTolerancia = () => {
swal({
type: 'success',
title: "Se actualizó la tolerancia exitosamente",
showConfirmButton: false,
timer: 1500
});
};
const inicializarInputsModalEditarTolerancia = (data) => {
let nombresCompletos = `${data.trabajador_apellidos} ${data.trabajador_nombres}`;
$("#spanNombres").text(nombresCompletos);
$("#txtHorarioLV").val(data.horarioLV);
$("#txtToleranciaLV").val(data.toleranciaLV);
$("#txtNuevoHorarioLV").val(data.nuevoHorarioLV);
$("#txtHorarioSabado").val(data.horarioSabado);
$("#txtToleranciaSabado").val(data.toleranciaSabado);
$("#txtNuevoHorarioSabado").val(data.nuevoHorarioSabado);
initDatePicker("#dpFechaInicio", "#dpFechaFin");
$("#dpFechaInicio").val(data.fechaInicio);
$("#dpFechaFin").val(data.fechaFin);
$("#txtObservacion").val(data.observacion);
};
function listarToleranciasIndividuales(objParams = {}){
ajaxWebService.get(URI_ADMINISTRATIVOS_TOLERANCIA_INDIVIDUAL, objParams).then((response) => {
let columns = getColumns();
......@@ -278,19 +384,27 @@ function listarToleranciasIndividuales(objParams = {}){
let classNameForDatatable = `display table table-bordered`;
makeDatatable(
wrapsNameDatatable,
{
data: response.data,
columns,
},
classNameForDatatable,
).then((nodes) => {
wrapsNameDatatable,
{
data: response.data,
columns,
},
classNameForDatatable,
).then((nodes) => {
nodes.container
.off()
.on("click", ".registrar", function () {
let data = nodes.datatable.DataTable().row($(this).parents("tr")).data();
// mostrarModalRegistro(data);
});
.off()
.on("click", ".verdetalle", function () {
let data = nodes.datatable.DataTable().row($(this).parents("tr")).data();
mostrarModalVerDetalleTolerancia(data);
})
.on("click", ".editar", function () {
let data = nodes.datatable.DataTable().row($(this).parents("tr")).data();
mostrarModalEditarTolerancia(data);
})
.on("click", ".eliminar", function () {
let data = nodes.datatable.DataTable().row($(this).parents("tr")).data();
mostrarModalEliminarTolerancia(data);
});
});
});
......
<div class="panel-body">
<form id="frm" onsubmit="return false;" autocomplete="off">
<div class="row">
<div class="form-group col-md-12">
<label>Personal</label>
<span class="label border-left-primary label-striped form-control" id="spanNombres"></span>
</div>
</div>
<div class="row">
<div class="form-group col-md-4">
<label>Horario LV</label>
<input type="time" class="form-control text-center" id="txtHorarioLV" disabled>
</div>
<div class="form-group col-md-4">
<label>Tolerancia(min)</label>
<input type="number" min="0" value="0" class="form-control text-center" id="txtToleranciaLV">
</div>
<div class="form-group col-md-4">
<label>Nuevo Horario LV</label>
<input type="time" min="00:00" max="23:59" class="form-control text-center" id="txtNuevoHorarioLV">
</div>
</div>
<div class="row">
<div class="form-group col-md-4">
<label>Horario Sabado</label>
<input type="time" class="form-control text-center" id="txtHorarioSabado" disabled>
</div>
<div class="form-group col-md-4">
<label>Tolerancia(min)</label>
<input type="number" min="0" value="0" class="form-control text-center" id="txtToleranciaSabado">
</div>
<div class="form-group col-md-4">
<label>Nuevo Horario Sabado</label>
<input type="time" min="00:00" max="23:59" class="form-control text-center" id="txtNuevoHorarioSabado">
</div>
</div>
<div class="row">
<div class="form-group col-md-6">
<label>Fecha Inicio</label>
<div class="input-group">
<span class="input-group-addon"><i class="icon-calendar"></i></span>
<input type="text" class="form-control" id="dpFechaInicio">
</div>
</div>
<div class="form-group col-md-6">
<label>Fecha Fin</label>
<div class="input-group">
<span class="input-group-addon"><i class="icon-calendar"></i></span>
<input type="text" class="form-control" id="dpFechaFin">
</div>
</div>
</div>
<div class="row">
<div class="form-group col-md-12">
<label>Observacion</label>
<textarea name="txtObservacion" id="txtObservacion" cols="30" rows="4" class="form-control"></textarea>
</div>
</div>
</form>
</div>
\ No newline at end of file
......@@ -57,5 +57,5 @@
<textarea name="txtObservacion" id="txtObservacion" cols="30" rows="4" class="form-control"></textarea>
</div>
</div>
</div>
</form>
\ No newline at end of file
</form>
</div>
\ No newline at end of file
......@@ -33,6 +33,7 @@
<!--axios-->
<script src="../plantilla/assets/js/plugins/tables/datatables/datatables.min.js" type="text/javascript"></script>
<script src="../js/lib/axios.min.js" type="text/javascript"></script>
<script src="../js/lib/sweetalert2.min.js" type="text/javascript"></script>
<!-- /Generales -->
<script src="../js/general.js" type="text/javascript"></script>
......
......@@ -2,91 +2,91 @@
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@include file="templates/header.jsp" %>
<head>
<%@include file="templates/header.jsp" %>
<!--template-core-->
<!--css de la pagina-->
<!--css de la pagina-->
<link href="../css/lib/sweetalert2.min.css" rel="stylesheet" type="text/css"/>
<!--css-->
</head>
<body>
<%@include file="templates/header-body.jsp" %>
<!--css-->
</head>
<body>
<%@include file="templates/header-body.jsp" %>
<!-- content -->
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-primary">
<div class="panel-heading">
<h5 class="panel-title">Busqueda</h5>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h5 class="panel-title">Busqueda</h5>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-6 form-group">
<label>Personal</label>
<select class="select-search form-control" id="cboPersonalFiltro">
</select>
</div>
<div class="col-md-6 form-group">
<label>Sede</label>
<select id="cboSedesFiltro" class="select-search form-control">
<div class="panel-body">
<div class="row">
<div class="col-md-6 form-group">
<label>Personal</label>
<select class="select-search form-control" id="cboPersonalFiltro">
</select>
</div>
<div class="col-md-6 form-group">
<label>Sede</label>
<select id="cboSedesFiltro" class="select-search form-control">
</select>
</div>
</div>
</select>
</div>
</div>
<div class="row">
<div class="col-md-6 form-group">
<label>Fecha Inicio</label>
<div class="input-group">
<span class="input-group-addon"><i class="icon-calendar"></i></span>
<input type="text" class="form-control" name="dpFechaInicioFiltro" id="dpFechaInicioFiltro">
</div>
</div>
<div class="col-md-6 form-group">
<label>Fecha Fin</label>
<div class="input-group">
<span class="input-group-addon"><i class="icon-calendar"></i></span>
<input type="text" class="form-control" name="dpFechaFinFiltro" id="dpFechaFinFiltro">
</div>
</div>
</div>
</div>
<div class="panel-footer">
<div class="text-center">
<button class="btn btn-primary" id="btnAplicarFiltro"><i class="icon-eye4"></i> Aplicar filtro</button>&nbsp;
<button class="btn btn-primary" id="btnMostrarTodo"><i class="icon-eye4"></i> Mostrar Todo</button>&nbsp;
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 form-group">
<label>Fecha Inicio</label>
<div class="input-group">
<span class="input-group-addon"><i class="icon-calendar"></i></span>
<input type="text" class="form-control" name="dpFechaInicioFiltro" id="dpFechaInicioFiltro">
</div>
</div>
<div class="col-md-6 form-group">
<label>Fecha Fin</label>
<div class="input-group">
<span class="input-group-addon"><i class="icon-calendar"></i></span>
<input type="text" class="form-control" name="dpFechaFinFiltro" id="dpFechaFinFiltro">
</div>
</div>
</div>
</div>
<div class="panel-footer">
<div class="text-center">
<button class="btn btn-primary" id="btnAplicarFiltro"><i class="icon-eye4"></i> Aplicar filtro</button>&nbsp;
<button class="btn btn-primary" id="btnMostrarTodo"><i class="icon-eye4"></i> Mostrar Todo</button>&nbsp;
</div>
</div>
</div>
</div>
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-primary card-3" style="margin-top: 30px">
<div class="panel-heading" style="padding: 8px 15px">
<h6 class="panel-title" style="font-size: 15px; font-family: inherit">LISTADO DE TOLERANCIAS INDIVIDUALES</h6>
<div class="heading-elements">
<button type="button" id="btnNuevaTolerancia" class="btn bg-slate border-slate-600 btn-xs"><i class="glyphicon glyphicon-plus"></i>&nbsp; Nueva tolerancia</button>
</div>
</div>
<div id="divDatatable">
</div>
</div>
</div>
<div class="panel panel-primary card-3" style="margin-top: 30px">
<div class="panel-heading" style="padding: 8px 15px">
<h6 class="panel-title" style="font-size: 15px; font-family: inherit">LISTADO DE TOLERANCIAS INDIVIDUALES</h6>
<div class="heading-elements">
<button type="button" id="btnNuevaTolerancia" class="btn bg-slate border-slate-600 btn-xs"><i class="glyphicon glyphicon-plus"></i>&nbsp; Nueva tolerancia</button>
</div>
</div>
<div id="divDatatable">
</div>
</div>
</div>
<!-- / content -->
<%@include file="templates/footer-body.jsp"%>
<!--js de la pagina-->
<%@include file="templates/footer-body.jsp"%>
<!--js de la pagina-->
<script src="../plantilla/assets/js/core/libraries/jquery_ui/widgets.min.js" type="text/javascript"></script>
<script src="../plantilla/assets/js/plugins/ui/moment/moment.min.js" type="text/javascript"></script>
<script src="../plantilla/assets/js/plugins/ui/moment/moment.min.js" type="text/javascript"></script>
<script src="../plantilla/assets/js/plugins/pickers/datepicker.js" type="text/javascript"></script>
<script src="../js/lib/bootstrap-select.min.js" type="text/javascript"></script>
<script src="../js/lib/bootstrap-select.min.js" type="text/javascript"></script>
<script src="../plantilla/assets/js/plugins/forms/selects/select2.min.js"></script>
<script src="../js/lib/lodash.js" type="text/javascript"></script>
<script src="../js/lib/sweetalert2.min.js" type="text/javascript"></script>
<script src="../js/lib/lodash.js" type="text/javascript"></script>
<script src="../js/pages/tolerancia_individual.js" type="text/javascript"></script>
<!--js-->
<!--js-->
</body>
</body>
</html>
\ No newline at end of file
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