-
+
@@ -287,114 +288,4 @@
-
-
-
-= $this->section("additionalInlineJs") ?>
-$('#papelFormatoId').select2({
- allowClear: false,
-});
-
-
- var ancho_libro = getDimensionLibro().ancho;
- var alto_libro = getDimensionLibro().alto;
-
- $('#retractilado').on("change", function () {
- checkRetractiladoComparador(this);
- servicioRetractilado()
- });
-
-
- $('#retractilado5').on("change", function () {
- checkRetractiladoComparador(this);
- servicioRetractilado5()
- });
-
- $('#fajaColor').on("change", function () {
- servicioFajaColor()
- });
-
- $('#ferro').on("change", function () {
- servicioFerro()
- });
-
- $('#prototipo').on("change", function () {
- servicioPrototipo()
- servicioFerro()
- });
-
-
-$('#papelFormatoId').on('select2:select', event_change_formato)
-$('.formato_libro').on('change', event_change_formato)
-
-function event_change_formato(){
- ancho_libro = getDimensionLibro().ancho;
- alto_libro = getDimensionLibro().alto;
-
-
- // Si es negro o color
- if ($('#tipoImpresion').select2('data')[0].id == 'negro' ||
- $('#tipoImpresion').select2('data')[0].id == 'color') {
- $('#compPaginasNegro').trigger('change')
- }
- // Si es negrohq o colorhq
- if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' ||
- $('#tipoImpresion').select2('data')[0].id == 'colorhq') {
- $('#compPaginasNegrohq').trigger('change');
- }
-
- $('.solapas_cubierta').trigger('change')
- $('.solapas_sobrecubierta').trigger('change')
-
- checkPaginasPresupuesto()
-
- updatePresupuesto({
- update_lineas: true,
- update_servicios: true,
- update_envios: true,
- update_resumen: true,
- update_tiradas_alternativas: true
- })
- //updateLineasPresupuesto()
- //update_servicios(false)
-}
-
-
-
-
-
-$("#solapas").on("click", function () {
- var e = document.getElementById('div_solapas_ancho');
- if (document.getElementById('solapas').checked) {
- e.style.display = "block";
- }
- else {
- e.style.display = "none";
- $('#solapas_ancho').val(0)
- }
-
- $('#serv_default').click()
-});
-
-
-$("#solapas_sobrecubierta").on("click", function () {
- var e = document.getElementById('div_solapas_ancho_sobrecubierta');
- if (document.getElementById('solapas_sobrecubierta').checked) {
- e.style.display = "block";
- }
- else {
- e.style.display = "none";
- $('#solapas_ancho_sobrecubierta').val(0)
- }
-
- $('#serv_default').click()
-});
-
-let initTamanioPersonalizado = papel_formato_personalizado==true?1:0); ?>;
-if(initTamanioPersonalizado != null){
- if ( initTamanioPersonalizado){
- $('#papelFormatoId').next(".select2-container").hide();
- }
-}
-= $this->endSection() ?>
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/comparador.js b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/comparador.js
index fef4b8da..61231bc8 100644
--- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/comparador.js
+++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/comparador.js
@@ -218,24 +218,7 @@ function computarPaginasColor(string) {
}
-function checkRetractiladoComparador(element) {
- switch (element.id) {
- case 'retractilado':
- if ($('#' + element.id).prop('checked')) {
- $('#retractilado5').prop('checked', false);
- }
- break;
- case 'retractilado5':
- if ($('#' + element.id).prop('checked')) {
- $('#retractilado').prop('checked', false);
- }
- break;
- default:
- break;
- }
-
-}
function updatePapelesComparador() {
@@ -502,16 +485,11 @@ function getDimensionLibro() {
var ancho = 0;
var alto = 0;
-
- if ($('#papelFormatoId').select2('data').length > 0) {
- if ($('#papelFormatoId').select2('data')[0].id.length > 0) {
- ancho = parseFloat($('#papelFormatoId').select2('data')[0].text.trim().split(" x ")[0]);
- alto = parseFloat($('#papelFormatoId').select2('data')[0].text.trim().split(" x ")[1]);
- }
- else if (document.getElementById('papelFormatoPersonalizado').checked) {
- ancho = parseFloat(document.getElementById('papelFormatoAncho').value);
- alto = parseFloat(document.getElementById('papelFormatoAlto').value);
- }
+ // TO-DO
+ if (!document.getElementById('papelFormatoPersonalizado').checked) {
+ ancho = 170//parseFloat($('#papelFormatoId').getText().trim().split(" x ")[0]);
+ alto = 240//parseFloat($('#papelFormatoId').getText().trim().split(" x ")[1]);
+
}
else if (document.getElementById('papelFormatoPersonalizado').checked) {
diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js
index 7e78df1c..8bfebb7b 100644
--- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js
+++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js
@@ -20,7 +20,12 @@ class PresupuestoAdminEdit {
this.cosido = $("#isCosido");
this.datosGenerales = new DatosGenerales(this.domItem.find('#accordionDatosPresupuestoTip'));
- this.datosLibro = new DatosLibro(this.domItem.find('#accordionDatosPresupuestoTip'));
+ this.datosLibro = new DatosLibro(this.domItem.find('#accordionDatosLibroTip',
+ {
+ addService: this.addService,
+ removeService: this.removeService,
+ checkPaginasPresupuesto: this.checkPaginasPresupuesto,
+ }));
this.calcularPresupuesto = false;
}
@@ -33,6 +38,7 @@ class PresupuestoAdminEdit {
});
this.datosGenerales.init();
+ this.datosLibro.init();
if (window.location.href.includes("edit")) {
@@ -69,6 +75,7 @@ class PresupuestoAdminEdit {
self.calcularPresupuesto = false;
self.datosGenerales.cargarDatos(response.data.datosGenerales);
+ self.datosLibro.cargarDatos(response.data.datosLibro);
/*self.direcciones.handleChangeCliente();
@@ -103,6 +110,65 @@ class PresupuestoAdminEdit {
).get();
}
+
+ addService() {
+
+ }
+
+ removeService() {
+
+ }
+
+
+ checkPaginasPresupuesto() {
+
+ cantidad_total = 0
+
+ tableLineasPresupuesto.rows().every(function (rowIdx, tableLoop, rowLoop) {
+ var rowData = this.data();
+ if (rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta' && rowData.row_id != 'lp_guardas')
+ cantidad_total += parseInt(rowData.paginas)
+ })
+ htmlString = ''
+
+ if (cantidad_total != parseInt($('#paginas').val())) {
+ htmlString = `
+
+
+
+
+
+
` +
+ window.Presupuestos.errores.paginasLP +
+ `
+
+
`;
+ }
+ $('#divAlarmasLineasPresupuesto').html(htmlString)
+ }
+
+ getDimensionLibro() {
+
+ var ancho = 0;
+ var alto = 0;
+
+
+ if ($('#papelFormatoPersonalizado').is(':checked')) {
+ ancho = parseFloat($('#papelFormatoAncho').val());
+ alto = parseFloat($('#papelFormatoAlto').val());
+ }
+ else {
+ ancho = parseFloat($('#papelFormatoId').getText().trim().split(" x ")[0]);
+ alto = parseFloat($('#papelFormatoId').getText().trim().split(" x ")[1]);
+ }
+
+ return {
+ ancho: ancho,
+ alto: alto
+ }
+ }
+
+
#checkChangesPresupuesto() {
// Detectar cambios en inputs de texto
$('input[type="text"]').on('change', function () {
@@ -150,7 +216,7 @@ document.addEventListener('DOMContentLoaded', function () {
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
- new Ajax('/translate/getTranslation', { locale: locale, translationFile: ['Maquinas'] }, {},
+ new Ajax('/translate/getTranslation', { locale: locale, translationFile: ['Presupuestos'] }, {},
function (translations) {
window.language = JSON.parse(translations);
new PresupuestoAdminEdit().init();
diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js
index 2f280aae..04dbf433 100644
--- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js
+++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js
@@ -1,17 +1,27 @@
+import ClassSelect from '../../../components/select2.js';
+import { getToken } from '../../../common/common.js';
+
class DatosLibro {
- constructor(domItem) {
+ constructor(domItem, functions = {}) {
this.domItem = domItem;
+ this.addService = functions.addService;
+ this.removeService = functions.removeService;
+ this.checkPaginasPresupuesto = functions.checkPaginasPresupuesto;
+
+ this.csrf_token = getToken();
+ this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val();
+
this.paginas = this.domItem.find('#paginas');
this.tirada = this.domItem.find('#tirada');
- this.tamanio = this.domItem.find('#papelFormatoId');
+ this.tamanio = new ClassSelect($("#papelFormatoId"), '/papel-formato/getSelect2', window.language["formatoLibro"]);
this.tamanioPersonalizado = this.domItem.find('#papelFormatoPersonalizado');
this.anchoPersonalizado = this.domItem.find('#papelFormatoAncho');
this.altoPersonalizado = this.domItem.find('#papelFormatoAlto');
this.merma = this.domItem.find('#merma');
- this.mermaCubierta = this.domItem.find('#mermaCubierta');
+ this.mermaCubierta = this.domItem.find('#mermacubierta');
this.solapasCubierta = this.domItem.find('#solapas');
this.solapasSobrecubierta = this.domItem.find('#solapas_sobrecubierta');
this.anchoSolapasCubierta = this.domItem.find('#anchoSolapasCubierta');
@@ -20,12 +30,28 @@ class DatosLibro {
this.divSolapasCubierta = this.domItem.find('#div_solapas_ancho');
this.divSolapasSobrecubierta = this.domItem.find('#div_solapas_ancho_sobrecubierta');
- this.acabadoCubierta = this.domItem.find('#acabado_cubierta_id');
- this.acabadoSobrecubierta = this.domItem.find('#acabado_sobrecubierta_id');
+ this.acabadoCubierta = new ClassSelect($("#acabado_cubierta_id"),
+ '/serviciosacabados/getacabados',
+ '',
+ false,
+ {
+ [this.csrf_token]: this.csrf_hash,
+ "cubierta": 1
+ }
+ );
+ this.acabadoSobrecubierta = new ClassSelect($("#acabado_sobrecubierta_id"),
+ '/serviciosacabados/getacabados',
+ '',
+ false,
+ {
+ [this.csrf_token]: this.csrf_hash,
+ "sobrecubierta": 1
+ }
+ );
this.retractilado = this.domItem.find('#retractilado');
this.retractilado5 = this.domItem.find('#retractilado5');
- this.imprimirFajaColor = this.domItem.find('#imprimirFajaColor');
+ this.imprimirFajaColor = this.domItem.find('#fajaColor');
this.prototipo = this.domItem.find('#prototipo');
this.ferro = this.domItem.find('#ferro');
this.ferroDigital = this.domItem.find('#ferroDigital');
@@ -35,20 +61,193 @@ class DatosLibro {
init() {
+ this.tamanio.init();
+ this.acabadoCubierta.init();
+ this.acabadoSobrecubierta.init();
+
+ if (window.location.href.includes("edit")) {
+ this.retractilado.on('change', this.checkRetractilado.bind(this));
+ this.retractilado5.on('change', this.checkRetractilado.bind(this));
+ this.imprimirFajaColor.on('change', (this.changeFajaColor.bind(this)));
+ this.ferro.on('change', this.changeFerro.bind(this));
+ this.prototipo.on('change', this.changePrototipo.bind(this));
+
+ this.tamanio.item.on('select2:select', this.changeFormato.bind(this));
+ $('.formato_libro').on('change', this.changeFormato.bind(this));
+
+ if ($('#tipo_impresion_id').val() != 1 && $('#tipo_impresion_id').val() != 3 &&
+ $('#tipo_impresion_id').val() != 5 && $('#tipo_impresion_id').val() != 7) {
+ this.solapasCubierta.on('change', this.changeSolapasCubierta.bind(this));
+ }
+
+ this.solapasSobrecubierta.on('change', this.changeSolapasSobrecubierta.bind(this));
+ }
}
+ changeFajaColor() {
+
+ if (this.imprimirFajaColor.prop('checked')) {
+ this.addService('fajaColor');
+ }
+ else {
+ this.removeService('fajaColor');
+ }
+ }
+
+ changeFerro() {
+
+ if (this.ferro.prop('checked')) {
+ this.addService('ferro');
+ }
+ else {
+ this.removeService('ferro');
+ }
+ }
+
+ changePrototipo() {
+
+ if (this.prototipo.prop('checked')) {
+ this.addService('prototipo');
+ }
+ else {
+ this.removeService('prototipo');
+ }
+ }
+
+
+ checkRetractilado(element) {
+
+ switch (element.id) {
+ case 'retractilado':
+ if ($('#' + element.id).prop('checked')) {
+ $('#retractilado5').prop('checked', false);
+ this.removeService('retractilado5');
+ this.addService('retractilado');
+ }
+ break;
+ case 'retractilado5':
+ if ($('#' + element.id).prop('checked')) {
+ $('#retractilado').prop('checked', false);
+ this.removeService('retractilado');
+ this.addService('retractilado5');
+ }
+ break;
+ default:
+ break;
+ }
+
+ }
+
+ changeFormato() {
+
+ // Si es negro o color
+ if ($('#tipoImpresion').select2('data')[0].id == 'negro' ||
+ $('#tipoImpresion').select2('data')[0].id == 'color') {
+ $('#compPaginasNegro').trigger('change')
+ }
+ // Si es negrohq o colorhq
+ if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' ||
+ $('#tipoImpresion').select2('data')[0].id == 'colorhq') {
+ $('#compPaginasNegrohq').trigger('change');
+ }
+
+ $('.solapas_cubierta').trigger('change');
+ $('.solapas_sobrecubierta').trigger('change');
+
+ this.checkPaginasPresupuesto();
+
+ // TO-DO
+ /*updatePresupuesto({
+ update_lineas: true,
+ update_servicios: true,
+ update_envios: true,
+ update_resumen: true,
+ update_tiradas_alternativas: true
+ })*/
+ }
+
+ changeSolapasCubierta() {
+
+ if (this.solapasCubierta.prop('checked', true)) {
+ this.divSolapasCubierta.removeClass('d-none');
+ }
+ else {
+ this.divSolapasCubierta.addClass('d-none');
+ this.anchoSolapasCubierta.val(0);
+ }
+ $('#serv_default').trigger('click');
+ }
+
+
+ changeSolapasSobrecubierta() {
+
+ if (this.solapasSobrecubierta.prop('checked', true)) {
+ this.divSolapasSobrecubierta.removeClass('d-none');
+ }
+ else {
+ this.divSolapasSobrecubierta.addClass('d-none');
+ this.anchoSolapasSobrecubierta.val(0);
+ }
+ $('#serv_default').trigger('click');
+ }
+
+
cargarDatos(datos) {
+ this.paginas.val(datos.paginas);
+ this.tirada.val(datos.tirada);
+ if (datos.papelFormatoPersonalizado) {
+ this.tamanioPersonalizado.prop('checked', true);
+ $(".tamanio-personalizado").removeClass('d-none');
+ $(".tamanio-estandar").addClass('d-none');
+ this.anchoPersonalizado.val(datos.papelFormatoAlto);
+ this.altoPersonalizado.val(datos.papelFormatoAncho);
+ }
+ else {
+ $(".tamanio-personalizado").addClass('d-none');
+ $(".tamanio-estandar").removeClass('d-none');
+ this.tamanio.setOption(datos.papelFormatoId, datos.papelFormatoNombre);
+ }
+
+ this.merma.val(datos.merma);
+ this.mermaCubierta.val(datos.mermaCubierta);
+
if ($('#tipo_impresion_id').val() == 1 || $('#tipo_impresion_id').val() == 3 ||
$('#tipo_impresion_id').val() == 5 || $('#tipo_impresion_id').val() == 7) {
$(".impresion-con-solapas").addClass('d-none');
}
+ else {
+ if (datos.solapas) {
+ this.solapasCubierta.val(datos.solapas);
+ this.anchoSolapasCubierta.val(datos.ancho_solapas);
+ $('#div_solapas_ancho').removeClass('d-none');
+ }
+ if (datos.solapas_sobrecubierta) {
+ this.solapasSobrecubierta.prop('checked', true);
+ this.anchoSolapasSobrecubierta.val(datos.ancho_solapas_sobrecubierta);
+ $('#div_solapas_ancho_sobrecubierta').removeClass('d-none');
+ }
+ }
+
+ this.acabadoCubierta.setOption(datos.acabadoCubierta.id, datos.acabadoCubierta.text);
if ($('#tipo_impresion_id').val() == 5 || $('#tipo_impresion_id').val() == 6 ||
$('#tipo_impresion_id').val() == 7 || $('#tipo_impresion_id').val() == 8
|| $('#tipo_impresion_id').val() == 21) {
$(".impresion-con-sobrecubierta").addClass('d-none');
}
+ else {
+
+ this.acabadoSobrecubierta.setOption(datos.acabadoSobrecubierta.id, datos.acabadoSobrecubierta.text);
+ }
+
+ this.retractilado.prop('checked', datos.retractilado);
+ this.retractilado5.prop('checked', datos.retractilado5);
+ this.imprimirFajaColor.prop('checked', datos.fajaColor);
+ this.prototipo.prop('checked', datos.prototipo);
+ this.ferro.prop('checked', datos.ferro);
+ this.ferroDigital.prop('checked', datos.ferroDigital);
+ this.marcapaginas.prop('checked', datos.marcapaginas);
}
}