import { getToken } from '../../common/common.js'; import { capitalizeFirstLetter } from '../../common/common.js'; import Ajax from '../../components/ajax.js'; import ClassSelect from '../../components/select2.js'; class DisenioInterior { constructor(domItem, wizardForm, validatorStepper, presupuestoCliente) { this.domItem = domItem; this.presupuestoCliente = presupuestoCliente; this.csrf_token = getToken(); this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val(); this.wizardStep = wizardForm.querySelector('#interior-libro'); this.validatorStepper = validatorStepper; this.allowNext = true; this.disenioInterior = this.domItem.find(".disenio-interior"); this.divPapelInterior = this.domItem.find("#divPapelInterior"); this.textoPapelInterior = this.domItem.find("#textoPapelInterior"); this.textoPapelInteriorColor = this.domItem.find("#textoPapelInteriorColor"); this.divPapelInteriorColor = this.domItem.find("#divPapelInteriorColor"); this.divPapelEspecialInterior = this.domItem.find("#divPapelEspecialInterior"); this.divPapelEspecialInteriorColor = this.domItem.find("#divPapelEspecialInteriorColor"); this.papelEspecialInterior = this.domItem.find("#papelEspecialInterior"); this.divGramajeInterior = this.domItem.find("#divGramajeInterior"); this.divGramajeInteriorColor = this.domItem.find("#divGramajeInteriorColor"); this.negroEstandar = this.domItem.find("#negroEstandar"); this.negroPremium = this.domItem.find("#negroPremium"); this.colorEstandar = this.domItem.find("#colorEstandar"); this.colorPremium = this.domItem.find("#colorPremium"); this.interiorColor = this.domItem.find(".interior-color"); this.disenioInterior_color = this.domItem.find(".disenio-interior-color"); this.papelInterior_color = this.domItem.find(".papel-interior-color"); this.colorEstandar_color = this.domItem.find("#colorEstandarColor"); this.colorPremium_color = this.domItem.find("#colorPremiumColor"); this.gramaje_color = this.domItem.find(".check-interior-color-gramaje"); this.checksGramaje = $('.gramaje-interior'); this.rl_interior = $(".rl-interior"); this.rl_tipo_interior = $("#rl_tipo_interior"); this.rl_papel_interior = $("#rl_papel_interior"); this.rl_papel_interior_color = $("#rl_papel_interior_color"); this.papelEspecial = new ClassSelect($("#papelEspecialInterior"), '/papelesgenericos/selectpapelespecial', window.translations["selectPapel"], false, { [this.csrf_token]: this.csrf_hash, tipo: this.getTipoImpresion(), cubierta: 0, } ); this.papelEspecialColor = new ClassSelect($("#papelEspecialInteriorColor"), '/papelesgenericos/selectpapelespecial', window.translations["selectPapel"], false, { [this.csrf_token]: this.csrf_hash, tipo: this.getTipoImpresionColor(), cubierta: 0, } ); this.papelInteriorDiferente = false; this.papelInterior = null; this.gramaje = null; this.papelInteriorColor = null; this.gramajeColor = null; this.cargando = true; this.initValidation(); } init() { const self = this; this.papelEspecial.init(); $('#papelEspecialInterior').on("change", this.#handlePapelInteriorEspecial.bind(this)); this.papelEspecialColor.init(); $('#papelEspecialInteriorColor').on("change", this.#handlePapelInteriorEspecialColor.bind(this)); // Eventos this.disenioInterior.on('click', this.#handleDisenioInterior.bind(this)); this.disenioInterior_color.on('click', this.#handleDisenioInterior.bind(this)); } updatePapeles(papeles = null) { const context = this; if (papeles == 'color') { this.divGramajeInteriorColor.empty(); new Ajax('/papelesgenericos/getpapelcliente', { [this.csrf_token]: this.csrf_hash, tirada: $('#tirada').val(), tipo: this.getTipoImpresion(), cubierta: 0, }, {}, (response) => { this.fillPapelesColor(response); }, (response) => { console.log(response); } ).get(); } if (papeles == 'negro' || papeles == null) { this.divGramajeInterior.empty(); new Ajax('/papelesgenericos/getpapelcliente', { [this.csrf_token]: this.csrf_hash, tirada: $('#tirada').val(), tipo: this.getTipoImpresion(), cubierta: 0, }, {}, (response) => { this.fillPapeles(response); }, (response) => { console.log(response); } ).get(); } } fillPapeles(response) { this.divPapelInterior.empty(); this.divGramajeInterior.empty(); if (response.papeles.length > 0) { this.textoPapelInterior.removeClass('d-none'); } else { this.textoPapelInterior.addClass("d-none"); } response.papeles.forEach(papel => { var container = $('
', { class: 'custom-selector custom-selector-papel d-flex flex-column align-items-center justify-content-center' }); var radioButton = $('', { type: 'radio', // Tipo de input name: 'calcular-presupuesto papel-interior', id: 'papel_' + papel.id, // ID único value: 'option1' // Valor del radio button }); // Crear una etiqueta para el radio button var label = $('