mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Arreglado el mostrar automaticamente el boton de guardar en presupuestos, corregidos bugs de checkboxes tambien
This commit is contained in:
@ -22,7 +22,7 @@ if (session()->has('error')) {
|
||||
</div>
|
||||
|
||||
|
||||
<?= $this->section('additionalInlineJs') ?>
|
||||
<?= $this->section('globalJsFunctions') ?>
|
||||
|
||||
function popAlert(message, alertClass, alertIcon, containerId = 'sk-alert'){
|
||||
var htmlString = `
|
||||
|
||||
@ -220,6 +220,7 @@ $(document).on('click', '.delete-add-row', function(e) {
|
||||
update_resumen: true,
|
||||
update_tiradas_alternativas: true
|
||||
})
|
||||
showBreadCrumbSaveButton(true);
|
||||
|
||||
})
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
* Seccion para las funciones generales de la pagina
|
||||
***************************************************************************************/
|
||||
|
||||
|
||||
$('.nav-servicios button').on('shown.bs.tab', function(){
|
||||
$("#tableOfServiciosEncuadernacion").DataTable().columns.adjust();
|
||||
$("#tableOfServiciosPreimpresion").DataTable().columns.adjust();
|
||||
@ -16,6 +15,7 @@ $('#serv_default').on('click', function(){
|
||||
get_tarifas_enc('default').then(
|
||||
get_tarifas_manipulado('default')
|
||||
)
|
||||
showBreadCrumbSaveButton(true);
|
||||
})
|
||||
|
||||
// Delete row
|
||||
@ -73,6 +73,7 @@ $(document).on('click', '.btn-delete-serv', function(e) {
|
||||
update_tiradas_alternativas: true
|
||||
})
|
||||
//updateTotales(false, true, false)
|
||||
showBreadCrumbSaveButton(true);
|
||||
|
||||
});
|
||||
|
||||
@ -369,6 +370,8 @@ $('#insertar_serv_acabado').on('click', function(){
|
||||
popErrorAlert(window.Presupuestos.errores.error_servicios_duplicados, 'serv-acabado-alert');
|
||||
}
|
||||
check_serv_acabado_error();
|
||||
showBreadCrumbSaveButton(true);
|
||||
|
||||
})
|
||||
|
||||
|
||||
@ -1298,13 +1301,16 @@ function servicioFerro(){
|
||||
}
|
||||
|
||||
$('#insertar_serv_preimpresion').on('click', function(){
|
||||
const tarifa_text = $('#add_servicio_preimpresion_list').select2('data')[0].text.trim()
|
||||
|
||||
if( $('#add_servicio_preimpresion_list').select2('data')[0].text.trim().length > 0){
|
||||
if($('#tableOfServiciosPreimpresion tr > td:contains(' + tarifa_text + ')').length == 0)
|
||||
get_tarifas_preimpresion($('#add_servicio_preimpresion_list').select2('data')[0].id);
|
||||
else{
|
||||
popErrorAlert(window.Presupuestos.errores.error_servicios_duplicados, 'serv-preimpresion-alert')
|
||||
|
||||
let data = $('#add_servicio_preimpresion_list').select2('data');
|
||||
if (data.length > 0) {
|
||||
const tarifa_text = data[0].text.trim();
|
||||
if (tarifa_text.length > 0) {
|
||||
if ($('#tableOfServiciosPreimpresion tr > td:contains(' + tarifa_text + ')').length == 0)
|
||||
get_tarifas_preimpresion(data[0].id);
|
||||
else {
|
||||
popErrorAlert(window.Presupuestos.errores.error_servicios_duplicados, 'serv-preimpresion-alert');
|
||||
}
|
||||
}
|
||||
}
|
||||
check_serv_preimpresion_error()
|
||||
|
||||
@ -61,6 +61,7 @@ $('#add_tirada_alt').on('click', function () {
|
||||
|
||||
const tirada_alt = parseInt($('#tirada_alt').val());
|
||||
add_tirada_alternativa(tirada_alt);
|
||||
showBreadCrumbSaveButton(true);
|
||||
});
|
||||
|
||||
|
||||
@ -274,6 +275,7 @@ $(document).on('click', '.btn-delete-tirada', function (e) {
|
||||
tableTiradas.row(row)
|
||||
.remove()
|
||||
.draw();
|
||||
showBreadCrumbSaveButton(true);
|
||||
})
|
||||
|
||||
|
||||
|
||||
@ -218,117 +218,45 @@ $(window).on('load', function() {
|
||||
|
||||
// Detectar cambios en inputs de texto
|
||||
$('input[type="text"]').on('input', function() {
|
||||
console.log("El campo de texto con ID '" + $(this).attr('id') + "' ha cambiado.");
|
||||
showBreadCrumbSaveButton(true);
|
||||
});
|
||||
|
||||
// Detectar cambios en inputs de texto
|
||||
$('input[type="number"]').on('input', function() {
|
||||
console.log("El campo de texto con ID '" + $(this).attr('id') + "' ha cambiado.");
|
||||
showBreadCrumbSaveButton(true);
|
||||
});
|
||||
|
||||
// Detectar cambios en select
|
||||
$('select').change(function() {
|
||||
console.log("El campo select con ID '" + $(this).attr('id') + "' ha cambiado.");
|
||||
showBreadCrumbSaveButton(true);
|
||||
});
|
||||
|
||||
// Detectar cambios en checkboxes
|
||||
$('input[type="checkbox"]').change(function() {
|
||||
console.log("El checkbox con ID '" + $(this).attr('id') + "' ha cambiado.");
|
||||
showBreadCrumbSaveButton(true);
|
||||
});
|
||||
|
||||
// Detectar cambios en textareas
|
||||
$('textarea').on('input', function() {
|
||||
console.log("El textarea con ID '" + $(this).attr('id') + "' ha cambiado.");
|
||||
showBreadCrumbSaveButton(true);
|
||||
});
|
||||
|
||||
// Detectar cambios en otros tipos de input (por ejemplo, radio buttons)
|
||||
// Detectar cambios en otros tipos de input
|
||||
$('input[type="radio"]').change(function() {
|
||||
console.log("El radio button con ID '" + $(this).attr('id') + "' ha cambiado.");
|
||||
showBreadCrumbSaveButton(true);
|
||||
});
|
||||
|
||||
// Detectar cambios en otros tipos de input (por ejemplo, radio buttons)
|
||||
// Detectar cambios en otros tipos de input
|
||||
$('input:not([type])').on('input', function() {
|
||||
console.log("El valor de un input sin tipo ha cambiado: " + $(this).val());
|
||||
showBreadCrumbSaveButton(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
// Obtener todos los campos de entrada del formulario
|
||||
const formInputs = document.querySelectorAll('input, textarea, select');
|
||||
|
||||
//console.log(formInputs)
|
||||
|
||||
// Crear un objeto para almacenar los valores originales
|
||||
const originalValues = {};
|
||||
|
||||
// Guardar los valores originales
|
||||
function saveOriginalValues(inputs) {
|
||||
inputs.forEach(input => {
|
||||
if (!input.id) return;
|
||||
|
||||
if (input.type === 'checkbox') {
|
||||
originalValues[input.id] = input.checked;
|
||||
} else {
|
||||
originalValues[input.id] = input.tagName.toLowerCase() === 'select'
|
||||
? $(input).val() // jQuery para obtener el valor de un select2
|
||||
: input.value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Agregar un evento de cambio a cada campo de entrada
|
||||
function addChangeEvent(inputs) {
|
||||
inputs.forEach(input => {
|
||||
if (!input.id) return;
|
||||
|
||||
if (input.tagName.toLowerCase() === 'select' && $(input).data('select2')) {
|
||||
// Para elementos select2
|
||||
$(input).on('change', verificarCambios);
|
||||
} else {
|
||||
// Para otros tipos de campos
|
||||
input.addEventListener('input', verificarCambios);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function verificarCambios() {
|
||||
// Verificar si hay cambios con respecto a los originales
|
||||
let cambiosDetectados = Array.from(formInputs).some(input => {
|
||||
if (!input.id) return false;
|
||||
|
||||
return input.type === 'checkbox'
|
||||
? input.checked !== originalValues[input.id]
|
||||
: input.tagName.toLowerCase() === 'select'
|
||||
? $(input).val() !== originalValues[input.id]
|
||||
: input.value !== originalValues[input.id];
|
||||
});
|
||||
|
||||
console.log(cambiosDetectados);
|
||||
|
||||
// Mostrar alerta solo si hay cambios
|
||||
showBreadCrumbSaveButton(cambiosDetectados);
|
||||
}
|
||||
|
||||
$('#bc-save').on( "click", function() {
|
||||
showBreadCrumbSaveButton(false);
|
||||
$('#saveForm').click()
|
||||
} );
|
||||
|
||||
// Llamar a funciones principales
|
||||
saveOriginalValues(formInputs);
|
||||
addChangeEvent(formInputs);
|
||||
|
||||
*/
|
||||
|
||||
$('#bc-save').on( "click", function() {
|
||||
//showBreadCrumbSaveButton(false);
|
||||
$('#saveForm').click()
|
||||
} );
|
||||
$('#bc-save').on( "click", function() {
|
||||
showBreadCrumbSaveButton(false);
|
||||
$('#saveForm').click()
|
||||
} );
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?= $this->section('additionalInlineJs') ?>
|
||||
<?= $this->section('globalJsFunctions') ?>
|
||||
|
||||
function showBreadCrumbSaveButton(showIt = false){
|
||||
if(showIt === true){
|
||||
|
||||
@ -346,6 +346,7 @@ if (isset($global_js_variables)) {
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
<?= $this->renderSection('globalJsFunctions') ?>
|
||||
|
||||
var theTable;
|
||||
var <?=csrf_token() ?? 'token'?>v = '<?= csrf_hash() ?>';
|
||||
|
||||
Reference in New Issue
Block a user