mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-24 01:30:21 +00:00
falta el selector de acabados
This commit is contained in:
@ -11,6 +11,7 @@ presupuesto.datos-generales-descripcion=Datos generales del presupuesto
|
||||
presupuesto.titulo=Título*
|
||||
presupuesto.autor=Autor
|
||||
presupuesto.isbn=ISBN
|
||||
presupuesto.tirada=Tirada
|
||||
presupuesto.tirada1=Tirada 1*
|
||||
presupuesto.tirada2=Tirada 2
|
||||
presupuesto.tirada3=Tirada 3
|
||||
@ -184,6 +185,27 @@ presupuesto.maquetacion.correccion-ortotipografica=Corrección ortotipográfica
|
||||
presupuesto.maquetacion.texto-mecanografiado=Texto mecanografiado
|
||||
presupuesto.maquetacion.diseno-portada=Diseño de portada
|
||||
presupuesto.maquetacion.epub=Generación Epub
|
||||
presupuesto.maquetacion.num-paginas-estimadas=Páginas estimadas
|
||||
presupuesto.maquetacion.precio-por-pagina-estimado=Precio por página estimado
|
||||
|
||||
# Presupuesto de marcapáginas
|
||||
presupuesto.marcapaginas=Presupuesto de marcapáginas
|
||||
presupuesto.marcapaginas.tamanio=Tamaño de los marcapáginas
|
||||
presupuesto.marcapaginas.caras-impresion=Caras impresas
|
||||
presupuesto.marcapaginas.caras-impresion-1=Una cara
|
||||
presupuesto.marcapaginas.caras-impresion-2=Dos caras
|
||||
presupuesto.marcapaginas.papel=Papel marcapáginas
|
||||
presupuesto.marcapaginas.papel.cartulina-grafica=Cartulina gráfica
|
||||
presupuesto.marcapaginas.papel.estucado-mate=Estucado mate
|
||||
presupuesto.marcapaginas.gramaje=Gramaje papel marcapáginas
|
||||
presupuesto.marcapaginas.acabado=Acabado marcapáginas
|
||||
presupuesto.marcapaginas.acabado.ninguno=Sin acabado
|
||||
presupuesto.marcapaginas.acabado.plastificado-brillo-1c=Plastificado brillo 1/C
|
||||
presupuesto.marcapaginas.acabado.plastificado-mate-1c=Plastificado mate 1/C
|
||||
presupuesto.marcapaginas.acabado.plastificado-brillo-2c=Plastificado brillo 2/C
|
||||
presupuesto.marcapaginas.acabado.plastificado-mate-2c=Plastificado mate 2/C
|
||||
presupuesto.marcapaginas.precio-unidad=Precio por unidad
|
||||
presupuesto.marcapaginas.precio-total=Precio total
|
||||
|
||||
# Errores
|
||||
presupuesto.errores-title=Corrija los siguientes errores:
|
||||
@ -208,4 +230,5 @@ presupuesto.errores.papel-cubierta=Seleccione el tipo de papel para la cubierta
|
||||
presupuesto.errores.gramaje-cubierta=Seleccione el gramaje del papel para la cubierta
|
||||
presupuesto.errores.acabado-cubierta=Seleccione el acabado de la cubierta
|
||||
|
||||
presupuesto.errores.presupuesto-maquetacion=No se pudo calcular el presupuesto de maquetación.
|
||||
presupuesto.errores.presupuesto-maquetacion=No se pudo calcular el presupuesto de maquetación.
|
||||
presupuesto.errores.presupuesto-marcapaginas=No se pudo calcular el presupuesto de marcapáginas.
|
||||
@ -1,10 +1,21 @@
|
||||
import * as Summary from "./summary.js";
|
||||
import { formateaMoneda } from "../utils.js";
|
||||
|
||||
|
||||
let valoresAcabados = [];
|
||||
|
||||
$(document).on('change', '#maquetacion', function (e) {
|
||||
e.preventDefault();
|
||||
if ($('#maquetacion').is(':checked')) {
|
||||
$.get("/presupuesto/public/maquetacion/form", function (data) {
|
||||
$("#maquetacionModalBody").html(data);
|
||||
valoresAcabados = $("#acabado-marcapaginas").html();
|
||||
if($('#caras-impresion').val() === 'una_cara') {
|
||||
$("#acabado-marcapaginas").html($(valoresAcabados).filter('.marcapaginas-1cara'));
|
||||
}
|
||||
else {
|
||||
$("#acabado-marcapaginas").html($(valoresAcabados).filter('.marcapaginas-2caras'));
|
||||
}
|
||||
$("#maquetacionModal").modal("show");
|
||||
});
|
||||
} else {
|
||||
@ -35,8 +46,8 @@ $(document).on("submit", "#maquetacionForm", function (e) {
|
||||
|
||||
const resumenHtml = `
|
||||
<div class="text-start">
|
||||
<p>Páginas calculadas: ${json.numPaginasEstimadas ?? "-"}</p>
|
||||
<p>Precio por página estimado: ${formateaMoneda(json.precioPaginaEstimado) || "-"}</p>
|
||||
<p>${json.language.num_paginas_estimadas || 'Páginas calculadas'}: ${json.numPaginasEstimadas ?? "-"}</p>
|
||||
<p>${json.language.precio_por_pagina_estimado || 'Precio por página estimado'}: ${formateaMoneda(json.precioPaginaEstimado) || "-"}</p>
|
||||
<hr class="my-2">
|
||||
${json.precio ?
|
||||
`<h3 class="mb-0"><strong>Precio:</strong> ${formateaMoneda(json.precio)}</h3>` : ""}
|
||||
@ -97,6 +108,15 @@ $(document).on("submit", "#maquetacionForm", function (e) {
|
||||
});
|
||||
});
|
||||
|
||||
$document).on('change', '#caras-impresion', function (e) {
|
||||
e.preventDefault();
|
||||
if($('#caras-impresion').val() === 'una_cara') {
|
||||
$("#acabado-marcapaginas").html($(valoresAcabados).filter('.marcapaginas-1cara'));
|
||||
} else {
|
||||
$("#acabado-marcapaginas").html($(valoresAcabados).filter('.marcapaginas-2caras'));
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('hidden.bs.modal', '#maquetacionModal', function () {
|
||||
|
||||
const calcularStr = $('#div-extras').data('language-calcular');
|
||||
@ -105,11 +125,3 @@ $(document).on('hidden.bs.modal', '#maquetacionModal', function () {
|
||||
$('label[for="maquetacion"] .service-price').text(calcularStr);
|
||||
});
|
||||
|
||||
function formateaMoneda(valor) {
|
||||
try {
|
||||
return new Intl.NumberFormat('es-ES', { style: 'currency', currency: 'EUR' }).format(valor);
|
||||
} catch {
|
||||
return valor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,107 @@
|
||||
import * as Summary from "./summary.js";
|
||||
import { formateaMoneda, formateaMoneda6Decimales } from "../utils.js";
|
||||
|
||||
$(document).on('change', '#marcapaginas', function (e) {
|
||||
e.preventDefault();
|
||||
if ($('#marcapaginas').is(':checked')) {
|
||||
$.get("/presupuesto/public/marcapaginas/form", function (data) {
|
||||
$("#marcapaginasModalBody").html(data);
|
||||
$("#marcapaginasModal").modal("show");
|
||||
});
|
||||
} else {
|
||||
const calcularStr = $('#div-extras').data('language-calcular');
|
||||
$('#marcapaginas').data('price', calcularStr);
|
||||
$('label[for="marcapaginas"] .service-price')
|
||||
.text(calcularStr);
|
||||
$('#marcapaginas').prop('checked', false);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("submit", "#marcapaginasForm", function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
const $form = $(this);
|
||||
|
||||
$.ajax({
|
||||
url: $form.attr("action"),
|
||||
type: $form.attr("method"),
|
||||
data: $form.serialize(),
|
||||
dataType: "json",
|
||||
success: function (json) {
|
||||
|
||||
const modalEl = document.getElementById("marcapaginasModal");
|
||||
const modal = bootstrap.Modal.getInstance(modalEl) || new bootstrap.Modal(modalEl);
|
||||
modal.hide();
|
||||
|
||||
|
||||
const resumenHtml = `
|
||||
<div class="text-start">
|
||||
<p>${json.language.precio_unidad || 'Precio por unidad'}: ${formateaMoneda6Decimales(json.precio_unitario) || "-"}</p>
|
||||
<h3 class="mb-0">${json.language.precio_total || 'Precio total'}: ${formateaMoneda(json.precio_total) || "-"}</h3>
|
||||
</div>
|
||||
`;
|
||||
|
||||
Swal.fire({
|
||||
title: json.language.presupuesto_marcapaginas || 'Presupuesto Marcapáginas',
|
||||
html: resumenHtml,
|
||||
icon: 'info',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: json.language.add_to_presupuesto || 'Añadir al presupuesto',
|
||||
cancelButtonText: json.language.cancel || 'Cancelar',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-secondary me-2', // clases para el botón confirmar
|
||||
cancelButton: 'btn btn-light' // clases para cancelar
|
||||
},
|
||||
buttonsStyling: false,
|
||||
reverseButtons: false,
|
||||
allowOutsideClick: false
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$('#marcapaginas').prop('checked', true);
|
||||
$('#marcapaginas').data('price', json.precio_total);
|
||||
$('label[for="marcapaginas"] .service-price')
|
||||
.text(formateaMoneda(json.precio_total));
|
||||
Summary.updateExtras();
|
||||
}
|
||||
else {
|
||||
const calcularStr = $('#div-extras').data('language-calcular');
|
||||
$('#marcapaginas').prop('checked', false);
|
||||
$('#marcapaginas').data('price', calcularStr);
|
||||
$('label[for="marcapaginas"] .service-price').text(calcularStr);
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
try {
|
||||
const errs = JSON.parse(xhr.responseText); // { numCaracteres: "…" , … }
|
||||
// limpia errores previos
|
||||
$form.find(".is-invalid").removeClass("is-invalid");
|
||||
$form.find(".invalid-feedback").text("");
|
||||
|
||||
// recorre los errores y los muestra
|
||||
Object.entries(errs).forEach(([field, msg]) => {
|
||||
const $input = $form.find(`[name="${field}"]`);
|
||||
if ($input.length) {
|
||||
$input.addClass("is-invalid");
|
||||
$input.siblings(".invalid-feedback").text(msg);
|
||||
}
|
||||
});
|
||||
} catch {
|
||||
$("#marcapaginasModalBody").html(
|
||||
"<div class='alert alert-danger'>" + xhr.responseText + "</div>"
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('hidden.bs.modal', '#marcapaginasModal', function () {
|
||||
|
||||
const calcularStr = $('#div-extras').data('language-calcular');
|
||||
$('#marcapaginas').prop('checked', false);
|
||||
$('#marcapaginas').data('price', calcularStr);
|
||||
$('label[for="marcapaginas"] .service-price').text(calcularStr);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
function formateaMoneda(valor) {
|
||||
try {
|
||||
return new Intl.NumberFormat('es-ES', { style: 'currency', currency: 'EUR' }).format(valor);
|
||||
} catch {
|
||||
return valor;
|
||||
}
|
||||
}
|
||||
export { formateaMoneda };
|
||||
|
||||
function formateaMoneda4Decimales(valor) {
|
||||
try {
|
||||
return new Intl.NumberFormat('es-ES', { style: 'currency', currency: 'EUR', minimumFractionDigits: 4 }).format(valor);
|
||||
} catch {
|
||||
return valor;
|
||||
}
|
||||
}
|
||||
export { formateaMoneda4Decimales };
|
||||
|
||||
function formateaMoneda6Decimales(valor) {
|
||||
try {
|
||||
return new Intl.NumberFormat('es-ES', { style: 'currency', currency: 'EUR', minimumFractionDigits: 6 }).format(valor);
|
||||
} catch {
|
||||
return valor;
|
||||
}
|
||||
}
|
||||
export { formateaMoneda6Decimales };
|
||||
@ -37,6 +37,7 @@
|
||||
<script th:src="@{/assets/js/pages/imprimelibros/presupuestador/imagen-selector.js}"></script>
|
||||
<script type="module" th:src="@{/assets/js/pages/imprimelibros/presupuestador/presupuestador.js}"></script>
|
||||
<script type="module" th:src="@{/assets/js/pages/imprimelibros/presupuestador/presupuesto-maquetacion.js}"></script>
|
||||
<script type="module" th:src="@{/assets/js/pages/imprimelibros/presupuestador/presupuesto-marcapaginas.js}"></script>
|
||||
</div>
|
||||
<script th:inline="javascript">
|
||||
window.languageBundle = /*[[${languageBundle}]]*/ {};
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
<div th:fragment="presupuestador">
|
||||
<!-- Modales-->
|
||||
<div
|
||||
th:replace="imprimelibros/partials/modal-form :: modal('maquetacionModal', 'presupuesto.maquetacion', 'modal-lg', 'maquetacionModalBody')">
|
||||
th:replace="imprimelibros/partials/modal-form :: modal('maquetacionModal', 'presupuesto.maquetacion', 'modal-md', 'maquetacionModalBody')">
|
||||
</div>
|
||||
|
||||
<div
|
||||
th:replace="imprimelibros/partials/modal-form :: modal('marcapaginasModal', 'presupuesto.marcapaginas', 'modal-lg', 'marcapaginasModalBody')">
|
||||
th:replace="imprimelibros/partials/modal-form :: modal('marcapaginasModal', 'presupuesto.marcapaginas', 'modal-md', 'marcapaginasModalBody')">
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xl-9">
|
||||
|
||||
@ -70,8 +70,4 @@
|
||||
<button type="submit" class="btn btn-secondary mt-3">Calcular Presupuesto</button>
|
||||
|
||||
</form>
|
||||
<div th:if="${resultado != null}" class="mt-4">
|
||||
<h3>Resultado del Presupuesto</h3>
|
||||
<pre th:text="${resultado}"></pre>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,51 @@
|
||||
<div th:fragment="marcapaginasForm">
|
||||
<form id="marcapaginasForm" novalidate th:action="@{/presupuesto/public/marcapaginas}" th:object="${presupuestoMarcapaginas}" method="get">
|
||||
<div class="form-group mb-3">
|
||||
<label th:text="#{presupuesto.tirada}" for="marcapaginas-tirada">Tirada</label>
|
||||
<input type="number" class="form-control" id="marcapaginas-tirada" th:field="*{unidades}" min="100" required>
|
||||
<div class="invalid-feedback"></div>
|
||||
</div>
|
||||
<div class="form-group mb-3">
|
||||
<label th:text="#{presupuesto.marcapaginas.tamanio}" for="tamanio-maquetacion">Tamaño</label>
|
||||
<select class="form-control" id="tamanio-maquetacion" th:field="*{tamanio}" required>
|
||||
<option value="_50x140_" selected>50x140 mm</option>
|
||||
<option value="_50x170_">50x170 mm</option>
|
||||
<option value="_50x210_">50x210 mm</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group mb-3">
|
||||
<label th:text="#{presupuesto.marcapaginas.caras-impresion}" for="caras-impresion">Caras impresión</label>
|
||||
<select class="form-control" id="caras-impresion" th:field="*{carasImpresion}" required>
|
||||
<option th:text="#{presupuesto.marcapaginas.caras-impresion-1}" value="una_cara">Una cara</option>
|
||||
<option th:text="#{presupuesto.marcapaginas.caras-impresion-2}" value="dos_caras" selected>Dos caras</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group mb-3">
|
||||
<label th:text="#{presupuesto.marcapaginas.papel}" for="papel-marcapaginas">Papel marcapáginas</label>
|
||||
<select class="form-control" id="papel-marcapaginas" th:field="*{papel}" required>
|
||||
<option th:text="#{presupuesto.marcapaginas.papel.cartulina-grafica}" value="cartulina_grafica">Cartulina gráfica</option>
|
||||
<option th:text="#{presupuesto.marcapaginas.papel.estucado-mate}" value="estucado_mate" selected>Estucado mate</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group mb-3">
|
||||
<label th:text="#{presupuesto.marcapaginas.gramaje}" for="gramaje-marcapaginas">Gramaje marcapáginas</label>
|
||||
<select class="form-control" id="gramaje-marcapaginas" th:field="*{gramaje}" required>
|
||||
<option value="300" selected>300</option>
|
||||
<option value="350">350</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group mb-3">
|
||||
<label th:text="#{presupuesto.marcapaginas.acabado}" for="acabado-marcapaginas">Acabado marcapáginas</label>
|
||||
<select class="form-control" id="acabado-marcapaginas" th:field="*{acabado}" required>
|
||||
<option class="marcapaginas-1cara marcapaginas-2caras" value="ninguno" th:text="#{presupuesto.marcapaginas.acabado.ninguno}" selected>Sin acabado</option>
|
||||
<option class="marcapaginas-1cara" value="plastificado_brillo_1c" th:text="#{presupuesto.marcapaginas.acabado.plastificado-brillo-1c}">Plastificado brillo</option>
|
||||
<option class="marcapaginas-1cara" value="plastificado_mate_1c" th:text="#{presupuesto.marcapaginas.acabado.plastificado-mate-1c}">Plastificado mate</option>
|
||||
<option class="marcapaginas-2caras" value="plastificado_brillo_2c" th:text="#{presupuesto.marcapaginas.acabado.plastificado-brillo-2c}">Plastificado brillo</option>
|
||||
<option class="marcapaginas-2caras" value="plastificado_mate_2c" th:text="#{presupuesto.marcapaginas.acabado.plastificado-mate-2c}">Plastificado mate</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-secondary mt-3">Calcular Presupuesto</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
Reference in New Issue
Block a user