Merge branch 'main' into feat/wiki

This commit is contained in:
amazuecos
2025-02-22 07:26:52 +01:00
83 changed files with 2851 additions and 867 deletions

View File

@ -26,6 +26,19 @@ export const initAutonumeric = () => {
});
}
})
$("span.autonumeric-decimal").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if (!autoNumericInstance) {
new AutoNumeric(this, {
digitGroupSeparator: ".",
decimalCharacter: ",",
allowDecimalPadding : 'floats',
decimalPlaces: $(this).data('decimal-places'),
unformatOnSubmit: true,
});
}
})
// $(':input[type="number"]').each(function(){
// $(this).attr('type','text')
// let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)

View File

@ -1,37 +1,37 @@
export const alertConfirmationDelete = (title,type="primary") => {
return Swal.fire({
title: '¿Está seguro?',
text: "Esta acción es irreversible.",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Sí',
cancelButtonText: 'Cancelar',
customClass: {
confirmButton: 'btn btn-danger me-1',
cancelButton: 'btn btn-label-secondary'
},
buttonsStyling: false
})
}
export const alertSuccessMessage = (title,type="primary") => {
return Swal.fire({
showCancelButton: false,
showConfirmButton : false,
title: title,
text: title,
icon: "success",
timer : 2000
export const alertConfirmationDelete = (title, type = "primary") => {
return Swal.fire({
title: '¿Está seguro?',
text: "Esta acción es irreversible.",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Sí',
cancelButtonText: 'Cancelar',
customClass: {
confirmButton: 'btn btn-danger me-1',
cancelButton: 'btn btn-label-secondary'
},
buttonsStyling: false
})
}
export const alertWarningMessage = (title,message,type="primary") => {
return Swal.fire({
export const alertSuccessMessage = (title, type = "primary") => {
return Swal.fire({
showCancelButton: false,
showConfirmButton: false,
title: title,
text: title,
icon: "success",
timer: 2000
})
}
export const alertWarningMessage = (title, message, type = "primary") => {
return Swal.fire({
title: title,
text: message,
icon: "warning",
@ -40,4 +40,27 @@ export const alertWarningMessage = (title,message,type="primary") => {
},
buttonsStyling: false
})
}
export const toastPresupuestoSummary = (value, target = 'body') => {
return Swal.mixin({
toast: true,
position: 'bottom-end',
html: `
<div class="d-flex flex-column p-0 m-0">
<p class="m-0">Total presupuesto</p>
<span class="badge badge-label-primary fs-small">${value}</span>
</div>`,
customClass: {
popup: 'bg-primary text-white',
},
target: target,
width : "200px",
padding : '1px',
allowEscapeKey: false,
showConfirmButton: false,
timer: 0,
timerProgressBar: false,
stopKeydownPropagation: false,
})
}

View File

@ -12,20 +12,31 @@ class previewFormas {
this.lomo = datos.lomo;
this.lomoSobrecubierta = datos.lomoSobrecubierta;
if (datos.solapas == undefined || datos.solapas == null || datos.solapas == false) {
let solapaTemp = null;
let solapaSobrecubiertaTemp = null;
if(typeof this.lomo === 'function') {
solapaTemp = datos.solapas ? datos.solapas() : null;
solapaSobrecubiertaTemp = datos.solapas_sobrecubierta ? datos.solapas_sobrecubierta(): null;
}
else {
solapaTemp = datos.solapas? datos.solapas : null;
solapaSobrecubiertaTemp = datos.solapas_sobrecubierta? datos.solapas_sobrecubierta : null;
}
if (solapaTemp == undefined || solapaTemp == null || solapaTemp == false) {
this.solapa = 0;
this.offsetSolapa = 0.0;
}
else {
this.solapa = datos.solapas;
this.solapa = solapaTemp;
this.offsetSolapa = 3.0;
}
if (datos.solapas_sobrecubierta == undefined || datos.solapas_sobrecubierta == null || datos.solapas_sobrecubierta == false) {
if (solapaSobrecubiertaTemp == undefined || solapaSobrecubiertaTemp == null || solapaSobrecubiertaTemp == false) {
this.solapas_sobrecubierta = 0;
this.offsetSolapa_sobrecubierta = 0.0;
}
else {
this.solapa_sobrecubierta = datos.solapas_sobrecubierta;
this.solapa_sobrecubierta = solapaSobrecubiertaTemp;
this.offsetSolapa_sobrecubierta = 3.0;
}
this.lomoRedondo = datos.lomoRedondo;
@ -45,14 +56,33 @@ class previewFormas {
this.lomo = datos.lomo;
this.lomoSobrecubierta = datos.lomoSobrecubierta;
if (datos.solapas == undefined || datos.solapas == null || datos.solapas == false) {
let solapaTemp = null;
let solapaSobrecubiertaTemp = null;
if(typeof this.lomo === 'function') {
solapaTemp = datos.solapas ? datos.solapas() : null;
solapaSobrecubiertaTemp = datos.solapas_sobrecubierta ? datos.solapas_sobrecubierta(): null;
}
else {
solapaTemp = datos.solapas? datos.solapas : null;
solapaSobrecubiertaTemp = datos.solapas_sobrecubierta? datos.solapas_sobrecubierta : null;
}
if (solapaTemp == undefined || solapaTemp == null || solapaTemp == false) {
this.solapa = 0;
this.offsetSolapa = 0.0;
}
else {
this.solapa = datos.solapas;
this.solapa = solapaTemp;
this.offsetSolapa = 3.0;
}
if (solapaSobrecubiertaTemp == undefined || solapaSobrecubiertaTemp == null || solapaSobrecubiertaTemp == false) {
this.solapas_sobrecubierta = 0;
this.offsetSolapa_sobrecubierta = 0.0;
}
else {
this.solapa_sobrecubierta = solapaSobrecubiertaTemp;
this.offsetSolapa_sobrecubierta = 3.0;
}
this.lomoRedondo = datos.lomoRedondo;
}
@ -486,7 +516,6 @@ class previewFormas {
this.ancho = this.ancho();
this.alto = this.alto();
this.lomoRedondo = this.lomoRedondo();
this.solapa = this.solapa();
}
let styleCotas = { size: 12, family: 'Public Sans' };

View File

@ -404,7 +404,9 @@ class PresupuestoAdminEdit {
}
// Funciones para detectar cambios en el formulario
this.#checkChangesPresupuesto();
setTimeout(() => {
this.#checkChangesPresupuesto();
}, 500);
$('#bc-save').on("click", function () {
showBreadCrumbSaveButton(false);
$('#saveForm').trigger('click');
@ -530,45 +532,57 @@ class PresupuestoAdminEdit {
#checkChangesPresupuesto() {
const self = this;
// Detectar cambios en inputs de texto
$('input[type="text"]').on('change', function () {
showBreadCrumbSaveButton(true);
if (!self.cargandoPresupuesto)
showBreadCrumbSaveButton(true);
});
// Detectar cambios en inputs de texto
$('input[type="number"]').on('change', function () {
showBreadCrumbSaveButton(true);
if (!self.cargandoPresupuesto)
showBreadCrumbSaveButton(true);
});
// Detectar cambios en select
$('select').on('change', function () {
showBreadCrumbSaveButton(true);
if (!self.cargandoPresupuesto)
showBreadCrumbSaveButton(true);
});
$('.select2bs').on('change', function (e) {
showBreadCrumbSaveButton(true);
if (!self.cargandoPresupuesto)
showBreadCrumbSaveButton(true);
});
// Detectar cambios en checkboxes
$('input[type="checkbox"]').change(function () {
showBreadCrumbSaveButton(true);
if (!self.cargandoPresupuesto)
showBreadCrumbSaveButton(true);
});
// Detectar cambios en textareas
$('textarea').on('input', function () {
showBreadCrumbSaveButton(true);
if (!self.cargandoPresupuesto)
showBreadCrumbSaveButton(true);
});
// Detectar cambios en otros tipos de input
$('input[type="radio"]').change(function () {
showBreadCrumbSaveButton(true);
if (!self.cargandoPresupuesto)
showBreadCrumbSaveButton(true);
});
// Detectar cambios en otros tipos de input
$('input:not([type])').on('input', function () {
showBreadCrumbSaveButton(true);
if (!self.cargandoPresupuesto)
showBreadCrumbSaveButton(true);
});
}
downloadPreviewImage() {
$(document).on("click", ".download-shape", (event) => {
let parentDiv = $(event.currentTarget).parent().parent();

View File

@ -1045,7 +1045,7 @@ class LineasPresupuesto {
data.totalClicksPedido = isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)
data.totalTinta = isNaN(parseFloat(row.precio_tinta)) ? "" : parseFloat(row.precio_tinta).toFixed(2)
data.totalImpresion = isNaN(parseFloat(row.precio_click_pedido + row.precio_tinta + data.totalCorte)) ? "" : parseFloat(row.precio_click_pedido + row.precio_tinta + data.totalCorte).toFixed(2)
data.totalImpresion = isNaN(parseFloat(row.precio_click_pedido) + parseFloat(row.precio_tinta) + parseFloat(row.total_corte)) ? "" : (parseFloat(row.precio_click_pedido) + parseFloat(row.precio_tinta) + parseFloat(row.total_corte)).toFixed(2)
data.gTintaNegroPed = isNaN(parseFloat(row.peso_gotas_negro_pedido)) ? "" : parseFloat(row.peso_gotas_negro_pedido).toFixed(2)
data.gTintaCyanPed = isNaN(parseFloat(row.peso_gotas_cyan_pedido)) ? "" : parseFloat(row.peso_gotas_cyan_pedido).toFixed(2)
@ -1553,7 +1553,7 @@ class LineasPresupuesto {
datos.paginas_color = parseInt($('#compPaginasColor').val())
}
else {
let paginas_color = isNaN(parseInt($('#lp_rot_color_numPagColor').val())) ? input_data.paginas : parseInt($('#lp_rot_color_numPagColor').val())
let paginas_color = isNaN(parseInt($('#lp_rot_color_numPagColor').val())) ? 0 : parseInt($('#lp_rot_color_numPagColor').val())
datos.paginas_negro = input_data.paginas - paginas_color;
datos.paginas_color = paginas_color;
}

View File

@ -1,3 +1,5 @@
import { toastPresupuestoSummary } from "../../../components/alerts/sweetAlert.js";
class Resumen {
constructor() {
@ -7,7 +9,7 @@ class Resumen {
init() {
const self = this;
this.toastPresupuestoTotal = null
$(".update-totales").on("change", function () {
self.updateTotales(true, true, true)
});
@ -16,6 +18,7 @@ class Resumen {
await self.updateTotales();
$(document).trigger('update-totales-completed');
});
$("#totalDespuesDecuento").on('change',this.updateToastSummary.bind(this))
}
cargar(resumen) {
@ -44,7 +47,7 @@ class Resumen {
$("#totalAntesDescuento").text(resumen.total_antes_descuento + "€" || "0€");
$("#total_descuentoPercent").val(resumen.total_descuentoPercent || "0");
$("#descuentoTotal").text(resumen.total_descuento + "€" || "0€");
$("#totalDespuesDecuento").text(resumen.total_presupuesto + "€" || "0€");
$("#totalDespuesDecuento").text(resumen.total_presupuesto + "€" || "0€").trigger("change")
$("#precioUnidadPresupuesto").text(resumen.total_precio_unidad + "€" || "0€");
$("#factor").text(resumen.total_factor || "0");
$("#factor_ponderado").text(resumen.total_factor_ponderado || "0");
@ -52,7 +55,7 @@ class Resumen {
if (resumen.total_aceptado !== undefined) {
$("#totalAceptado").val(resumen.total_aceptado + "€" || "0€");
}
}
update() {
@ -101,6 +104,7 @@ class Resumen {
let sumForFactorPonderado = 0.0;
let costeMaquinaHoras = 0.0;
let margenPorHoras = 0.0;
if (updateLP) {
@ -113,31 +117,31 @@ class Resumen {
totalPapel += parseFloat($('#' + rowData.row_id + '_totalPapelPedido').val())
margenPapel += parseFloat($('#' + rowData.row_id + '_margenPapelPedido').val())
sumForFactor += parseFloat($('#' + rowData.row_id + '_totalPapelPedido').val())
sumForFactor -= parseFloat($('#' + rowData.row_id + '_margenPapelPedido').val())
//sumForFactor += parseFloat($('#' + rowData.row_id + '_totalPapelPedido').val())
//sumForFactor -= parseFloat($('#' + rowData.row_id + '_margenPapelPedido').val())
}
if (rowData.check_impresion_total) {
totalImpresion += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
costeMaquinaHoras += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
margenPorHoras += parseFloat($('#' + rowData.row_id + '_margenImpresion').val())
totalImpresion += parseFloat($('#' + rowData.row_id + '_totalClicks').val())
margenImpresion += parseFloat($('#' + rowData.row_id + '_margenClicks').val())
sumForFactor += parseFloat($('#' + rowData.row_id + '_totalClicks').val())
//sumForFactor += parseFloat($('#' + rowData.row_id + '_totalClicks').val())
if (rowData.maquinaTipo == 'inkjet') {
totalImpresion += parseFloat(rowData.totalTinta)
totalImpresion += parseFloat(rowData.totalCorte)?? 0;
sumForFactor += (parseFloat(rowData.totalTinta) + parseFloat(rowData.totalCorte))
//sumForFactor += (parseFloat(rowData.totalTinta) + parseFloat(rowData.totalCorte))
}
sumForFactor -= parseFloat($('#' + rowData.row_id + '_margenClicks').val())
//sumForFactor -= parseFloat($('#' + rowData.row_id + '_margenClicks').val())
if (!isNaN(parseFloat($('#' + rowData.row_id + '_totalTinta').val()))) {
/*if (!isNaN(parseFloat($('#' + rowData.row_id + '_totalTinta').val()))) {
totalImpresion += parseFloat($('#' + rowData.row_id + '_totalTinta').val())
sumForFactor += parseFloat($('#' + rowData.row_id + '_totalTinta').val())
}
}*/
}
})
}
@ -145,7 +149,10 @@ class Resumen {
totalImpresion -= parseFloat(margenImpresion);
totalPapel -= parseFloat(margenPapel);
margenImpresion += parseFloat(margenPorHoras);
margenImpresion += parseFloat(margenPorHoras) + parseFloat(costeMaquinaHoras);
sumForFactor += totalImpresion;
sumForFactor += totalPapel;
let porcentajeMargenPapel = isNaN(margenPapel / (totalPapel) * 100.0) ? 0 : margenPapel / (totalPapel) * 100.0
$('#porcentajeMargenPapel').text(porcentajeMargenPapel.toFixed(0) + '%')
@ -211,7 +218,7 @@ class Resumen {
$('#tableOfServiciosExtra').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
let rowData = this.data();
let total_servicio = self.roundToTwoDecimals(parseFloat(rowData.precio));
let coste_servicio = self.roundToTwoDecimals(parseFloat(rowData.coste));
let coste_servicio = self.roundToTwoDecimals(parseFloat(rowData.margen));
totalServicios += total_servicio
margenServicios += total_servicio - coste_servicio;
});
@ -300,7 +307,7 @@ class Resumen {
$('#descuentoTotal').attr('val', (totalDescuento).toFixed(2))
$('#totalDespuesDecuento').attr('val', (totalPresupuesto).toFixed(2))
$('#precioUnidadPresupuesto').attr('val', (precioUnidad).toFixed(4))
$('#totalDespuesDecuento').trigger("change")
$('#factor').text(this.addSeparatorsNF(((totalPresupuesto - totalEnvios - margenEnvios) / sumForFactor).toFixed(2), ".", ",", "."))
$('#factor').attr('val', ((totalPresupuesto - totalEnvios - margenEnvios) / sumForFactor).toFixed(2))
@ -313,37 +320,37 @@ class Resumen {
getData(){
let data = {
'total_coste_papel': $('#totalCostePapel').text().replace('€', ''),
'total_margen_papel': $('#margenPapel').text().replace('€', ''),
'total_margenPercent_papel': $('#porcentajeMargenPapel').text().replace('%', ''),
'total_coste_papel': $('#totalCostePapel').text().replace('€', '').replace('.', '').replace(',', '.'),
'total_margen_papel': $('#margenPapel').text().replace('€', '').replace('.', '').replace(',', '.'),
'total_margenPercent_papel': $('#porcentajeMargenPapel').text().replace('%', '').replace('.', '').replace(',', '.'),
'total_coste_impresion': $('#totalCosteImpresion').text().replace('€', ''),
'total_margen_impresion': $('#margenImpresion').text().replace('€', ''),
'total_margenPercent_impresion': $('#porcentajeMargenImpresion').text().replace('%', ''),
'total_coste_impresion': $('#totalCosteImpresion').text().replace('€', '').replace('.', '').replace(',', '.'),
'total_margen_impresion': $('#margenImpresion').text().replace('€', '').replace('.', '').replace(',', '.'),
'total_margenPercent_impresion': $('#porcentajeMargenImpresion').text().replace('%', '').replace('.', '').replace(',', '.'),
'total_coste_servicios': $('#totalServicios').text().replace('€', ''),
'total_margen_servicios': $('#margenServicios').text().replace('€', ''),
'total_margenPercent_servicios': $('#porcentajeMargenServicios').text().replace('%', ''),
'total_coste_servicios': $('#totalServicios').text().replace('€', '').replace('.', '').replace(',', '.'),
'total_margen_servicios': $('#margenServicios').text().replace('€', '').replace('.', '').replace(',', '.'),
'total_margenPercent_servicios': $('#porcentajeMargenServicios').text().replace('%', '').replace('.', '').replace(',', '.'),
'total_coste_envios': $('#totalEnvios').text().replace('€', ''),
'total_margen_envios': $('#margenEnvios').text().replace('€', ''),
'total_coste_envios': $('#totalEnvios').text().replace('€', '').replace('.', '').replace(',', '.'),
'total_margen_envios': $('#margenEnvios').text().replace('€', '').replace('.', '').replace(',', '.'),
'total_costes': $('#totalCostes').text().replace('€', ''),
'total_margenes': $('#totalMargenes').text().replace('€', ''),
'total_costes': $('#totalCostes').text().replace('€', '').replace('.', '').replace(',', '.'),
'total_margenes': $('#totalMargenes').text().replace('€', '').replace('.', '').replace(',', '.'),
'total_antes_descuento': $('#totalAntesDescuento').text().replace('€', ''),
'total_descuento': $('#descuentoTotal').text().replace('€', ''),
'total_descuentoPercent': $('#total_descuentoPercent').val().replace('€', ''),
'total_presupuesto': $('#totalDespuesDecuento').text().replace('€', ''),
'total_precio_unidad': $('#precioUnidadPresupuesto').text().replace('€', ''),
'total_antes_descuento': $('#totalAntesDescuento').text().replace('€', '').replace('.', '').replace(',', '.'),
'total_descuento': $('#descuentoTotal').text().replace('€', '').replace('.', '').replace(',', '.'),
'total_descuentoPercent': $('#total_descuentoPercent').val().replace('€', '').replace('.', '').replace(',', '.'),
'total_presupuesto': $('#totalDespuesDecuento').text().replace('€', '').replace('.', '').replace(',', '.'),
'total_precio_unidad': $('#precioUnidadPresupuesto').text().replace('€', '').replace('.', '').replace(',', '.'),
'total_factor': $('#factor').text().replace(/,/g, '.'),
'total_factor_ponderado': $('#factor_ponderado').text().replace(/,/g, '.'),
'total_factor_ponderado': $('#factor_ponderado').text().replace(/,/g, '.')
};
if($('#confirmar_presupuesto').prop('checked')){
data.confirmar = '1';
data.total_aceptado = $('#totalDespuesDecuento').text().replace('€', '');
data.total_aceptado = $('#totalDespuesDecuento').text().replace('€', '').replace('.', '').replace(',', '.');
}
return data;
@ -352,6 +359,25 @@ class Resumen {
roundToTwoDecimals(num) {
return parseFloat(num.toFixed(2));
}
updateToastSummary()
{
if(this.toastPresupuestoTotal){
this.toastPresupuestoTotal.close()
}
this.toastPresupuestoTotal = toastPresupuestoSummary($("#totalDespuesDecuento").text() ?? 0)
this.toastPresupuestoTotal.fire().then((result) => {
if(result.isDismissed && result.dismiss == 'close'){
this.updateToastSummary()
$('html, body').animate(
{
scrollTop: $("#totalDespuesDecuento").offset().top
},
1000)
}
})
}
}
export default Resumen;

View File

@ -0,0 +1,309 @@
import Table from '../../components/table.js';
import Ajax from '../../components/ajax.js';
class Ticket {
constructor() {
// check if url includes "add"
this.action = 'list';
if (window.location.href.includes("add"))
this.action = "add";
else if (window.location.href.includes("edit"))
this.action = "edit";
this.table = null;
this.init();
}
init() {
if (this.action == "edit") {
$('.gallery-img').on('click', function () {
let imageUrl = $(this).data('src'); // Obtiene la URL de la imagen
$('#modalImage').attr('src', imageUrl); // Cambia la imagen en el modal
$('#imageModal').modal('show'); // Muestra el modal
});
}
else if (this.action == "list") {
this.#initDatatable();
}
}
#initDatatable() {
const self = this;
self.#headerSearcher();
const actions = ['view'];
let columns = [];
if (window.userType == 1) {
columns = [
{ 'data': 'id' },
{
'data': 'categoria_id',
render: function (data, type, row) {
return window.language.Tickets[row.categoria];
}
},
{
'data': 'seccion_id',
render: function (data, type, row) {
return window.language.Tickets[row.seccion];
}
},
{
'data': 'estado_id',
render: function (data, type, row) {
return window.language.Tickets[row.estado];
}
},
{
'data': 'prioridad',
render: function (data, type, row) {
return window.language.Tickets[data];
},
},
{ 'data': 'titulo' },
{
'data': 'usuario_id',
render: function (data, type, row) {
return row.usuario;
},
},
{
'data': 'user_soporte_id',
render: function (data, type, row) {
return row.user_soporte;
},
},
{ 'data': 'created_at' },
];
}
else {
columns = [
{ 'data': 'id' },
{
'data': 'categoria_id',
render: function (data, type, row) {
return window.language.Tickets[row.categoria];
}
},
{
'data': 'seccion_id',
render: function (data, type, row) {
return window.language.Tickets[row.seccion];
}
},
{
'data': 'estado_id',
render: function (data, type, row) {
return window.language.Tickets[row.estado];
}
},
{ 'data': 'titulo' },
{ 'data': 'created_at' },
];
}
this.table = new Table(
$('#tableOfTickets'),
'tickets',
'/soporte/ticketlist',
columns,
);
this.table.init({
actions: actions,
buttonsExport: true,
});
this.table.table.on('init.dt', function () {
self.table.table.page.len(100).draw();
self.table.table.draw();
});
this.table.setEditCallback(function (id) {
window.location.href = '/soporte/edit/' + id;
})
}
#headerSearcher() {
const self = this;
$('#tableOfTickets thead tr.search-header').remove();
let searchRow = $('#tableOfTickets thead tr').first().clone(true);
searchRow.addClass('search-header').appendTo('#tableOfTickets thead');
$('#tableOfTickets thead tr:eq(1) th').each(function (i) {
if (!$(this).hasClass("noFilter")) {
var title = $(this).text();
if (title == window.language.Tickets.fechaCreacion) {
$(this).html('<input id="bs-rangepicker-range" type="text" class="form-control " style="min-width:100px;max-width:120px;font-size:0.8rem !important;" />');
var bsRangePickerRange = $('#bs-rangepicker-range')
bsRangePickerRange.daterangepicker({
ranges: {
[window.language.datePicker.hoy]: [moment(), moment()],
[window.language.datePicker.ayer]: [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
[window.language.datePicker.ultimos7]: [moment().subtract(6, 'days'), moment()],
[window.language.datePicker.ultimos30]: [moment().subtract(29, 'days'), moment()],
[window.language.datePicker.esteMes]: [moment().startOf('month'), moment().endOf('month')],
[window.language.datePicker.ultimoMes]: [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
},
opens: 'right',
language: $('html').attr('lang'),
"locale": {
"customRangeLabel": window.language.datePicker.personalizar,
"format": "YYYY-MM-DD",
"separator": " ",
"applyLabel": window.language.datePicker.aplicar,
"cancelLabel": window.language.datePicker.limpiar,
},
"alwaysShowCalendars": true,
autoUpdateInput: false,
});
bsRangePickerRange.on('apply.daterangepicker', function (ev, picker) {
$(this).val(picker.startDate.format('YYYY-MM-DD') + ' ' + picker.endDate.format('YYYY-MM-DD'));
self.table.table
.column(i)
.search(this.value)
.draw();
});
bsRangePickerRange.on('cancel.daterangepicker', function (ev, picker) {
$(this).val('');
self.table.table
.column(i)
.search(this.value)
.draw();
});
}
else if (title == window.language.Tickets.tipo) {
// Agregar un selector en la tercera columna
$(this).html('<select class="form-control" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>');
// Agregar opciones al selector
var selectorTipo = $('select', this);
selectorTipo.append('<option value="">Todos</option>'); // Opción vacía
selectorTipo.append('<option value="errores">' + window.language.Tickets.errores + '</option>');
selectorTipo.append('<option value="consultas">' + window.language.Tickets.consultas + '</option>');
selectorTipo.append('<option value="sugerencias">' + window.language.Tickets.sugerencias + '</option>');
selectorTipo.on('change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
self.table.table.column(i).search(val).draw();
});
}
else if (title == window.language.Tickets.seccion) {
// Agregar un selector en la tercera columna
$(this).html('<select class="form-control" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>');
// Agregar opciones al selector
var selectorSeccion = $('select', this);
selectorSeccion.append('<option value="">Todos</option>'); // Opción vacía
selectorSeccion.append('<option value="presupuestos">' + window.language.Tickets.presupuestos + '</option>');
selectorSeccion.append('<option value="pedidos">' + window.language.Tickets.pedidos + '</option>');
selectorSeccion.append('<option value="facturacion">' + window.language.Tickets.facturacion + '</option>');
selectorSeccion.append('<option value="logistica">' + window.language.Tickets.logistica + '</option>');
selectorSeccion.append('<option value="configuracion">' + window.language.Tickets.configuracion + '</option>');
selectorSeccion.append('<option value="general">' + window.language.Tickets.general + '</option>');
selectorSeccion.on('change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
self.table.table.column(i).search(val).draw();
});
}
else if (title == window.language.Tickets.estado) {
// Agregar un selector en la tercera columna
$(this).html('<select class="form-control" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>');
// Agregar opciones al selector
var selectorEstado = $('select', this);
selectorEstado.append('<option value="">Todos</option>'); // Opción vacía
selectorEstado.append('<option value="abierto">' + window.language.Tickets.abierto + '</option>');
selectorEstado.append('<option value="en_proceso">' + window.language.Tickets.en_proceso + '</option>');
selectorEstado.append('<option value="resuelto">' + window.language.Tickets.resuelto + '</option>');
selectorEstado.on('change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
self.table.table.column(i).search(val).draw();
});
}
else if (title == window.language.Tickets.prioridad) {
// Agregar un selector en la tercera columna
$(this).html('<select class="form-control" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>');
// Agregar opciones al selector
var selectorPrioridad = $('select', this);
selectorPrioridad.append('<option value="">Todos</option>'); // Opción vacía
selectorPrioridad.append('<option value="baja">' + window.language.Tickets.baja + '</option>');
selectorPrioridad.append('<option value="media">' + window.language.Tickets.media + '</option>');
selectorPrioridad.append('<option value="baja">' + window.language.Tickets.alta + '</option>');
selectorPrioridad.on('change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
self.table.table.column(i).search(val).draw();
});
}
else {
$(this).html('<input type="text" class="form-control " style="min-width:100px;max-width:120px;font-size:0.8rem !important;" />');
$('input', this).on('change clear', function () {
if (self.table.table.column(i).search() !== this.value) {
self.table.table
.column(i)
.search(this.value)
.draw();
}
});
}
}
else {
$(this).html('<span></span>');
}
});
}
}
document.addEventListener('DOMContentLoaded', function () {
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
new Ajax('/translate/getTranslation', { locale: locale, translationFile: ['Tickets', 'datePicker'] }, {},
function (translations) {
window.language = JSON.parse(translations);
new Ticket();
},
function (error) {
console.log("Error getting translations:", error);
}
).post();
});
export default Ticket;