File "FOR-S-CCI-17.js"
Full Path: C:/wamp64/www/CALIDADWEB/CALIDADWEB/FRONTED/INPUTS/FOR-S-CCI-17.js
File size: 4.25 KB
MIME-type: text/plain
Charset: utf-8
//---------------------------------------------------------------- Frecuencia Inspeccion----------------------------------//----------------------------------------------------------------------------
document.addEventListener("DOMContentLoaded", function () {
// ==========================
// 1️⃣ Selector dependiente
// ==========================
const areasPorPlanta = {
"DERIVADOS CÁRNICOS PEREIRA": [
"ALISTAMIENTO, MEZCLADO Y MOLIENDA MPC",
"ALMACENAMIENTO DE EMPAQUES",
"ALMACENAMIENTO DE PT",
"COCCION",
"CUARTO DE PRODUCTO EN PROCESO",
"CUARTO MPC 1, 2 Y 3",
"EMBUTIDO",
"ESCALAS Y FILTROS SANITARIOS",
"LOCKERS Y VESTIERES",
"PESAJE DE MPNC",
"TERMOFORMADO - EMBALAJE",
"TUNEL DE CHOQUE",
"TUNEL Y ALMACENAMIENTO DE CANASTILLAS",
"ZONA DE PICADO Y TAJADO"
],
"BENEFICIO Y PRODUCCIÓN PEREIRA": [
"ALMACENAMIENTO",
"DESPACHOS",
"DESPRESE Y MARINADO",
"ENFRIAMIENTO DE CANAL",
"ENFRIAMIENTO DE VISCERAS",
"EVISCERACION",
"FILETEO DE PAVO",
"FILETEO DE POLLO",
"LAVADO DE CANASTILLAS",
"FILETEO Y MARINADO DE PAVOS",
"PLANTA DE HIELO - SALMUERA",
"PLATAFORMA",
"POST PROCESO"
]
};
const tipoPlantaSelect = document.getElementById("tipoPlantaSelect");
const procesoSelect = document.getElementById("procesoSelect");
const nivelSelect = document.getElementById("nivelInspeccion");
const tbody = document.querySelector("#tblFrecuenciaDatos tbody");
const btnCargarFrecuenciaDatos = document.querySelector(".btnCargarFrecuenciaDatos");
const form = document.getElementById("formFrecuenciaInspeccion");
// ==========================
// 1️⃣.1 Llenar procesos según la planta
// ==========================
tipoPlantaSelect.addEventListener("change", function () {
const tipoSeleccionado = this.value;
procesoSelect.innerHTML = '<option value="" selected hidden>Selecciona Proceso</option>';
if (areasPorPlanta[tipoSeleccionado]) {
areasPorPlanta[tipoSeleccionado].forEach(area => {
const option = document.createElement("option");
option.value = area;
option.textContent = area;
procesoSelect.appendChild(option);
});
}
});
// ==========================
// 2️⃣ Cargar datos en la tabla
// ==========================
});
$(document).ready(function() {
// Inicialización de tu DataTable aquí (si no está ya)
// const tabla = $("#tblFrecuenciaDatos").DataTable({ ... });
// Forzar estilos después de la carga
$("#tblFrecuenciaDatos").on('draw.dt', function () {
// Seleccionamos todos los inputs numéricos problemáticos dentro de la tabla
$("#tblFrecuenciaDatos").find(".inputCantidad, .inputAusentes, .inputIncompletos").css({
"width": "70px",
"padding": "2px",
"text-align": "left"
});
});
// También forzar al cargar la página (por si acaso)
$("#tblFrecuenciaDatos").find(".inputCantidad, .inputAusentes, .inputIncompletos").css({
"width": "70px",
"padding": "2px",
"text-align": "left"
});
});
$(document).ready(function() {
// 🔍 Función para buscar empleado por cédula
function buscarEmpleado(inputId) {
let cedula = $(inputId).val().trim();
if (cedula !== '') {
$.ajax({
url: '../../BACKEND/models/buscar_empleado.php', // ✅ revisa si necesitas ../models/
type: 'POST',
data: { cedula: cedula },
dataType: 'json',
success: function(response) {
if (response.error) {
$(inputId).val('NO ENCONTRADO');
} else if (response.mostrar) {
// ✅ muestra la respuesta en el mismo input
$(inputId).val(response.mostrar);
} else {
$(inputId).val('SIN DATOS');
}
},
error: function() {
$(inputId).val('ERROR SERVIDOR');
}
});
}
}
// 👂 Detectar cuando el input pierde el foco (blur)
$('#nombreCalidadfrecuencia').on('blur', function() {
buscarEmpleado('#nombreCalidadfrecuencia');
});
});