mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into 'mig/tarifas_fresado_t_d'
Main See merge request jjimenez/safekat!403
This commit is contained in:
@ -324,7 +324,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
// Cubierta
|
||||
$cubierta = [
|
||||
'papel_generico_cubierta' => $modelPapelGenerico->getIdFromCode($cubierta['papelCubierta']),
|
||||
'papel_generico_cubierta' => $modelPapelGenerico->where('id', $cubierta['papelCubierta'])->first()->toArray(),
|
||||
'gramajeCubierta' => intval($cubierta['gramajeCubierta']),
|
||||
'carasCubierta' => intval($cubierta['carasImpresion'] ?? 0),
|
||||
'solapasCubierta' => intval($cubierta['solapas'] ?? 0),
|
||||
@ -696,7 +696,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
// Cubierta
|
||||
$cubierta = [
|
||||
'papel_generico_cubierta' => $modelPapelGenerico->getIdFromCode($cubierta['papelCubierta']),
|
||||
'papel_generico_cubierta' => $modelPapelGenerico->where('id', $cubierta['papelCubierta'])->first()->toArray(),
|
||||
'gramajeCubierta' => intval($cubierta['gramajeCubierta']),
|
||||
'carasCubierta' => intval($cubierta['carasImpresion'] ?? 0),
|
||||
'solapasCubierta' => intval($cubierta['solapas'] ?? 0),
|
||||
|
||||
@ -394,6 +394,9 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
if ($papel_especial == true) {
|
||||
$builder->where("t1.show_in_client_special", 1);
|
||||
}
|
||||
else{
|
||||
$builder->where("t1.show_in_client_special", 0);
|
||||
}
|
||||
|
||||
if ($tipo == 'colorhq' || $tipo == 'negrohq') {
|
||||
$builder->where("t2.rotativa", 0);
|
||||
|
||||
@ -138,101 +138,29 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-8 mb-3 d-flex flex-column align-items-center">
|
||||
<div id="textoPapelCubierta" class="col-sm-8 mb-3 d-flex flex-column align-items-center d-none">
|
||||
<h3 class="mb-1 fw-bold"> Papel cubierta </h3>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div id="divPapelCubierta" name="div_papel_cubierta" class="row col-sm-10 mb-5 justify-content-center">
|
||||
|
||||
<div id="cartulinaEstucada" cod="CAR1"
|
||||
class="calcular-presupuesto min-width-fit d-flex flex-column align-items-center justify-content-center papel-cubierta imagen-selector image-container">
|
||||
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/cartulina-grafica.png") ?>"
|
||||
alt="Cartulina estucada">
|
||||
<label class="form-label">
|
||||
Cartulina gráfica estucada a una cara
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div id="estucadoMate" cod="EST2"
|
||||
class="calcular-presupuesto min-width-fit d-flex flex-column align-items-center justify-content-center papel-cubierta imagen-selector image-container">
|
||||
<img class="image-presupuesto"
|
||||
src="<?= site_url("assets/img/presupuestoCliente/estucado-mate-cubierta.png") ?>" alt="Estucado mate">
|
||||
<label class="form-label">
|
||||
Estucado Mate
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="divPapelEspecialCubierta" name="div_papel_especial_cubierta"
|
||||
class="row col-sm-10 mb-3 justify-content-center d-none">
|
||||
<div class="col-sm-5 mb-0">
|
||||
<label for="titulo" class="form-label">
|
||||
Seleccione el papel especial
|
||||
</label>
|
||||
<select id="papelEspecialCubiertaSel" name="papel_especial_cubierta"
|
||||
class="form-control select2bs2 calcular-presupuesto col-5 mb-0">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="divGramajeCubierta" name="div_gramaje_cubierta" class="row col-sm-10 mb-3 justify-content-center d-none">
|
||||
|
||||
|
||||
<div id="divGramaje170Cubierta" class="checkbox-presupuesto-container col-md mb-md-0 mb-2">
|
||||
<div class="form-check custom-option custom-option-icon gramaje-cubierta">
|
||||
<label class="form-check-label custom-option-content" for="gramaje170Cubierta">
|
||||
<span class="custom-option-body">
|
||||
<span class="custom-option-title"> 170 gr </span>
|
||||
</span>
|
||||
<input id="gramaje170Cubierta" name="gramajeCubiertaRadio" data-value="170"
|
||||
class="check-gramaje-cubierta calcular-presupuesto form-check-input" type="radio" value="170" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="divGramaje250Cubierta" class="checkbox-presupuesto-container col-md mb-md-0 mb-2">
|
||||
<div class="form-check custom-option custom-option-icon gramaje-cubierta">
|
||||
<label class="form-check-label custom-option-content" for="gramaje250Cubierta">
|
||||
<span class="custom-option-body">
|
||||
<span class="custom-option-title"> 250 gr </span>
|
||||
</span>
|
||||
<input id="gramaje250Cubierta" name="gramajeCubiertaRadio" data-value="250"
|
||||
class="check-gramaje-cubierta calcular-presupuesto form-check-input" type="radio" value="250" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="divGramaje270Cubierta" class="checkbox-presupuesto-container col-md mb-md-0 mb-2">
|
||||
<div class="form-check custom-option custom-option-icon gramaje-cubierta">
|
||||
<label class="form-check-label custom-option-content" for="gramaje270Cubierta">
|
||||
<span class="custom-option-body">
|
||||
<span class="custom-option-title"> 270 gr </span>
|
||||
</span>
|
||||
<input id="gramaje270Cubierta" name="gramajeCubiertaRadio" data-value="270"
|
||||
class="check-gramaje-cubierta calcular-presupuesto form-check-input" type="radio" value="270" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="divGramaje300Cubierta" class="checkbox-presupuesto-container col-md mb-md-0 mb-2">
|
||||
<div class="form-check custom-option custom-option-icon gramaje-cubierta">
|
||||
<label class="form-check-label custom-option-content" for="gramaje300Cubierta">
|
||||
<span class="custom-option-body">
|
||||
<span class="custom-option-title"> 300 gr </span>
|
||||
</span>
|
||||
<input id="gramaje300Cubierta" name="gramajeCubiertaRadio" data-value="300"
|
||||
class="check-gramaje-cubierta calcular-presupuesto form-check-input" type="radio" value="300" />
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-text">
|
||||
Recomendado
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="divGramaje350Cubierta" class="checkbox-presupuesto-container col-md mb-md-0 mb-2">
|
||||
<div class="form-check custom-option custom-option-icon gramaje-cubierta">
|
||||
<label class="form-check-label custom-option-content" for="gramaje350Cubierta">
|
||||
<span class="custom-option-body">
|
||||
<span class="custom-option-title"> 350 gr </span>
|
||||
</span>
|
||||
<input id="gramaje350Cubierta" name="gramajeCubiertaRadio" data-value="350"
|
||||
class="check-gramaje-cubierta calcular-presupuesto form-check-input" type="radio" value="350" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<hr class="col-sm-10 my-10">
|
||||
|
||||
<div class="col-sm-8 mb-3 d-flex flex-column align-items-center">
|
||||
|
||||
@ -1,16 +1,40 @@
|
||||
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 DisenioCubierta {
|
||||
|
||||
constructor(domItem, wizardForm, validatorStepper) {
|
||||
|
||||
constructor(domItem, wizardForm, validatorStepper, presupuestoCliente) {
|
||||
|
||||
this.domItem = domItem;
|
||||
this.allowNext = true;
|
||||
|
||||
this.presupuestoCliente = presupuestoCliente;
|
||||
|
||||
this.csrf_token = getToken();
|
||||
this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val();
|
||||
|
||||
this.wizardStep = wizardForm.querySelector('#cubierta-libro');
|
||||
this.validatorStepper = validatorStepper;
|
||||
|
||||
this.disenioCubierta = this.domItem.find(".tipo-cubierta");
|
||||
this.solapasCubierta = this.domItem.find(".solapas-cubierta");
|
||||
this.papelCubierta = this.domItem.find(".papel-cubierta");
|
||||
this.textoPapelCubierta = this.domItem.find("#textoPapelCubierta");
|
||||
|
||||
this.divPapelEspecial = this.domItem.find("#divPapelEspecialCubierta");
|
||||
this.papelEspecial = new ClassSelect($("#papelEspecialCubiertaSel"),
|
||||
'/papelesgenericos/selectpapelespecial',
|
||||
window.translations["selectPapel"],
|
||||
false,
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
tipo: 'colorhq',
|
||||
cubierta: 1,
|
||||
}
|
||||
);
|
||||
|
||||
this.divSolapas = this.domItem.find("#divSolapasCubierta");
|
||||
this.divCarasImpresion = this.domItem.find("#divCarasImpresion");
|
||||
@ -35,16 +59,7 @@ class DisenioCubierta {
|
||||
this.estucadoMate = this.domItem.find("#estucadoMate");
|
||||
|
||||
this.divPapelCubierta = this.domItem.find("#divPapelCubierta");
|
||||
|
||||
this.divGramajeCubierta = this.domItem.find("#divGramajeCubierta");
|
||||
this.gramaje = this.domItem.find(".check-gramaje-cubierta");
|
||||
this.gramaje170 = $(this.domItem.find("#divGramaje170Cubierta"));
|
||||
this.gramaje250 = $(this.domItem.find("#divGramaje250Cubierta"));
|
||||
this.gramaje270 = $(this.domItem.find("#divGramaje270Cubierta"));
|
||||
this.gramaje300 = $(this.domItem.find("#divGramaje300Cubierta"));
|
||||
this.gramaje350 = $(this.domItem.find("#divGramaje350Cubierta"));
|
||||
|
||||
this.checksGramaje = $('.check-gramaje-cubierta');
|
||||
|
||||
this.cubiertaPlastificado = this.domItem.find("#plastificado");
|
||||
this.cubiertaBarniz = this.domItem.find("#barniz");
|
||||
@ -91,12 +106,14 @@ class DisenioCubierta {
|
||||
else if (targetElement.classList.contains('solapas-cubierta')) {
|
||||
this.#handleMenuSolapas();
|
||||
}
|
||||
else if (targetElement.classList.contains('papel-cubierta')) {
|
||||
this.#handleMenuPapel();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this.papelCubierta = null;
|
||||
this.gramaje = null;
|
||||
|
||||
this.cargando = true;
|
||||
}
|
||||
|
||||
|
||||
@ -104,10 +121,12 @@ class DisenioCubierta {
|
||||
|
||||
const self = this;
|
||||
|
||||
this.papelEspecial.init();
|
||||
$('#papelEspecialCubiertaSel').on("change", this.#handlePapelCubiertaEspecial.bind(this));
|
||||
|
||||
// Eventos
|
||||
this.disenioCubierta.on('click', this.#handleDisenioCubierta.bind(this));
|
||||
this.solapasCubierta.on('click', this.#handleSolapasCubierta.bind(this));
|
||||
this.papelCubierta.on('click', this.#handlePapelCubierta.bind(this));
|
||||
this.tamanioSolapasCubierta.on('change', this.#handleTamanioSolapas.bind(this));
|
||||
this.altoFaja.on('blur', this.#handleInputs);
|
||||
this.solapasSobrecubierta.on('blur', this.#handleInputs);
|
||||
@ -129,23 +148,16 @@ class DisenioCubierta {
|
||||
this.observer.observe(this.tapaBlanda[0], { attributes: true });
|
||||
this.observer.observe(this.tapaDuraLomoRecto[0], { attributes: true });
|
||||
this.observer.observe(this.tapaDuraLomoRedondo[0], { attributes: true });
|
||||
this.observer.observe(this.cartulinaEstucada[0], { attributes: true });
|
||||
this.observer.observe(this.estucadoMate[0], { attributes: true });
|
||||
this.observer.observe(this.conSolapas[0], { attributes: true });
|
||||
this.observer.observe(this.sinSolapas[0], { attributes: true });
|
||||
|
||||
this.checksGramaje.each(function () {
|
||||
|
||||
const customOptionEL = $(this);
|
||||
customOptionEL.on('click', function () {
|
||||
self.#handleClickGramaje(customOptionEL);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
cargarDatos(datosCubierta, datosGuardas, datosSobrecubierta) {
|
||||
|
||||
this.papelCubierta = datosCubierta.papel.id;
|
||||
this.gramaje = datosCubierta.gramaje;
|
||||
|
||||
if (datosCubierta.lomoRedondo) {
|
||||
this.tapaDuraLomoRedondo.trigger('click');
|
||||
}
|
||||
@ -259,17 +271,19 @@ class DisenioCubierta {
|
||||
validators: {
|
||||
callback: {
|
||||
callback: function (input) {
|
||||
const div = $('#divPapelCubierta');
|
||||
if (div.hasClass("d-none")) return true;
|
||||
|
||||
div.find('.fv-plugins-message-container').remove();
|
||||
if ($('.papel-cubierta.selected').length > 0) {
|
||||
$('#divPapelCubierta').find('.fv-plugins-message-container').remove();
|
||||
$('#divPapelEspecialCubierta').find('.fv-plugins-message-container').remove();
|
||||
|
||||
const papelSeleccionado = $('.custom-selector-papel-cubierta input[type="radio"]:checked');
|
||||
if (papelSeleccionado.length > 0) {
|
||||
return true;
|
||||
|
||||
}
|
||||
else {
|
||||
div.append(`
|
||||
$('#divPapelCubierta').append(`
|
||||
<div class="fv-plugins-message-container invalid-feedback">
|
||||
<div data-field="div_papel_cubierta" data-validator="callback" style="margin-top: 50px;">
|
||||
<div data-field="div_impresion_interior" data-validator="callback" style="margin-top: 50px;">
|
||||
${window.translations["validation"].papel_interior}
|
||||
</div>
|
||||
</div>
|
||||
@ -280,20 +294,47 @@ class DisenioCubierta {
|
||||
}
|
||||
}
|
||||
},
|
||||
div_papel_especial_cubierta: {
|
||||
validators: {
|
||||
callback: {
|
||||
callback: function (input) {
|
||||
|
||||
$('#divPapelEspecialCubierta').find('.fv-plugins-message-container').remove();
|
||||
if ($('#divPapelEspecialCubierta').hasClass("d-none")) return true;
|
||||
|
||||
if ($('#papelEspecialCubiertaSel').select2('data').length > 0)
|
||||
return true;
|
||||
else {
|
||||
$('#divPapelEspecialCubierta').append(`
|
||||
<div class="fv-plugins-message-container invalid-feedback">
|
||||
<div data-field="div_impresion_interior" data-validator="callback" style="margin-top: 50px;">
|
||||
${window.translations["validation"].papel_interior}
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
div_gramaje_cubierta: {
|
||||
validators: {
|
||||
callback: {
|
||||
callback: function (input) {
|
||||
const div = $('#divGramajeCubierta'); // Selecciona el div
|
||||
|
||||
div.find('.fv-plugins-message-container').remove();
|
||||
if ($('.check-gramaje-cubierta:checked').length > 0) {
|
||||
const divGramajeInterior = $('#divGramajeCubierta'); // Selecciona el div
|
||||
|
||||
const gramajeSeleccionado = $('.custom-selector-gramaje-cubierta input[type="radio"]:checked');
|
||||
if (gramajeSeleccionado.length > 0) {
|
||||
return true;
|
||||
|
||||
}
|
||||
else {
|
||||
div.append(`
|
||||
divGramajeInterior.append(`
|
||||
<div class="fv-plugins-message-container invalid-feedback">
|
||||
<div data-field="div_gramaje_cubierta" data-validator="callback" style="margin-top: 50px;">
|
||||
<div data-field="div_impresion_interior" data-validator="callback" style="margin-top: 50px;">
|
||||
${window.translations["validation"].gramaje_interior}
|
||||
</div>
|
||||
</div>
|
||||
@ -319,6 +360,7 @@ class DisenioCubierta {
|
||||
case 'div_solapas_cubierta':
|
||||
case 'div_papel_cubierta':
|
||||
case 'div_gramaje_cubierta':
|
||||
case 'div_papel_especial_cubierta':
|
||||
return '.col-sm-10';
|
||||
default:
|
||||
return '.col-sm-3';
|
||||
@ -338,45 +380,48 @@ class DisenioCubierta {
|
||||
processMenuLateral() {
|
||||
|
||||
let menu_off = true;
|
||||
|
||||
if($('.papel-cubierta.selected').length>0 && this.getGramaje() != null){
|
||||
this.rl_papel_cubierta.text($($('.papel-cubierta.selected').find('.form-label')).text() + " " +
|
||||
this.getGramaje() + " gr");
|
||||
|
||||
const papel = this.getPapel(true);
|
||||
const gramaje = this.getGramaje();
|
||||
|
||||
if (papel != null && gramaje != null) {
|
||||
|
||||
this.rl_papel_cubierta.text(papel + " " + gramaje + " gr");
|
||||
this.rl_acabado_cubierta.text(this.domItem.find("#plastificado").children("option:selected").text());
|
||||
this.rl_papel_cubierta.removeClass('d-none');
|
||||
this.rl_acabado_cubierta.removeClass('d-none');
|
||||
|
||||
if(this.carasCubierta.find('option:selected').length>0){
|
||||
if (this.carasCubierta.find('option:selected').length > 0) {
|
||||
this.rl_caras_cubierta.text("Impresa " + this.carasCubierta.find('option:selected').text());
|
||||
this.rl_caras_cubierta.removeClass('d-none');
|
||||
menu_off = false;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this.rl_caras_cubierta.addClass('d-none');
|
||||
}
|
||||
|
||||
|
||||
menu_off = false;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this.rl_papel_cubierta.addClass('d-none');
|
||||
this.rl_acabado_cubierta.addClass('d-none');
|
||||
}
|
||||
|
||||
|
||||
if (!menu_off)
|
||||
this.rl_cubierta.removeClass('d-none');
|
||||
else
|
||||
this.rl_cubierta.addClass('d-none');
|
||||
|
||||
// Sobrecubierta solo se muestra si cubierta ok
|
||||
if(!this.rl_cubierta.hasClass('d-none')){
|
||||
if (!this.rl_cubierta.hasClass('d-none')) {
|
||||
this.rl_sobrecubierta.removeClass('d-none');
|
||||
if(!this.sobrecubierta.is(":checked")){
|
||||
if (!this.sobrecubierta.is(":checked")) {
|
||||
this.rl_no_sobrecubierta.removeClass('d-none');
|
||||
this.rl_papel_sobrecubierta.addClass('d-none');
|
||||
this.rl_tamanio_sobrecubierta.addClass('d-none');
|
||||
this.rl_acabado_sobrecubierta.addClass('d-none');
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this.rl_no_sobrecubierta.addClass('d-none');
|
||||
this.rl_papel_sobrecubierta.removeClass('d-none');
|
||||
this.rl_tamanio_sobrecubierta.removeClass('d-none');
|
||||
@ -386,12 +431,12 @@ class DisenioCubierta {
|
||||
this.rl_papel_sobrecubierta.text(sobrecubierta.papel + " " + sobrecubierta.gramaje + " gr")
|
||||
this.rl_tamanio_sobrecubierta.text("Solapas: " + sobrecubierta.solapas + " mm")
|
||||
let acabado_text = sobrecubierta.plastificado;
|
||||
if(acabado_text.includes("Sin plastificar"))
|
||||
if (acabado_text.includes("Sin plastificar"))
|
||||
acabado_text = "Sin plastificar";
|
||||
this.rl_acabado_sobrecubierta.text(acabado_text);
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this.rl_sobrecubierta.addClass('d-none');
|
||||
}
|
||||
|
||||
@ -419,11 +464,30 @@ class DisenioCubierta {
|
||||
}
|
||||
|
||||
|
||||
getPapel() {
|
||||
getPapel(forResumen = false) {
|
||||
|
||||
try {
|
||||
if (this.papelCubierta.filter('.selected').length > 0) {
|
||||
return this.papelCubierta.filter('.selected').attr('cod');
|
||||
let checkedPapel = $('.custom-selector-papel-cubierta input[type="radio"]:checked');
|
||||
if (this.papelCubierta != null && checkedPapel != null && checkedPapel.length > 0) {
|
||||
if (forResumen) {
|
||||
|
||||
if (checkedPapel.length == 0)
|
||||
return null;
|
||||
let radioButtonId = checkedPapel[0].id;
|
||||
if (radioButtonId == 'papelEspecialCubierta')
|
||||
return capitalizeFirstLetter(this.papelEspecial.getText());
|
||||
else {
|
||||
let associatedLabel = $('label[for="' + radioButtonId + '"]');
|
||||
return capitalizeFirstLetter($(associatedLabel[0]).text().toLocaleLowerCase());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this.divPapelEspecial.hasClass('d-none'))
|
||||
return this.papelCubierta;
|
||||
else {
|
||||
return this.papelEspecial.getVal();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -435,17 +499,13 @@ class DisenioCubierta {
|
||||
|
||||
getGramaje() {
|
||||
|
||||
let checkedGramaje = $('.custom-selector-gramaje-cubierta input[type="radio"]:checked');
|
||||
|
||||
try {
|
||||
|
||||
if (this.divGramajeCubierta.hasClass("d-none"))
|
||||
return null;
|
||||
|
||||
if (this.gramaje.filter(':checked').length > 0)
|
||||
return this.gramaje.filter(':checked').attr('data-value');
|
||||
|
||||
else
|
||||
return null;
|
||||
|
||||
if (checkedGramaje.length == 0)
|
||||
return null;
|
||||
return checkedGramaje[0].id.split('_')[1];
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
@ -606,8 +666,6 @@ class DisenioCubierta {
|
||||
element.closest(class2Find).toggleClass('selected');
|
||||
element.closest('.image-presupuesto').toggleClass('selected');
|
||||
|
||||
$(".papel-cubierta").removeClass("selected");
|
||||
|
||||
if (this.tapaBlanda.hasClass("selected")) {
|
||||
if (this.carasCubierta.val() == 2) {
|
||||
this.cartulinaEstucada.removeClass("d-none");
|
||||
@ -651,30 +709,10 @@ class DisenioCubierta {
|
||||
}
|
||||
|
||||
|
||||
#handlePapelCubierta(event) {
|
||||
// Accede al ID del elemento que disparó el evento
|
||||
const element = $(event.target);
|
||||
|
||||
let class2Find = '.papel-cubierta';
|
||||
|
||||
let containers = element.closest(class2Find).parent().find(class2Find);
|
||||
for (let container of containers) {
|
||||
if (container != element.closest(class2Find)[0]) {
|
||||
$(container).removeClass('selected');
|
||||
$(container).find('.image-presupuesto').removeClass('selected');
|
||||
}
|
||||
}
|
||||
|
||||
element.closest(class2Find).toggleClass('selected');
|
||||
element.closest('.image-presupuesto').toggleClass('selected');
|
||||
|
||||
element.trigger('change');
|
||||
}
|
||||
|
||||
#handleMenuTipoCubierta() {
|
||||
|
||||
if (this.tapaBlanda.hasClass("selected")) {
|
||||
|
||||
|
||||
this.divSolapas.removeClass("d-none");
|
||||
this.divCarasImpresion.removeClass("d-none");
|
||||
this.divConfigGuardas.addClass("d-none");
|
||||
@ -684,15 +722,14 @@ class DisenioCubierta {
|
||||
this.divSolapas.addClass("d-none");
|
||||
this.divCarasImpresion.addClass("d-none");
|
||||
this.divConfigGuardas.removeClass("d-none");
|
||||
this.#handleMenuPapel();
|
||||
|
||||
}
|
||||
else {
|
||||
this.divSolapas.addClass("d-none");
|
||||
this.divCarasImpresion.addClass("d-none");
|
||||
this.divConfigGuardas.addClass("d-none");
|
||||
this.#handleMenuPapel();
|
||||
}
|
||||
|
||||
this.#handleMenuPapel();
|
||||
}
|
||||
|
||||
|
||||
@ -708,42 +745,228 @@ class DisenioCubierta {
|
||||
|
||||
#handleMenuPapel() {
|
||||
|
||||
$(".check-gramaje-cubierta").prop("checked", false);
|
||||
this.divGramajeCubierta.empty();
|
||||
new Ajax('/papelesgenericos/getpapelcliente',
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
tipo: 'colorhq',
|
||||
cubierta: 1,
|
||||
},
|
||||
{},
|
||||
(response) => { this.fillPapeles(response); },
|
||||
(response) => { console.log(response); }
|
||||
).get();
|
||||
}
|
||||
|
||||
if (!this.tapaBlanda.hasClass("selected") && !this.tapaDuraLomoRecto.hasClass("selected") && !this.tapaDuraLomoRedondo.hasClass("selected")) {
|
||||
this.divGramajeCubierta.addClass("d-none");
|
||||
this.estucadoMate.removeClass("selected");
|
||||
this.cartulinaEstucada.removeClass("selected");
|
||||
|
||||
#handlePapelCubiertaEspecial() {
|
||||
|
||||
const context = this;
|
||||
|
||||
this.papelCubierta = this.papelEspecial.getVal();
|
||||
|
||||
new Ajax('/papelesgenericos/getpapelcliente',
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
papel: this.papelCubierta,
|
||||
tipo: 'colorhq',
|
||||
cubierta: 1,
|
||||
},
|
||||
{},
|
||||
this.fillGramajes.bind(context),
|
||||
(response) => { console.log(response); }
|
||||
).get();
|
||||
|
||||
}
|
||||
|
||||
|
||||
fillPapeles(response) {
|
||||
|
||||
this.divPapelCubierta.empty();
|
||||
this.divGramajeCubierta.empty();
|
||||
|
||||
if (response.papeles.length > 0) {
|
||||
this.textoPapelCubierta.removeClass('d-none');
|
||||
}
|
||||
else {
|
||||
this.textoPapelCubierta.addClass("d-none");
|
||||
}
|
||||
|
||||
response.papeles.forEach(papel => {
|
||||
var container = $('<div>', {
|
||||
class: 'custom-selector custom-selector-papel-cubierta d-flex flex-column align-items-center justify-content-center'
|
||||
});
|
||||
|
||||
var radioButton = $('<input>', {
|
||||
type: 'radio', // Tipo de input
|
||||
name: 'calcular-presupuesto papel-cubierta',
|
||||
id: 'papelCubierta_' + papel.id, // ID único
|
||||
value: 'option1' // Valor del radio button
|
||||
});
|
||||
|
||||
// Crear una etiqueta para el radio button
|
||||
var label = $('<label>', {
|
||||
for: 'papelCubierta_' + papel.id,
|
||||
text: papel.nombre
|
||||
});
|
||||
|
||||
radioButton.on('click', this.#handleGramajeCubierta.bind(this));
|
||||
|
||||
container.append(radioButton).append(label);
|
||||
$('#divPapelCubierta').append(container);
|
||||
|
||||
if (this.papelCubierta == papel.id) {
|
||||
radioButton.prop('checked', true);
|
||||
radioButton.trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
if (response.papeles_especiales.length > 0) {
|
||||
this.divPapelCubierta.removeClass('d-none');
|
||||
|
||||
var container = $('<div>', {
|
||||
class: 'custom-selector custom-selector-papel-cubierta d-flex flex-column align-items-center justify-content-center'
|
||||
});
|
||||
|
||||
var radioButton = $('<input>', {
|
||||
type: 'radio',
|
||||
name: 'calcular-presupuesto papel-cubierta',
|
||||
id: 'papelEspecialCubierta',
|
||||
value: 'option1'
|
||||
});
|
||||
|
||||
// Crear una etiqueta para el radio button
|
||||
var label = $('<label>', {
|
||||
for: 'papelEspecialCubierta',
|
||||
text: 'PAPEL ESPECIAL'
|
||||
});
|
||||
|
||||
radioButton.on('click', this.#handleGramajeCubierta.bind(this));
|
||||
|
||||
response.papeles_especiales.forEach(papel => {
|
||||
if (papel.id == this.papelCubierta) {
|
||||
radioButton.prop('checked', true);
|
||||
radioButton.trigger('click');
|
||||
|
||||
this.papelEspecial.setOption(papel.id, papel.nombre);
|
||||
this.#handlePapelCubiertaEspecial();
|
||||
}
|
||||
});
|
||||
|
||||
container.append(radioButton).append(label);
|
||||
$('#divPapelCubierta').append(container);
|
||||
}
|
||||
}
|
||||
|
||||
#handleGramajeCubierta() {
|
||||
|
||||
const context = this;
|
||||
|
||||
// Accede al ID del elemento que disparó el evento
|
||||
const element = $(event.target);
|
||||
const papel = element[0].id.split('_')[1];
|
||||
this.papelCubierta = papel;
|
||||
|
||||
$('#' + papel).prop('checked', true);
|
||||
|
||||
|
||||
if (element[0].id == 'papelEspecialCubierta') {
|
||||
|
||||
if(!this.cargando)
|
||||
this.gramaje = null;
|
||||
this.divGramajeCubierta.empty();
|
||||
this.divPapelEspecial.removeClass("d-none");
|
||||
$('#papelEspecialCubiertaSel').off("change");
|
||||
this.papelEspecial.empty();
|
||||
$('#papelEspecialCubiertaSel').on("change", this.#handlePapelCubiertaEspecial.bind(this));
|
||||
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
this.divPapelEspecial.addClass("d-none");
|
||||
$('#papelEspecialCubiertaSel').off("change");
|
||||
this.papelEspecial.empty();
|
||||
$('#papelEspecialCubiertaSel').on("change", this.#handlePapelCubiertaEspecial.bind(this));
|
||||
this.divGramajeCubierta.empty();
|
||||
new Ajax('/papelesgenericos/getpapelcliente',
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
papel: papel,
|
||||
tipo: 'colorhq',
|
||||
cubierta: 1,
|
||||
},
|
||||
{},
|
||||
this.fillGramajes.bind(context),
|
||||
(response) => { console.log(response); }
|
||||
).get();
|
||||
}
|
||||
if (!this.cargando)
|
||||
this.gramaje = null;
|
||||
else {
|
||||
this.cargando = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fillGramajes(response) {
|
||||
|
||||
|
||||
this.divGramajeCubierta.empty()
|
||||
let showGramaje = false;
|
||||
|
||||
if (response.papeles.length <= 0 && response.papeles_especiales.length <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.cartulinaEstucada.hasClass("selected")) {
|
||||
this.divGramajeCubierta.removeClass("d-none");
|
||||
this.gramaje170.addClass("d-none");
|
||||
this.gramaje250.removeClass("d-none");
|
||||
this.gramaje270.removeClass("d-none");
|
||||
this.gramaje300.removeClass("d-none");
|
||||
this.gramaje350.removeClass("d-none");
|
||||
}
|
||||
else if (this.estucadoMate.hasClass("selected")) {
|
||||
if (this.tapaBlanda.hasClass("selected")) {
|
||||
this.divGramajeCubierta.removeClass("d-none");
|
||||
this.gramaje170.addClass("d-none");
|
||||
this.gramaje250.removeClass("d-none");
|
||||
this.gramaje270.addClass("d-none");
|
||||
this.gramaje300.removeClass("d-none");
|
||||
this.gramaje350.removeClass("d-none");
|
||||
}
|
||||
else {
|
||||
this.divGramajeCubierta.removeClass("d-none");
|
||||
this.gramaje170.removeClass("d-none");
|
||||
this.gramaje250.addClass("d-none");
|
||||
this.gramaje270.addClass("d-none");
|
||||
this.gramaje300.addClass("d-none");
|
||||
this.gramaje350.addClass("d-none");
|
||||
let papel = response.papeles.length > 0 ? response.papeles : response.papeles_especiales;
|
||||
|
||||
$('#gramaje170Cubierta').trigger("click");
|
||||
papel.forEach(valor => {
|
||||
|
||||
var container = $('<div>', {
|
||||
class: 'custom-selector custom-selector-gramaje-cubierta d-flex flex-column align-items-center justify-content-center gramaje-cubierta',
|
||||
});
|
||||
|
||||
var radioButton = $('<input>', {
|
||||
type: 'radio', // Tipo de input
|
||||
name: 'calcular-presupuesto gramaje-cubierta',
|
||||
id: 'gramajeCubierta_' + valor.gramaje, // ID único
|
||||
value: 'option1' // Valor del radio button
|
||||
});
|
||||
|
||||
// Crear una etiqueta para el radio button
|
||||
var label = $('<label>', {
|
||||
for: "gramajeCubierta_" + valor.gramaje,
|
||||
text: valor.gramaje + " gr"
|
||||
});
|
||||
|
||||
radioButton.on('click', (event) => {
|
||||
const element = $(event.target);
|
||||
const gramaje = element[0].id;
|
||||
|
||||
this.presupuestoCliente.checkForm(event);
|
||||
});
|
||||
|
||||
|
||||
container.append(radioButton).append(label);
|
||||
$('#divGramajeCubierta').append(container);
|
||||
|
||||
if (this.gramaje != null) {
|
||||
if (this.gramaje == parseInt(valor.gramaje)) {
|
||||
radioButton.prop('checked', true);
|
||||
radioButton.trigger('click');
|
||||
}
|
||||
}
|
||||
|
||||
showGramaje = true;
|
||||
});
|
||||
|
||||
if ($("#divGramajeCubierta").hasClass("d-none") && showGramaje) {
|
||||
$("#divGramajeCubierta").removeClass("d-none");
|
||||
}
|
||||
else if (!showGramaje) {
|
||||
$("#divGramajeCubierta").addClass("d-none");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -116,7 +116,7 @@ class DisenioInterior {
|
||||
|
||||
const context = this;
|
||||
|
||||
if (papeles == 'color' || papeles == null) {
|
||||
if (papeles == 'color') {
|
||||
this.divGramajeInteriorColor.empty();
|
||||
new Ajax('/papelesgenericos/getpapelcliente',
|
||||
{
|
||||
@ -214,7 +214,7 @@ class DisenioInterior {
|
||||
radioButton.prop('checked', true);
|
||||
radioButton.trigger('click');
|
||||
|
||||
this.papelEspecial.setVal(papel.id);
|
||||
this.papelEspecial.setOption(papel.id, papel.nombre);
|
||||
}
|
||||
});
|
||||
|
||||
@ -291,7 +291,7 @@ class DisenioInterior {
|
||||
radioButton.prop('checked', true);
|
||||
radioButton.trigger('click');
|
||||
|
||||
this.papelEspecialColor.setVal(papel.id);
|
||||
this.papelEspecialColor.setOption(papel.id, papel.nombre);
|
||||
}
|
||||
});
|
||||
|
||||
@ -837,19 +837,15 @@ class DisenioInterior {
|
||||
const element = $(event.target);
|
||||
const papel = element[0].id.split('_')[1];
|
||||
this.papelInterior = papel;
|
||||
if (!this.cargando)
|
||||
this.gramaje = null;
|
||||
else {
|
||||
this.cargando = false;
|
||||
}
|
||||
|
||||
|
||||
$('#' + papel).prop('checked', true);
|
||||
|
||||
let tipo = this.getTipoImpresion();
|
||||
|
||||
if (element[0].id == 'papelEspecialInterior') {
|
||||
|
||||
this.gramaje = null;
|
||||
if(!this.cargando)
|
||||
this.gramaje = null;
|
||||
this.divGramajeInterior.empty();
|
||||
this.divPapelEspecialInterior.removeClass("d-none");
|
||||
this.papelEspecialInterior.empty();
|
||||
@ -872,6 +868,11 @@ class DisenioInterior {
|
||||
(response) => { console.log(response); }
|
||||
).get();
|
||||
}
|
||||
if (!this.cargando)
|
||||
this.gramaje = null;
|
||||
else {
|
||||
this.cargando = false;
|
||||
}
|
||||
}
|
||||
|
||||
#handlePapelInteriorEspecial() {
|
||||
@ -971,11 +972,13 @@ class DisenioInterior {
|
||||
this.divGramajeInterior.empty()
|
||||
let showGramaje = false;
|
||||
|
||||
if (response.papeles.length <= 0) {
|
||||
if (response.papeles.length <= 0 && response.papeles_especiales.length <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
response.papeles.forEach(valor => {
|
||||
let papel = response.papeles.length > 0 ? response.papeles : response.papeles_especiales;
|
||||
|
||||
papel.forEach(valor => {
|
||||
|
||||
var container = $('<div>', {
|
||||
class: 'custom-selector custom-selector-gramaje d-flex flex-column align-items-center justify-content-center gramaje-interior',
|
||||
|
||||
@ -34,7 +34,7 @@ class PresupuestoCliente {
|
||||
|
||||
this.datosGenerales = new DatosGenerales($("#datos-generales"), this.clientePresupuestoWizard, this.validationStepper);
|
||||
this.disenioInterior = new DisenioInterior($("#interior-libro"), this.clientePresupuestoWizard, this.validationStepper, this);
|
||||
this.disenioCubierta = new DisenioCubierta($("#cubierta-libro"), this.clientePresupuestoWizard, this.validationStepper);
|
||||
this.disenioCubierta = new DisenioCubierta($("#cubierta-libro"), this.clientePresupuestoWizard, this.validationStepper, this);
|
||||
this.direcciones = new Direcciones($("#direcciones-libro"), this.clientePresupuestoWizard, this.validationStepper);
|
||||
this.resumen = new Resumen($("#resumen-libro"), this.datosGenerales, this.disenioInterior, this.disenioCubierta, this.direcciones);
|
||||
|
||||
|
||||
@ -280,7 +280,7 @@ class Resumen {
|
||||
this.cabezada.text(this.disenioCubierta.getCabezada(true));
|
||||
|
||||
}
|
||||
this.papelCubierta.text($($('.papel-cubierta.selected').find('.form-label')).text())
|
||||
this.papelCubierta.text(this.disenioCubierta.getPapel(true));
|
||||
this.gramajeCubierta.text(this.disenioCubierta.getGramaje());
|
||||
this.cubiertaAcabados.text(this.disenioCubierta.getAcabados(true));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user