diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index d45c9ea8..75e2c176 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -728,6 +728,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController 'servicios' => $reqData['servicios'] ?? [], ); + $datos_presupuesto['id'] = $id; + $resultado_presupuesto = $this->calcular_presupuesto($datos_presupuesto, $selected_tirada, true); if (isset($resultado_presupuesto['errors'])) { @@ -1402,7 +1404,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController if ($interior == -1) { $errorModel = new ErrorPresupuesto(); $errorModel->insertError( - $datos_entrada['id'], + $datos_entrada['id']==0?null:$datos_entrada['id'], auth()->user()->id, ' No se puede obtener el interior', diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js index 1472fc2b..ce9cc8b5 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js @@ -125,7 +125,7 @@ class Direcciones { validators: { callback: { callback: () => { - const div = $('#divErrorEnvios'); // Selecciona el div + /* const div = $('#divErrorEnvios'); // Selecciona el div div.find('.fv-plugins-message-container').remove(); @@ -149,6 +149,8 @@ class Direcciones { `); return false; + */ + return true; }, } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js index 2bdc5862..02560fd3 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js @@ -439,7 +439,11 @@ class PresupuestoCliente { } } else { - popSuccessAlert(response.message); + if(response.error){ + popErrorAlert("No se ha podido guardar el presupuesto. Por favor, póngase en contacto con el departamento comercial."); + } + else + popSuccessAlert(response.message); } }, () => { $('#loader').modal('hide'); } diff --git a/httpdocs/assets/js/safekat/pages/preview.js b/httpdocs/assets/js/safekat/pages/preview.js index 1b881164..4e52b96d 100644 --- a/httpdocs/assets/js/safekat/pages/preview.js +++ b/httpdocs/assets/js/safekat/pages/preview.js @@ -1,7 +1,7 @@ class previewFormas { constructor(container, tipoLibro, tipoTapa, size, datos) { - + this.container = container; this.tipoLibro = tipoLibro; this.tipoTapa = tipoTapa; @@ -11,10 +11,14 @@ class previewFormas { this.alto = datos.alto; this.lomo = datos.lomo; - if(datos.solapas == undefined || datos.solapas == null || datos.solapas == false) + if (datos.solapas == undefined || datos.solapas == null || datos.solapas == false) { this.solapa = 0; - else + this.offsetSolapa = 0.0; + } + else { this.solapa = datos.solapas; + this.offsetSolapa = 3.0; + } this.lomoRedondo = datos.lomoRedondo; } @@ -49,7 +53,7 @@ class previewFormas { let sangradoTexto = "Sangrado 5 mm"; let sangradoValor = parseFloat(5); // mm let offsetSolapaValor = parseFloat(0); // mm - + // Definicion de los parametros del Esquema de Cubierta (EC) if (this.solapa == 0) { if (this.size == "thumbnail") { @@ -59,13 +63,13 @@ class previewFormas { anchoSangrado = 800; // px altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px } - + altoLibro = altoSangrado * 0.97; anchoLibro = anchoSangrado * 0.419; anchoSolapa = 0; lomoLibro = anchoSangrado * 0.133; anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro; - + } else { if (this.size == "thumbnail") { anchoSangrado = 350; // px @@ -80,14 +84,14 @@ class previewFormas { lomoLibro = anchoSangrado * 0.09; anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro; } - + // Clear the canvas element this.container.empty(); // Get the element for placing the graphical elements var previewEC = new Two({ fitted: true }).appendTo(this.container[0]); // Calculate the center of the canvas element var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2); - + var sangrado = previewEC.makeRectangle( origenEC.x, origenEC.y, @@ -98,7 +102,7 @@ class previewFormas { sangrado.dashes = [5, 5]; sangrado.fill = '#FCEAF1'; sangrado.linewidth = 1; - + if (this.solapa != 0) { var solapas = previewEC.makeRectangle( origenEC.x, @@ -107,7 +111,7 @@ class previewFormas { altoLibro); solapas.stroke = 'black'; solapas.linewidth = 1; - + // Cotas Solapas if (this.size != "thumbnail") { var cotaSolapa2 = previewEC.makeDobleArrow( @@ -124,7 +128,7 @@ class previewFormas { origenEC.y - (altoLibro / 3), 10); cotaSolapa1.linewidth = 2; - + // Textos Solapas let stylesSolapa = { size: 18, family: 'Public Sans' }; previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa); @@ -133,9 +137,9 @@ class previewFormas { previewEC.makeText(anchoSolapa.toFixed(1) + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas); previewEC.makeText(anchoSolapa.toFixed(1) + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas); } - + } - + var libro = previewEC.makeRectangle( origenEC.x, origenEC.y, @@ -143,7 +147,7 @@ class previewFormas { altoLibro); libro.stroke = 'black'; libro.linewidth = 1; - + var lomo = previewEC.makeRectangle( origenEC.x, origenEC.y, @@ -152,7 +156,7 @@ class previewFormas { lomo.stroke = 'black'; lomo.fill = '#F4F8F2'; lomo.linewidth = 1; - + // Cotas y textos if (this.size != "thumbnail") { // Cotas: @@ -198,8 +202,8 @@ class previewFormas { origenEC.y - (altoLibro / 3), 10); cotaPortada.linewidth = 2; - - + + // Textos: // Titulos generales let stylesEC = { size: 22, weight: 'bold', family: 'Public Sans' }; @@ -222,11 +226,11 @@ class previewFormas { origenEC.x, origenEC.y + (altoLibro / 2) + 50, styleCotas); - + } - + previewEC.update(); - + } @@ -237,14 +241,14 @@ class previewFormas { let styleCotas = { size: 12, family: 'Public Sans' }; let sangradoTexto = "Sangrado 20 mm"; let sangradoValor = parseFloat(20); // mm - if(this.ancho >= 210 || this.alto >= 297){ + if (this.ancho >= 210 || this.alto >= 297) { sangradoValor = parseFloat(15); // mm sangradoTexto = "Sangrado 15 mm"; } let anchoPliegue = parseFloat(7); // mm cajo let altoPliegue = parseFloat(7); // mm let anchoCarton = parseFloat(6); // mm - if(this.lomoRedondo) + if (this.lomoRedondo) anchoCarton += parseFloat(6); // mm // Definicion de los parametros del Esquema de Cubierta (EC) if (this.size == "thumbnail") { @@ -258,15 +262,15 @@ class previewFormas { anchoLibro = anchoSangrado * 0.39; lomoLibro = anchoSangrado * 0.133; anchoCubierta = (2 * anchoLibro) + lomoLibro; - + // Clear the canvas element this.container.empty(); // Get the element for placing the graphical elements var previewEC = new Two({ fitted: true }).appendTo($(this.container)[0]); - + // Calculate the center of the canvas element var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2); - + var sangrado = previewEC.makeRectangle( origenEC.x, origenEC.y, @@ -277,7 +281,7 @@ class previewFormas { sangrado.dashes = [5, 5]; sangrado.fill = '#FCEAF1'; sangrado.linewidth = 1; - + var libro = previewEC.makeRectangle( origenEC.x, origenEC.y, @@ -285,7 +289,7 @@ class previewFormas { altoLibro); libro.stroke = 'black'; libro.linewidth = 1; - + var lomo = previewEC.makeRectangle( origenEC.x, origenEC.y, @@ -294,7 +298,7 @@ class previewFormas { lomo.stroke = 'black'; lomo.fill = '#F4F8F2'; lomo.linewidth = 1; - + // Cotas y textos if (this.size != "thumbnail") { // Cotas: @@ -340,8 +344,8 @@ class previewFormas { origenEC.y - (altoLibro / 3), 10); cotaPortada.linewidth = 2; - - + + // Textos: // Titulos generales let stylesEC = { size: 22, weight: 'bold', family: 'Public Sans' }; @@ -358,16 +362,16 @@ class previewFormas { previewEC.makeText((this.lomo + anchoCarton).toFixed(1) + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas); previewEC.makeText((this.ancho + anchoPliegue).toFixed(1) + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas); previewEC.makeText((this.ancho + anchoPliegue).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas); - previewEC.makeText((this.alto + altoPliegue).toFixed(1)+ " mm", origenEC.x + (lomoLibro / 2) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2; + previewEC.makeText((this.alto + altoPliegue).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2; previewEC.makeText((this.alto + (2 * sangradoValor) + altoPliegue).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro) + 55, origenEC.y, styleCotas).rotation = -Math.PI / 2; previewEC.makeText((2 * this.ancho) + this.lomo + (2 * sangradoValor) + +(2 * anchoPliegue) + anchoCarton + " mm", origenEC.x, origenEC.y + (altoLibro / 2) + 50, styleCotas); - + } - - previewEC.update(); + + previewEC.update(); } #portadaEspiral(isTapaDura = false) { @@ -377,8 +381,8 @@ class previewFormas { let styleCotas = { size: 12, family: 'Public Sans' }; let sangradoTexto = (isTapaDura) ? "Sangrado 20 mm" : "Sangrado 5 mm"; let sangradoValor = (isTapaDura) ? parseFloat(20) : parseFloat(5); // mm - - + + // Definicion de los parametros del Esquema de Cubierta (EC) if ((this.solapa !== 0) && (!isTapaDura)) { if (this.size == "thumbnail") { @@ -396,7 +400,7 @@ class previewFormas { anchoCubierta = 2 * (anchoLibro + anchoSolapa + sangrado) + anchoCalle; offsetCubierta = anchoLibro / 2 + anchoCalle / 2 + anchoSolapa / 2 + sangrado; } else { - if (this.size == "thumbnail") { + if (this.size == "thumbnail") { anchoSangrado = 350; // px altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px } else { @@ -410,11 +414,11 @@ class previewFormas { anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + anchoCalle; offsetCubierta = anchoLibro / 2 + anchoCalle / 2 + anchoSolapa + sangradoValor; } - + var previewEC = new Two({ fitted: true }).appendTo(this.container[0]); // Calculate the center of the canvas element var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2); - + var sangrado = previewEC.makeRectangle( origenEC.x, origenEC.y, @@ -425,7 +429,7 @@ class previewFormas { sangrado.dashes = [5, 5]; sangrado.fill = '#FCEAF1'; sangrado.linewidth = 1; - + if ((this.solapa != 0) && (!isTapaDura)) { var solapa1 = previewEC.makeRectangle( origenEC.x + (anchoLibro + anchoCalle / 2 + anchoSolapa / 2 + sangradoValor), @@ -434,7 +438,7 @@ class previewFormas { altoLibro); solapa1.stroke = 'black'; solapa1.linewidth = 1; - + var solapa2 = previewEC.makeRectangle( origenEC.x - (anchoLibro + anchoCalle / 2 + anchoSolapa / 2 + sangradoValor), origenEC.y, @@ -442,7 +446,7 @@ class previewFormas { altoLibro); solapa2.stroke = 'black'; solapa2.linewidth = 1; - + // Cotas y textos if (this.size != "thumbnail") { // Cotas @@ -460,7 +464,7 @@ class previewFormas { origenEC.y - (altoLibro / 3), 10); cotaSolapa1.linewidth = 2; - + // Textos Solapas let stylesSolapa = { size: 18, family: 'Public Sans' }; previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y, stylesSolapa); @@ -469,9 +473,9 @@ class previewFormas { previewEC.makeText((this.solapa).toFixed(1) + " mm", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas); previewEC.makeText(this.solapa.toFixed(1) + " mm", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas); } - + } - + var portada = previewEC.makeRectangle( origenEC.x + (anchoLibro / 2 + anchoCalle / 2 + sangradoValor), origenEC.y, @@ -479,7 +483,7 @@ class previewFormas { altoLibro); portada.stroke = 'black'; portada.linewidth = 1; - + var contraportada = previewEC.makeRectangle( origenEC.x - (anchoLibro / 2 + anchoCalle / 2 + sangradoValor), origenEC.y, @@ -487,7 +491,7 @@ class previewFormas { altoLibro); contraportada.stroke = 'black'; contraportada.linewidth = 1; - + var calle = previewEC.makeRectangle( origenEC.x, origenEC.y, @@ -497,7 +501,7 @@ class previewFormas { calle.dashes = [2, 5]; calle.fill = '#F4F8F2'; calle.linewidth = 1; - + // Cotas y textos if (this.size != "thumbnail") { // Cotas: @@ -536,8 +540,8 @@ class previewFormas { origenEC.y - (altoLibro / 3), 10); cotaPortada.linewidth = 2; - - + + // Textos: // Titulos generales let stylesEC = { size: 22, weight: 'bold', family: 'Public Sans' }; @@ -573,9 +577,9 @@ class previewFormas { origenEC.y + (altoLibro / 2) + 50, styleCotas); } - + previewEC.update(); - + } @@ -586,8 +590,7 @@ class previewFormas { let styleCotas = { size: 12, family: 'Public Sans' }; let sangradoTexto = "Sangrado 5 mm"; let sangradoValor = parseFloat(5); // mm - let offsetSolapaValor = parseFloat(0); // mm - + // Definicion de los parametros del Esquema de Cubierta (EC) if (this.solapa == 0) { if (this.size == "thumbnail") { @@ -602,7 +605,7 @@ class previewFormas { anchoSolapa = 0; lomoLibro = 0; // ESTA ES LA DIFERENCIA PARA GRAPADO anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro; - + } else { if (this.size == "thumbnail") { anchoSangrado = 350; // px @@ -617,11 +620,11 @@ class previewFormas { lomoLibro = 0; // ESTA ES LA DIFERENCIA PARA GRAPADO anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro; } - + var previewEC = new Two({ fitted: true }).appendTo(this.container[0]); // Calculate the center of the canvas element var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2); - + var sangrado = previewEC.makeRectangle( origenEC.x, origenEC.y, @@ -632,7 +635,7 @@ class previewFormas { sangrado.dashes = [5, 5]; sangrado.fill = '#FCEAF1'; sangrado.linewidth = 1; - + if (this.solapa != 0) { var solapas = previewEC.makeRectangle( origenEC.x, @@ -641,7 +644,7 @@ class previewFormas { altoLibro); solapas.stroke = 'black'; solapas.linewidth = 1; - + // Cotas y textos if (this.size != "thumbnail") { // Cotas @@ -659,7 +662,7 @@ class previewFormas { origenEC.y - (altoLibro / 3), 10); cotaSolapa1.linewidth = 2; - + // Textos Solapas let stylesSolapa = { size: 18, family: 'Public Sans' }; previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa); @@ -668,9 +671,9 @@ class previewFormas { previewEC.makeText(this.solapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas); previewEC.makeText(this.solapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas); } - + } - + var libro = previewEC.makeRectangle( origenEC.x, origenEC.y, @@ -678,7 +681,7 @@ class previewFormas { altoLibro); libro.stroke = 'black'; libro.linewidth = 1; - + var lomo = previewEC.makeRectangle( origenEC.x, origenEC.y, @@ -687,7 +690,7 @@ class previewFormas { lomo.stroke = 'black'; lomo.fill = '#F4F8F2'; lomo.linewidth = 1; - + // Cotas y textos if (this.size != "thumbnail") { // Cotas: @@ -726,7 +729,7 @@ class previewFormas { origenEC.y - (altoLibro / 3), 10); cotaPortada.linewidth = 2; - + // Textos: // Titulos generales let stylesEC = { size: 22, weight: 'bold', family: 'Public Sans' }; @@ -739,16 +742,16 @@ class previewFormas { previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2; previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2; // Cotas - previewEC.makeText((anchoLibro + offsetSolapaValor).toFixed(1) + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas); - previewEC.makeText((anchoLibro + offsetSolapaValor).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas); - previewEC.makeText(altoLibro.toFixed(1) + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2; - previewEC.makeText(altoLibro.toFixed(1) + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2; - previewEC.makeText(((2 * anchoLibro) + (2 * (anchoSolapa + offsetSolapaValor)) + lomoLibro + (2 * sangradoValor)).toFixed(1) + " mm", + previewEC.makeText((this.ancho + this.offsetSolapa).toFixed(1) + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas); + previewEC.makeText((this.ancho + this.offsetSolapa).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas); + previewEC.makeText(this.alto.toFixed(1) + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2; + previewEC.makeText(this.alto.toFixed(1) + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2; + previewEC.makeText(((2 * anchoLibro) + (2 * (this.solapa + this.offsetSolapa)) + this.lomo + (2 * sangradoValor)).toFixed(1) + " mm", origenEC.x, origenEC.y + (altoLibro / 2) + 50, styleCotas); } - + previewEC.update(); } }