From 586dfa7343e082e45bf20d6f6f5eb24cec2b8240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Sun, 15 Dec 2024 21:13:25 +0100 Subject: [PATCH 01/89] trabajando en datoslibro --- ci4/app/Config/Routes.php | 1 + .../Presupuestos/Presupuestoadmin.php | 119 +++++++++++++ .../presupuestos/admin/_datosLibroItems.php | 145 ++++++---------- .../admin/_datosPresupuestoItems.php | 48 ++---- .../admin/viewPresupuestoadminForm.php | 106 ++---------- .../presupuestoAdmin/presupuestoAdminEdit.js | 162 ++++++++++++++++++ .../sections/datosGenerales.js | 56 ++++++ .../presupuestoAdmin/sections/datosLibro.js | 55 ++++++ 8 files changed, 478 insertions(+), 214 deletions(-) create mode 100644 httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js create mode 100644 httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosGenerales.js create mode 100644 httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index bcbf0798..0974fafd 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -570,6 +570,7 @@ $routes->group('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos $routes->get('list/(:num)', 'Presupuestoadmin::list/$1', ['as' => 'presupuestoAdminList']); // HOMOGENIZAR CON ARGS DINAMICOS!!! $routes->get('add/(:num)', 'Presupuestoadmin::add/$1', ['as' => 'newPresupuestoAdmin']); $routes->get('edit/(:any)', 'Presupuestoadmin::edit/$1', ['as' => 'editarPresupuestoAdmin']); + $routes->get('cargar/(:any)', 'Presupuestoadmin::cargar/$1'); $routes->post('add/(:num)', 'Presupuestoadmin::add/$1', ['as' => 'createPresupuestoAdmin']); $routes->post('create', 'Presupuestoadmin::create', ['as' => 'ajaxCreatePresupuestoAdmin']); $routes->put('(:num)/update', 'Presupuestoadmin::update/$1', ['as' => 'ajaxUpdatePresupuestoAdmin']); diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index 36c8a103..79b805b3 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -6,6 +6,8 @@ use App\Entities\Presupuestos\PresupuestoEntity; use App\Models\Collection; use App\Models\Configuracion\MaquinaModel; use App\Models\Configuracion\PapelGenericoModel; +use App\Models\Configuracion\PapelFormatoModel; +use App\Models\Clientes\ClienteModel; use App\Models\Configuracion\PapelImpresionModel; use App\Models\Configuracion\TipoPresupuestoModel; use App\Models\Presupuestos\PresupuestoAcabadosModel; @@ -468,6 +470,123 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController return $response; } + public function cargar($id){ + if ($this->request->isAJAX()) { + + $modelPapelFormato = new PapelFormatoModel(); + $modelCliente = new ClienteModel(); + + + $presupuesto = $this->model->find($id); + $data = []; + if ($presupuesto) { + + $data['lc'] = $presupuesto->lomo_cubierta; + $data['lsc'] = $presupuesto->lomo_sobrecubierta; + $data['tipo_impresion'] = $presupuesto->tipo_impresion_id; + $data['cosido'] = $presupuesto->cosido; + + $data['datosGenerales']['id'] = $presupuesto->id; + $data['datosGenerales']['state'] = intval($presupuesto->estado_id); + $data['datosGenerales']['updated_at'] = date('d/m/Y', strtotime($presupuesto->updated_at)); + $data['datosGenerales']['created_at'] = date('d/m/Y', strtotime($presupuesto->created_at)); + $data['datosGenerales']['inc_rei'] = $presupuesto->inc_rei == null ? 0 : $presupuesto->inc_rei; + $data['datosGenerales']['titulo'] = $presupuesto->titulo; + $data['datosGenerales']['autor'] = $presupuesto->autor; + $data['datosGenerales']['coleccion'] = $presupuesto->coleccion; + $data['datosGenerales']['numero_edicion'] = $presupuesto->numero_edicion; + $data['datosGenerales']['isbn'] = $presupuesto->isbn; + $data['datosGenerales']['pais'] = $presupuesto->pais_id; + $data['datosGenerales']['cliente']['id'] = $presupuesto->cliente_id; + $data['datosGenerales']['cliente']['nombre'] = $modelCliente->getNombre($presupuesto->cliente_id); + $data['datosGenerales']['referenciaCliente'] = $presupuesto->referencia_cliente; + + /* + model('App\Models\Clientes\ClienteModel') + ->find($presupuesto->cliente_id)->nombre; + $data['datosGenerales']['papelFormatoId'] = $presupuesto->papel_formato_id; + $data['datosGenerales']['papelFormatoNombre'] = $modelPapelFormato->getNombre($presupuesto->papel_formato_id); + $data['datosGenerales']['papelFormatoPersonalizado'] = $presupuesto->papel_formato_personalizado; + $data['datosGenerales']['papelFormatoAncho'] = $presupuesto->papel_formato_ancho; + $data['datosGenerales']['papelFormatoAlto'] = $presupuesto->papel_formato_alto; + + $data['datosGenerales']['posPaginasColor'] = $presupuesto->comp_pos_paginas_color; + $data['datosGenerales']['papelInteriorDiferente'] = $presupuesto->papel_interior_diferente; + $data['datosGenerales']['paginasColorConsecutivas'] = $presupuesto->paginas_color_consecutivas; + + $data['datosGenerales']['tipo'] = $this->getTipoLibro($presupuesto->tipo_impresion_id ?? null); + $data['datosGenerales']['prototipo'] = $presupuesto->prototipo; + $data['datosGenerales']['ferro'] = $presupuesto->ferro; + $data['datosGenerales']['ferroDigital'] = $presupuesto->ferro_digital; + $data['datosGenerales']['marcapaginas'] = $presupuesto->marcapaginas; + $data['datosGenerales']['retractilado'] = $presupuesto->retractilado; + $data['datosGenerales']['retractilado5'] = $presupuesto->retractilado5; + + $datos_papel = $this->obtenerDatosPapel($presupuesto->id); + $data['interior'] = $datos_papel['interior'] ? $datos_papel['interior'] : []; + + $data['cubierta'] = $datos_papel['cubierta'] ? $datos_papel['cubierta'] : []; + $data['cubierta']['tapa'] = $this->obtenerTipoTapa($presupuesto->tipo_impresion_id ?? null); + $data['cubierta']['lomoRedondo'] = $presupuesto->lomo_redondo ? 1 : 0; + $data['cubierta']['solapas'] = $presupuesto->solapas ? 1 : 0; + $data['cubierta']['solapas_ancho'] = $presupuesto->solapas_ancho; + $data['cubierta']['cabezada'] = $presupuesto->cabezada; + $modelAcabado = model("App\Models\Tarifas\Acabados\TarifaAcabadoModel"); + $data['cubierta']['acabado']['id'] = $presupuesto->acabado_cubierta_id; + if ($presupuesto->acabado_cubierta_id == 0) { + $data['cubierta']['acabado']['text'] = "Ninguno"; + } else { + $data['cubierta']['acabado']['text'] = $modelAcabado->find($presupuesto->acabado_cubierta_id)->nombre; + } + $data['cubierta']['retractilado'] = $presupuesto->retractilado ? 1 : 0; + + $data['sobrecubierta'] = array_key_exists('sobrecubierta', $datos_papel) ? $datos_papel['sobrecubierta'] : []; + $data['sobrecubierta']['solapas'] = $presupuesto->solapas_sobrecubierta ? 1 : 0; + $data['sobrecubierta']['solapas_ancho'] = $presupuesto->solapas_ancho_sobrecubierta; + $data['sobrecubierta']['acabado']['id'] = $presupuesto->acabado_sobrecubierta_id; + if ($presupuesto->acabado_sobrecubierta_id == 0) { + $data['sobrecubierta']['acabado']['text'] = "Ninguno"; + } else { + $data['sobrecubierta']['acabado']['text'] = $modelAcabado->find($presupuesto->acabado_sobrecubierta_id)->nombre; + } + + $data['guardas'] = array_key_exists('guardas', $datos_papel) ? $datos_papel['guardas'] : []; + + $modelLinea = new PresupuestoLineaModel(); + $lineas = $modelLinea->where('presupuesto_id', $id)->findAll(); + + [$data['datosGenerales']['paginasNegro'], $data['datosGenerales']['paginasColor']] = + $this->getPaginas($lineas); + + if (intval($presupuesto->envios_recoge_cliente) == 1) { + $data['direcciones']['entrega_taller'] = 1; + } else { + $data['direcciones']['entrega_taller'] = 0; + $data['direcciones'] = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id); + } + + if (intval($presupuesto->estado_id) == 2) { + $data['resumen']['base'] = $presupuesto->total_aceptado; + $data['resumen']['precio_unidad'] = $presupuesto->total_precio_unidad; + } + + $tiradas_alternativas = json_decode($presupuesto->tirada_alternativa_json_data); + if (!is_null($tiradas_alternativas)) { + for ($i = 0; $i < count($tiradas_alternativas); $i++) { + $tirada = $tiradas_alternativas[$i]; + $data['datosGenerales']['tirada' . ($i + 2)] = $tirada->tirada; + } + }*/ + + return $this->respond([ + 'status' => 1, + 'data' => $data + ]); + } + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } public function datatable() { diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php index bd524b58..aaea7f7b 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php @@ -19,7 +19,7 @@ - > + > @@ -30,7 +30,7 @@ - + @@ -42,27 +42,19 @@ * -
- papel_formato_personalizado == true ? '' : 'style="display: none"'; ?> type="number" id="papelFormatoAncho" name="papel_formato_ancho" maxLength="8" step="0.01" class="form-control formato_libro" value="papel_formato_ancho) ?>"> +
- papel_formato_personalizado == true ? '' : 'style="display: none"'; ?> type="number" id="papelFormatoAlto" name="papel_formato_alto" maxLength="8" step="0.01" class="form-control formato_libro" value="papel_formato_alto) ?>"> +
@@ -76,7 +68,7 @@ - + @@ -85,7 +77,7 @@ - + @@ -96,37 +88,33 @@
- -
+
- solapas == true ? 'checked' : ''; ?>> +
-
- -
-
-
- solapas_sobrecubierta == true ? 'checked' : ''; ?>> - -
-
-
- +
+
+
+ + +
+
+
- papel_formato_personalizado == true ? 'checked' : ''; ?>> +
@@ -136,35 +124,24 @@
-
- - solapas == true): ?> -
- - - -
- - solapas_sobrecubierta == true): ?> -
- - - +
+ + +
+
+ +
+
+ + +
+
@@ -187,44 +164,24 @@ *
- -
-
- - -
+
+
+ +
- -
- - - +
+
+
- -
@@ -237,7 +194,7 @@
@@ -248,7 +205,7 @@
@@ -260,7 +217,7 @@
@@ -271,7 +228,7 @@
@@ -291,7 +248,7 @@
@@ -303,7 +260,7 @@
@@ -314,7 +271,7 @@
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoItems.php index f4410468..31e708a0 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoItems.php @@ -16,7 +16,7 @@ - +
@@ -26,9 +26,9 @@ - "> + - "> +
@@ -38,11 +38,11 @@ - + - @@ -54,15 +54,11 @@ - + + + +
@@ -77,7 +73,7 @@ - +
@@ -87,7 +83,7 @@ - +
@@ -101,7 +97,7 @@ - +
@@ -110,7 +106,7 @@ - + @@ -119,7 +115,7 @@ - + @@ -131,7 +127,7 @@ - - $v) : ?> - - @@ -167,7 +155,7 @@ - + diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php index 9dfc18c8..1a27ea3f 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php @@ -10,21 +10,27 @@

+ + + + getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> - - + + + + + @@ -168,98 +174,13 @@ } } }); - - $('#clienteId').select2({ - allowClear: false, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function(params) { - return { - id: 'id', - text: 'nombre', - searchTerm: params.term, - : v - }; - }, - delay: 60, - processResults: function(response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - - /******************************* - * Inicialización de los Select2 - *******************************/ - $('#incRei').select2({ - allowClear: false, - }); - - $('#paisId').select2({ - allowClear: false, - }); + endSection() ?> - - - -section("additionalInlineJs") ?> -$(window).on('load', function() { - - // Detectar cambios en inputs de texto - $('input[type="text"]').on('input', function() { - showBreadCrumbSaveButton(true); - }); - - // Detectar cambios en inputs de texto - $('input[type="number"]').on('input', function() { - showBreadCrumbSaveButton(true); - }); - - // Detectar cambios en select - $('select').change(function() { - showBreadCrumbSaveButton(true); - }); - - // Detectar cambios en checkboxes - $('input[type="checkbox"]').change(function() { - showBreadCrumbSaveButton(true); - }); - - // Detectar cambios en textareas - $('textarea').on('input', function() { - showBreadCrumbSaveButton(true); - }); - - // Detectar cambios en otros tipos de input - $('input[type="radio"]').change(function() { - showBreadCrumbSaveButton(true); - }); - - // Detectar cambios en otros tipos de input - $('input:not([type])').on('input', function() { - showBreadCrumbSaveButton(true); - }); - -}); - -$('#bc-save').on( "click", function() { - showBreadCrumbSaveButton(false); - $('#saveForm').click() -} ); - -endSection() ?> @@ -370,6 +291,7 @@ $('#bc-save').on( "click", function() { "> + endSection() ?> section('additionalExternalJs') ?> @@ -393,5 +315,9 @@ $('#bc-save').on( "click", function() { + + + + endSection() ?> diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js new file mode 100644 index 00000000..7e78df1c --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js @@ -0,0 +1,162 @@ +import { getToken } from '../../common/common.js'; +import Ajax from '../../components/ajax.js'; + +import DatosGenerales from './sections/datosGenerales.js'; +import DatosLibro from './sections/datosLibro.js'; + +class PresupuestoAdminEdit { + + constructor() { + + this.domItem = $('#presupuestoForm'); + + this.csrf_token = getToken(); + this.csrf_hash = $('#presupuestoForm').find('input[name="' + this.csrf_token + '"]').val(); + + this.lc = $("#lomo_cubierta"); + this.lsc = $("#lomo_sobrecubierta"); + this.cosido = $("#isCosido"); + this.tipo_impresion = $("#tipo_impresion_id"); + this.cosido = $("#isCosido"); + + this.datosGenerales = new DatosGenerales(this.domItem.find('#accordionDatosPresupuestoTip')); + this.datosLibro = new DatosLibro(this.domItem.find('#accordionDatosPresupuestoTip')); + + this.calcularPresupuesto = false; + } + + init() { + + // Fuerza el foco en el campo de búsqueda de select2 + $(document).on('select2:open', () => { + document.querySelector('.select2-search__field').focus(); + }); + + this.datosGenerales.init(); + + if (window.location.href.includes("edit")) { + + setTimeout(() => { + this.#cargarPresupuesto(); + }, 0); + + const successMessage = sessionStorage.getItem('message'); + if (successMessage) { + popSuccessAlert(successMessage); + sessionStorage.removeItem('message'); + } + } + } + + #cargarPresupuesto() { + + const self = this; + + $('#loader').modal('show'); + let id = window.location.href.split("/").pop() + new Ajax('/presupuestoadmin/cargar/' + id, + {}, + {}, + (response) => { + + if (response.status === 1) { + + self.lc.val(parseFloat(response.data.lc).toFixed(2)); + self.lsc.val(parseFloat(response.data.lsc).toFixed(2)); + self.cosido.val(response.data.cosido); + self.tipo_impresion.val(response.data.tipo_impresion); + + self.calcularPresupuesto = false; + + self.datosGenerales.cargarDatos(response.data.datosGenerales); + + /*self.direcciones.handleChangeCliente(); + + self.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales); + + self.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente); + self.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta); + */ + setTimeout(() => { + + $('#loader').modal('hide'); + + if (response.data.state != 2) { + + self.calcularPresupuesto = true; + } + + }, 0); + + // Funciones para detectar cambios en el formulario + this.#checkChangesPresupuesto(); + $('#bc-save').on("click", function () { + showBreadCrumbSaveButton(false); + $('#saveForm').trigger('click'); + }); + } + }, + () => { + $('#loader').modal('hide'); + this.calcularPresupuesto = true; + } + ).get(); + } + + #checkChangesPresupuesto() { + // Detectar cambios en inputs de texto + $('input[type="text"]').on('change', function () { + showBreadCrumbSaveButton(true); + }); + + // Detectar cambios en inputs de texto + $('input[type="number"]').on('change', function () { + showBreadCrumbSaveButton(true); + }); + + // Detectar cambios en select + $('select').on('change', function () { + showBreadCrumbSaveButton(true); + }); + + $('.select2bs').on('change', function (e) { + showBreadCrumbSaveButton(true); + }); + + // Detectar cambios en checkboxes + $('input[type="checkbox"]').change(function () { + showBreadCrumbSaveButton(true); + }); + + // Detectar cambios en textareas + $('textarea').on('input', function () { + showBreadCrumbSaveButton(true); + }); + + // Detectar cambios en otros tipos de input + $('input[type="radio"]').change(function () { + showBreadCrumbSaveButton(true); + }); + + // Detectar cambios en otros tipos de input + $('input:not([type])').on('input', function () { + showBreadCrumbSaveButton(true); + }); + } + +} + +document.addEventListener('DOMContentLoaded', function () { + + const locale = document.querySelector('meta[name="locale"]').getAttribute('content'); + + new Ajax('/translate/getTranslation', { locale: locale, translationFile: ['Maquinas'] }, {}, + function (translations) { + window.language = JSON.parse(translations); + new PresupuestoAdminEdit().init(); + }, + function (error) { + console.log("Error getting translations:", error); + } + ).post(); +}); \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosGenerales.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosGenerales.js new file mode 100644 index 00000000..9b39ff91 --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosGenerales.js @@ -0,0 +1,56 @@ +import ClassSelect from '../../../components/select2.js'; + +class DatosGenerales{ + + constructor(domItem){ + + this.domItem = domItem; + + this.id = this.domItem.find('#id'); + this.fecha = this.domItem.find('#updated_at'); + this.estado = this.domItem.find('#estado_id'); + this.inc_rei = this.domItem.find('#incRei'); + this.titulo = this.domItem.find('#titulo'); + this.autor = this.domItem.find('#autor'); + this.coleccion = this.domItem.find('#coleccion'); + this.numeroEdicion = this.domItem.find('#numeroEdicion'); + this.isbn = this.domItem.find('#isbn'); + this.pais = this.domItem.find('#paisId'); + + this.cliente = new ClassSelect($('#clienteId'), '/clientes/cliente/getSelect2', 'Seleccione cliente'); + this.referenciaCliente = this.domItem.find('#referenciaCliente'); + + } + + init(){ + + this.cliente.init(); + + this.inc_rei.select2({ + allowClear: false, + }); + + this.pais.select2({ + allowClear: false, + }); + } + + cargarDatos(datos){ + + this.id.val(datos.id); + this.fecha.val(datos.updated_at); + this.estado.val(datos.state); + this.inc_rei.val(datos.inc_rei).trigger('change'); + this.titulo.val(datos.titulo); + this.autor.val(datos.autor); + this.coleccion.val(datos.coleccion); + this.numeroEdicion.val(datos.numero_edicion); + this.isbn.val(datos.isbn); + this.pais.val(datos.pais).trigger('change'); + + this.cliente.setOption(datos.cliente.id, datos.cliente.nombre); + this.referenciaCliente.val(datos.referenciaCliente); + } +} + +export default DatosGenerales; \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js new file mode 100644 index 00000000..2f280aae --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js @@ -0,0 +1,55 @@ +class DatosLibro { + + constructor(domItem) { + + this.domItem = domItem; + + this.paginas = this.domItem.find('#paginas'); + this.tirada = this.domItem.find('#tirada'); + this.tamanio = this.domItem.find('#papelFormatoId'); + 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.solapasCubierta = this.domItem.find('#solapas'); + this.solapasSobrecubierta = this.domItem.find('#solapas_sobrecubierta'); + this.anchoSolapasCubierta = this.domItem.find('#anchoSolapasCubierta'); + this.anchoSolapasSobrecubierta = this.domItem.find('#anchoSolapasSobrecubierta'); + + 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.retractilado = this.domItem.find('#retractilado'); + this.retractilado5 = this.domItem.find('#retractilado5'); + this.imprimirFajaColor = this.domItem.find('#imprimirFajaColor'); + this.prototipo = this.domItem.find('#prototipo'); + this.ferro = this.domItem.find('#ferro'); + this.ferroDigital = this.domItem.find('#ferroDigital'); + this.marcapaginas = this.domItem.find('#marcapaginas'); + + } + + init() { + + } + + cargarDatos(datos) { + + 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'); + } + + 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'); + } + } +} + +export default DatosLibro; \ No newline at end of file From 7aa75cdd594068683c6a439c6bae31f1c880420c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Mon, 16 Dec 2024 00:14:56 +0100 Subject: [PATCH 02/89] trabajando en eventos datosLibro --- .../Presupuestos/Presupuestoadmin.php | 52 +++-- .../presupuestos/admin/_datosLibroItems.php | 131 +---------- .../form/presupuestos/admin/comparador.js | 32 +-- .../presupuestoAdmin/presupuestoAdminEdit.js | 70 +++++- .../presupuestoAdmin/sections/datosLibro.js | 211 +++++++++++++++++- 5 files changed, 326 insertions(+), 170 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index 79b805b3..300c8677 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -501,26 +501,48 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $data['datosGenerales']['cliente']['nombre'] = $modelCliente->getNombre($presupuesto->cliente_id); $data['datosGenerales']['referenciaCliente'] = $presupuesto->referencia_cliente; - /* - model('App\Models\Clientes\ClienteModel') - ->find($presupuesto->cliente_id)->nombre; - $data['datosGenerales']['papelFormatoId'] = $presupuesto->papel_formato_id; - $data['datosGenerales']['papelFormatoNombre'] = $modelPapelFormato->getNombre($presupuesto->papel_formato_id); - $data['datosGenerales']['papelFormatoPersonalizado'] = $presupuesto->papel_formato_personalizado; - $data['datosGenerales']['papelFormatoAncho'] = $presupuesto->papel_formato_ancho; - $data['datosGenerales']['papelFormatoAlto'] = $presupuesto->papel_formato_alto; + + $data['datosLibro']['papelFormatoId'] = $presupuesto->papel_formato_id; + $data['datosLibro']['papelFormatoNombre'] = $modelPapelFormato->getNombre($presupuesto->papel_formato_id); + $data['datosLibro']['papelFormatoPersonalizado'] = $presupuesto->papel_formato_personalizado; + $data['datosLibro']['papelFormatoAncho'] = $presupuesto->papel_formato_ancho; + $data['datosLibro']['papelFormatoAlto'] = $presupuesto->papel_formato_alto; + $data['datosLibro']['paginas'] = $presupuesto->paginas; + $data['datosLibro']['tirada'] = $presupuesto->tirada; + $data['datosLibro']['merma'] = $presupuesto->merma; + $data['datosLibro']['mermaCubierta'] = $presupuesto->merma_cubierta; + $data['datosLibro']['solapasCubierta'] = $presupuesto->solapas; + $data['datosLibro']['solapasSobrecubierta'] = $presupuesto->solapas_sobrecubierta; + $data['datosLibro']['solapasCubiertaAncho'] = $presupuesto->solapas_ancho; + $data['datosLibro']['solapasSobrecubiertaAncho'] = $presupuesto->solapas_ancho_sobrecubierta; + $modelAcabado = model("App\Models\Tarifas\Acabados\TarifaAcabadoModel"); + $data['datosLibro']['acabadoCubierta']['id'] = $presupuesto->acabado_cubierta_id; + if ($presupuesto->acabado_cubierta_id == 0) { + $data['datosLibro']['acabadoCubierta']['text'] = "Ninguno"; + } else { + $data['datosLibro']['acabadoCubierta']['text'] = $modelAcabado->find($presupuesto->acabado_cubierta_id)->nombre; + } + $data['datosLibro']['acabadoSobrecubierta']['id'] = $presupuesto->acabado_sobrecubierta_id; + if ($presupuesto->acabado_sobrecubierta_id == 0) { + $data['datosLibro']['acabadoSobrecubierta']['text'] = "Ninguno"; + } else { + $data['datosLibro']['acabadoSobrecubierta']['text'] = $modelAcabado->find($presupuesto->acabado_sobrecubierta_id)->nombre; + } + $data['datosLibro']['prototipo'] = $presupuesto->prototipo; + $data['datosLibro']['ferro'] = $presupuesto->ferro; + $data['datosLibro']['ferroDigital'] = $presupuesto->ferro_digital; + $data['datosLibro']['marcapaginas'] = $presupuesto->marcapaginas; + $data['datosLibro']['retractilado'] = $presupuesto->retractilado; + $data['datosLibro']['retractilado5'] = $presupuesto->retractilado5; + $data['datosLibro']['fajaColor'] = $presupuesto->faja_color; + + /* $data['datosGenerales']['posPaginasColor'] = $presupuesto->comp_pos_paginas_color; $data['datosGenerales']['papelInteriorDiferente'] = $presupuesto->papel_interior_diferente; $data['datosGenerales']['paginasColorConsecutivas'] = $presupuesto->paginas_color_consecutivas; - $data['datosGenerales']['tipo'] = $this->getTipoLibro($presupuesto->tipo_impresion_id ?? null); - $data['datosGenerales']['prototipo'] = $presupuesto->prototipo; - $data['datosGenerales']['ferro'] = $presupuesto->ferro; - $data['datosGenerales']['ferroDigital'] = $presupuesto->ferro_digital; - $data['datosGenerales']['marcapaginas'] = $presupuesto->marcapaginas; - $data['datosGenerales']['retractilado'] = $presupuesto->retractilado; - $data['datosGenerales']['retractilado5'] = $presupuesto->retractilado5; + $datos_papel = $this->obtenerDatosPapel($presupuesto->id); $data['interior'] = $datos_papel['interior'] ? $datos_papel['interior'] : []; diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php index aaea7f7b..9eac25d9 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php @@ -38,21 +38,22 @@
- - - +
+ + +
-
+
-
+
@@ -126,7 +127,7 @@
-
+
@@ -135,7 +136,7 @@
-
+
@@ -287,114 +288,4 @@
- - - -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(); - } -} -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 = ` + `; + } + $('#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); } } From 4e7f53ba6c318158d47538301122346f6430cbb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Tue, 17 Dec 2024 12:55:44 +0100 Subject: [PATCH 03/89] trabajando en el comparador --- ci4/app/Controllers/Js_loader.php | 7 - .../Presupuestos/Presupuestoadmin.php | 4 +- .../presupuestos/admin/_datosLibroItems.js | 144 --------------- .../presupuestos/admin/_datosLibroItems.php | 13 +- .../admin/_datosPresupuestoClienteItems.php | 10 +- .../admin/viewPresupuestoadminForm.php | 1 - .../presupuestoAdmin/presupuestoAdminEdit.js | 3 + .../presupuestoAdmin/sections/comparador.js | 44 +++++ .../presupuestoAdmin/sections/datosLibro.js | 165 ++++++++++++++++-- 9 files changed, 217 insertions(+), 174 deletions(-) delete mode 100644 ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.js create mode 100644 httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js diff --git a/ci4/app/Controllers/Js_loader.php b/ci4/app/Controllers/Js_loader.php index e402c125..c2c056ce 100755 --- a/ci4/app/Controllers/Js_loader.php +++ b/ci4/app/Controllers/Js_loader.php @@ -33,13 +33,6 @@ class Js_loader extends BaseController } - - function datosLibro_js() - { - $this->response->setHeader('Content-Type', 'text/javascript'); - return view('themes/vuexy/form/presupuestos/admin/_datosLibroItems.js'); - } - function previsualizador_js() { $this->response->setHeader('Content-Type', 'text/javascript'); diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index 300c8677..4a8a9832 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -528,7 +528,6 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController } else { $data['datosLibro']['acabadoSobrecubierta']['text'] = $modelAcabado->find($presupuesto->acabado_sobrecubierta_id)->nombre; } - $data['datosLibro']['prototipo'] = $presupuesto->prototipo; $data['datosLibro']['ferro'] = $presupuesto->ferro; $data['datosLibro']['ferroDigital'] = $presupuesto->ferro_digital; @@ -537,6 +536,9 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $data['datosLibro']['retractilado5'] = $presupuesto->retractilado5; $data['datosLibro']['fajaColor'] = $presupuesto->faja_color; + $data['comparador']['tipo_impresion'] = $presupuesto->comp_tipo_impresion; + $data['comparador']['json_data'] = $presupuesto->comparador_json_data; + /* $data['datosGenerales']['posPaginasColor'] = $presupuesto->comp_pos_paginas_color; $data['datosGenerales']['papelInteriorDiferente'] = $presupuesto->papel_interior_diferente; diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.js b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.js deleted file mode 100644 index 2e974ab5..00000000 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.js +++ /dev/null @@ -1,144 +0,0 @@ -$('#paginas').on("change", function () { - - const url2 = window.location.href; - const url_parts2 = url2.split('/'); - - if($('#tipo_impresion_id').val() == 21){ - if(parseInt($('#paginas').val()) > 80){ - $('#paginas').val(80) - } - } - - if(url_parts2[url_parts2.length-2] == 'edit'){ - - checkPaginasPresupuesto() - - // Si es negro o color - if ($('#tipoImpresion').select2('data')[0].id == 'negro' || - $('#tipoImpresion').select2('data')[0].id == 'color') { - $('#compPaginasNegro').val(parseInt($('#paginas').val())-parseInt($('#compPaginasColor').val())); - $('#compPaginasNegro').trigger('change') - } - // Si es negrohq o colorhq - if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' || - $('#tipoImpresion').select2('data')[0].id == 'colorhq') { - $('#compPaginasNegrohq').val(parseInt($('#paginas').val())-parseInt($('#compPaginasColorhq').val())); - $('#compPaginasNegrohq').trigger('change'); - } - - //update_servicios(false) - //updateLineasPresupuesto() - updatePresupuesto({ - update_lineas: true, - update_servicios: true, - update_envios: true, - update_resumen: true, - update_tiradas_alternativas: true - }) - } -}); - - -$('#tirada').on("change", function (update_tiradas_alternativas = true) { - - calcular_mermas() - - const url2 = window.location.href; - const url_parts2 = url2.split('/'); - - if(url_parts2[url_parts2.length-2] == 'edit'){ - //update_servicios(false) - //updateLineasPresupuesto() - if(update_tiradas_alternativas) - updatePresupuesto({ - update_lineas: true, - update_servicios: false, - update_envios: false, - update_resumen: false, - update_tiradas_alternativas: false - }) - else - updatePresupuesto({ - update_lineas: true, - update_servicios: false, - update_envios: false, - update_resumen: false, - update_tiradas_alternativas: false - }) - checkInsertar() - } -}) - -function calcular_mermas(){ - - const tirada = parseInt($('#tirada').val()) - var merma = 0 - htmlString = '' - - if(tirada> parseInt($('#POD').val())){ - merma = tirada*0.1<=30 ? tirada*0.1 : 30 - } - else{ - merma_lineas = [] - tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) { - var rowData = this.data(); - if(rowData.row_id != 'lp_guardas' && rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta'){ - const formas_linea = parseInt($('#isCosido').val())==0?parseInt(rowData.formas):parseInt(rowData.formas)/2 - if(formas_linea > tirada) - merma_lineas.push(formas_linea-tirada) - else - merma_lineas.push(tirada%formas_linea) - } - - }) - - - if(merma_lineas.length>0) - merma = Math.max(...merma_lineas) - else{ - htmlString = ` - `; - - - merma = 0 - - } - - } - $('#mermacubierta').val(parseInt(merma)) - $('#merma').val(parseInt(merma)) - $('#alert-datosLibro').html(htmlString) -} - - -$('#papelFormatoPersonalizado').on("click",function(){ - - if($('#papelFormatoPersonalizado').is(':checked')){ - document.getElementById("papelFormatoAncho").style.display = "block"; - document.getElementById("papelFormatoAlto").style.display = "block"; - $('#papelFormatoId').hide(); - $('#papelFormatoId').val(0).change(); - document.getElementById("label_papelFormatoId").innerHTML = - window.Presupuestos.papelFormatoId + " (" + - window.Presupuestos.papelFormatoAncho + " x " + window.Presupuestos.papelFormatoAncho + ")*"; - } - else{ - document.getElementById("papelFormatoAncho").value= ""; - document.getElementById("papelFormatoAlto").value= ""; - document.getElementById("papelFormatoAncho").style.display = "none"; - document.getElementById("papelFormatoAlto").style.display = "none"; - $('#papelFormatoId').show(); - document.getElementById("label_papelFormatoId").innerHTML = - window.Presupuestos.papelFormatoId + '*'; - } -}); - diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php index 9eac25d9..de44d064 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php @@ -38,13 +38,14 @@
-
- - + +
+
+
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php index bf952469..0022fc3a 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php @@ -13,7 +13,7 @@
- +
@@ -23,16 +23,16 @@
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php index 1a27ea3f..afd59484 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php @@ -303,7 +303,6 @@ - diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js index 8bfebb7b..e7f6ad1b 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js @@ -3,6 +3,7 @@ import Ajax from '../../components/ajax.js'; import DatosGenerales from './sections/datosGenerales.js'; import DatosLibro from './sections/datosLibro.js'; +import Comparador from './sections/comparador.js'; class PresupuestoAdminEdit { @@ -26,6 +27,7 @@ class PresupuestoAdminEdit { removeService: this.removeService, checkPaginasPresupuesto: this.checkPaginasPresupuesto, })); + this.comparador = new Comparador(this.domItem.find('#accordionDatosPresupuestoClienteTip')); this.calcularPresupuesto = false; } @@ -39,6 +41,7 @@ class PresupuestoAdminEdit { this.datosGenerales.init(); this.datosLibro.init(); + this.comparador.init(); if (window.location.href.includes("edit")) { diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js new file mode 100644 index 00000000..f198aa96 --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js @@ -0,0 +1,44 @@ +import ClassSelect from '../../../components/select2.js'; +import { getToken } from '../../../common/common.js'; + +class Comparador { + + constructor(domItem) { + + this.domItem = domItem; + + this.csrf_token = getToken(); + this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val(); + + this.comparador_json = this.domItem.find("#comparador_json_data"); + this.tipo_impresion = $("#tipoImpresion"); + + this.paginasNegro = $('#compPaginasNegro'); + this.papelNegro = new ClassSelect($('#compPapelNegro'), + '/papelesgenericos/getpapelcliente', 'Seleccione papel', false, + { + [this.csrf_token]: this.csrf_hash, + tirada: $('#tirada').val(), + tipo: 'negro', + cubierta: 0, + }); + + this.gramajeNegro = $('#compGramajeNegro'); + + } + + init() { + this.papelNegro.init(); + } + + cargarDatos(datos) { + + this.tipo_impresion.val(datos.tipo_impresion); + this.comparador_json.val(JSON.stringify(datos.json_data)); + + //if (datos.json_data.bn) + + } +} + +export default Comparador; \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js index 04dbf433..cdc5d0ed 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js @@ -16,7 +16,7 @@ class DatosLibro { this.paginas = this.domItem.find('#paginas'); this.tirada = this.domItem.find('#tirada'); - this.tamanio = new ClassSelect($("#papelFormatoId"), '/papel-formato/getSelect2', window.language["formatoLibro"]); + this.tamanio = new ClassSelect($("#papelFormatoId"), '/papel-formato/getSelect2', window.language.Presupuestos.formatoLibro); this.tamanioPersonalizado = this.domItem.find('#papelFormatoPersonalizado'); this.anchoPersonalizado = this.domItem.find('#papelFormatoAncho'); this.altoPersonalizado = this.domItem.find('#papelFormatoAlto'); @@ -24,8 +24,8 @@ class DatosLibro { 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'); - this.anchoSolapasSobrecubierta = this.domItem.find('#anchoSolapasSobrecubierta'); + this.anchoSolapasCubierta = this.domItem.find('#solapas_ancho'); + this.anchoSolapasSobrecubierta = this.domItem.find('#solapas_ancho_sobrecubierta'); this.divSolapasCubierta = this.domItem.find('#div_solapas_ancho'); this.divSolapasSobrecubierta = this.domItem.find('#div_solapas_ancho_sobrecubierta'); @@ -81,6 +81,10 @@ class DatosLibro { } this.solapasSobrecubierta.on('change', this.changeSolapasSobrecubierta.bind(this)); + this.tamanioPersonalizado.on('change', this.changeTipoTamanio.bind(this)); + + this.paginas.on('change', this.changePaginas.bind(this)); + this.tirada.on('change', this.changeTirada.bind(this)); } } @@ -166,9 +170,31 @@ class DatosLibro { })*/ } + + changeTipoTamanio(){ + + if(this.tamanioPersonalizado.prop('checked')){ + $('.tamanio-personalizado').removeClass('d-none'); + $('.tamanio-estandar').addClass('d-none'); + this.tamanio.setVal(''); + $("#label_papelFormatoId").text( + window.language.Presupuestos.papelFormatoId + " (" + + window.language.Presupuestos.papelFormatoAncho + " x " + window.language.Presupuestos.papelFormatoAncho + ")*"); + } + else{ + this.anchoPersonalizado.val(""); + this.altoPersonalizado.val(""); + $('.tamanio-personalizado').addClass('d-none'); + $('.tamanio-estandar').removeClass('d-none'); + $("#label_papelFormatoId").text( + window.language.Presupuestos.papelFormatoId + '*'); + } + } + + changeSolapasCubierta() { - if (this.solapasCubierta.prop('checked', true)) { + if (this.solapasCubierta.prop('checked')) { this.divSolapasCubierta.removeClass('d-none'); } else { @@ -181,7 +207,7 @@ class DatosLibro { changeSolapasSobrecubierta() { - if (this.solapasSobrecubierta.prop('checked', true)) { + if (this.solapasSobrecubierta.prop('checked')) { this.divSolapasSobrecubierta.removeClass('d-none'); } else { @@ -191,6 +217,125 @@ class DatosLibro { $('#serv_default').trigger('click'); } + changePaginas() { + + if($('#tipo_impresion_id').val() == 21){ + if(parseInt($('#paginas').val()) > 80){ + $('#paginas').val(80) + } + } + + if(window.location.href.includes('edit')){ + + checkPaginasPresupuesto() + + // Si es negro o color + if ($('#tipoImpresion').select2('data')[0].id == 'negro' || + $('#tipoImpresion').select2('data')[0].id == 'color') { + $('#compPaginasNegro').val(parseInt($('#paginas').val())-parseInt($('#compPaginasColor').val())); + $('#compPaginasNegro').trigger('change') + } + // Si es negrohq o colorhq + if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' || + $('#tipoImpresion').select2('data')[0].id == 'colorhq') { + $('#compPaginasNegrohq').val(parseInt($('#paginas').val())-parseInt($('#compPaginasColorhq').val())); + $('#compPaginasNegrohq').trigger('change'); + } + + // TO-DO + /* + updatePresupuesto({ + update_lineas: true, + update_servicios: true, + update_envios: true, + update_resumen: true, + update_tiradas_alternativas: true + }) + */ + } + } + + + changeTirada(update_tiradas_alternativas = true) { + + this.calcular_mermas() + + const url2 = window.location.href; + const url_parts2 = url2.split('/'); + + if(url_parts2[url_parts2.length-2] == 'edit'){ + //update_servicios(false) + //updateLineasPresupuesto() + if(update_tiradas_alternativas) + updatePresupuesto({ + update_lineas: true, + update_servicios: false, + update_envios: false, + update_resumen: false, + update_tiradas_alternativas: false + }) + else + updatePresupuesto({ + update_lineas: true, + update_servicios: false, + update_envios: false, + update_resumen: false, + update_tiradas_alternativas: false + }) + checkInsertar() + } + } + + calcular_mermas(){ + + const tirada = parseInt($('#tirada').val()) + var merma = 0 + htmlString = '' + + if(tirada> parseInt($('#POD').val())){ + merma = tirada*0.1<=30 ? tirada*0.1 : 30 + } + else{ + merma_lineas = [] + tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) { + var rowData = this.data(); + if(rowData.row_id != 'lp_guardas' && rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta'){ + const formas_linea = parseInt($('#isCosido').val())==0?parseInt(rowData.formas):parseInt(rowData.formas)/2 + if(formas_linea > tirada) + merma_lineas.push(formas_linea-tirada) + else + merma_lineas.push(tirada%formas_linea) + } + + }) + + + if(merma_lineas.length>0) + merma = Math.max(...merma_lineas) + else{ + htmlString = ` + `; + + + merma = 0 + + } + + } + $('#mermacubierta').val(parseInt(merma)) + $('#merma').val(parseInt(merma)) + $('#alert-datosLibro').html(htmlString) + } + cargarDatos(datos) { @@ -217,14 +362,14 @@ class DatosLibro { $(".impresion-con-solapas").addClass('d-none'); } else { - if (datos.solapas) { - this.solapasCubierta.val(datos.solapas); - this.anchoSolapasCubierta.val(datos.ancho_solapas); + if (datos.solapasCubierta) { + this.solapasCubierta.prop('checked', true); + this.anchoSolapasCubierta.val(datos.solapasCubiertaAncho); $('#div_solapas_ancho').removeClass('d-none'); } - if (datos.solapas_sobrecubierta) { + if (datos.solapasSobrecubierta) { this.solapasSobrecubierta.prop('checked', true); - this.anchoSolapasSobrecubierta.val(datos.ancho_solapas_sobrecubierta); + this.anchoSolapasSobrecubierta.val(datos.solapasSobrecubiertaAncho); $('#div_solapas_ancho_sobrecubierta').removeClass('d-none'); } } From 643f84684a133ef26d6d1e1d524dafa81ab07bfc Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Tue, 17 Dec 2024 14:38:02 +0100 Subject: [PATCH 04/89] trabajando en comparador --- ci4/app/Config/Routes.php | 3 + ci4/app/Controllers/Configuracion/Users.php | 6 +- .../Presupuestos/Presupuestoadmin.php | 198 ++++++++-------- ci4/app/Entities/Usuarios/UserEntity.php | 1 + .../Configuracion/PapelGenericoModel.php | 218 +++++++++++------- ci4/app/Models/Usuarios/UserModel.php | 123 +--------- .../admin/_datosPresupuestoClienteItems.php | 165 +------------ .../admin/_lineasPresupuestoItems.php | 21 +- .../admin/viewPresupuestoadminForm.php | 2 +- .../presupuestoAdmin/presupuestoAdminEdit.js | 1 + .../presupuestoAdmin/sections/comparador.js | 21 +- 11 files changed, 267 insertions(+), 492 deletions(-) diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 0974fafd..94d0516a 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -579,6 +579,9 @@ $routes->group('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos $routes->post('datatable_2', 'Presupuestoadmin::datatable_2', ['as' => 'updateDataOfPresupuestoAdmin']); $routes->post('allmenuitems', 'Presupuestoadmin::allItemsSelect', ['as' => 'select2ItemsOfPresupuestoAdmin']); $routes->post('menuitems', 'Presupuestoadmin::menuItems', ['as' => 'menuItemsOfPresupuestoAdmin']); + + $routes->get('papelgenerico', 'Presupuestoadmin::getPapelGenerico'); + $routes->get('papelgramaje', 'Presupuestoadmin::getGramaje'); }); $routes->resource('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestoadmin', 'except' => 'show,new,create,update']); diff --git a/ci4/app/Controllers/Configuracion/Users.php b/ci4/app/Controllers/Configuracion/Users.php index 8fcc153e..c537dd57 100755 --- a/ci4/app/Controllers/Configuracion/Users.php +++ b/ci4/app/Controllers/Configuracion/Users.php @@ -89,6 +89,8 @@ class Users extends \App\Controllers\GoBaseController // Marcar el username como NULL $sanitizedData = $this->sanitized($postData, true); + $email = $sanitizedData['email']; + unset($sanitizedData['email']); $noException = true; @@ -100,7 +102,7 @@ class Users extends \App\Controllers\GoBaseController try { // The Email is unique - if ($this->user_model->isEmailUnique($sanitizedData['email'])) { + if ($this->user_model->isEmailUnique($email)) { // Crear el usuario si pasa la validación $user = new \CodeIgniter\Shield\Entities\User([ @@ -109,8 +111,6 @@ class Users extends \App\Controllers\GoBaseController 'last_name' => $sanitizedData['last_name'], 'cliente_id' => $sanitizedData['cliente_id'], 'comments' => $sanitizedData['comments'], - 'email' => $sanitizedData['email'], - 'password' => $sanitizedData['password'], 'status' => $sanitizedData['status'] ?? 0, 'active' => $sanitizedData['active'] ?? 0, ]); diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index 4a8a9832..d7240367 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -336,15 +336,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null); $this->viewData['incReiList'] = array('incidencia' => lang('Presupuestos.incidencia'), 'reimpresion' => lang('Presupuestos.reimpresion'), 'sin_cargo' => lang('Presupuestos.sinCargo')); $this->viewData['papelFormatoList'] = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null); - $this->viewData['papelGenericoNegroList'] = $this->getPapelGenericoNegro(); - $this->viewData['papelGenericoNegroHQList'] = $this->getPapelGenericoNegroHQ(); - $this->viewData['papelGenericoColorList'] = $this->getPapelGenericoColor(); - $this->viewData['papelGenericoColorHQList'] = $this->getPapelGenericoColorHQ(); - $this->viewData['papelGenericoCubiertaList'] = $this->getPapelGenericoCubierta(); - $this->viewData['papelGenericoGuardasList'] = $this->getPapelGenericoGuardas(); - $this->viewData['papelGenericoSobrecubiertaList'] = $this->getPapelGenericoSobreCubierta(); - $this->viewData['papelGenericoRotativaNegroList'] = $this->getPapelGenericoRotativaNegro(); - $this->viewData['papelGenericoRotativaColorList'] = $this->getPapelGenericoRotativaColor(); + // Acabados exteriores $this->viewData['acabadosCubierta'] = $this->getAcabadosCubierta(); @@ -475,6 +467,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $modelPapelFormato = new PapelFormatoModel(); $modelCliente = new ClienteModel(); + $modelPapelGenerico = new PapelGenericoModel(); $presupuesto = $this->model->find($id); @@ -537,7 +530,12 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $data['datosLibro']['fajaColor'] = $presupuesto->faja_color; $data['comparador']['tipo_impresion'] = $presupuesto->comp_tipo_impresion; - $data['comparador']['json_data'] = $presupuesto->comparador_json_data; + $data['comparador']['json_data'] = json_decode($presupuesto->comparador_json_data, true); + foreach ($data['comparador']['json_data'] as &$item) { + $item['papel_nombre'] = $modelPapelGenerico->getNombre($item['papel_id'])['nombre']; + } + + /* $data['datosGenerales']['posPaginasColor'] = $presupuesto->comp_pos_paginas_color; @@ -1231,105 +1229,99 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController return $data; } + public function getPapelGenerico(){ - protected function getPapelGenericoRotativaNegro() - { - $model = model('App\Models\Configuracion\PapelGenericoModel'); - $data = $model->getPapelForComparador('negro', false, false, true); - array_unshift($data, (object)array( - "id" => 0, - "nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))]) - )); - return $data; + if ($this->request->isAJAX()) { + + $POD_value = $this->getPOD(); + $tirada = $this->request->getGet("tirada"); + $isPOD = intval($tirada)<=intval($POD_value); + + $tipo_impresion_id = $this->request->getGet("tipo_impresion"); + $tapa_dura = model('App\Models\Configuracion\TipoPresupuestoModel')->get_isTapaDura(intval($tipo_impresion_id)); + + $tipo = $this->request->getGet("tipo"); + + $uso = $this->request->getGet("uso") ?? 'interior'; + $cubierta = false; + if($uso=='cubierta'){ + $cubierta = true; + } + $sobrecubierta = false; + if($uso=='sobrecubierta'){ + $sobrecubierta = true; + } + $guardas = false; + if($uso=='guardas'){ + $guardas = true; + } + $rotativa = false; + if($uso=='rotativa'){ + $rotativa = true; + } + + $model = model('App\Models\Configuracion\PapelGenericoModel'); + $query = $model->getPapelForComparador($tipo, $cubierta, $sobrecubierta, $rotativa, $guardas, $tapa_dura, $isPOD); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("lg_papel_generico.nombre", $this->request->getGet("q")) + ->groupEnd(); + } + + return $this->response->setJSON($query->orderBy("t1.nombre", "asc")->get()->getResultObject()); + } else { + return $this->failUnauthorized('Invalid request', 403); + } } - protected function getPapelGenericoRotativaColor() - { - $model = model('App\Models\Configuracion\PapelGenericoModel'); - $data = $model->getPapelForComparador('color', false, false, true); - array_unshift($data, (object)array( - "id" => 0, - "nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))]) - )); - return $data; + public function getGramaje(){ + if ($this->request->isAJAX()) { + + $papel_generico_id = $this->request->getGet("papel_generico"); + + $POD_value = $this->getPOD(); + $tirada = $this->request->getGet("tirada"); + $isPOD = intval($tirada)<=intval($POD_value); + + $tipo_impresion_id = $this->request->getGet("tipo_impresion"); + $tapa_dura = model('App\Models\Configuracion\TipoPresupuestoModel')->get_isTapaDura(intval($tipo_impresion_id)); + + $tipo = $this->request->getGet("tipo"); + + $uso = $this->request->getGet("uso") ?? 'interior'; + $cubierta = false; + if($uso=='cubierta'){ + $cubierta = true; + } + $sobrecubierta = false; + if($uso=='sobrecubierta'){ + $sobrecubierta = true; + } + $guardas = false; + if($uso=='guardas'){ + $guardas = true; + } + $rotativa = false; + if($uso=='rotativa'){ + $rotativa = true; + } + + $model = model('App\Models\Configuracion\PapelGenericoModel'); + $query = $model->getGramajeForComparador($tipo, $papel_generico_id, $cubierta, $sobrecubierta, $rotativa, $guardas, $tapa_dura, $isPOD); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("lg_papel_generico.nombre", $this->request->getGet("q")) + ->groupEnd(); + } + + return $this->response->setJSON($query->orderBy("t1.nombre", "asc")->get()->getResultObject()); + } else { + return $this->failUnauthorized('Invalid request', 403); + } } - protected function getPapelGenericoNegro() - { - $model = model('App\Models\Configuracion\PapelGenericoModel'); - $data = $model->getPapelForComparador('negro', false, false); - array_unshift($data, (object)array( - "id" => 0, - "nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))]) - )); - return $data; - } - protected function getPapelGenericoNegroHQ() - { - $model = model('App\Models\Configuracion\PapelGenericoModel'); - $data = $model->getPapelForComparador('negrohq', false, false); - array_unshift($data, (object)array( - "id" => 0, - "nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))]) - )); - return $data; - } - - protected function getPapelGenericoColor() - { - $model = model('App\Models\Configuracion\PapelGenericoModel'); - $data = $model->getPapelForComparador('color', false, false); - array_unshift($data, (object)array( - "id" => 0, - "nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))]) - )); - return $data; - } - - protected function getPapelGenericoColorHQ() - { - $model = model('App\Models\Configuracion\PapelGenericoModel'); - $data = $model->getPapelForComparador('colorhq', false, false); - array_unshift($data, (object)array( - "id" => 0, - "nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))]) - )); - return $data; - } - - protected function getPapelGenericoCubierta() - { - $model = model('App\Models\Configuracion\PapelGenericoModel'); - $data = $model->getPapelForComparador('colorhq', true, false); - array_unshift($data, (object)array( - "id" => 0, - "nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))]) - )); - return $data; - } - - protected function getPapelGenericoGuardas() - { - $model = model('App\Models\Configuracion\PapelGenericoModel'); - $data = $model->getPapelForComparador('colorhq', false, false, false, true); - array_unshift($data, (object)array( - "id" => 0, - "nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))]) - )); - return $data; - } - - protected function getPapelGenericoSobreCubierta() - { - $model = model('App\Models\Configuracion\PapelGenericoModel'); - $data = $model->getPapelForComparador('colorhq', false, true); - array_unshift($data, (object)array( - "id" => 0, - "nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papel'))]) - )); - return $data; - } + protected function getServiciosPreimpresion() { diff --git a/ci4/app/Entities/Usuarios/UserEntity.php b/ci4/app/Entities/Usuarios/UserEntity.php index 61f750ce..34206cad 100755 --- a/ci4/app/Entities/Usuarios/UserEntity.php +++ b/ci4/app/Entities/Usuarios/UserEntity.php @@ -13,6 +13,7 @@ class UserEntity extends \CodeIgniter\Entity\Entity "status" => null, "status_message" => null, 'active' => null, + "comments" => null, "last_active" => null, "created_at" => null, "updated_at" => null, diff --git a/ci4/app/Models/Configuracion/PapelGenericoModel.php b/ci4/app/Models/Configuracion/PapelGenericoModel.php index 4f2d8cf9..739ccf6d 100755 --- a/ci4/app/Models/Configuracion/PapelGenericoModel.php +++ b/ci4/app/Models/Configuracion/PapelGenericoModel.php @@ -129,141 +129,185 @@ class PapelGenericoModel extends \App\Models\BaseModel return empty($search) ? $builder : $builder - ->groupStart() - ->like("t1.id", $search) - ->orLike("t1.nombre", $search) - ->orLike("t1.code", $search) - ->orLike("t1.code_ot", $search) - ->orLike("t1.id", $search) - ->orLike("t1.nombre", $search) - ->orLike("t1.code", $search) - ->orLike("t1.code_ot", $search) - ->groupEnd(); + ->groupStart() + ->like("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.code", $search) + ->orLike("t1.code_ot", $search) + ->orLike("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.code", $search) + ->orLike("t1.code_ot", $search) + ->groupEnd(); } - public function getPapelForComparador($tipo, $is_cubierta = false, $is_sobrecubierta = false, $rotativa = false, $is_guardas = false, $mostrar_cliente = null) - { + public function getPapelForComparador( + $tipo, + $is_cubierta = false, + $is_sobrecubierta = false, + $rotativa = false, + $is_guardas = false, + $tapa_dura = false, + $POD = false + ) { /* 1.-> Tipo impresion 2.-> Maquina 3.-> Papeles impresion asociados a esa maquina 4.-> papeles genericos que aparecen en esos papeles impresion */ + + if ($POD == true && ($tipo == 'color' || $tipo == 'negro')) { + if ($tipo == 'color') + $tipo = 'colorhq'; + else if ($tipo == 'negro') + $tipo = 'negrohq'; + } + $builder = $this->db ->table($this->table . " t1") ->select( - "t1.id as id, t1.nombre AS nombre" + "t1.id as id, t1.nombre AS nombre", // for debug, t2.nombre AS nombre_papel_impresion, t4.nombre AS maquina_nombre, t5.uso AS tarifa_uso, t5.tipo AS tarifa_tipo" ) - ->distinct('t1.id') - ->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "left") - ->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "left") - ->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left") - ->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "left") + ->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "inner") + ->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "inner") + ->join("lg_maquinas t4", "t3.maquina_id = t4.id", "inner") + ->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "inner") ->where("t1.is_deleted", 0) + ->where("t1.show_in_client", 1) ->where("t2.is_deleted", 0) ->where("t2.isActivo", 1) ->where("t3.active", 1) ->where("t4.is_deleted", 0) ->where("t4.tipo", "impresion") ->where("t5.is_deleted", 0) - ->where("t5.tipo", $tipo); + ->where("t5.tipo", $tipo) + ->distinct('t1.id'); + + // Validación adicional para asegurar que t1.id esté presente en las combinaciones con t3.active = 1 + $builder->whereIn("t1.id", function ($subQuery) { + $subQuery->select("t1_inner.id") + ->from("lg_papel_generico t1_inner") + ->join("lg_papel_impresion t2_inner", "t2_inner.papel_generico_id = t1_inner.id", "inner") + ->join("lg_maquina_papel_impresion t3_inner", "t3_inner.papel_impresion_id = t2_inner.id", "inner") + ->where("t3_inner.active", 1); + }); if ($is_cubierta == true) { - $builder->where("t2.cubierta", 1); $builder->where("t5.uso", 'cubierta'); - } - - if ($is_sobrecubierta == true) { + if ($tapa_dura == true) { + $builder->where("t2.use_for_tapa_dura", 1); + } + } else if ($is_sobrecubierta == true) { $builder->where("t2.sobrecubierta", 1); $builder->where("t5.uso", 'sobrecubierta'); - } - - if ($is_cubierta == false && $is_sobrecubierta == false) { - $builder->where("t5.uso", 'interior'); - } - - if ($is_guardas == true) { + } else if ($is_guardas == true) { $builder->where("t2.guardas", 1); + } else { + $builder->where("t2.interior", 1); + $builder->where("t5.uso", 'interior'); + if ($tipo == 'negro' || $tipo == 'negrohq') + $builder->where("t2.bn", 1); + else if ($tipo == 'color' || $tipo == 'colorhq') + $builder->where("t2.color", 1); } - if ($rotativa == true) { + if ($tipo == 'colorhq' || $tipo == 'negrohq') { + $builder->where("t2.rotativa", 0); + } else if ($rotativa && $POD == false) { $builder->where("t2.rotativa", 1); + } else if ($POD) { + $builder->where("t2.rotativa", 0); } - if ($mostrar_cliente != null) { - $builder->where("t1.show_in_client", $mostrar_cliente); - } - - $data = $builder->orderBy("t1.nombre", "asc")->get()->getResultObject(); - //var_dump($this->db->getLastQuery()); - return $data; + //$query = $this->db->getLastQuery(); + return $builder; } - public function getGramajeComparador(string $papel_generico_nombre = "", $uso = "", $ejemplares = 0) - { - if ($uso == 'cubierta' || $uso == 'sobrecubierta') - $tipo = 'colorhq'; - else - $tipo = $uso; // color y colorhq valen para los dos - if ($uso == 'bn') - $tipo = "negro"; - if ($uso == 'bnhq') - $tipo = "negrohq"; + public function getGramajeForComparador( + $tipo, + $selected_papel_id, + $is_cubierta = false, + $is_sobrecubierta = false, + $rotativa = false, + $is_guardas = false, + $tapa_dura = false, + $POD = false + ) { + if ($POD == true && ($tipo == 'color' || $tipo == 'negro')) { + if ($tipo == 'color') + $tipo = 'colorhq'; + else if ($tipo == 'negro') + $tipo = 'negrohq'; + } + $builder = $this->db ->table($this->table . " t1") ->select( - "t2.gramaje AS text" + "t2.gramaje as id, t2.gramaje as nombre", + // for debug, t2.nombre AS nombre_papel_impresion, t4.nombre AS maquina_nombre, t5.uso AS tarifa_uso, t5.tipo AS tarifa_tipo" ) - ->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "left") - ->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "left") - ->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left") - ->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "left") + ->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "inner") + ->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "inner") + ->join("lg_maquinas t4", "t3.maquina_id = t4.id", "inner") + ->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "inner") + ->where("t1.id", $selected_papel_id) ->where("t1.is_deleted", 0) + ->where("t1.show_in_client", 1) ->where("t2.is_deleted", 0) ->where("t2.isActivo", 1) ->where("t3.active", 1) ->where("t4.is_deleted", 0) ->where("t4.tipo", "impresion") + ->where("t5.is_deleted", 0) ->where("t5.tipo", $tipo) - ->where("t1.nombre", $papel_generico_nombre); + ->distinct('t2.gramaje'); - $uso_tarifa = 'interior'; + // Validación adicional para asegurar que t1.id esté presente en las combinaciones con t3.active = 1 + $builder->whereIn("t1.id", function ($subQuery) { + $subQuery->select("t1_inner.id") + ->from("lg_papel_generico t1_inner") + ->join("lg_papel_impresion t2_inner", "t2_inner.papel_generico_id = t1_inner.id", "inner") + ->join("lg_maquina_papel_impresion t3_inner", "t3_inner.papel_impresion_id = t2_inner.id", "inner") + ->where("t3_inner.active", 1); + }); - if ($uso == 'bn' || $uso == 'bnhq') - $builder->where("t2.bn", 1); - else if ($uso == 'color' || $uso == 'colorhq') - $builder->where("t2.color", 1); - else if ($uso == 'cubierta') { - $uso_tarifa = 'cubierta'; + if ($is_cubierta == true) { $builder->where("t2.cubierta", 1); - } else if ($uso == 'sobrecubierta') { - $uso_tarifa = 'sobrecubierta'; + $builder->where("t5.uso", 'cubierta'); + if ($tapa_dura == true) { + $builder->where("t2.use_for_tapa_dura", 1); + } + } else if ($is_sobrecubierta == true) { $builder->where("t2.sobrecubierta", 1); + $builder->where("t5.uso", 'sobrecubierta'); + } else if ($is_guardas == true) { + $builder->where("t2.guardas", 1); + } else { + $builder->where("t2.interior", 1); + $builder->where("t5.uso", 'interior'); + if ($tipo == 'negro' || $tipo == 'negrohq') + $builder->where("t2.bn", 1); + else if ($tipo == 'color' || $tipo == 'colorhq') + $builder->where("t2.color", 1); } - $builder->where("t5.uso", $uso_tarifa); - - $builder->where("t4.min <=", $ejemplares); - $builder->where("t4.max >=", $ejemplares); - - $values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject(); - $id = 1; - foreach ($values as $value) { - $value->id = $id; - $id++; + if ($tipo == 'colorhq' || $tipo == 'negrohq') { + $builder->where("t2.rotativa", 0); + } else if ($rotativa && $POD == false) { + $builder->where("t2.rotativa", 1); + } else if ($POD) { + $builder->where("t2.rotativa", 0); } - $values_array = array_map(function ($value) { - return $value->text; - }, $values); - $unique_values = array_unique($values_array); - return array_values(array_intersect_key($values, $unique_values)); + //$query = $this->db->getLastQuery(); + return $builder; } //tipo: negro, negrohq, color, colorhq @@ -323,7 +367,6 @@ class PapelGenericoModel extends \App\Models\BaseModel }, $values); $unique_values = array_unique($values_array); return array_values(array_intersect_key($values, $unique_values)); - } @@ -337,9 +380,9 @@ class PapelGenericoModel extends \App\Models\BaseModel */ if ($POD == true && ($tipo == 'color' || $tipo == 'negro')) { - if($tipo == 'color') + if ($tipo == 'color') $tipo = 'colorhq'; - else if($tipo == 'negro') + else if ($tipo == 'negro') $tipo = 'negrohq'; } @@ -403,7 +446,7 @@ class PapelGenericoModel extends \App\Models\BaseModel if ($is_cubierta == true) { $builder->where("t2.cubierta", 1); $builder->where("t5.uso", 'cubierta'); - if($tapa_dura == true){ + if ($tapa_dura == true) { $builder->where("t2.use_for_tapa_dura", 1); } } else { @@ -417,19 +460,16 @@ class PapelGenericoModel extends \App\Models\BaseModel if ($papel_especial == true) { $builder->where("t1.show_in_client_special", 1); - } - else{ + } else { $builder->where("t1.show_in_client_special", 0); } if ($tipo == 'colorhq' || $tipo == 'negrohq') { $builder->where("t2.rotativa", 0); - } - else{ - if($POD == false){ + } else { + if ($POD == false) { $builder->where("t2.rotativa", 1); - } - else if ($POD == true){ + } else if ($POD == true) { $builder->where("t2.rotativa", 0); } } diff --git a/ci4/app/Models/Usuarios/UserModel.php b/ci4/app/Models/Usuarios/UserModel.php index a4748d14..d4e2d993 100755 --- a/ci4/app/Models/Usuarios/UserModel.php +++ b/ci4/app/Models/Usuarios/UserModel.php @@ -20,14 +20,13 @@ class UserModel extends \App\Models\BaseModel protected $allowedFields = [ "username", - "email", "first_name", "last_name", "client_id", "status", "status_message", "active", - "country", + "comments", "last_active", "created_at", "updated_at", @@ -39,143 +38,25 @@ class UserModel extends \App\Models\BaseModel protected $validationRules = [ - "address" => [ - "label" => "Users.address", - "rules" => "trim|max_length[255]", - ], - "blocked" => [ - "label" => "Users.blocked", - "rules" => "required|permit_empty", - ], - "city" => [ - "label" => "Users.city", - "rules" => "trim|max_length[255]", - ], - "country" => [ - "label" => "Users.country", - "rules" => "trim|max_length[2]", - ], - "date_birth" => [ - "label" => "Users.dateBirth", - "rules" => "valid_date|permit_empty", - ], - "email" => [ - "label" => "Users.email", - "rules" => "trim|required|max_length[150]|valid_email", - ], - "email_confirmed" => [ - "label" => "Users.emailConfirmed", - "rules" => "required|integer", - ], "first_name" => [ "label" => "Users.firstName", "rules" => "trim|max_length[150]", ], - "language" => [ - "label" => "Users.language", - "rules" => "trim|max_length[10]", - ],/* - "last_access" => [ - "label" => "Users.lastAccess", - "rules" => "valid_date", - ],*/ - "last_ip" => [ - "label" => "Users.lastIp", - "rules" => "max_length[50]", - ], "last_name" => [ "label" => "Users.lastName", "rules" => "trim|max_length[150]", ], - "mobile" => [ - "label" => "Users.mobile", - "rules" => "trim|max_length[50]", - ], - "password" => [ - "label" => "Users.password", - "rules" => "required|max_length[35]", - ], - "picture" => [ - "label" => "Users.picture", - "rules" => "trim|max_length[150]", - ], - "state" => [ - "label" => "Users.state", - "rules" => "trim|max_length[255]", - ], - "zip_code" => [ - "label" => "Users.zipCode", - "rules" => "trim|max_length[50]", - ], ]; protected $validationMessages = [ - "address" => [ - "max_length" => "Users.validation.address.max_length", - ], - - "blocked" => [ - "required" => "Users.validation.email_confirmed.required", - ], - "city" => [ - "max_length" => "Users.validation.city.max_length", - ], - "country" => [ - "max_length" => "Users.validation.country.max_length", - "required" => "Users.validation.country.required", - ], - "date_birth" => [ - "valid_date" => "Users.validation.date_birth.valid_date", - ], - "email" => [ - "max_length" => "Users.validation.email.max_length", - "required" => "Users.validation.email.required", - "valid_email" => "Users.validation.email.valid_email", - ], - "email_confirmed" => [ - "integer" => "Users.validation.email_confirmed.integer", - "required" => "Users.validation.email_confirmed.required", - ], "first_name" => [ "max_length" => "Users.validation.first_name.max_length", "required" => "Users.validation.first_name.required", ], - - "language" => [ - "max_length" => "Users.validation.language.max_length", - "required" => "Users.validation.language.required", - ], - "last_access" => [ - "required" => "Users.validation.last_access.required", - "valid_date" => "Users.validation.last_access.valid_date", - ], - "last_ip" => [ - "max_length" => "Users.validation.last_ip.max_length", - "required" => "Users.validation.last_ip.required", - ], "last_name" => [ "max_length" => "Users.validation.last_name.max_length", "required" => "Users.validation.last_name.required", - ], - "mobile" => [ - "max_length" => "Users.validation.mobile.max_length", - "required" => "Users.validation.mobile.required", - ], - "password" => [ - "max_length" => "Users.validation.password.max_length", - "required" => "Users.validation.password.required", - ], - "picture" => [ - "max_length" => "Users.validation.picture.max_length", - "required" => "Users.validation.picture.required", - ], - "state" => [ - "max_length" => "Users.validation.state.max_length", - "required" => "Users.validation.state.required", - ], - "zip_code" => [ - "max_length" => "Users.validation.zip_code.max_length", - ], + ], ]; public function getGroupsTitles($user_token){ diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php index 0022fc3a..b9c143f3 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php @@ -74,17 +74,10 @@

- +
@@ -578,161 +571,7 @@ allowClear: false, }); - $('#compPapelNegro').select2({ - allowClear: false, - }); - - $('#compGramajeNegro').select2({ - - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'bn', - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - datos: $('#compPapelNegro').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - - $('#compPapelNegrohq').select2({ - allowClear: false, - }); - - $('#compGramajeNegrohq').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'bnhq', - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - datos: $('#compPapelNegrohq').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - - }); - - $('#compPapelColor').select2({ - allowClear: false, - }); - - $('#compPapelColorhq').select2({ - allowClear: false, - }); - - $('#compGramajeColor').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'color', - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - datos: $('#compPapelColor').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - - $('#compGramajeColorhq').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'colorhq', - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - datos: $('#compPapelColorhq').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - - $('#compPapelCubierta').select2({ - allowClear: false, - }); - - $('#compGramajeCubierta').select2({ - allowClear: false, - }); - - $('#compPapelSobrecubierta').select2({ - allowClear: false, - }); - - $('#compGramajeSobrecubierta').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - }); - - $('#encuadernacion').select2({ - allowClear: false, - }); - $('#compCarasCubierta').select2({ allowClear: false, @@ -1543,6 +1382,7 @@ function checkComparadorInt(is_color, is_hq, actualizarLineaPlana=false, actualizarLineaRot=false) { + /* TO-DO with select2 component try{ clearIntLineas(is_color); @@ -1587,6 +1427,7 @@ }catch(e){ console.log(e) } + */ } diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.php index 330ec907..d6bb3738 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.php @@ -74,17 +74,17 @@ section("additionalInlineJs") ?> -window.papelGenericoNegroList = ; -window.papelGenericoNegroHQList = ; -window.papelGenericoColorList = ; -window.papelGenericoColorHQList = ; -window.papelGenericoCubiertaList = ; -window.papelGenericoSobrecubiertaList = ; -window.papelGenericoRotativaNegroList = ; -window.papelGenericoRotativaColorList = ; +window.papelGenericoNegroList = []; +window.papelGenericoNegroHQList = []; +window.papelGenericoColorList = []; +window.papelGenericoColorHQList = []; +window.papelGenericoCubiertaList = []; +window.papelGenericoSobrecubiertaList = []; +window.papelGenericoRotativaNegroList = []; +window.papelGenericoRotativaColorList = []; - window.papelGenericoGuardasList = ; + window.papelGenericoGuardasList = []; window.lineasPresupuestoList = ; @@ -95,8 +95,11 @@ window.routes_lp = { } + +/* fill_lp_from_bbdd() checkPaginasPresupuesto() +*/ endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php index afd59484..9e5a7e7a 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php @@ -309,7 +309,7 @@ - + diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js index e7f6ad1b..7dfaf2eb 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js @@ -79,6 +79,7 @@ class PresupuestoAdminEdit { self.datosGenerales.cargarDatos(response.data.datosGenerales); self.datosLibro.cargarDatos(response.data.datosLibro); + self.comparador.cargarDatos(response.data.comparador); /*self.direcciones.handleChangeCliente(); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js index f198aa96..c86df266 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js @@ -15,20 +15,29 @@ class Comparador { this.paginasNegro = $('#compPaginasNegro'); this.papelNegro = new ClassSelect($('#compPapelNegro'), - '/papelesgenericos/getpapelcliente', 'Seleccione papel', false, + '/presupuestoadmin/papelgenerico', 'Seleccione papel', false, { [this.csrf_token]: this.csrf_hash, + tipo_impresion: this.tipo_impresion.val(), tirada: $('#tirada').val(), tipo: 'negro', - cubierta: 0, }); - this.gramajeNegro = $('#compGramajeNegro'); + this.gramajeNegro = new ClassSelect($('#compGramajeNegro'), + '/presupuestoadmin/papelgramaje', 'Seleccione gramaje', false, + { + [this.csrf_token]: this.csrf_hash, + papel_generico: this.papelNegro.getVal(), + tipo_impresion: this.tipo_impresion.val(), + tirada: $('#tirada').val(), + tipo: 'negro', + }); } init() { this.papelNegro.init(); + this.gramajeNegro.init(); } cargarDatos(datos) { @@ -36,7 +45,11 @@ class Comparador { this.tipo_impresion.val(datos.tipo_impresion); this.comparador_json.val(JSON.stringify(datos.json_data)); - //if (datos.json_data.bn) + if (datos.json_data.bn){ + this.paginasNegro.val(datos.json_data.bn.paginas); + this.papelNegro.setOption(datos.json_data.bn.papel_id, datos.json_data.bn.papel_nombre); + this.gramajeNegro.setOption(datos.json_data.bn.gramaje, datos.json_data.bn.gramaje); + } } } From 2df473edb68781e3217206567ce393b249b88dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Tue, 17 Dec 2024 21:47:08 +0100 Subject: [PATCH 05/89] trabajando en el comparador --- ci4/app/Config/Routes.php | 3 +- .../Presupuestos/Presupuestoadmin.php | 50 +- ci4/app/Language/es/Presupuestos.php | 3 + .../presupuestos/admin/_comentariosItems.php | 4 +- .../form/presupuestos/admin/_datosEnvios.php | 4 +- .../admin/_datosPresupuestoClienteItems.php | 1241 +--------------- .../admin/_datosServiciosItems.php | 5 +- .../admin/_lineasPresupuestoItems.php | 4 +- .../admin/_presupuestoDireccionesForm.php | 4 +- .../form/presupuestos/admin/_previewItems.php | 3 +- .../admin/_tiradasAlternativasItems.php | 4 +- .../form/presupuestos/admin/comparador.js | 195 +-- .../admin/viewPresupuestoadminForm.php | 6 +- .../presupuestoAdmin/sections/comparador.js | 1269 ++++++++++++++++- .../presupuestoAdmin/sections/datosLibro.js | 4 +- 15 files changed, 1345 insertions(+), 1454 deletions(-) diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 94d0516a..d9c91ec9 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -570,7 +570,6 @@ $routes->group('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos $routes->get('list/(:num)', 'Presupuestoadmin::list/$1', ['as' => 'presupuestoAdminList']); // HOMOGENIZAR CON ARGS DINAMICOS!!! $routes->get('add/(:num)', 'Presupuestoadmin::add/$1', ['as' => 'newPresupuestoAdmin']); $routes->get('edit/(:any)', 'Presupuestoadmin::edit/$1', ['as' => 'editarPresupuestoAdmin']); - $routes->get('cargar/(:any)', 'Presupuestoadmin::cargar/$1'); $routes->post('add/(:num)', 'Presupuestoadmin::add/$1', ['as' => 'createPresupuestoAdmin']); $routes->post('create', 'Presupuestoadmin::create', ['as' => 'ajaxCreatePresupuestoAdmin']); $routes->put('(:num)/update', 'Presupuestoadmin::update/$1', ['as' => 'ajaxUpdatePresupuestoAdmin']); @@ -580,6 +579,8 @@ $routes->group('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos $routes->post('allmenuitems', 'Presupuestoadmin::allItemsSelect', ['as' => 'select2ItemsOfPresupuestoAdmin']); $routes->post('menuitems', 'Presupuestoadmin::menuItems', ['as' => 'menuItemsOfPresupuestoAdmin']); + $routes->get('cargar/(:any)', 'Presupuestoadmin::cargar/$1'); + $routes->post('comparadorplana', 'Presupuestoadmin::obtenerComparadorPlana'); $routes->get('papelgenerico', 'Presupuestoadmin::getPapelGenerico'); $routes->get('papelgramaje', 'Presupuestoadmin::getGramaje'); }); diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index d7240367..914fb0b1 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -19,6 +19,7 @@ use App\Models\Presupuestos\PresupuestoModel; use App\Models\Presupuestos\PresupuestoPreimpresionesModel; use App\Models\Presupuestos\PresupuestoServiciosExtraModel; use App\Services\PresupuestoService; +use App\Services\PresupuestoClienteService; use Exception; class Presupuestoadmin extends \App\Controllers\BaseResourceController @@ -534,14 +535,11 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController foreach ($data['comparador']['json_data'] as &$item) { $item['papel_nombre'] = $modelPapelGenerico->getNombre($item['papel_id'])['nombre']; } - + $data['comparador']['posPagColor'] = $presupuesto->comp_pos_paginas_color; /* - $data['datosGenerales']['posPaginasColor'] = $presupuesto->comp_pos_paginas_color; - $data['datosGenerales']['papelInteriorDiferente'] = $presupuesto->papel_interior_diferente; - $data['datosGenerales']['paginasColorConsecutivas'] = $presupuesto->paginas_color_consecutivas; - + $datos_papel = $this->obtenerDatosPapel($presupuesto->id); @@ -610,6 +608,44 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController } } + + public function obtenerComparadorPlana(){ + echo "hola"; + //if($this->request->isAJAX()){ + + $cliente_id = $this->request->getPost('cliente_id'); + $datosPedido = $this->request->getPost('datosPedido'); + $papel_generico = $this->request->getPost('papel_generico'); + $gramaje = $this->request->getPost('gramaje'); + $papelInteriorDirefente = $this->request->getPost('papelInteriorDiferente'); + $paginas_color = $this->request->getPost('paginas_color'); + $isColor = $this->request->getPost('isColor'); + $isHq = $this->request->getPost('isHq'); + $tipo_impresion_id = $this->request->getPost('tipo_impresion_id'); + $uso = $this->request->getPost('uso'); + + $data = (object)array( + 'cliente_id' => $cliente_id, + 'datosPedido' => $datosPedido, + 'papel_generico' => $papel_generico, + 'gramaje' => $gramaje, + 'papelInteriorDirefente' => $papelInteriorDirefente, + 'paginas_color' => $paginas_color, + 'isColor' => $isColor, + 'isHq' => $isHq, + 'tipo_impresion_id' => $tipo_impresion_id, + 'uso' => $uso + ); + + $data = PresupuestoClienteService::obtenerComparadorInteriorPlana($data); + return $this->respond($data); + /*} + else{ + return $this->failUnauthorized('Invalid request', 403); + }*/ + } + + public function datatable() { if ($this->request->isAJAX()) { @@ -1310,11 +1346,11 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $query = $model->getGramajeForComparador($tipo, $papel_generico_id, $cubierta, $sobrecubierta, $rotativa, $guardas, $tapa_dura, $isPOD); if ($this->request->getGet("q")) { $query->groupStart() - ->orLike("lg_papel_generico.nombre", $this->request->getGet("q")) + ->orLike("lg_papel_impresion.gramaje", $this->request->getGet("q")) ->groupEnd(); } - return $this->response->setJSON($query->orderBy("t1.nombre", "asc")->get()->getResultObject()); + return $this->response->setJSON($query->orderBy("t2.gramaje", "asc")->get()->getResultObject()); } else { return $this->failUnauthorized('Invalid request', 403); } diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index fee02953..59d13387 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -369,6 +369,9 @@ return [ 'paginas' => 'El campo páginas tiene que ser mayor que cero', 'paginasLP' => 'El número de páginas no coincide con el total', 'tiradas' => 'El campo tiradas tiene que ser mayor que cero', + 'seleccionePapel' => 'Seleccione un papel', + 'seleccioneGramaje' => 'Seleccione un gramaje', + 'seleccioneCliente' => 'Seleccione un cliente', 'dimension' => 'La dimensión del libro tiene que ser mayor que 60mm', 'lineaDuplicada' => 'Ya existe ese tipo de linea en el presupuesto', 'errorRotColor' => 'Papeles y gramajes deben ser iguales en color y BN', diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_comentariosItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_comentariosItems.php index 64c4289c..f5b3c691 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_comentariosItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_comentariosItems.php @@ -158,7 +158,7 @@ section("additionalInlineJs") ?> - +/* $("textarea[name*='comentarios_']").each(function(){ if (!$.trim($(this).val())) { // textarea is empty or contains only white-space @@ -167,7 +167,7 @@ $("textarea[name*='comentarios_']").each(function(){ $("#mostrar_" + $(this).attr('name')).show(); } }); - +*/ endSection() ?> diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosEnvios.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosEnvios.php index 26a0f0b7..641d40f8 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosEnvios.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosEnvios.php @@ -59,7 +59,7 @@ section("additionalInlineJs") ?> - +/* window.paisList = ; window.direccionesList = ; @@ -74,5 +74,5 @@ window.token_ajax= {: v}; $( document ).ready(function() { load_datos_envios(); }); - +*/ endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php index b9c143f3..f17fa7a0 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php @@ -81,7 +81,7 @@
-
@@ -95,21 +95,14 @@

- +
-
@@ -123,21 +116,14 @@

- +
-
@@ -151,21 +137,14 @@

- +
-
@@ -190,17 +169,10 @@
-
@@ -224,18 +196,11 @@
-
-
@@ -266,13 +231,6 @@
@@ -286,13 +244,13 @@ -
+
-
+
- - - - -section("additionalInlineJs") ?> - - autosize($('#compCalPaginasColor')); - - function init_comparador() { - $('#tipoImpresion').select2({ - allowClear: false, - }); - - - - $('#compCarasCubierta').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - }); - - $('#compPapelGuardas').select2({ - allowClear: false, - }); - - $('#compCarasGuardas').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - }); - - - updatePapelesComparador(); - const paginasColor = document.getElementById('compCalPaginasColor'); - if (paginasColor.value.length > 0) { - computarPaginasColor(paginasColor.value); - } - - computarPaginasColor($('#compPosPaginasColor').val()); - } - - $('#compSobrecubierta').on('change', function(){ - if ($('#compSobrecubierta').val()==1){ - value = false - } - else{ - value = 'disabled' - $('#compPapelSobrecubierta').val(0) - $('#compGramajeSobrecubierta').val('') - $('#compGramajeSobrecubierta').select2("destroy") - $('#compGramajeSobrecubierta').select2({allowClear: false, minimumResultsForSearch: Infinity}) - - } - $('#compPapelSobrecubierta').prop('disabled', value); - $('#compGramajeSobrecubierta').prop('disabled', value); - }) - - function init_lineas_comparador(){ - var comp_data = - - try{ - $("#compPapelNegro").val(parseInt(comp_data.bn.papel_id)).trigger('change'); - - try{ - var newState = new Option(comp_data.bn.gramaje, comp_data.bn.gramaje, true, true); - // Append it to the select - $("#compGramajeNegro").append(newState).trigger('change'); - $('#compGramajeNegro').prop('disabled', false); - }catch(e){} - }catch(e){} - - try{ - $("#compPapelNegrohq").val(parseInt(comp_data.bnhq.papel_id)).trigger('change'); - - try{ - var newState = new Option(comp_data.bnhq.gramaje, comp_data.bnhq.gramaje, true, true); - // Append it to the select - $("#compGramajeNegrohq").append(newState).trigger('change'); - $('#compGramajeNegrohq').prop('disabled', false); - }catch(e){} - }catch(e){} - - try{ - $("#compPapelColor").val(parseInt(comp_data.color.papel_id)).trigger('change'); - - try{ - var newState = new Option(comp_data.color.gramaje, comp_data.color.gramaje, true, true); - // Append it to the select - $("#compGramajeColor").append(newState).trigger('change'); - $('#compGramajeColor').prop('disabled', false); - }catch(e){} - }catch(e){} - - try{ - $("#compPapelColorhq").val(parseInt(comp_data.colorhq.papel_id)).trigger('change'); - - try{ - var newState = new Option(comp_data.colorhq.gramaje, comp_data.colorhq.gramaje, true, true); - // Append it to the select - $("#compGramajeColorhq").append(newState).trigger('change'); - $('#compGramajeColorhq').prop('disabled', false); - }catch(e){} - }catch(e){} - - try{ - $("#compCarasCubierta").val(parseInt(comp_data.cubierta.paginas)).change(); - try{ - $("#compPapelCubierta").val(parseInt(comp_data.cubierta.papel_id)).trigger('select2:select'); - - try{ - var newState = new Option(comp_data.cubierta.gramaje, comp_data.cubierta.gramaje, true, true); - // Append it to the select - $("#compGramajeCubierta").append(newState).trigger('change'); - $('#compGramajeCubierta').prop('disabled', false); - }catch(e){} - }catch(e){} - }catch(e){} - - try{ - $("#compSobrecubierta").val(parseInt(comp_data.sobrecubierta.imprimir)).change(); - try{ - $("#compPapelSobrecubierta").val(parseInt(comp_data.sobrecubierta.papel_id)).trigger('select2:select'); - - try{ - var newState = new Option(comp_data.sobrecubierta.gramaje, comp_data.sobrecubierta.gramaje, true, true); - // Append it to the select - $("#compGramajeSobrecubierta").append(newState).trigger('change'); - $('#compGramajeSobrecubierta').prop('disabled', false); - }catch(e){} - }catch(e){} - }catch(e){} - - try{ - $("#compCarasGuardas").val(parseInt(comp_data.guardas.paginas_impresion)).change(); - $("#compPapelGuardas").val(parseInt(comp_data.guardas.papel_id)).trigger('change'); - }catch(e){} - - } - - var tableCompIntPlana = new DataTable('#tableCompIntPlana',{ - scrollX: true, - searching: false, - paging: false, - info: false, - ordering: false, - responsive: true, - select: false, - language: { - url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" - }, - columns: [ - { 'data': 'tipo', - 'render': function ( data, type, row, meta ) { - if(data=='bn') - return ''; - else if(data=='bnhq') - return ''; - else if(data=='color') - return ''; - else if(data=='colorhq') - return ''; - } - }, - { 'data': 'paginas' }, - { 'data': 'papel' }, - { 'data': 'gramaje' }, - { 'data': 'marca' }, - { 'data': 'maquina' }, - { 'data': 'numeroPliegos' }, - { 'data': 'pliegosPedido' }, - { 'data': 'precioPliego' }, - { 'data': 'libro' }, - { 'data': 'totalPapelPedido' }, - { 'data': 'lomo' }, - { 'data': 'peso' }, - { 'data': 'horasMaquina' }, - { 'data': 'precioImpresion' }, - { 'data': 'total' }, - { 'data': 'maquinaId'}, - { 'data': 'maquinaVelocidad'}, - { 'data': 'tiempoMaquina'}, - { 'data': 'papelGenericoId'}, - { 'data': 'papelImpresionId'}, - { 'data': 'tarifa_impresion_id'} - ], - columnDefs: [ - { - target: [16,17,18,19,20,21], - visible: false, - searchable: false - }, - ] - }); - - - var tableCompIntRotativa = new DataTable('#tableCompIntRotativa',{ - scrollX: true, - searching: false, - paging: false, - info: false, - ordering: false, - responsive: true, - select: false, - language: { - url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" - }, - columns: [ - { 'data': 'tipo', - 'render': function ( data, type, row, meta ) { - if(data=='rotativa') - return ''; - } - }, - { 'data': 'paginas' }, - { 'data': 'papel' }, - { 'data': 'gramaje' }, - { 'data': 'marca' }, - { 'data': 'aFavorFibra', - 'render': function(data, type, row, meta){ - if(data=='si') - return ''; - else if(data=='no') - return ''; - } - }, - { 'data': 'maquina' }, - { 'data': 'numeroPliegos' }, - { 'data': 'pliegosPedido' }, - { 'data': 'precioPliego' }, - { 'data': 'libro' }, - { 'data': 'totalPapelPedido' }, - { 'data': 'lomo' }, - { 'data': 'peso' }, - { 'data': 'horasMaquina' }, - { 'data': 'precioImpresion' }, - { 'data': 'precioPagNegro' }, - { 'data': 'precioPagColor' }, - { 'data': 'totalTinta' }, - { 'data': 'totalCorte' }, - { 'data': 'total' }, - { 'data': 'maquinaId'}, - { 'data': 'maquinaVelocidad'}, - { 'data': 'tiempoMaquina'}, - { 'data': 'papelGenericoId'}, - { 'data': 'papelImpresionId'}, - { 'data': 'paginasColor'}, - { 'data': 'tarifa_impresion_id'} - ], - columnDefs: [ - { - target: [21,22,23,24,25,26,27], - visible: false, - searchable: false - }, - ] - }); - - var tableCompCubierta = new DataTable('#tableCompCubierta',{ - scrollX: true, - searching: false, - paging: false, - info: false, - ordering: true, - responsive: true, - select: false, - language: { - url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" - }, - columns: [ - { 'data': 'tipo', - 'render': function ( data, type, row, meta ) { - if(data=='cubierta') - return ''; - else if(data=='sobrecubierta') - return ''; - } - }, - { 'data': 'paginas' }, - { 'data': 'papel' }, - { 'data': 'gramaje' }, - { 'data': 'marca' }, - { 'data': 'maquina' }, - { 'data': 'numeroPliegos' }, - { 'data': 'pliegosPedido' }, - { 'data': 'precioPliego' }, - { 'data': 'libro' }, - { 'data': 'totalPapelPedido' }, - { 'data': 'lomo' }, - { 'data': 'peso' }, - { 'data': 'horasMaquina' }, - { 'data': 'precioImpresion' }, - { 'data': 'total' }, - { 'data': 'maquinaId'}, - { 'data': 'maquinaVelocidad'}, - { 'data': 'tiempoMaquina'}, - { 'data': 'papelGenericoId'}, - { 'data': 'papelImpresionId'}, - { 'data': 'tarifa_impresion_id'} - ], - columnDefs: [ - { - target: [16,17,18,19,20,21], - visible: false, - searchable: false - }, - ], - "order": [ [0, 'asc'],[15, 'asc'] ] - }); - - - var tableCompGuardas = new DataTable('#tableCompGuardas',{ - scrollX: true, - searching: false, - paging: false, - info: false, - ordering: false, - responsive: true, - select: false, - language: { - url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" - }, - columns: [ - { 'data': 'tipo', - 'render': function ( data, type, row, meta ) { - - return ''; - } - - }, - { 'data': 'paginas' }, - { 'data': 'papel' }, - { 'data': 'gramaje' }, - { 'data': 'marca' }, - { 'data': 'maquina' }, - { 'data': 'numeroPliegos' }, - { 'data': 'pliegosPedido' }, - { 'data': 'precioPliego' }, - { 'data': 'libro' }, - { 'data': 'totalPapelPedido' }, - { 'data': 'lomo' }, - { 'data': 'peso' }, - { 'data': 'horasMaquina' }, - { 'data': 'precioImpresion' }, - { 'data': 'total' }, - { 'data': 'maquinaId'}, - { 'data': 'maquinaVelocidad'}, - { 'data': 'tiempoMaquina'}, - { 'data': 'papelGenericoId'}, - { 'data': 'papelImpresionId'}, - { 'data': 'tarifa_impresion_id'}, - { 'data': 'paginas_impresion'}, - ], - columnDefs: [ - { - target: [16,17,18,19,20,21,22], - visible: false, - searchable: false - }, - ] - }); - - function checkComparadorGuardas(actualizarLinea = false){ - - if ($('#compPapelGuardas').select2('data')[0].id > 0 ){ - - const dimension = getDimensionLibro(); - - let datos = { - tipo_impresion_id: , - type: 'guardas', - paginas: 8, - paginas_impresion: parseInt($('#compCarasGuardas').select2('data')[0].id), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - color: 1, - hq: 1, - ancho: dimension.ancho, - alto: dimension.alto, - papel_generico_id: $('#compPapelGuardas').select2('data')[0].id, - papel_generico: $('#compPapelGuardas').select2('data')[0].text.trim(), - gramaje: parseInt($('#compGramajeGuardas').val()), - cliente_id: $('#clienteId').find(":selected").val(), - : v - }; - - $.ajax({ - type: "POST", - url: "/presupuestoadmin/datatable", - data: datos, - success: function (data) { - - clearGuardas(); - - if(data.lineas.length >0){ - fillGuardas(data); - selectGuardasLineas(); - $('#title_guardas').html('' + ' (' + tableCompGuardas.rows().count() + ')'); - $('#insertarGuardasBtn').removeClass('d-none') - if(actualizarLinea){ - var rows = $("#tableCompCubierta").DataTable().rows( '.selected' ).data().toArray(); - for(row of rows){ - fill_lp_guardas(row, true); - } - } - } - else{ - $('#title_guardas').html(''); - $('#insertarGuardasBtn').addClass('d-none') - $('#total_comp_guardas').html('0.00') - - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - } - - else{ - clearGuardas(); - } - } - - - $('.comp_guardas_items').on('change', function (e) { - - checkComparadorGuardas(false); - }); - - - - async function getLineasIntPlana(is_color, is_hq, actualizarLinea){ - - const dimension = getDimensionLibro(); - - let datos = { - tipo_impresion_id: , - type: 'interior', - color: is_color?1:0, - hq: is_hq?1:0, - paginas: parseInt($(''+ elementos.paginas).val()), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#merma').val()), - ancho: dimension.ancho, - alto: dimension.alto, - papel_generico_id: $(''+ elementos.papel).select2('data')[0].id, - papel_generico: $(''+ elementos.papel).select2('data')[0].text.trim(), - gramaje: $(''+ elementos.gramaje).select2('data')[0].text.trim() , - cliente_id: $('#clienteId').find(":selected").val(), - : v - }; - - $.ajax({ - type: "POST", - url: "/presupuestoadmin/datatable", - data: datos, - success: function (data) { - - clearIntLineas(is_color); - - if(data.lineas.length >0){ - - fillIntPlana(data, is_color, is_hq); - selectIntLineas(); - $('#title_int_plana').html('' + ' (' + tableCompIntPlana.rows().count() + ')'); - $('#insertarPlanaBtn').removeClass('d-none') - if(actualizarLinea){ - var rows = $("#tableCompIntPlana").DataTable().rows( '.selected' ).data().toArray(); - for(row of rows){ - - if(row['tipo'] =='bn' && !is_color && !is_hq){ - if($('#lp_bn').css('display')!='none') - fill_lp_bn(row, true); - } - else if(row['tipo'] =='bnhq' && !is_color && is_hq){ - if($('#lp_bnhq').css('display')!='none') - fill_lp_bnhq(row, true); - } - else if(row['tipo'] =='color' && is_color && !is_hq){ - if($('#lp_color').css('display')!='none') - fill_lp_color(row, true); - } - else if(row['tipo'] =='colorhq' && is_color && is_hq){ - if($('#lp_colorhq').css('display')!='none') - fill_lp_colorhq(row, true); - } - } - } - } - else{ - $('#title_int_plana').html(''); - $('#insertarPlanaBtn').addClass('d-none') - $('#total_comp_plana').html('0.00'); - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - return false; - } - - async function getLineasIntRot(is_hq, actualizarLinea=false){ - - const dimension = getDimensionLibro(); - - // Rotativa solo negro o color (no hq) - if ( is_hq==false){ - - if(checkInputsForRotativa()){ - - let datos = { - tipo_impresion_id: , - type: 'interior_rot', - paginas: parseInt($('#paginas').val()), - paginas_negro: parseInt($('#compPaginasNegro').val()), - paginas_color: parseInt($('#compPaginasColor').val()), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#merma').val()), - ancho: dimension.ancho, - alto: dimension.alto, - // el papel y el gramaje se coge del negro (siempre estará) - papel_generico_id: $('#compPapelNegro').select2('data')[0].id, - papel_generico: $('#compPapelNegro').select2('data')[0].text.trim(), - gramaje: $('#compGramajeNegro').select2('data')[0].text.trim() , - cliente_id: $('#clienteId').find(":selected").val(), - : v - }; - - $.ajax({ - type: "POST", - url: "/presupuestoadmin/datatable", - data: datos, - success: function (data) { - - clearIntRot(); - - if(data.lineas.length >0){ - - fillIntRot(data); - selectIntRotLineas(); - $('#title_int_rot').html('' + ' (' + tableCompIntRotativa.rows().count() + ')'); - $('#insertarRotativaBtn').removeClass('d-none') - if(actualizarLinea){ - var rows = $("#tableCompIntRotativa").DataTable().rows( '.selected' ).data().toArray(); - for(row of rows){ - if(row['paginasColor'] ==0){ - if($('#lp_rot_bn').css('display')!='none') - fill_lp_rot_bn(row, true); - } - else if(row['paginasColor'] >0){ - if($('#lp_rot_color').css('display')!='none') - fill_lp_rot_color(row, true); - } - } - } - } - else{ - $('#title_int_rot').html(''); - $('#insertarRotativaBtn').addClass('d-none') - $('#total_comp_rot').html('0.00') - - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - } - } - return false; - } - - $('.comp_cubierta_items').on('change', function (){ - - checkComparadorCubierta() - }); - - - function checkComparadorCubierta(actualizarLinea = false){ - - if ($('#compCarasCubierta option:selected').val().length > 0 && - $('#compPapelCubierta').select2('data').length > 0 && - $('#compGramajeCubierta').select2('data').length > 0 ){ - - const dimension = getDimensionLibro(); - - let datos = { - tipo_impresion_id: , - type: 'cubierta', - paginas: parseInt($('#compCarasCubierta option:selected').val()), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - color: 1, - ancho: dimension.ancho, - alto: dimension.alto, - lomo: getLomoLineasPresupuesto(), - solapas: $('#solapas').is(':checked')?1:0, - solapas_ancho: $('#solapas').is(':checked')?parseInt($('#solapas_ancho').val()):0, - papel_generico_id: $('#compPapelCubierta').select2('data')[0].id, - papel_generico: $('#compPapelCubierta').select2('data')[0].text.trim(), - gramaje: $('#compGramajeCubierta').select2('data')[0].text.trim() , - cliente_id: $('#clienteId').find(":selected").val(), - : v - }; - - $.ajax({ - type: "POST", - url: "/presupuestoadmin/datatable", - data: datos, - success: function (data) { - - clearCubierta(); - - if(data.lineas.length >0){ - fillCubierta(data); - selectCubiertaLineas(); - tableCompCubierta.order([0, 'asc']).draw() - $('#title_cubierta').html('' + (tableCompCubierta.rows().count()>0 ?(' (' + tableCompCubierta.rows().count() + ')'):'')); - $('#insertarCubiertaBtn').removeClass('d-none') - if(actualizarLinea){ - var rows = $("#tableCompCubierta").DataTable().rows( '.selected' ).data().toArray(); - for(row of rows){ - if (row.tipo=='cubierta') - fill_lp_cubierta(row, true); - } - } - } - else{ - $('#title_cubierta').html('' + (tableCompCubierta.rows().count()>0 ?(' (' + tableCompCubierta.rows().count() + ')'):'')); - if(tableCompCubierta.rows().count()==0){ - $('#insertarCubiertaBtn').addClass('d-none') - $('#total_comp_cubierta').html('0.00') - } - else{ - selectCubiertaLineas(); - } - - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - } - - else{ - clearCubierta(); - } - } - - $('.comp_sobrecubierta_items').on('change', function (){ - - checkComparadorSobrecubierta() - }); - - - function checkComparadorSobrecubierta(actualizarLinea = false){ - - if ($('#compSobrecubierta option:selected').val() == 1 && - $('#compPapelSobrecubierta').select2('data').length > 0 && - $('#compGramajeSobrecubierta').select2('data').length > 0 ){ - - - const dimension = getDimensionLibro(); - - let datos = { - tipo_impresion_id: , - type: 'sobrecubierta', - paginas: 4, - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - color: 1, - ancho: dimension.ancho, - alto: dimension.alto, - lomo: getLomoLineasPresupuesto() + getLomoCubiertaLineasPresupuesto(), - solapas: $('#solapas_sobrecubierta').is(':checked')?1:0, - solapas_ancho: $('#solapas_sobrecubierta').is(':checked')?parseInt($('#solapas_ancho_sobrecubierta').val()):0, - papel_generico_id: $('#compPapelSobrecubierta').select2('data')[0].id, - papel_generico: $('#compPapelSobrecubierta').select2('data')[0].text.trim(), - gramaje: $('#compGramajeSobrecubierta').select2('data')[0].text.trim() , - cliente_id: $('#clienteId').find(":selected").val(), - : v - }; - - $.ajax({ - type: "POST", - url: "/presupuestoadmin/datatable", - data: datos, - success: function (data) { - - clearSobrecubierta(); - - if(data.lineas.length >0){ - - fillSobrecubierta(data); - selectCubiertaLineas(); - tableCompCubierta.order([ [0, 'asc'],[15, 'asc'] ]).draw() - $('#title_cubierta').html('' + (tableCompCubierta.rows().count()>0 ?(' (' + tableCompCubierta.rows().count() + ')'):'')); - $('#insertarCubiertaBtn').removeClass('d-none') - if(actualizarLinea){ - var rows = $("#tableCompCubierta").DataTable().rows( '.selected' ).data().toArray(); - for(row of rows){ - if (row.tipo=='sobrecubierta') - fill_lp_sobrecubierta(row, true); - } - } - } - else{ - $('#title_cubierta').html('' + (tableCompCubierta.rows().count()>0 ?(' (' + tableCompCubierta.rows().count() + ')'):'')); - if(tableCompCubierta.rows().count()==0){ - $('#insertarCubiertaBtn').addClass('d-none') - $('#total_comp_cubierta').html('0.00') - } - else{ - selectCubiertaLineas(); - } - - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - } - - else{ - clearSobrecubierta(); - } - } - - - - $('.comp_negro_items').on('change', function (e) { - - checkComparadorInt(false,false); - }); - - $('.comp_negrohq_items').on('change', function (e) { - - checkComparadorInt(false, true); - }); - - $('.comp_color_items').on('change', function (e) { - - checkComparadorInt(true, false); - }); - - $('.comp_colorhq_items').on('change', function (e) { - checkComparadorInt(true, true); - }); - - - - $('#tipoImpresion').on("change.select2", function () { - updatePapelesComparador(); - $('#title_int_rot').html(''); - $('#title_int_plana').html(''); - if (($('#tipoImpresion').select2('data')[0].id == 'negro' || - $('#tipoImpresion').select2('data')[0].id == 'color')){ - - $('#tableCompIntRotativa').DataTable().clear().draw(); - $('#total_comp_rot').html("0.00"); - - - $('#compPaginasColor').val('0') - $('#compPaginasColorhq').val('0') - $('#compPaginasNegrohq').val('0'); - $('#compPaginasNegro').val($('#paginas').val()) - - if($('#tipoImpresion').select2('data')[0].id == 'negro'){ - $('#compGramajeColor').val('').trigger('change') - $('#compPapelColor').val(0).trigger('change') - } - - if( $('#tableCompIntPlana').DataTable().rows().count() > 0 && - $('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) { - - $('#tableCompIntPlana').DataTable().clear().draw(); - $('#total_comp_plana').html("0.00"); - } - - } - else if (($('#tipoImpresion').select2('data')[0].id == 'negrohq' || - $('#tipoImpresion').select2('data')[0].id == 'colorhq')){ - - $('#tableCompIntRotativa').DataTable().clear().draw(); - $('#total_comp_rot').html("0.00"); - - $('#compPaginasColorhq').val('0') - $('#compPaginasColor').val('0') - $('#compPaginasNegro').val('0') - $('#compPaginasNegrohq').val($('#paginas').val()) - - if($('#tipoImpresion').select2('data')[0].id == 'negrohq'){ - $('#compGramajeColorhq').val('').trigger('change') - $('#compPapelColorhq').val(0).trigger('change') - } - - if($('#tableCompIntPlana').DataTable().rows().count() > 0 && - !$('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) { - - $('#tableCompIntPlana').DataTable().clear().draw(); - $('#total_comp_plana').html("0.00"); - } - } - }); - - $('#tipoImpresion').on("select2:close", function () { - - $('#paginas').change() - }) - - - function checkComparadorInt(is_color, is_hq, actualizarLineaPlana=false, actualizarLineaRot=false) { - - /* TO-DO with select2 component - try{ - - clearIntLineas(is_color); - clearIntRot(); - $('#title_int_rot').html(''); - $('#title_int_plana').html(''); - - elementos = getIDsComparador(is_color, is_hq) - - if ($(''+ elementos.papel).select2('data').length > 0 && - $(''+ elementos.gramaje).select2('data').length > 0 && - parseInt($(''+ elementos.paginas).val()) >= 0 && - checkDatosPedidoForComp()) { - - - getLineasIntPlana(is_color, is_hq, actualizarLineaPlana).then((result) =>{ - // Para rotativa, si es color el papel y el gramaje tiene que ser igual - if(!is_color) - { - getLineasIntRot(is_hq, actualizarLineaRot); - } - else - { - if(!is_hq){ - if ($('#compPapelNegro').select2('data').length>0 && $('#compPapelColor').select2('data').length>0 && - $('#compGramajeNegro').select2('data').length>0 && $('#compGramajeColor').select2('data').length>0) - { - if(($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id && - $('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim())) - { - getLineasIntRot(is_hq, actualizarLineaRot); - } - else - { - $('#errorComRot').html(''); - } - } - } - } - }); - } - }catch(e){ - console.log(e) - } - */ - } - - - $('#compPapelNegro').on('select2:select', function (e){ - - if($('#compPapelNegro').select2('data')[0].id=='0'){ - $('#compGramajeNegro').val('').change(); - $('#compGramajeNegro').prop('disabled', true); - } - - else{ - $('#insertarPlanaBtn').addClass('d-none') - $('#insertarRotativaBtn').addClass('d-none') - $('#total_comp_plana').html('0.00') - $('#total_comp_rot').html('0.00') - $('#compGramajeNegro').val('').change(); - $('#compGramajeNegro').empty().trigger("change"); - $('#compGramajeNegro').prop('disabled', false); - $('#compGramajeNegro').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'bn', - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - datos: $('#compPapelNegro').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - } - }); - - $('#compPapelNegrohq').on('select2:select', function (e){ - - if($('#compPapelNegrohq').select2('data')[0].id=='0'){ - $('#compGramajeNegrohq').val('').change(); - $('#compGramajeNegrohq').prop('disabled', true); - } - else{ - $('#insertarPlanaBtn').addClass('d-none') - $('#insertarRotativaBtn').addClass('d-none') - $('#total_comp_plana').html('0.00') - $('#total_comp_rot').html('0.00') - $('#compGramajeNegrohq').empty().trigger("change"); - $('#compGramajeNegrohq').prop('disabled', false); - $('#compGramajeNegrohq').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'bnhq', - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - datos: $('#compPapelNegrohq').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - } - }); - - - $('#compPapelColor').on('select2:select', function (e){ - - if($('#compPapelColor').select2('data')[0].id=='0'){ - $('#compGramajeColor').val('').change(); - $('#compGramajeColor').prop('disabled', true); - } - else{ - $('#insertarPlanaBtn').addClass('d-none') - $('#insertarRotativaBtn').addClass('d-none') - $('#total_comp_plana').html('0.00') - $('#total_comp_rot').html('0.00') - $('#compGramajeColor').empty().trigger("change"); - $('#compGramajeColor').prop('disabled', false); - $('#compPapelColor').find('option[value="0"]').remove(); - $('#compGramajeColor').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'color', - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - datos: $('#compPapelColor').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - } - }); - - - $('#compPapelColorhq').on('select2:select', function (e){ - - if($('#compPapelColorhq').select2('data')[0].id=='0'){ - $('#compGramajeColorhq').val('').change(); - $('#compGramajeColorhq').prop('disabled', true); - } - else{ - $('#insertarPlanaBtn').addClass('d-none') - $('#insertarRotativaBtn').addClass('d-none') - $('#total_comp_plana').html('0.00') - $('#total_comp_rot').html('0.00') - $('#compGramajeColorhq').empty().trigger("change"); - $('#compGramajeColorhq').prop('disabled', false); - $('#compPapelColorhq').find('option[value="0"]').remove(); - $('#compGramajeColorhq').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'colorhq', - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - datos: $('#compPapelColorhq').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - } - }); - - $('#compPapelCubierta').on('select2:select', function (e){ - if($('#compPapelCubierta').select2('data')[0].id=='0'){ - $('#compGramajeCubierta').val('').change(); - $('#compGramajeCubierta').prop('disabled', true); - } - else{ - clearCubierta(); - $('#compGramajeCubierta').empty().trigger("change"); - $('#compGramajeCubierta').val('').trigger('change'); - $('#compGramajeCubierta').prop('disabled', false); - $('#compPapelCubierta').find('option[value="0"]').remove(); - $('#compGramajeCubierta').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'cubierta', - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - datos: $('#compPapelCubierta').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - } - }); - - $('#compPapelSobrecubierta').on('select2:open', function (e){ - $('#compGramajeSobrecubierta').val(0).trigger('change'); - $('#compGramajeSobrecubierta').select2("destroy") - $('#compGramajeSobrecubierta').select2({allowClear: false, minimumResultsForSearch: Infinity}) - }) - - - $('#compPapelSobrecubierta').on('select2:select', function (e){ - if($('#compPapelSobrecubierta').select2('data')[0].id=='0'){ - - $('#compGramajeSobrecubierta').prop('disabled', true); - } - else{ - clearSobrecubierta(); - $('#compGramajeSobrecubierta').prop('disabled', false); - $('#compPapelSobrecubierta').find('option[value="0"]').remove(); - $('#compGramajeSobrecubierta').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - ajax: { - url: '', - type: 'post', - dataType: 'json', - - data: function (params) { - return { - tipo: 'gramaje', - uso: 'sobrecubierta', - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - datos: $('#compPapelSobrecubierta').select2('data')[0].text.trim() , - : v - }; - }, - delay: 60, - processResults: function (response) { - yeniden(response.); - return { - results: response.menu - }; - }, - cache: true - } - }); - } - }); - - - function checkDatosPedidoForComp() { - - const dimension = getDimensionLibro(); - - if (parseInt($('#paginas').val()) <= 0){ - popErrorAlert('', 'divAlarmasComparador'); - return false; - } - if (parseInt($('#tirada').val()) <= 0){ - popErrorAlert('', 'divAlarmasComparador'); - return false; - } - if('ancho' in dimension && 'alto' in dimension){ - - if(dimension.alto < 60 || dimension.ancho < 60 || isNaN(dimension.alto) || isNaN(dimension.ancho) ){ - popErrorAlert('', 'divAlarmasComparador'); - return false; - } - } - else{ - popErrorAlert('', 'divAlarmasComparador'); - return false; - } - return true; - } - - init_comparador() - init_lineas_comparador() - -endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosServiciosItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosServiciosItems.php index d6fbe850..4804f3a3 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosServiciosItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosServiciosItems.php @@ -286,6 +286,7 @@ section("additionalInlineJs") ?> // Generación de la lista de servicios de acabado (id, nombre) + ; window.serviciosacabadosList = ; window.serviciosAutomaticos = ; @@ -318,7 +319,7 @@ init_servicio_extra() - /* ELIMINADO PARA COMPROBAR EL MAXIMO DE SOLAPAS DESDE EL BACKEND + /// ELIMINADO PARA COMPROBAR EL MAXIMO DE SOLAPAS DESDE EL BACKEND PENDIENTE $('.solapas_cubierta').on('change', function(){ @@ -364,6 +365,6 @@ $('#compGramajeSobrecubierta').trigger('change') }) - */ + */?> endSection() ?> diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.php index d6bb3738..1b655662 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.php @@ -74,7 +74,7 @@ section("additionalInlineJs") ?> -window.papelGenericoNegroList = []; +/*window.papelGenericoNegroList = []; window.papelGenericoNegroHQList = []; window.papelGenericoColorList = []; window.papelGenericoColorHQList = []; @@ -95,7 +95,7 @@ window.routes_lp = { } - +*/ /* fill_lp_from_bbdd() diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_presupuestoDireccionesForm.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_presupuestoDireccionesForm.php index 601eeca8..6a25b1b9 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_presupuestoDireccionesForm.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_presupuestoDireccionesForm.php @@ -140,7 +140,7 @@ section("additionalInlineJs") ?> - +/* $('#cancelAdd').on('click', function(){ $('#addressForm').modal("hide"); }) @@ -394,5 +394,5 @@ $('#addressForm').on('hidden.bs.modal', function () { $('#add_saveDirection').prop('checked', false) $('#add_entregaPieCalle').prop('checked', false) }) - +*/ endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_previewItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_previewItems.php index 10529606..e898e029 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_previewItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_previewItems.php @@ -918,7 +918,7 @@ section("additionalInlineJs") ?> - +/* $('#tab-pv-bn').on( "click", function() { @@ -980,6 +980,7 @@ $('#tab-pv-sobrecubierta').on( "click", function() { previewInteriorPlana('sobrecubierta', , ); } ); +*/ endSection() ?> diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_tiradasAlternativasItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_tiradasAlternativasItems.php index ecb7af82..f4a35236 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_tiradasAlternativasItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_tiradasAlternativasItems.php @@ -52,14 +52,14 @@ section("additionalInlineJs") ?> - window.datatable_lang_url = "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"; + /* window.datatable_lang_url = "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"; window.datatable_TA_url = ""; window.get_tirada_url = ""; window.error_lang_tirada_alt_duplicada = ""; window.error_lang_tirada_alt_tipo = ""; - + */ 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 61231bc8..bdebd239 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/comparador.js +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/comparador.js @@ -1,81 +1,11 @@ /******************************* * Eventos asociados a elementos HTML *******************************/ -$('#compPaginasNegro').on("change", function () { - var negro = parseInt(document.getElementById('compPaginasNegro').value); - const paginas = parseInt(document.getElementById('paginas').value); - if (paginas < negro) { - document.getElementById('compPaginasNegro').value = paginas; - negro = paginas; - } - var color = parseInt(document.getElementById('compPaginasColor').value); - if ($('#tipoImpresion').select2('data')[0].id == 'color') { - - var newValue = paginas - negro; - if (newValue != color) { - document.getElementById('compPaginasColor').value = newValue >= 0 ? newValue : 0; - $('#compPaginasColor').change(); - } - } -}); - -$('#compPaginasColor').on("change", function () { - const paginas = parseInt(document.getElementById('paginas').value); - var color = parseInt(document.getElementById('compPaginasColor').value); - var negro = parseInt(document.getElementById('compPaginasNegro').value); - - if (paginas < color) { - document.getElementById('compPaginasColor').value = paginas; - color = paginas - } - var newValue = paginas - color; - if (newValue != negro) { - document.getElementById('compPaginasNegro').value = newValue >= 0 ? newValue : 0; - $('#compPaginasNegro').change(); - } -}); - -$('#compPaginasNegrohq').on("change", function () { - - var negro = parseInt(document.getElementById('compPaginasNegrohq').value); - const paginas = parseInt(document.getElementById('paginas').value); - if (paginas < negro) { - document.getElementById('compPaginasNegrogq').value = paginas; - negro = paginas; - } - var color = parseInt(document.getElementById('compPaginasColorhq').value); - if ($('#tipoImpresion').select2('data')[0].id == 'colorhq') { - - var newValue = paginas - negro; - if (newValue != color) { - document.getElementById('compPaginasColorhq').value = newValue >= 0 ? newValue : 0; - $('#compPaginasColorhq').change(); - } - } - -}); - -$('#compPaginasColorhq').on("change", function () { - const paginas = parseInt(document.getElementById('paginas').value); - var color = parseInt(document.getElementById('compPaginasColorhq').value); - var negro = parseInt(document.getElementById('compPaginasNegrohq').value); - - if (paginas < color) { - document.getElementById('compPaginasColorhq').value = paginas; - color = paginas - } - var newValue = paginas - color; - if (newValue != negro) { - document.getElementById('compPaginasNegrohq').value = newValue >= 0 ? newValue : 0; - $('#compPaginasNegrohq').change(); - } -}); -$('#prototipo').on("change", function () { - $('#ferro').prop('checked', true) -}); + + @@ -84,28 +14,6 @@ $('#compPosPaginasColor').on("keyup", function () { }); -// Este evento recoloca los headers de las tablas cuando se pulsa el -// boton del acordeon -$('.accordion-button').on('click', function (e) { - - if (e.target.id.includes("plana")) { - $("#tableCompIntPlana").DataTable().columns.adjust(); - } - else if (e.target.id.includes("rotativa")) { - $("#tableCompIntRotativa").DataTable().columns.adjust(); - } - else if (e.target.id.includes("cubierta")) { - $("#tableCompCubierta").DataTable().columns.adjust(); - } - else if (e.target.id.includes("guardas")) { - $("#tableCompGuardas").DataTable().columns.adjust(); - } - else if (e.target.id.includes("LineasPresupuesto")) { - $("#tableLineasPresupuesto").DataTable().columns.adjust(); - } - - -}); @@ -189,110 +97,11 @@ function getRowFromLineaRot(linea) { -function computarPaginasColor(string) { - - var numbers = []; - for (const [, beginStr, endStr] of string.matchAll(/(\d+)(?:-(\d+))?/g)) { - const [begin, end] = [beginStr, endStr].map(Number); - numbers.push(begin); - if (endStr !== undefined) { - for (let num = begin + 1; num <= end; num++) { - numbers.push(num); - } - } - } - var numbers2 = []; - numbers.forEach(function (value, i) { - // Si es impar y no está el siguiente par hay que añadirlo - if (value % 2 != 0 && numbers[i + 1] != value + 1) { - numbers2.push(value + 1); - } - }); - numbers = numbers.concat(numbers2); - numbers.sort(function (a, b) { - return a - b; - }); - calPagesTextarea = document.getElementById('compCalPaginasColor'); - calPagesTextarea.value = numbers; - autosize.update(calPagesTextarea); -} -function updatePapelesComparador() { - var e = document.getElementById("tipoImpresion"); - elements_negro = document.getElementsByClassName('comp-negro-selected'); - elements_negrohq = document.getElementsByClassName('comp-negrohq-selected'); - elements_color = document.getElementsByClassName('comp-color-selected'); - elements_colorhq = document.getElementsByClassName('comp-colorhq-selected'); - switch (e.value) { - case "negro": - Array.from(elements_color).forEach(element => { - element.style.display = "none"; - }); - Array.from(elements_negro).forEach(element => { - element.style.display = "flex"; - }); - Array.from(elements_negrohq).forEach(element => { - element.style.display = "none"; - }); - Array.from(elements_colorhq).forEach(element => { - element.style.display = "none"; - }); - break; - - case "negrohq": - Array.from(elements_color).forEach(element => { - element.style.display = "none"; - - }); - Array.from(elements_negro).forEach(element => { - element.style.display = "none"; - }); - Array.from(elements_negrohq).forEach(element => { - element.style.display = "flex"; - }); - Array.from(elements_colorhq).forEach(element => { - element.style.display = "none"; - }); - break; - - case "color": - Array.from(elements_negro).forEach(element => { - element.style.display = "flex"; - }); - Array.from(elements_negrohq).forEach(element => { - element.style.display = "none"; - }); - Array.from(elements_color).forEach(element => { - element.style.display = "flex"; - }); - Array.from(elements_colorhq).forEach(element => { - element.style.display = "none"; - }); - break; - - case "colorhq": - Array.from(elements_negro).forEach(element => { - element.style.display = "none"; - }); - Array.from(elements_negrohq).forEach(element => { - element.style.display = "flex"; - }); - Array.from(elements_color).forEach(element => { - element.style.display = "none"; - }); - Array.from(elements_colorhq).forEach(element => { - element.style.display = "flex"; - }); - break; - - default: - break; - } -} diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php index 9e5a7e7a..120cb0e9 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php @@ -304,14 +304,14 @@ - + + - + --> diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js index c86df266..795fda67 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js @@ -1,5 +1,6 @@ import ClassSelect from '../../../components/select2.js'; import { getToken } from '../../../common/common.js'; +import Ajax from '../../../components/ajax.js'; class Comparador { @@ -7,6 +8,8 @@ class Comparador { this.domItem = domItem; + this.tipo_impresion_id = parseInt($('#tipo_impresion_id').val()); + this.csrf_token = getToken(); this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val(); @@ -18,8 +21,8 @@ class Comparador { '/presupuestoadmin/papelgenerico', 'Seleccione papel', false, { [this.csrf_token]: this.csrf_hash, - tipo_impresion: this.tipo_impresion.val(), - tirada: $('#tirada').val(), + tipo_impresion: this.tipo_impresion_id, + tirada: () => $('#tirada').val(), tipo: 'negro', }); @@ -27,31 +30,1283 @@ class Comparador { '/presupuestoadmin/papelgramaje', 'Seleccione gramaje', false, { [this.csrf_token]: this.csrf_hash, - papel_generico: this.papelNegro.getVal(), - tipo_impresion: this.tipo_impresion.val(), - tirada: $('#tirada').val(), + papel_generico: () => this.papelNegro.getVal(), + tipo_impresion: this.tipo_impresion_id, + tirada: () => $('#tirada').val(), tipo: 'negro', }); + this.paginasColor = $('#compPaginasColor'); + this.papelColor = new ClassSelect($('#compPapelColor'), + '/presupuestoadmin/papelgenerico', 'Seleccione papel', false, + { + [this.csrf_token]: this.csrf_hash, + tipo_impresion: this.tipo_impresion_id, + tirada: () => $('#tirada').val(), + tipo: 'color', + }); + this.gramajeColor = new ClassSelect($('#compGramajeColor'), + '/presupuestoadmin/papelgramaje', 'Seleccione gramaje', false, + { + [this.csrf_token]: this.csrf_hash, + papel_generico: () => this.papelColor.getVal(), + tipo_impresion: this.tipo_impresion_id, + tirada: () => $('#tirada').val(), + tipo: 'color', + }); + + this.paginasNegrohq = $('#compPaginasNegrohq'); + this.papelNegrohq = new ClassSelect($('#compPapelNegrohq'), + '/presupuestoadmin/papelgenerico', 'Seleccione papel', false, + { + [this.csrf_token]: this.csrf_hash, + tipo_impresion: this.tipo_impresion_id, + tirada: () => $('#tirada').val(), + tipo: 'negrohq', + }); + + this.gramajeNegrohq = new ClassSelect($('#compGramajeNegrohq'), + '/presupuestoadmin/papelgramaje', 'Seleccione gramaje', false, + { + [this.csrf_token]: this.csrf_hash, + papel_generico: () => this.papelNegrohq.getVal(), + tipo_impresion: this.tipo_impresion_id, + tirada: () => $('#tirada').val(), + tipo: 'negrohq', + }); + + this.paginasColorhq = $('#compPaginasColorhq'); + this.papelColorhq = new ClassSelect($('#compPapelColorhq'), + '/presupuestoadmin/papelgenerico', 'Seleccione papel', false, + { + [this.csrf_token]: this.csrf_hash, + tipo_impresion: this.tipo_impresion_id, + tirada: () => $('#tirada').val(), + tipo: 'colorhq', + }); + + this.gramajeColorhq = new ClassSelect($('#compGramajeColorhq'), + '/presupuestoadmin/papelgramaje', 'Seleccione gramaje', false, + { + [this.csrf_token]: this.csrf_hash, + papel_generico: () => this.papelColorhq.getVal(), + tipo_impresion: this.tipo_impresion_id, + tirada: () => $('#tirada').val(), + tipo: 'colorhq', + }); + + this.paginasCubierta = $('#compCarasCubierta'); + this.papelCubierta = new ClassSelect($('#compPapelCubierta'), + '/presupuestoadmin/papelgenerico', 'Seleccione papel', false, + { + [this.csrf_token]: this.csrf_hash, + tipo_impresion: this.tipo_impresion_id, + tirada: () => $('#tirada').val(), + tipo: 'colorhq', + uso: 'cubierta', + }); + this.gramajeCubierta = new ClassSelect($('#compGramajeCubierta'), + '/presupuestoadmin/papelgramaje', 'Seleccione gramaje', false, + { + [this.csrf_token]: this.csrf_hash, + papel_generico: () => this.papelCubierta.getVal(), + tipo_impresion: this.tipo_impresion_id, + tirada: () => $('#tirada').val(), + tipo: 'colorhq', + uso: 'cubierta', + }); + if (this.tipo_impresion_id != 5 && this.tipo_impresion_id != 6 && this.tipo_impresion_id != 7 && this.tipo_impresion_id != 8 && this.tipo_impresion_id != 21) { + this.sobrecubierta = $('#compSobrecubierta'); + this.papelSobrecubierta = new ClassSelect($('#compPapelSobrecubierta'), + '/presupuestoadmin/papelgenerico', 'Seleccione papel', false, + { + [this.csrf_token]: this.csrf_hash, + tipo_impresion: this.tipo_impresion_id, + tirada: () => $('#tirada').val(), + tipo: 'colorhq', + uso: 'sobrecubierta', + }); + this.gramajeSobrecubierta = new ClassSelect($('#compGramajeSobrecubierta'), + '/presupuestoadmin/papelgramaje', 'Seleccione gramaje', false, + { + [this.csrf_token]: this.csrf_hash, + papel_generico: () => this.papelSobrecubierta.getVal(), + tipo_impresion: this.tipo_impresion_id, + tirada: () => $('#tirada').val(), + tipo: 'colorhq', + uso: 'sobrecubierta', + }); + } + + if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) { + this.papelGuardas = new ClassSelect($('#compPapelGuardas'), + '/presupuestoadmin/papelgenerico', 'Seleccione papel', false, + { + [this.csrf_token]: this.csrf_hash, + tipo_impresion: this.tipo_impresion_id, + tirada: () => $('#tirada').val(), + tipo: 'guardas', + }); + this.carasGuardas = $('#compCarasGuardas'); + this.gramajeGuardas = $('#compGramajeGuardas'); + this.btnInsertarGuardas = $('#insertarGuardasBtn'); + } + + this.posPagColor = $('#compPosPaginasColor'); + this.calculatedColorPages = $('#compCalPaginasColor'); + + this.tableCompCubierta = null; + this.tableCompGuardas = null; + this.tableCompIntPlana = null; + this.tableCompIntRotativa = null; + this.btnInsertarPlana = $('#insertarPlanaBtn'); + this.btnInsertarRotativa = $('#insertarRotativaBtn'); + this.btnInsertarCubierta = $('#insertarCubiertaBtn'); } init() { + + autosize($('#compCalPaginasColor')); + + this.generateTables(); + + this.initSelect2(); + + this.initEvents(); + } + + initSelect2() { + + if ($('#tipo_impresion_id').val() == 1 || $('#tipo_impresion_id').val() == 3 || + $('#tipo_impresion_id').val() == 5 || $('#tipo_impresion_id').val() == 7) { + $('#compCarasCubierta').select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + }); + + $('#compPapelGuardas').select2({ + allowClear: false, + }); + + $('#compCarasGuardas').select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + }); + } this.papelNegro.init(); this.gramajeNegro.init(); + this.papelColor.init(); + this.gramajeColor.init(); + this.papelNegrohq.init(); + this.gramajeNegrohq.init(); + this.papelColorhq.init(); + this.gramajeColorhq.init(); + this.papelCubierta.init(); + this.gramajeCubierta.init(); + if (this.tipo_impresion_id != 5 && this.tipo_impresion_id != 6 && this.tipo_impresion_id != 7 && this.tipo_impresion_id != 8 && this.tipo_impresion_id != 21) { + this.papelSobrecubierta.init(); + this.gramajeSobrecubierta.init(); + this.papelSobrecubierta.onChange(() => this.gramajeSobrecubierta.setVal(0)) + this.sobrecubierta.on('change', () => { + if (this.sobrecubierta.val() == 1) { + $('#compPapelSobrecubierta').prop('disabled', false); + $('#compGramajeSobrecubierta').prop('disabled', false); + } + else { + this.papelSobrecubierta.setVal(0); + this.gramajeSobrecubierta.setVal(0); + $('#compPapelSobrecubierta').prop('disabled', true); + $('#compGramajeSobrecubierta').prop('disabled', true); + + } + }); + } + + if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) { + this.papelGuardas.init(); + } + + this.papelNegro.onChange(() => this.gramajeNegro.setVal(0)) + this.papelNegrohq.onChange(() => this.gramajeNegrohq.setVal(0)) + this.papelColor.onChange(() => this.gramajeColor.setVal(0)) + this.papelColorhq.onChange(() => this.gramajeColorhq.setVal(0)) + this.papelCubierta.onChange(() => this.gramajeCubierta.setVal(0)) + + + this.tipo_impresion.select2({ + allowClear: false, + }); + + this.posPagColor.on('keyup', () => this.#computarPaginasColor(this.posPagColor.val())); } + initEvents() { + + this.tipo_impresion.on("change", this.#handleTipoImpresion.bind(this)); + $('.accordion-button').on('click', function (e) { + + if (e.target.id.includes("plana")) { + $("#tableCompIntPlana").DataTable().columns.adjust(); + } + else if (e.target.id.includes("rotativa")) { + $("#tableCompIntRotativa").DataTable().columns.adjust(); + } + else if (e.target.id.includes("cubierta")) { + $("#tableCompCubierta").DataTable().columns.adjust(); + } + else if (e.target.id.includes("guardas")) { + $("#tableCompGuardas").DataTable().columns.adjust(); + } + else if (e.target.id.includes("LineasPresupuesto")) { + $("#tableLineasPresupuesto").DataTable().columns.adjust(); + } + }); + this.paginasNegro.on("change", this.#changePaginasComparador.bind(this)); + this.paginasNegrohq.on("change", this.#changePaginasComparador.bind(this)); + this.paginasColor.on("change", this.#changePaginasComparador.bind(this)); + this.paginasColorhq.on("change", this.#changePaginasComparador.bind(this)); + + $('.comp_negro_items').on('change', this.obtenerComparadorInterior.bind(this)); + $('.comp_negrohq_items').on('change', this.obtenerComparadorInterior.bind(this)); + $('.comp_color_items').on('change', this.obtenerComparadorInterior.bind(this)); + $('.comp_colorhq_items').on('change', this.obtenerComparadorInterior.bind(this)); + } + + #changePaginasComparador(element) { + + const paginas = parseInt($('#paginas').val()); + const newPaginas = parseInt($(element.currentTarget).val()); + + if (paginas < newPaginas) { + $(element.currentTarget).val(paginas) + } + if ($(element.currentTarget).attr('id') == this.paginasNegro.attr('id')) { + if (!$('.comp-color-selected').hasClass('d-none')) { + this.paginasColor.val((paginas - newPaginas) > 0 ? paginas - newPaginas : 0); + } + } + else if ($(element.currentTarget).attr('id') == this.paginasNegro.attr('id')) { + if (!$('.comp-colorhq-selected').hasClass('d-none')) { + this.paginasColorhq.val((paginas - newPaginas) > 0 ? paginas - newPaginas : 0); + } + } + else if ($(element.currentTarget).attr('id') == this.paginasColor.attr('id')) { + this.paginasNegro.val((paginas - newPaginas) > 0 ? paginas - newPaginas : 0); + } + else if ($(element.currentTarget).attr('id') == this.paginasColorhq.attr('id')) { + this.paginasNegrohq.val((paginas - newPaginas) > 0 ? paginas - newPaginas : 0); + } + } + + cargarDatos(datos) { - this.tipo_impresion.val(datos.tipo_impresion); + this.tipo_impresion.val(datos.tipo_impresion).trigger('change'); + this.updateOpcionesComparador(); this.comparador_json.val(JSON.stringify(datos.json_data)); - if (datos.json_data.bn){ + if (datos.json_data.bn) { this.paginasNegro.val(datos.json_data.bn.paginas); this.papelNegro.setOption(datos.json_data.bn.papel_id, datos.json_data.bn.papel_nombre); this.gramajeNegro.setOption(datos.json_data.bn.gramaje, datos.json_data.bn.gramaje); } + if (datos.json_data.bnhq) { + this.paginasNegrohq.val(datos.json_data.bnhq.paginas); + this.papelNegrohq.setOption(datos.json_data.bnhq.papel_id, datos.json_data.bnhq.papel_nombre); + this.gramajeNegrohq.setOption(datos.json_data.bnhq.gramaje, datos.json_data.bnhq.gramaje); + } + if (datos.json_data.color) { + this.paginasColor.val(datos.json_data.color.paginas); + this.papelColor.setOption(datos.json_data.color.papel_id, datos.json_data.color.papel_nombre); + this.gramajeColor.setOption(datos.json_data.color.gramaje, datos.json_data.color.gramaje); + } + if (datos.json_data.colorhq) { + this.paginasColorhq.val(datos.json_data.colorhq.paginas); + this.papelColorhq.setOption(datos.json_data.colorhq.papel_id, datos.json_data.colorhq.papel_nombre); + this.gramajeColorhq.setOption(datos.json_data.colorhq.gramaje, datos.json_data.colorhq.gramaje); + } + if (datos.json_data.cubierta) { + this.paginasCubierta.val(datos.json_data.cubierta.paginas); + this.papelCubierta.setOption(datos.json_data.cubierta.papel_id, datos.json_data.cubierta.papel_nombre); + this.gramajeCubierta.setOption(datos.json_data.cubierta.gramaje, datos.json_data.cubierta.gramaje); + } + if (datos.json_data.sobrecubierta) { + this.sobrecubierta.val(datos.json_data.sobrecubierta.imprimir).trigger('change'); + this.papelSobrecubierta.setOption(datos.json_data.sobrecubierta.papel_id, datos.json_data.sobrecubierta.papel_nombre); + this.gramajeSobrecubierta.setOption(datos.json_data.sobrecubierta.gramaje, datos.json_data.sobrecubierta.gramaje); + } + + if (datos.posPagColor.length > 0) { + this.posPagColor.val(datos.posPagColor); + this.#computarPaginasColor(datos.posPagColor); + } + } + + + generateTables() { + + this.tableCompIntPlana = new DataTable('#tableCompIntPlana', { + scrollX: true, + searching: false, + paging: false, + info: false, + ordering: false, + responsive: true, + select: false, + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + columns: [ + { + 'data': 'tipo', + 'render': function (data, type, row, meta) { + if (data == 'bn') + return window.language.Presupuestos.bn; + else if (data == 'bnhq') + return window.language.Presupuestos.bnhq; + else if (data == 'color') + return window.language.Presupuestos.color; + else if (data == 'colorhq') + return window.language.Presupuestos.colorhq; + } + }, + { 'data': 'paginas' }, + { 'data': 'papel' }, + { 'data': 'gramaje' }, + { 'data': 'marca' }, + { 'data': 'maquina' }, + { 'data': 'numeroPliegos' }, + { 'data': 'pliegosPedido' }, + { 'data': 'precioPliego' }, + { 'data': 'libro' }, + { 'data': 'totalPapelPedido' }, + { 'data': 'lomo' }, + { 'data': 'peso' }, + { 'data': 'horasMaquina' }, + { 'data': 'precioImpresion' }, + { 'data': 'total' }, + { 'data': 'maquinaId' }, + { 'data': 'maquinaVelocidad' }, + { 'data': 'tiempoMaquina' }, + { 'data': 'papelGenericoId' }, + { 'data': 'papelImpresionId' }, + { 'data': 'tarifa_impresion_id' } + ], + columnDefs: [ + { + target: [16, 17, 18, 19, 20, 21], + visible: false, + searchable: false + }, + ] + }); + + + this.tableCompIntRotativa = new DataTable('#tableCompIntRotativa', { + scrollX: true, + searching: false, + paging: false, + info: false, + ordering: false, + responsive: true, + select: false, + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + columns: [ + { + 'data': 'tipo', + 'render': function (data, type, row, meta) { + if (data == 'rotativa') + return window.language.Presupuestos.rotativa; + } + }, + { 'data': 'paginas' }, + { 'data': 'papel' }, + { 'data': 'gramaje' }, + { 'data': 'marca' }, + { + 'data': 'aFavorFibra', + 'render': function (data, type, row, meta) { + if (data == 'si') + return window.language.Presupuestos.si; + else if (data == 'no') + return window.language.Presupuestos.no; + } + }, + { 'data': 'maquina' }, + { 'data': 'numeroPliegos' }, + { 'data': 'pliegosPedido' }, + { 'data': 'precioPliego' }, + { 'data': 'libro' }, + { 'data': 'totalPapelPedido' }, + { 'data': 'lomo' }, + { 'data': 'peso' }, + { 'data': 'horasMaquina' }, + { 'data': 'precioImpresion' }, + { 'data': 'precioPagNegro' }, + { 'data': 'precioPagColor' }, + { 'data': 'totalTinta' }, + { 'data': 'totalCorte' }, + { 'data': 'total' }, + { 'data': 'maquinaId' }, + { 'data': 'maquinaVelocidad' }, + { 'data': 'tiempoMaquina' }, + { 'data': 'papelGenericoId' }, + { 'data': 'papelImpresionId' }, + { 'data': 'paginasColor' }, + { 'data': 'tarifa_impresion_id' } + ], + columnDefs: [ + { + target: [21, 22, 23, 24, 25, 26, 27], + visible: false, + searchable: false + }, + ] + }); + + this.tableCompCubierta = new DataTable('#tableCompCubierta', { + scrollX: true, + searching: false, + paging: false, + info: false, + ordering: true, + responsive: true, + select: false, + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + columns: [ + { + 'data': 'tipo', + 'render': function (data, type, row, meta) { + if (data == 'cubierta') + return window.language.Presupuestos.cubierta; + else if (data == 'sobrecubierta') + return window.language.Presupuestos.sobrecubierta; + } + }, + { 'data': 'paginas' }, + { 'data': 'papel' }, + { 'data': 'gramaje' }, + { 'data': 'marca' }, + { 'data': 'maquina' }, + { 'data': 'numeroPliegos' }, + { 'data': 'pliegosPedido' }, + { 'data': 'precioPliego' }, + { 'data': 'libro' }, + { 'data': 'totalPapelPedido' }, + { 'data': 'lomo' }, + { 'data': 'peso' }, + { 'data': 'horasMaquina' }, + { 'data': 'precioImpresion' }, + { 'data': 'total' }, + { 'data': 'maquinaId' }, + { 'data': 'maquinaVelocidad' }, + { 'data': 'tiempoMaquina' }, + { 'data': 'papelGenericoId' }, + { 'data': 'papelImpresionId' }, + { 'data': 'tarifa_impresion_id' } + ], + columnDefs: [ + { + target: [16, 17, 18, 19, 20, 21], + visible: false, + searchable: false + }, + ], + "order": [[0, 'asc'], [15, 'asc']] + }); + + if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) { + this.tableCompGuardas = new DataTable('#tableCompGuardas', { + scrollX: true, + searching: false, + paging: false, + info: false, + ordering: false, + responsive: true, + select: false, + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + columns: [ + { + 'data': 'tipo', + 'render': function (data, type, row, meta) { + + return window.language.Presupuestos.Guardas; + } + + }, + { 'data': 'paginas' }, + { 'data': 'papel' }, + { 'data': 'gramaje' }, + { 'data': 'marca' }, + { 'data': 'maquina' }, + { 'data': 'numeroPliegos' }, + { 'data': 'pliegosPedido' }, + { 'data': 'precioPliego' }, + { 'data': 'libro' }, + { 'data': 'totalPapelPedido' }, + { 'data': 'lomo' }, + { 'data': 'peso' }, + { 'data': 'horasMaquina' }, + { 'data': 'precioImpresion' }, + { 'data': 'total' }, + { 'data': 'maquinaId' }, + { 'data': 'maquinaVelocidad' }, + { 'data': 'tiempoMaquina' }, + { 'data': 'papelGenericoId' }, + { 'data': 'papelImpresionId' }, + { 'data': 'tarifa_impresion_id' }, + { 'data': 'paginas_impresion' }, + ], + columnDefs: [ + { + target: [16, 17, 18, 19, 20, 21, 22], + visible: false, + searchable: false + }, + ] + }); + } + + } + + updateOpcionesComparador() { + + const selValue = this.tipo_impresion.val(); + const elements_negro = $('.comp-negro-selected'); + const elements_negrohq = $('.comp-negrohq-selected'); + const elements_color = $('.comp-color-selected'); + const elements_colorhq = $('.comp-colorhq-selected'); + if (selValue.includes("hq")) { + Array.from(elements_negro).forEach(element => { + $(element).addClass('d-none'); + }); + Array.from(elements_color).forEach(element => { + $(element).addClass('d-none'); + }); + if (selValue.includes('color')) { + Array.from(elements_colorhq).forEach(element => { + $(element).removeClass('d-none'); + }); + } + Array.from(elements_negrohq).forEach(element => { + $(element).removeClass('d-none'); + }); + } + else { + Array.from(elements_negrohq).forEach(element => { + $(element).addClass('d-none'); + }); + Array.from(elements_colorhq).forEach(element => { + $(element).addClass('d-none'); + }); + if (selValue.includes('color')) { + Array.from(elements_color).forEach(element => { + $(element).removeClass('d-none'); + }); + } + Array.from(elements_negro).forEach(element => { + $(element).removeClass('d-none'); + }); + } + + if (selValue.includes('color')) { + $('.pos-paginas-color').removeClass('d-none'); + } + else { + $('.pos-paginas-color').addClass('d-none'); + } + } + + #computarPaginasColor(string) { + + var numbers = []; + for (const [, beginStr, endStr] of string.matchAll(/(\d+)(?:-(\d+))?/g)) { + const [begin, end] = [beginStr, endStr].map(Number); + numbers.push(begin); + if (endStr !== undefined) { + for (let num = begin + 1; num <= end; num++) { + numbers.push(num); + } + } + } + var numbers2 = []; + numbers.forEach(function (value, i) { + // Si es impar y no está el siguiente par hay que añadirlo + if (value % 2 != 0 && numbers[i + 1] != value + 1) { + numbers2.push(value + 1); + } + }); + numbers = numbers.concat(numbers2); + numbers.sort(function (a, b) { + return a - b; + }); + this.calculatedColorPages.val(numbers); + autosize.update(this.calculatedColorPages); + } + + #handleTipoImpresion() { + + this.updateOpcionesComparador(); + $('#title_int_rot').html(window.language.Presupuestos.compInteriorRotativa); + $('#title_int_plana').html(window.language.Presupuestos.compInteriorPlana); + if (($('#tipoImpresion').select2('data')[0].id == 'negro' || + $('#tipoImpresion').select2('data')[0].id == 'color')) { + + $('#tableCompIntRotativa').DataTable().clear().draw(); + $('#total_comp_rot').html("0.00"); + + $('#compPaginasColor').val('0') + $('#compPaginasColorhq').val('0') + $('#compPaginasNegrohq').val('0'); + $('#compPaginasNegro').val($('#paginas').val()) + + if ($('#tipoImpresion').select2('data')[0].id == 'negro') { + $('#compGramajeColor').val('').trigger('change') + $('#compPapelColor').val(0).trigger('change') + } + + if ($('#tableCompIntPlana').DataTable().rows().count() > 0 && + $('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) { + + $('#tableCompIntPlana').DataTable().clear().draw(); + $('#total_comp_plana').html("0.00"); + } + + } + else if (($('#tipoImpresion').select2('data')[0].id == 'negrohq' || + $('#tipoImpresion').select2('data')[0].id == 'colorhq')) { + + $('#tableCompIntRotativa').DataTable().clear().draw(); + $('#total_comp_rot').html("0.00"); + + $('#compPaginasColorhq').val('0') + $('#compPaginasColor').val('0') + $('#compPaginasNegro').val('0') + $('#compPaginasNegrohq').val($('#paginas').val()) + + if ($('#tipoImpresion').select2('data')[0].id == 'negrohq') { + $('#compGramajeColorhq').val('').trigger('change') + $('#compPapelColorhq').val(0).trigger('change') + } + + if ($('#tableCompIntPlana').DataTable().rows().count() > 0 && + !$('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) { + + $('#tableCompIntPlana').DataTable().clear().draw(); + $('#total_comp_plana').html("0.00"); + } + } + } + + getDataForComp(uso = 'interior') { + + let ancho = 0; + let alto = 0; + let papel_generico = {}; + let gramaje = {}; + let paginasColor = 0; + + if (!$('#papelFormatoPersonalizado').prop('checked')) { + const selectedFormat = $('#papelFormatoId').select2('data')[0].text; + ancho = Math.round(parseFloat(selectedFormat.trim().split(" x ")[0]), 2); + alto = Math.round(parseFloat(selectedFormat.trim().split(" x ")[1]), 2); + + } + else { + ancho = Math.round(parseFloat($('#papelFormatoAncho').val()), 2); + alto = Math.round(parseFloat($('#papelFormatoAlto').val()), 2); + } + + if (parseInt($('#paginas').val()) <= 0) { + popErrorAlert(window.language.Presupuestos.errores.paginas, 'divAlarmasComparador'); + return { error: true, data: {} }; + } + if (parseInt($('#tirada').val()) <= 0) { + popErrorAlert(window.language.Presupuestos.errores.tiradas, 'divAlarmasComparador'); + return { error: true, data: {} }; + } + if (ancho && alto) { + + if (alto < 60 || ancho < 60 || isNaN(alto) || isNaN(ancho)) { + popErrorAlert(window.language.Presupuestos.errores.dimension, 'divAlarmasComparador'); + return { error: true, data: {} }; + } + } + else { + popErrorAlert(window.language.Presupuestos.errores.dimension, 'divAlarmasComparador'); + return { error: true, data: {} }; + } + + if (uso == 'interior') { + let papeles = []; + let gramajes = []; + if (this.tipo_impresion.val().includes('hq')) { + if (this.tipo_impresion.val().includes('color')) { + papeles.push(this.papelColorhq); + gramajes.push(this.gramajeColorhq); + } + papeles.push(this.papelNegrohq); + gramajes.push(this.gramajeNegrohq); + } + else { + if (this.tipo_impresion.val().includes('color')) { + papeles.push(this.papelColor); + gramajes.push(this.gramajeColor); + } + papeles.push(this.papelNegro); + gramajes.push(this.gramajeNegro); + } + for (let element of papeles) { + if (element.getVal() == 0 || element.getVal() == null) { + popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador'); + return { error: true, data: {} }; + } + }; + for (let element of gramajes) { + + if (element.getVal() == 0 || element.getVal() == null) { + popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador'); + return { error: true, data: {} }; + } + }; + + if (this.tipo_impresion.val().includes('color')) { + if (this.tipo_impresion.val().includes('hq')) { + papel_generico.color= { id: this.papelColorhq.getVal(), nombre: this.papelColorhq.getText() }; + gramaje.color= this.gramajeColorhq.getVal(); + paginasColor = this.paginasColorhq.val(); + } + papel_generico.negro= { id: this.papelNegrohq.getVal(), nombre: this.papelNegrohq.getText() } ; + gramaje.negro= this.gramajeNegrohq.getVal() ; + } + else { + if (this.tipo_impresion.val().includes('hq')) { + papel_generico.color = { id: this.papelColor.getVal(), nombre: this.papelColor.getText() } ; + gramaje.color = this.gramajeColor.getVal() ; + paginasColor = this.paginasColor.val(); + } + papel_generico.negro= { id: this.papelNegro.getVal(), nombre: this.papelNegro.getText() } ; + gramaje.negro= this.gramajeNegro.getVal() ; + } + } + + const datosPedido = { + paginas: $('#paginas').val(), + tirada: $('#tirada').val(), + merma: $('#merma').val(), + ancho: ancho, + alto: alto, + isCosido: $('#isCosido').val(), + a_favor_fibra: 1, + }; + + + if ($('#clienteId').select2('data').length == 0 || $('#clienteId').select2('data').id < 1) { + popErrorAlert(window.language.Presupuestos.errores.seleccioneCliente, 'divAlarmasComparador'); + return { error: true, data: {} }; + } + + let datos = { + datosPedido: datosPedido, + uso: uso, + tipo_impresion_id: this.tipo_impresion_id, + cliente_id: $('#clienteId').select2('data')[0].id, + papelInteriorDiferente: 1, + papel_generico: papel_generico, + gramaje: gramaje, + isColor: this.tipo_impresion.val().includes('color'), + isHq: this.tipo_impresion.val().includes('hq'), + paginas_color: paginasColor + } + + + return { error: false, data: datos }; + } + + obtenerComparadorInterior(actualizarLineaPlana = false, actualizarLineaRot = false) { + + + try { + + this.tableCompIntPlana.clear().draw(); + this.tableCompIntRotativa.clear().draw(); + this.btnInsertarPlana.addClass('d-none'); + $('#title_int_rot').html(window.language.Presupuestos.compInteriorRotativa); + $('#title_int_plana').html(window.language.Presupuestos.compInteriorPlana); + + const datosComp = this.getDataForComp('interior'); + if(datosComp.error){ + return; + } + else{ + + datosComp.data[this.csrf_token] = this.csrf_hash; + new Ajax('/presupuestoadmin/comparadorplana', + datosComp.data, + {}, + (response) =>{ + console.log(response); + }, + (error) =>{ + console.log(error); + } + ).post(); + } + /* + elementos = getIDsComparador(is_color, is_hq) + + + if ($('' + elementos.papel).select2('data').length > 0 && + $('' + elementos.gramaje).select2('data').length > 0 && + parseInt($('' + elementos.paginas).val()) >= 0 && + checkDatosPedidoForComp()) { + + + getLineasIntPlana(is_color, is_hq, actualizarLineaPlana).then((result) => { + // Para rotativa, si es color el papel y el gramaje tiene que ser igual + if (!is_color) { + getLineasIntRot(is_hq, actualizarLineaRot); + } + else { + if (!is_hq) { + if ($('#compPapelNegro').select2('data').length > 0 && $('#compPapelColor').select2('data').length > 0 && + $('#compGramajeNegro').select2('data').length > 0 && $('#compGramajeColor').select2('data').length > 0) { + if (($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id && + $('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim())) { + getLineasIntRot(is_hq, actualizarLineaRot); + } + else { + $('#errorComRot').html(''); + } + } + } + } + }); + }*/ + } catch (e) { + console.log(e) + } + } } +/* + $('#compSobrecubierta').on('change', function(){ + if ($('#compSobrecubierta').val()==1){ + value = false + } + else{ + value = 'disabled' + $('#compPapelSobrecubierta').val(0) + $('#compGramajeSobrecubierta').val('') + $('#compGramajeSobrecubierta').select2("destroy") + $('#compGramajeSobrecubierta').select2({allowClear: false, minimumResultsForSearch: Infinity}) + + } + $('#compPapelSobrecubierta').prop('disabled', value); + $('#compGramajeSobrecubierta').prop('disabled', value); + }) + + + + + function checkComparadorGuardas(actualizarLinea = false){ + + if ($('#compPapelGuardas').select2('data')[0].id > 0 ){ + + const dimension = getDimensionLibro(); + + let datos = { + tipo_impresion_id: , + type: 'guardas', + paginas: 8, + paginas_impresion: parseInt($('#compCarasGuardas').select2('data')[0].id), + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#mermacubierta').val()), + color: 1, + hq: 1, + ancho: dimension.ancho, + alto: dimension.alto, + papel_generico_id: $('#compPapelGuardas').select2('data')[0].id, + papel_generico: $('#compPapelGuardas').select2('data')[0].text.trim(), + gramaje: parseInt($('#compGramajeGuardas').val()), + cliente_id: $('#clienteId').find(":selected").val(), + : v + }; + + $.ajax({ + type: "POST", + url: "/presupuestoadmin/datatable", + data: datos, + success: function (data) { + + clearGuardas(); + + if(data.lineas.length >0){ + fillGuardas(data); + selectGuardasLineas(); + $('#title_guardas').html('' + ' (' + tableCompGuardas.rows().count() + ')'); + $('#insertarGuardasBtn').removeClass('d-none') + if(actualizarLinea){ + var rows = $("#tableCompCubierta").DataTable().rows( '.selected' ).data().toArray(); + for(row of rows){ + fill_lp_guardas(row, true); + } + } + } + else{ + $('#title_guardas').html(''); + $('#insertarGuardasBtn').addClass('d-none') + $('#total_comp_guardas').html('0.00') + + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + } + + else{ + clearGuardas(); + } + } + + + $('.comp_guardas_items').on('change', function (e) { + + checkComparadorGuardas(false); + }); + + + + async function getLineasIntPlana(is_color, is_hq, actualizarLinea){ + + const dimension = getDimensionLibro(); + + let datos = { + tipo_impresion_id: , + type: 'interior', + color: is_color?1:0, + hq: is_hq?1:0, + paginas: parseInt($(''+ elementos.paginas).val()), + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#merma').val()), + ancho: dimension.ancho, + alto: dimension.alto, + papel_generico_id: $(''+ elementos.papel).select2('data')[0].id, + papel_generico: $(''+ elementos.papel).select2('data')[0].text.trim(), + gramaje: $(''+ elementos.gramaje).select2('data')[0].text.trim() , + cliente_id: $('#clienteId').find(":selected").val(), + : v + }; + + $.ajax({ + type: "POST", + url: "/presupuestoadmin/datatable", + data: datos, + success: function (data) { + + clearIntLineas(is_color); + + if(data.lineas.length >0){ + + fillIntPlana(data, is_color, is_hq); + selectIntLineas(); + $('#title_int_plana').html('' + ' (' + tableCompIntPlana.rows().count() + ')'); + $('#insertarPlanaBtn').removeClass('d-none') + if(actualizarLinea){ + var rows = $("#tableCompIntPlana").DataTable().rows( '.selected' ).data().toArray(); + for(row of rows){ + + if(row['tipo'] =='bn' && !is_color && !is_hq){ + if($('#lp_bn').css('display')!='none') + fill_lp_bn(row, true); + } + else if(row['tipo'] =='bnhq' && !is_color && is_hq){ + if($('#lp_bnhq').css('display')!='none') + fill_lp_bnhq(row, true); + } + else if(row['tipo'] =='color' && is_color && !is_hq){ + if($('#lp_color').css('display')!='none') + fill_lp_color(row, true); + } + else if(row['tipo'] =='colorhq' && is_color && is_hq){ + if($('#lp_colorhq').css('display')!='none') + fill_lp_colorhq(row, true); + } + } + } + } + else{ + $('#title_int_plana').html(''); + $('#insertarPlanaBtn').addClass('d-none') + $('#total_comp_plana').html('0.00'); + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + return false; + } + + async function getLineasIntRot(is_hq, actualizarLinea=false){ + + const dimension = getDimensionLibro(); + + // Rotativa solo negro o color (no hq) + if ( is_hq==false){ + + if(checkInputsForRotativa()){ + + let datos = { + tipo_impresion_id: , + type: 'interior_rot', + paginas: parseInt($('#paginas').val()), + paginas_negro: parseInt($('#compPaginasNegro').val()), + paginas_color: parseInt($('#compPaginasColor').val()), + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#merma').val()), + ancho: dimension.ancho, + alto: dimension.alto, + // el papel y el gramaje se coge del negro (siempre estará) + papel_generico_id: $('#compPapelNegro').select2('data')[0].id, + papel_generico: $('#compPapelNegro').select2('data')[0].text.trim(), + gramaje: $('#compGramajeNegro').select2('data')[0].text.trim() , + cliente_id: $('#clienteId').find(":selected").val(), + : v + }; + + $.ajax({ + type: "POST", + url: "/presupuestoadmin/datatable", + data: datos, + success: function (data) { + + clearIntRot(); + + if(data.lineas.length >0){ + + fillIntRot(data); + selectIntRotLineas(); + $('#title_int_rot').html('' + ' (' + tableCompIntRotativa.rows().count() + ')'); + $('#insertarRotativaBtn').removeClass('d-none') + if(actualizarLinea){ + var rows = $("#tableCompIntRotativa").DataTable().rows( '.selected' ).data().toArray(); + for(row of rows){ + if(row['paginasColor'] ==0){ + if($('#lp_rot_bn').css('display')!='none') + fill_lp_rot_bn(row, true); + } + else if(row['paginasColor'] >0){ + if($('#lp_rot_color').css('display')!='none') + fill_lp_rot_color(row, true); + } + } + } + } + else{ + $('#title_int_rot').html(''); + $('#insertarRotativaBtn').addClass('d-none') + $('#total_comp_rot').html('0.00') + + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + } + } + return false; + } + + $('.comp_cubierta_items').on('change', function (){ + + checkComparadorCubierta() + }); + + + function checkComparadorCubierta(actualizarLinea = false){ + + if ($('#compCarasCubierta option:selected').val().length > 0 && + $('#compPapelCubierta').select2('data').length > 0 && + $('#compGramajeCubierta').select2('data').length > 0 ){ + + const dimension = getDimensionLibro(); + + let datos = { + tipo_impresion_id: , + type: 'cubierta', + paginas: parseInt($('#compCarasCubierta option:selected').val()), + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#mermacubierta').val()), + color: 1, + ancho: dimension.ancho, + alto: dimension.alto, + lomo: getLomoLineasPresupuesto(), + solapas: $('#solapas').is(':checked')?1:0, + solapas_ancho: $('#solapas').is(':checked')?parseInt($('#solapas_ancho').val()):0, + papel_generico_id: $('#compPapelCubierta').select2('data')[0].id, + papel_generico: $('#compPapelCubierta').select2('data')[0].text.trim(), + gramaje: $('#compGramajeCubierta').select2('data')[0].text.trim() , + cliente_id: $('#clienteId').find(":selected").val(), + : v + }; + + $.ajax({ + type: "POST", + url: "/presupuestoadmin/datatable", + data: datos, + success: function (data) { + + clearCubierta(); + + if(data.lineas.length >0){ + fillCubierta(data); + selectCubiertaLineas(); + tableCompCubierta.order([0, 'asc']).draw() + $('#title_cubierta').html('' + (tableCompCubierta.rows().count()>0 ?(' (' + tableCompCubierta.rows().count() + ')'):'')); + $('#insertarCubiertaBtn').removeClass('d-none') + if(actualizarLinea){ + var rows = $("#tableCompCubierta").DataTable().rows( '.selected' ).data().toArray(); + for(row of rows){ + if (row.tipo=='cubierta') + fill_lp_cubierta(row, true); + } + } + } + else{ + $('#title_cubierta').html('' + (tableCompCubierta.rows().count()>0 ?(' (' + tableCompCubierta.rows().count() + ')'):'')); + if(tableCompCubierta.rows().count()==0){ + $('#insertarCubiertaBtn').addClass('d-none') + $('#total_comp_cubierta').html('0.00') + } + else{ + selectCubiertaLineas(); + } + + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + } + + else{ + clearCubierta(); + } + } + + $('.comp_sobrecubierta_items').on('change', function (){ + + checkComparadorSobrecubierta() + }); + + + function checkComparadorSobrecubierta(actualizarLinea = false){ + + if ($('#compSobrecubierta option:selected').val() == 1 && + $('#compPapelSobrecubierta').select2('data').length > 0 && + $('#compGramajeSobrecubierta').select2('data').length > 0 ){ + + + const dimension = getDimensionLibro(); + + let datos = { + tipo_impresion_id: , + type: 'sobrecubierta', + paginas: 4, + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#mermacubierta').val()), + color: 1, + ancho: dimension.ancho, + alto: dimension.alto, + lomo: getLomoLineasPresupuesto() + getLomoCubiertaLineasPresupuesto(), + solapas: $('#solapas_sobrecubierta').is(':checked')?1:0, + solapas_ancho: $('#solapas_sobrecubierta').is(':checked')?parseInt($('#solapas_ancho_sobrecubierta').val()):0, + papel_generico_id: $('#compPapelSobrecubierta').select2('data')[0].id, + papel_generico: $('#compPapelSobrecubierta').select2('data')[0].text.trim(), + gramaje: $('#compGramajeSobrecubierta').select2('data')[0].text.trim() , + cliente_id: $('#clienteId').find(":selected").val(), + : v + }; + + $.ajax({ + type: "POST", + url: "/presupuestoadmin/datatable", + data: datos, + success: function (data) { + + clearSobrecubierta(); + + if(data.lineas.length >0){ + + fillSobrecubierta(data); + selectCubiertaLineas(); + tableCompCubierta.order([ [0, 'asc'],[15, 'asc'] ]).draw() + $('#title_cubierta').html('' + (tableCompCubierta.rows().count()>0 ?(' (' + tableCompCubierta.rows().count() + ')'):'')); + $('#insertarCubiertaBtn').removeClass('d-none') + if(actualizarLinea){ + var rows = $("#tableCompCubierta").DataTable().rows( '.selected' ).data().toArray(); + for(row of rows){ + if (row.tipo=='sobrecubierta') + fill_lp_sobrecubierta(row, true); + } + } + } + else{ + $('#title_cubierta').html('' + (tableCompCubierta.rows().count()>0 ?(' (' + tableCompCubierta.rows().count() + ')'):'')); + if(tableCompCubierta.rows().count()==0){ + $('#insertarCubiertaBtn').addClass('d-none') + $('#total_comp_cubierta').html('0.00') + } + else{ + selectCubiertaLineas(); + } + + } + yeniden(data.); + return true; + }, + error: function(e){ + return false; + } + }) + } + + else{ + clearSobrecubierta(); + } + } + + + + + + $('#tipoImpresion').on("select2:close", function () { + + $('#paginas').change() + }) + + + +*/ export default Comparador; \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js index cdc5d0ed..fb852a7c 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js @@ -97,7 +97,7 @@ class DatosLibro { this.removeService('fajaColor'); } } - + changeFerro() { if (this.ferro.prop('checked')) { @@ -112,6 +112,7 @@ class DatosLibro { if (this.prototipo.prop('checked')) { this.addService('prototipo'); + this.ferro.prop('checked', true).trigger('change'); } else { this.removeService('prototipo'); @@ -396,4 +397,5 @@ class DatosLibro { } } + export default DatosLibro; \ No newline at end of file From bb138019d512b59cba7580a90d8318777bf6b0e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Tue, 17 Dec 2024 23:35:44 +0100 Subject: [PATCH 06/89] terminado comparador plana --- .../Presupuestos/Presupuestoadmin.php | 24 +-- .../Services/PresupuestoClienteService.php | 11 +- .../form/presupuestos/admin/comparador.js | 60 ------- .../presupuestoAdmin/sections/comparador.js | 161 +++++++++++++++--- 4 files changed, 158 insertions(+), 98 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index 914fb0b1..4a40f096 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -610,26 +610,25 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController public function obtenerComparadorPlana(){ - echo "hola"; - //if($this->request->isAJAX()){ + + if($this->request->isAJAX()){ $cliente_id = $this->request->getPost('cliente_id'); $datosPedido = $this->request->getPost('datosPedido'); $papel_generico = $this->request->getPost('papel_generico'); $gramaje = $this->request->getPost('gramaje'); - $papelInteriorDirefente = $this->request->getPost('papelInteriorDiferente'); $paginas_color = $this->request->getPost('paginas_color'); $isColor = $this->request->getPost('isColor'); $isHq = $this->request->getPost('isHq'); $tipo_impresion_id = $this->request->getPost('tipo_impresion_id'); $uso = $this->request->getPost('uso'); - $data = (object)array( + $data = array( 'cliente_id' => $cliente_id, - 'datosPedido' => $datosPedido, + 'datosPedido' => (object)$datosPedido, 'papel_generico' => $papel_generico, 'gramaje' => $gramaje, - 'papelInteriorDirefente' => $papelInteriorDirefente, + 'papelInteriorDiferente' => true, 'paginas_color' => $paginas_color, 'isColor' => $isColor, 'isHq' => $isHq, @@ -637,12 +636,17 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController 'uso' => $uso ); - $data = PresupuestoClienteService::obtenerComparadorInteriorPlana($data); - return $this->respond($data); - /*} + $data = PresupuestoClienteService::obtenerPresupuestoClienteInterior($data, true); + return $this->respond( + [ + 'status' => 1, + 'data' => $data + ] + ); + } else{ return $this->failUnauthorized('Invalid request', 403); - }*/ + } } diff --git a/ci4/app/Services/PresupuestoClienteService.php b/ci4/app/Services/PresupuestoClienteService.php index d066937d..c181d990 100644 --- a/ci4/app/Services/PresupuestoClienteService.php +++ b/ci4/app/Services/PresupuestoClienteService.php @@ -241,7 +241,7 @@ class PresupuestoClienteService extends BaseService * - isHq: si es alta calidad * - paginas_color: número de páginas a color */ - private static function obtenerPresupuestoClienteInterior($data) + public static function obtenerPresupuestoClienteInterior($data, $return_raw = false) { $uso = $data['uso']; @@ -351,6 +351,15 @@ class PresupuestoClienteService extends BaseService // Si hay negro y color, y se hace con el mismo papel, hay que buscar la combinación // más económica con la misma máquna + if($return_raw){ + $linea_negro_plana = array_values(array_unique($linea_negro_plana, SORT_REGULAR)); + $linea_color_plana = array_values(array_unique($linea_color_plana, SORT_REGULAR)); + + return[ + 'negro' => $linea_negro_plana, + 'color' => $linea_color_plana + ]; + } if ( $paginas_negro > 0 && $paginas_color > 0 && $data['papelInteriorDiferente'] == 0 && count($linea_negro_plana) > 0 && count($linea_color_plana) > 0 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 bdebd239..0a71c2c5 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/comparador.js +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/comparador.js @@ -21,40 +21,7 @@ $('#compPosPaginasColor').on("keyup", function () { /******************************* * Metodos *******************************/ -function getRowFromLineaInt(tipo, linea) { - $precio_impresion = isNaN(parseFloat(linea.fields.precio_impresion_horas + linea.fields.margen_impresion_horas + linea.fields.precio_click_pedido)) ? "" : - parseFloat(linea.fields.precio_impresion_horas + linea.fields.margen_impresion_horas + linea.fields.precio_click_pedido).toFixed(2); - - - data = { - 'tipo': tipo, - 'paginas': linea.fields.paginas, - 'papel': linea.fields.papel_generico, - 'gramaje': linea.fields.gramaje, - 'marca': linea.fields.papel_impresion, - 'maquina': linea.fields.maquina, - 'numeroPliegos': isNaN(parseFloat(linea.fields.pliegos_libro)) ? "" : parseFloat(linea.fields.pliegos_libro).toFixed(2), - 'pliegosPedido': isNaN(parseFloat(linea.fields.pliegos_pedido)) ? "" : parseFloat(linea.fields.pliegos_pedido).toFixed(2), - 'precioPliego': isNaN(parseFloat(linea.fields.precios_pliegos)) ? "" : parseFloat(linea.fields.precios_pliegos).toFixed(6), - 'libro': isNaN(parseFloat(linea.fields.precio_libro)) ? "" : parseFloat(linea.fields.precio_libro).toFixed(2), - 'totalPapelPedido': isNaN(parseFloat(linea.fields.precio_pedido)) ? "" : parseFloat(linea.fields.precio_pedido).toFixed(2), - 'lomo': isNaN(parseFloat(linea.fields.mano)) ? "" : parseFloat(linea.fields.mano).toFixed(2), - 'peso': isNaN(parseFloat(linea.fields.peso)) ? "" : parseFloat(linea.fields.peso).toFixed(2), - 'horasMaquina': isNaN(parseFloat(linea.fields.horas_maquina)) ? "" : parseFloat(linea.fields.horas_maquina).toFixed(2), - 'precioImpresion': $precio_impresion, - 'total': isNaN(parseFloat(linea.fields.total_impresion).toFixed(2)) ? "" : parseFloat(linea.fields.total_impresion).toFixed(2), - 'maquinaId': linea.fields.maquina_id, - 'maquinaVelocidad': linea.fields.maquina_velocidad, - 'tiempoMaquina': linea.fields.tiempo_maquina, - 'papelGenericoId': linea.fields.papel_generico_id, - 'papelImpresionId': linea.fields.papel_impresion_id, - 'tarifa_impresion_id': linea.fields.tarifa_impresion_id, - } - if(data['tipo']=='guardas') - data['paginas_impresion'] = linea.fields.paginas_impresion; - return data; -} function getRowFromLineaRot(linea) { @@ -160,34 +127,7 @@ function clearIntRot() { } -function selectIntLineas() { - var negro_selected = false; - var color_selected = false; - $("#tableCompIntPlana").DataTable().rows('.selected').deselect(); - $("#tableCompIntPlana").DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) { - if (!negro_selected && $('#tableCompIntPlana').DataTable().cell(rowIdx, 0).data().includes('bn')) { - $("#tableCompIntPlana").DataTable().row(rowIdx).nodes().to$().toggleClass('selected'); - negro_selected = true; - } - if (!color_selected && $('#tableCompIntPlana').DataTable().cell(rowIdx, 0).data().includes('color')) { - $("#tableCompIntPlana").DataTable().row(rowIdx).nodes().to$().toggleClass('selected'); - color_selected = true; - } - }); - var table = $("#tableCompIntPlana").DataTable(); - var rows = table.rows('.selected').indexes(); - var data = table.rows(rows).data(); - - var value_total = 0.00; - - for (let i = 0; i < data.length; i++) { - - value_total += parseFloat(data[i]['total']) - } - - $('#total_comp_plana').html(value_total.toFixed(2)); -} function selectIntRotLineas() { diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js index 795fda67..9cc3a2a1 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js @@ -162,6 +162,8 @@ class Comparador { this.btnInsertarPlana = $('#insertarPlanaBtn'); this.btnInsertarRotativa = $('#insertarRotativaBtn'); this.btnInsertarCubierta = $('#insertarCubiertaBtn'); + + this.cargando = false; } init() { @@ -261,10 +263,6 @@ class Comparador { $("#tableLineasPresupuesto").DataTable().columns.adjust(); } }); - this.paginasNegro.on("change", this.#changePaginasComparador.bind(this)); - this.paginasNegrohq.on("change", this.#changePaginasComparador.bind(this)); - this.paginasColor.on("change", this.#changePaginasComparador.bind(this)); - this.paginasColorhq.on("change", this.#changePaginasComparador.bind(this)); $('.comp_negro_items').on('change', this.obtenerComparadorInterior.bind(this)); $('.comp_negrohq_items').on('change', this.obtenerComparadorInterior.bind(this)); @@ -275,25 +273,25 @@ class Comparador { #changePaginasComparador(element) { const paginas = parseInt($('#paginas').val()); - const newPaginas = parseInt($(element.currentTarget).val()); + const newPaginas = parseInt($('#' + element).val()); if (paginas < newPaginas) { - $(element.currentTarget).val(paginas) + $('#' + element).val(paginas) } - if ($(element.currentTarget).attr('id') == this.paginasNegro.attr('id')) { + if (element == this.paginasNegro.attr('id')) { if (!$('.comp-color-selected').hasClass('d-none')) { this.paginasColor.val((paginas - newPaginas) > 0 ? paginas - newPaginas : 0); } } - else if ($(element.currentTarget).attr('id') == this.paginasNegro.attr('id')) { + else if (element == this.paginasNegrohq.attr('id')) { if (!$('.comp-colorhq-selected').hasClass('d-none')) { this.paginasColorhq.val((paginas - newPaginas) > 0 ? paginas - newPaginas : 0); } } - else if ($(element.currentTarget).attr('id') == this.paginasColor.attr('id')) { + else if (element == this.paginasColor.attr('id')) { this.paginasNegro.val((paginas - newPaginas) > 0 ? paginas - newPaginas : 0); } - else if ($(element.currentTarget).attr('id') == this.paginasColorhq.attr('id')) { + else if (element == this.paginasColorhq.attr('id')) { this.paginasNegrohq.val((paginas - newPaginas) > 0 ? paginas - newPaginas : 0); } } @@ -301,6 +299,8 @@ class Comparador { cargarDatos(datos) { + this.cargando = true; + this.tipo_impresion.val(datos.tipo_impresion).trigger('change'); this.updateOpcionesComparador(); this.comparador_json.val(JSON.stringify(datos.json_data)); @@ -340,6 +340,9 @@ class Comparador { this.posPagColor.val(datos.posPagColor); this.#computarPaginasColor(datos.posPagColor); } + + this.cargando = false; + this.paginasNegro.trigger('change'); } @@ -763,7 +766,7 @@ class Comparador { gramajes.push(this.gramajeNegro); } for (let element of papeles) { - if (element.getVal() == 0 || element.getVal() == null) { + if (element.getVal() == 0 || element.getVal() == null) { popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador'); return { error: true, data: {} }; } @@ -778,21 +781,21 @@ class Comparador { if (this.tipo_impresion.val().includes('color')) { if (this.tipo_impresion.val().includes('hq')) { - papel_generico.color= { id: this.papelColorhq.getVal(), nombre: this.papelColorhq.getText() }; - gramaje.color= this.gramajeColorhq.getVal(); + papel_generico.color = { id: this.papelColorhq.getVal(), nombre: this.papelColorhq.getText() }; + gramaje.color = this.gramajeColorhq.getVal(); paginasColor = this.paginasColorhq.val(); } - papel_generico.negro= { id: this.papelNegrohq.getVal(), nombre: this.papelNegrohq.getText() } ; - gramaje.negro= this.gramajeNegrohq.getVal() ; + papel_generico.negro = { id: this.papelNegrohq.getVal(), nombre: this.papelNegrohq.getText() }; + gramaje.negro = this.gramajeNegrohq.getVal(); } else { if (this.tipo_impresion.val().includes('hq')) { - papel_generico.color = { id: this.papelColor.getVal(), nombre: this.papelColor.getText() } ; - gramaje.color = this.gramajeColor.getVal() ; + papel_generico.color = { id: this.papelColor.getVal(), nombre: this.papelColor.getText() }; + gramaje.color = this.gramajeColor.getVal(); paginasColor = this.paginasColor.val(); } - papel_generico.negro= { id: this.papelNegro.getVal(), nombre: this.papelNegro.getText() } ; - gramaje.negro= this.gramajeNegro.getVal() ; + papel_generico.negro = { id: this.papelNegro.getVal(), nombre: this.papelNegro.getText() }; + gramaje.negro = this.gramajeNegro.getVal(); } } @@ -817,7 +820,6 @@ class Comparador { uso: uso, tipo_impresion_id: this.tipo_impresion_id, cliente_id: $('#clienteId').select2('data')[0].id, - papelInteriorDiferente: 1, papel_generico: papel_generico, gramaje: gramaje, isColor: this.tipo_impresion.val().includes('color'), @@ -829,11 +831,20 @@ class Comparador { return { error: false, data: datos }; } - obtenerComparadorInterior(actualizarLineaPlana = false, actualizarLineaRot = false) { - + obtenerComparadorInterior(event, actualizarLineaPlana = false, actualizarLineaRot = false) { try { + const self = this; + + if (this.cargando) { + return + } + + if (event.currentTarget.id.includes('Paginas')) { + this.#changePaginasComparador(event.currentTarget.id); + } + this.tableCompIntPlana.clear().draw(); this.tableCompIntRotativa.clear().draw(); this.btnInsertarPlana.addClass('d-none'); @@ -841,19 +852,51 @@ class Comparador { $('#title_int_plana').html(window.language.Presupuestos.compInteriorPlana); const datosComp = this.getDataForComp('interior'); - if(datosComp.error){ + if (datosComp.error) { return; } - else{ + else { datosComp.data[this.csrf_token] = this.csrf_hash; new Ajax('/presupuestoadmin/comparadorplana', datosComp.data, {}, - (response) =>{ - console.log(response); + (response) => { + if (response.data.negro.length > 0) { + const isHq = response.data.negro[0].fields.tipo_linea.includes('hq'); + let sorted = response.data.negro.sort( + (p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? + -1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0); + sorted.forEach(function (linea) { + if (typeof linea.error == "undefined") + $('#tableCompIntPlana').DataTable().row + .add(self.getRowFromLineaInt(isHq ? 'bnhq' : 'bn', linea)) + .draw() + }); + } + if (response.data.color.length > 0) { + const isHq = response.data.color[0].fields.tipo_linea.includes('hq'); + let sorted = response.data.color.sort( + (p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? + -1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0); + sorted.forEach(function (linea) { + if (typeof linea.error == "undefined") + $('#tableCompIntPlana').DataTable().row + .add(self.getRowFromLineaInt(isHq ? 'colorhq' : 'color', linea)) + .draw() + }); + } + this.selectIntLineas(); + if ($('#tableCompIntPlana').DataTable().rows().count() > 0) { + $('#title_int_plana').html(window.language.Presupuestos.compInteriorPlana + ' (' + self.tableCompIntPlana.rows().count() + ')'); + $('#insertarPlanaBtn').removeClass('d-none'); + } + else{ + $('#title_int_plana').html(window.language.Presupuestos.compInteriorPlana); + $('#insertarPlanaBtn').addClass('d-none'); + } }, - (error) =>{ + (error) => { console.log(error); } ).post(); @@ -895,6 +938,70 @@ class Comparador { } + + selectIntLineas() { + var negro_selected = false; + var color_selected = false; + $("#tableCompIntPlana").DataTable().rows('.selected').deselect(); + $("#tableCompIntPlana").DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) { + if (!negro_selected && $('#tableCompIntPlana').DataTable().cell(rowIdx, 0).data().includes('bn')) { + $("#tableCompIntPlana").DataTable().row(rowIdx).nodes().to$().toggleClass('selected'); + negro_selected = true; + } + if (!color_selected && $('#tableCompIntPlana').DataTable().cell(rowIdx, 0).data().includes('color')) { + $("#tableCompIntPlana").DataTable().row(rowIdx).nodes().to$().toggleClass('selected'); + color_selected = true; + } + }); + + var table = $("#tableCompIntPlana").DataTable(); + var rows = table.rows('.selected').indexes(); + var data = table.rows(rows).data(); + + var value_total = 0.00; + + for (let i = 0; i < data.length; i++) { + + value_total += parseFloat(data[i]['total']) + } + + $('#total_comp_plana').html(value_total.toFixed(2)); + } + + getRowFromLineaInt(tipo, linea) { + + const precio_impresion = isNaN(parseFloat(linea.fields.precio_impresion_horas + linea.fields.margen_impresion_horas + linea.fields.precio_click_pedido)) ? "" : + parseFloat(linea.fields.precio_impresion_horas + linea.fields.margen_impresion_horas + linea.fields.precio_click_pedido).toFixed(2); + + + let data = { + 'tipo': tipo, + 'paginas': linea.fields.paginas, + 'papel': linea.fields.papel_generico, + 'gramaje': linea.fields.gramaje, + 'marca': linea.fields.papel_impresion, + 'maquina': linea.fields.maquina, + 'numeroPliegos': isNaN(parseFloat(linea.fields.pliegos_libro)) ? "" : parseFloat(linea.fields.pliegos_libro).toFixed(2), + 'pliegosPedido': isNaN(parseFloat(linea.fields.pliegos_pedido)) ? "" : parseFloat(linea.fields.pliegos_pedido).toFixed(2), + 'precioPliego': isNaN(parseFloat(linea.fields.precios_pliegos)) ? "" : parseFloat(linea.fields.precios_pliegos).toFixed(6), + 'libro': isNaN(parseFloat(linea.fields.precio_libro)) ? "" : parseFloat(linea.fields.precio_libro).toFixed(2), + 'totalPapelPedido': isNaN(parseFloat(linea.fields.precio_pedido)) ? "" : parseFloat(linea.fields.precio_pedido).toFixed(2), + 'lomo': isNaN(parseFloat(linea.fields.mano)) ? "" : parseFloat(linea.fields.mano).toFixed(2), + 'peso': isNaN(parseFloat(linea.fields.peso)) ? "" : parseFloat(linea.fields.peso).toFixed(2), + 'horasMaquina': isNaN(parseFloat(linea.fields.horas_maquina)) ? "" : parseFloat(linea.fields.horas_maquina).toFixed(2), + 'precioImpresion': precio_impresion, + 'total': isNaN(parseFloat(linea.fields.total_impresion).toFixed(2)) ? "" : parseFloat(linea.fields.total_impresion).toFixed(2), + 'maquinaId': linea.fields.maquina_id, + 'maquinaVelocidad': linea.fields.maquina_velocidad, + 'tiempoMaquina': linea.fields.tiempo_maquina, + 'papelGenericoId': linea.fields.papel_generico_id, + 'papelImpresionId': linea.fields.papel_impresion_id, + 'tarifa_impresion_id': linea.fields.tarifa_impresion_id, + } + if (data['tipo'] == 'guardas') + data['paginas_impresion'] = linea.fields.paginas_impresion; + return data; + } } /* From 8dca0936c580c3bab7995449af099fd8b477b969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Wed, 18 Dec 2024 22:32:23 +0100 Subject: [PATCH 07/89] trabajando en cubierta --- ci4/app/Config/Routes.php | 3 +- .../Presupuestos/Presupuestoadmin.php | 461 ++++++++------- .../Services/PresupuestoClienteService.php | 61 +- .../form/presupuestos/admin/comparador.js | 425 -------------- .../presupuestoAdmin/sections/comparador.js | 527 +++++++++++++++--- 5 files changed, 768 insertions(+), 709 deletions(-) diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index d9c91ec9..ff28a98c 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -580,7 +580,8 @@ $routes->group('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos $routes->post('menuitems', 'Presupuestoadmin::menuItems', ['as' => 'menuItemsOfPresupuestoAdmin']); $routes->get('cargar/(:any)', 'Presupuestoadmin::cargar/$1'); - $routes->post('comparadorplana', 'Presupuestoadmin::obtenerComparadorPlana'); + $routes->post('comparadorinterior', 'Presupuestoadmin::obtenerComparadorInterior'); + $routes->post('comparadorexteriores', 'Presupuestoadmin::obtenerComparadorExteriores'); $routes->get('papelgenerico', 'Presupuestoadmin::getPapelGenerico'); $routes->get('papelgramaje', 'Presupuestoadmin::getGramaje'); }); diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index 4a40f096..cd73620d 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -82,9 +82,9 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController { - - if ($this->request->getPost()) : + + if ($this->request->getPost()): $nullIfEmpty = true; // !(phpversion() >= '8.1'); @@ -104,36 +104,36 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController } $noException = true; - if ($successfulResult = $this->canValidate($this->model->validationRulesAdd, $this->model->validationMessagesAdd)) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : + if ($successfulResult = $this->canValidate($this->model->validationRulesAdd, $this->model->validationMessagesAdd)): // if ($successfulResult = $this->validate($this->formValidationRules) ) : - if ($this->canValidate($this->model->validationRulesAdd, $this->model->validationMessagesAdd)) : + if ($this->canValidate($this->model->validationRulesAdd, $this->model->validationMessagesAdd)): try { $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); } catch (\Exception $e) { $noException = false; $this->dealWithException($e); } - else : + else: $this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Presupuestos.presupuesto'))]); $this->session->setFlashdata('formErrors', $this->model->errors()); endif; $thenRedirect = true; // Change this to false if you want your user to stay on the form after submission endif; - if ($noException && $successfulResult) : + if ($noException && $successfulResult): $id = $this->model->db->insertID(); $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; - if ($thenRedirect) : - if (!empty($this->indexRoute)) : + if ($thenRedirect): + if (!empty($this->indexRoute)): //return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message); return redirect()->to(site_url('presupuestoadmin/edit/' . $id))->with('sweet-success', $message); - else : + else: return $this->redirect2listView('sweet-success', $message); endif; - else : + else: $this->session->setFlashData('sweet-success', $message); endif; @@ -167,20 +167,20 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController public function edit($requestedId = null) { - if ($requestedId == null) : + if ($requestedId == null): return $this->redirect2listView(); endif; $id = filter_var($requestedId, FILTER_SANITIZE_URL); $presupuestoEntity = $this->model->find($id); - if ($presupuestoEntity == false) : + if ($presupuestoEntity == false): $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Presupuestos.presupuesto')), $id]); return $this->redirect2listView('sweet-error', $message); endif; - - if ($this->request->getPost()) : + + if ($this->request->getPost()): $nullIfEmpty = true; // !(phpversion() >= '8.1'); @@ -252,16 +252,16 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $successfulResult = false; } else { - if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) + if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) - if ($this->canValidate()) : + if ($this->canValidate()): try { $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); } catch (\Exception $e) { $noException = false; $this->dealWithException($e); } - else : + else: $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Presupuestos.presupuesto'))]); $this->session->setFlashdata('formErrors', $this->model->errors()); @@ -273,16 +273,16 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController endif; } - if ($noException && $successfulResult) : + if ($noException && $successfulResult): $id = $presupuestoEntity->id ?? $id; $message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Presupuestos.presupuesto'))]) . '.'; // $message .= anchor("admin/presupuestos/{$id}/edit", lang('Basic.global.continueEditing') . '?'); //$message = ucfirst(str_replace("'", "\'", $message)); - if ($thenRedirect) : - if (!empty($this->indexRoute)) : + if ($thenRedirect): + if (!empty($this->indexRoute)): return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); - else : + else: if ($this->request->isAJAX()) { $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); @@ -296,14 +296,14 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController } endif; - else : + else: if ($this->request->isAJAX()) { - if($presupuestoEntity->estado_id==1 && $presupuestoEntity->confirmar==1){ + if ($presupuestoEntity->estado_id == 1 && $presupuestoEntity->confirmar == 1) { $this->model->confirmarPresupuesto($id); PresupuestoService::crearPedido($id); } - + $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); $data = [ @@ -345,7 +345,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController // Lineas Presupuesto [$cambios_lineas, $this->viewData['lineasPresupuesto']] = $this->getLineasPresupuesto($presupuestoEntity); - $this->viewData['presupuestoEntity']->cambios_lineas=$cambios_lineas; + $this->viewData['presupuestoEntity']->cambios_lineas = $cambios_lineas; // Servicios $this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion(); @@ -353,10 +353,10 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $this->viewData['serviciosManipulado'] = $this->getServiciosManipulado(); $this->viewData['serviciosAcabado'] = $this->getServiciosAcabado(); $this->viewData['serviciosExtra'] = $this->getServiciosExtra(); - + [$cambios_en_servicios, $servicios] = $this->getLineasServicios($presupuestoEntity); - $this->viewData['presupuestoEntity']->cambios_servicios=$cambios_en_servicios; - + $this->viewData['presupuestoEntity']->cambios_servicios = $cambios_en_servicios; + $this->viewData['serviciosEncuadernacionList'] = $servicios->serviciosEncuadernacion; $this->viewData['serviciosAcabadosList'] = $servicios->serviciosAcabado; $this->viewData['serviciosManipuladoList'] = $servicios->serviciosManipulado; @@ -365,8 +365,8 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController // Direciones presupuesto [$cambios_en_direcciones, $this->viewData['direccionesList']] = $this->getLineasDirecciones($presupuestoEntity); - $this->viewData['presupuestoEntity']->cambios_direcciones=$cambios_en_direcciones; - + $this->viewData['presupuestoEntity']->cambios_direcciones = $cambios_en_direcciones; + $this->viewData['POD'] = $this->getPOD(); $this->viewData['serviciosAutomaticos'] = [ @@ -386,7 +386,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController // Si se ha llamado a esta funcion porque se ha duplicado el presupuesto // se actualiza la bbdd para que sólo ejecute algunas funciones una vez - if($presupuestoEntity->is_duplicado){ + if ($presupuestoEntity->is_duplicado) { $this->model->removeIsDuplicado($presupuestoEntity->id); } @@ -406,22 +406,23 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController public function delete($id = null) { if (!empty(static::$pluralObjectNameCc) && !empty(static::$singularObjectNameCc)) { - $objName = mb_strtolower(lang(ucfirst(static::$pluralObjectNameCc).'.'.static::$singularObjectNameCc)); + $objName = mb_strtolower(lang(ucfirst(static::$pluralObjectNameCc) . '.' . static::$singularObjectNameCc)); } else { $objName = lang('Basic.global.record'); } - - if (!$this->soft_delete){ + + if (!$this->soft_delete) { if (!$this->model->delete($id)) { return $this->failNotFound(lang('Basic.global.deleteError', [$objName])); } - } - else{ + } else { $datetime = (new \CodeIgniter\I18n\Time("now")); - $rawResult = $this->model->where('id',$id) - ->set(['deleted_at' => $datetime->format('Y-m-d H:i:s'), - 'is_deleted' => $this->delete_flag]) + $rawResult = $this->model->where('id', $id) + ->set([ + 'deleted_at' => $datetime->format('Y-m-d H:i:s'), + 'is_deleted' => $this->delete_flag + ]) ->update(); if (!$rawResult) { return $this->failNotFound(lang('Basic.global.deleteError', [$objName])); @@ -463,7 +464,8 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController return $response; } - public function cargar($id){ + public function cargar($id) + { if ($this->request->isAJAX()) { $modelPapelFormato = new PapelFormatoModel(); @@ -474,12 +476,12 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $presupuesto = $this->model->find($id); $data = []; if ($presupuesto) { - + $data['lc'] = $presupuesto->lomo_cubierta; $data['lsc'] = $presupuesto->lomo_sobrecubierta; $data['tipo_impresion'] = $presupuesto->tipo_impresion_id; $data['cosido'] = $presupuesto->cosido; - + $data['datosGenerales']['id'] = $presupuesto->id; $data['datosGenerales']['state'] = intval($presupuesto->estado_id); $data['datosGenerales']['updated_at'] = date('d/m/Y', strtotime($presupuesto->updated_at)); @@ -495,7 +497,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $data['datosGenerales']['cliente']['nombre'] = $modelCliente->getNombre($presupuesto->cliente_id); $data['datosGenerales']['referenciaCliente'] = $presupuesto->referencia_cliente; - + $data['datosLibro']['papelFormatoId'] = $presupuesto->papel_formato_id; $data['datosLibro']['papelFormatoNombre'] = $modelPapelFormato->getNombre($presupuesto->papel_formato_id); $data['datosLibro']['papelFormatoPersonalizado'] = $presupuesto->papel_formato_personalizado; @@ -536,7 +538,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $item['papel_nombre'] = $modelPapelGenerico->getNombre($item['papel_id'])['nombre']; } $data['comparador']['posPagColor'] = $presupuesto->comp_pos_paginas_color; - + /* @@ -609,9 +611,10 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController } - public function obtenerComparadorPlana(){ + public function obtenerComparadorInterior() + { - if($this->request->isAJAX()){ + if ($this->request->isAJAX()) { $cliente_id = $this->request->getPost('cliente_id'); $datosPedido = $this->request->getPost('datosPedido'); @@ -623,9 +626,11 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $tipo_impresion_id = $this->request->getPost('tipo_impresion_id'); $uso = $this->request->getPost('uso'); + $tipo_maquina = $this->request->getPost('tipo_maquina'); + $data = array( 'cliente_id' => $cliente_id, - 'datosPedido' => (object)$datosPedido, + 'datosPedido' => (object) $datosPedido, 'papel_generico' => $papel_generico, 'gramaje' => $gramaje, 'papelInteriorDiferente' => true, @@ -636,15 +641,94 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController 'uso' => $uso ); - $data = PresupuestoClienteService::obtenerPresupuestoClienteInterior($data, true); + if ($tipo_maquina == 'rotativa') { + $data['papelInteriorDiferente'] = false; + $lineas = PresupuestoClienteService::obtenerPresupuestoClienteInteriorRotativa($data, true); + } else + $lineas = PresupuestoClienteService::obtenerPresupuestoClienteInterior($data, true); return $this->respond( [ 'status' => 1, - 'data' => $data + 'data' => $lineas ] ); + } else { + return $this->failUnauthorized('Invalid request', 403); } - else{ + } + + public function obtenerComparadorExteriores() + { + + $resultado = []; + if ($this->request->isAJAX()) { + + $cubierta = $this->request->getPost('cubierta') ?? false; + $sobrecubierta = $this->request->getPost('sobrecubierta') ?? false; + + // cubierta y sobrecubierta siempre colorhq + $isColor = true; + $isHq = true; + + if ($cubierta) { + + $cliente_id = $cubierta['cliente_id']; + $datosPedido = $cubierta['datosPedido']; + $papel_generico = $cubierta['papel_generico']; + $gramaje = $cubierta['gramaje']; + $paginas_color = $this->request->getPost('paginas_color') ?? 0; + $tipo_impresion_id = $this->request->getPost('tipo_impresion_id'); + $uso = $this->request->getPost('uso'); + $lomoRedondo = $cubierta['lomoRedondo'] ?? false; + + $data = array( + 'cliente_id' => $cliente_id, + 'datosPedido' => (object) $datosPedido, + 'papel_generico' => $papel_generico, + 'gramaje' => $gramaje, + 'paginas_color' => $paginas_color, + 'isColor' => $isColor, + 'isHq' => $isHq, + 'tipo_impresion_id' => $tipo_impresion_id, + 'uso' => $uso, + 'lomoRedondo' => $lomoRedondo + ); + $lineas = PresupuestoClienteService::obtenerCubierta($data, true); + $resultado['cubierta'] = $lineas; + } + + if ($sobrecubierta) { + + $cliente_id = $sobrecubierta['cliente_id']; + $datosPedido = $sobrecubierta['datosPedido']; + $papel_generico = $sobrecubierta['papel_generico']; + $gramaje = $sobrecubierta['gramaje']; + $paginas_color = $this->request->getPost('paginas_color') ?? 0; + $tipo_impresion_id = $this->request->getPost('tipo_impresion_id'); + $uso = $this->request->getPost('uso'); + + $data = array( + 'cliente_id' => $cliente_id, + 'datosPedido' => (object) $datosPedido, + 'papel_generico' => $papel_generico, + 'gramaje' => $gramaje, + 'paginas_color' => $paginas_color, + 'isColor' => $isColor, + 'isHq' => $isHq, + 'tipo_impresion_id' => $tipo_impresion_id, + 'uso' => $uso + ); + $lineas = PresupuestoClienteService::obtenerSobrecubierta($data, true); + $resultado['sobrecubierta'] = $lineas; + } + + return $this->respond( + [ + 'status' => 1, + 'data' => $resultado + ] + ); + } else { return $this->failUnauthorized('Invalid request', 403); } } @@ -687,41 +771,41 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $resourceData = $this->model->getResource($searchValues, $tipo_impresion_id)->orderBy($order1, $dir1)->orderBy($order2, $dir2) ->orderBy($order3, $dir3)->limit($length, $start)->get()->getResultObject(); - foreach ($resourceData as $item) : - if (isset($item->comentarios_pdf) && strlen($item->comentarios_pdf) > 100) : + foreach ($resourceData as $item): + if (isset($item->comentarios_pdf) && strlen($item->comentarios_pdf) > 100): $item->comentarios_pdf = character_limiter($item->comentarios_pdf, 100); endif; - if (isset($item->causa_cancelacion) && strlen($item->causa_cancelacion) > 100) : + if (isset($item->causa_cancelacion) && strlen($item->causa_cancelacion) > 100): $item->causa_cancelacion = character_limiter($item->causa_cancelacion, 100); endif; - if (isset($item->comentarios_cliente) && strlen($item->comentarios_cliente) > 100) : + if (isset($item->comentarios_cliente) && strlen($item->comentarios_cliente) > 100): $item->comentarios_cliente = character_limiter($item->comentarios_cliente, 100); endif; - if (isset($item->comentarios_safekat) && strlen($item->comentarios_safekat) > 100) : + if (isset($item->comentarios_safekat) && strlen($item->comentarios_safekat) > 100): $item->comentarios_safekat = character_limiter($item->comentarios_safekat, 100); endif; - if (isset($item->comentarios_tarifa) && strlen($item->comentarios_tarifa) > 100) : + if (isset($item->comentarios_tarifa) && strlen($item->comentarios_tarifa) > 100): $item->comentarios_tarifa = character_limiter($item->comentarios_tarifa, 100); endif; - if (isset($item->comentarios_produccion) && strlen($item->comentarios_produccion) > 100) : + if (isset($item->comentarios_produccion) && strlen($item->comentarios_produccion) > 100): $item->comentarios_produccion = character_limiter($item->comentarios_produccion, 100); endif; - if (isset($item->tirada_alternativa_json_data) && strlen($item->tirada_alternativa_json_data) > 100) : + if (isset($item->tirada_alternativa_json_data) && strlen($item->tirada_alternativa_json_data) > 100): $item->tirada_alternativa_json_data = character_limiter($item->tirada_alternativa_json_data, 100); endif; - if (isset($item->titulo) && strlen($item->titulo) > 100) : + if (isset($item->titulo) && strlen($item->titulo) > 100): $item->titulo = character_limiter($item->titulo, 100); endif; - if (isset($item->paginas_color_posicion) && strlen($item->paginas_color_posicion) > 100) : + if (isset($item->paginas_color_posicion) && strlen($item->paginas_color_posicion) > 100): $item->paginas_color_posicion = character_limiter($item->paginas_color_posicion, 100); endif; - if (isset($item->aprobado_json_data) && strlen($item->aprobado_json_data) > 100) : + if (isset($item->aprobado_json_data) && strlen($item->aprobado_json_data) > 100): $item->aprobado_json_data = character_limiter($item->aprobado_json_data, 100); endif; - if (isset($item->comparador_json_data) && strlen($item->comparador_json_data) > 100) : + if (isset($item->comparador_json_data) && strlen($item->comparador_json_data) > 100): $item->comparador_json_data = character_limiter($item->comparador_json_data, 100); endif; - if (isset($item->ws_externo_json_data) && strlen($item->ws_externo_json_data) > 100) : + if (isset($item->ws_externo_json_data) && strlen($item->ws_externo_json_data) > 100): $item->ws_externo_json_data = character_limiter($item->ws_externo_json_data, 100); endif; endforeach; @@ -731,7 +815,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $isColor = $reqData['color'] ?? false; $isHq = $reqData['hq'] ?? false; - $datosPedido = (object)array( + $datosPedido = (object) array( 'paginas' => intval($reqData['paginas']) ?? 0, 'tirada' => intval($reqData['tirada']) ?? 0, 'merma' => intval($reqData['merma']) ?? 0, @@ -757,7 +841,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $datosTipolog = $reqData['negro'] ?? null; if (!is_null($datosTipolog)) { $datosTipolog = []; - $data = (object)array( + $data = (object) array( 'negro' => floatval($reqData['negro']) ?? 0, 'cyan' => floatval($reqData['cyan']) ?? 0, 'magenta' => floatval($reqData['magenta']) ?? 0, @@ -801,7 +885,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController } else if ($type == 'interior_rot') { - $paginas = (object)array( + $paginas = (object) array( 'negro' => intval($reqData['paginas_negro'] ?? 0), 'color' => intval($reqData['paginas_color'] ?? 0), ); @@ -809,7 +893,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $datosTipolog = $reqData['negro'] ?? null; if (!is_null($datosTipolog)) { $datosTipolog = []; - $data = (object)array( + $data = (object) array( 'negro' => floatval($reqData['negro']) ?? 0, 'cyan' => floatval($reqData['cyan']) ?? 0, 'magenta' => floatval($reqData['magenta']) ?? 0, @@ -828,7 +912,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController 'cliente_id' => $cliente_id, 'datosTipolog' => $datosTipolog ]; - + $resourceData = PresupuestoService::obtenerComparadorRotativa($input_data); } else if ($type == 'cubierta' || $type == 'sobrecubierta') { @@ -844,10 +928,10 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController 'papel_generico' => $papel_generico, 'gramaje' => $gramaje, 'isColor' => 1, // Cubierta y sobrecubierta siempre color HQ - 'isHq' => 1, + 'isHq' => 1, 'cliente_id' => $cliente_id, ); - + $resourceData = PresupuestoService::obtenerComparadorPlana($input_data); } @@ -900,25 +984,22 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController ]; return $this->respond($data); - } - - else if ($tipo == 'duplicar'){ + } else if ($tipo == 'duplicar') { $presupuesto_id = $reqData['presupuesto_id'] ?? -1; $result = $this->duplicarPresupuesto($presupuesto_id); $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); - if($result['success']){ + if ($result['success']) { $data = [ 'id' => $result['id'], $csrfTokenName => $newTokenHash - ]; + ]; return $this->respond($data); - } - else{ + } else { $data = [ 'error' => $result['message'], $csrfTokenName => $newTokenHash - ]; + ]; return $this->respond($data); } } @@ -942,7 +1023,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController switch ($tipo_impresion_id) { - // Fresado tapa dura + // Fresado tapa dura case 1: $viewData['pageTitle'] = lang('Presupuestos.moduleTitleFresadoTD'); $viewData['isCosido'] = 0; @@ -950,7 +1031,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $breadcrumbTitle = lang("App.menu_libros_fresasdo_tapa_dura"); break; - // Fresado tapa blanda + // Fresado tapa blanda case 2: $viewData['pageTitle'] = lang('Presupuestos.moduleTitleFresadoTB'); $viewData['isCosido'] = 0; @@ -958,7 +1039,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $breadcrumbTitle = lang("App.menu_libros_fresasdo_tapa_blanda"); break; - // Cosido tapa dura + // Cosido tapa dura case 3: $viewData['pageTitle'] = lang('Presupuestos.moduleTitleCosidoTD'); $viewData['isCosido'] = 1; @@ -966,7 +1047,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $breadcrumbTitle = lang("App.menu_libros_cosido_tapa_dura"); break; - // Cosido tapa blanda + // Cosido tapa blanda case 4: $viewData['pageTitle'] = lang('Presupuestos.moduleTitleCosidoTB'); $viewData['isCosido'] = 1; @@ -974,7 +1055,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $breadcrumbTitle = lang("App.menu_libros_cosido_tapa_blanda"); break; - // Espiral tapa dura + // Espiral tapa dura case 5: $viewData['pageTitle'] = lang('Presupuestos.moduleTitleEspiralTD'); $viewData['isCosido'] = 0; @@ -982,7 +1063,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $breadcrumbTitle = lang("App.menu_libros_espiral_tapa_dura"); break; - // Espiral tapa blanda + // Espiral tapa blanda case 6: $viewData['pageTitle'] = lang('Presupuestos.moduleTitleEspiralTB'); $viewData['isCosido'] = 0; @@ -990,7 +1071,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $breadcrumbTitle = lang("App.menu_libros_espiral_tapa_blanda"); break; - // Wire-o tapa dura + // Wire-o tapa dura case 7: $viewData['pageTitle'] = lang('Presupuestos.moduleTitleWireoTD'); $viewData['isCosido'] = 0; @@ -998,7 +1079,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $breadcrumbTitle = lang("App.menu_libros_wireo_tapa_dura"); break; - // Wire-o tapa blanda + // Wire-o tapa blanda case 8: $viewData['pageTitle'] = lang('Presupuestos.moduleTitleWireoTB'); $viewData['isCosido'] = 0; @@ -1006,7 +1087,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $breadcrumbTitle = lang("App.menu_libros_wireo_tapa_blanda"); break; - // Grapado + // Grapado case 21: $viewData['pageTitle'] = lang('Presupuestos.moduleTitleGrapado'); $viewData['isCosido'] = 0; @@ -1026,7 +1107,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController return $viewData; } - + /** * Duplica un presupuesto dado por su ID. @@ -1041,67 +1122,68 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController * Si ocurre una excepción, la clave 'success' será false y una clave 'message' contendrá el mensaje de la excepción. * @throws \Exception Si ocurre un error durante la operación. */ - private function duplicarPresupuesto($id){ + private function duplicarPresupuesto($id) + { - try{ - - $presupuesto = $this->model->find($id); - $presupuesto->titulo = $presupuesto->titulo .' - ' . lang('Presupuestos.duplicado'); - $presupuesto->is_duplicado = 1; - $presupuesto->estado_id = 1; - $new_id = $this->model->insert($presupuesto); - - $presupuestoAcabadosModel = model('App\Models\Presupuestos\PresupuestoAcabadosModel'); - foreach ($presupuestoAcabadosModel->where('presupuesto_id', $presupuesto->id)->findAll() as $acabado) { - $acabado->presupuesto_id = $new_id; - $presupuestoAcabadosModel->insert($acabado); - } - - $presupuestoEncuadernacionesModel = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel'); - foreach ($presupuestoEncuadernacionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $encuadernacion) { - $encuadernacion->presupuesto_id = $new_id; - $presupuestoEncuadernacionesModel->insert($encuadernacion); - } - - $presupuestoManipuladosModel = model('App\Models\Presupuestos\PresupuestoManipuladosModel'); - foreach ($presupuestoManipuladosModel->where('presupuesto_id', $presupuesto->id)->findAll() as $manipulado) { - $manipulado->presupuesto_id = $new_id; - $presupuestoManipuladosModel->insert($manipulado); - } - - $presupuestoPreimpresionesModel = model('App\Models\Presupuestos\PresupuestoPreimpresionesModel'); - foreach ($presupuestoPreimpresionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $preimpresion) { - $preimpresion->presupuesto_id = $new_id; - $presupuestoPreimpresionesModel->insert($preimpresion); - } + try { - $presupuestoServiciosExtraModel = model('App\Models\Presupuestos\PresupuestoServiciosExtraModel'); - foreach ($presupuestoServiciosExtraModel->where('presupuesto_id', $presupuesto->id)->findAll() as $servicioExtra) { - $servicioExtra->presupuesto_id = $new_id; - $presupuestoServiciosExtraModel->insert($preimpresion); - } - - $presupuestoDireccionesModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel'); - foreach ($presupuestoDireccionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $direccion) { - $direccion->presupuesto_id = $new_id; - $presupuestoDireccionesModel->insert($direccion); - } - - $presupuestoLineaModel = model('App\Models\Presupuestos\PresupuestoLineaModel'); - $presupuestoLineaModel->duplicateLineasPresupuesto($presupuesto->id, $new_id); - - return [ - 'success' => true, - 'id' => $new_id - ]; - - }catch(\Exception $e){ - return [ - 'success' => false, - 'message' => $e->getMessage() - ]; - } - } + $presupuesto = $this->model->find($id); + $presupuesto->titulo = $presupuesto->titulo . ' - ' . lang('Presupuestos.duplicado'); + $presupuesto->is_duplicado = 1; + $presupuesto->estado_id = 1; + $new_id = $this->model->insert($presupuesto); + + $presupuestoAcabadosModel = model('App\Models\Presupuestos\PresupuestoAcabadosModel'); + foreach ($presupuestoAcabadosModel->where('presupuesto_id', $presupuesto->id)->findAll() as $acabado) { + $acabado->presupuesto_id = $new_id; + $presupuestoAcabadosModel->insert($acabado); + } + + $presupuestoEncuadernacionesModel = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel'); + foreach ($presupuestoEncuadernacionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $encuadernacion) { + $encuadernacion->presupuesto_id = $new_id; + $presupuestoEncuadernacionesModel->insert($encuadernacion); + } + + $presupuestoManipuladosModel = model('App\Models\Presupuestos\PresupuestoManipuladosModel'); + foreach ($presupuestoManipuladosModel->where('presupuesto_id', $presupuesto->id)->findAll() as $manipulado) { + $manipulado->presupuesto_id = $new_id; + $presupuestoManipuladosModel->insert($manipulado); + } + + $presupuestoPreimpresionesModel = model('App\Models\Presupuestos\PresupuestoPreimpresionesModel'); + foreach ($presupuestoPreimpresionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $preimpresion) { + $preimpresion->presupuesto_id = $new_id; + $presupuestoPreimpresionesModel->insert($preimpresion); + } + + $presupuestoServiciosExtraModel = model('App\Models\Presupuestos\PresupuestoServiciosExtraModel'); + foreach ($presupuestoServiciosExtraModel->where('presupuesto_id', $presupuesto->id)->findAll() as $servicioExtra) { + $servicioExtra->presupuesto_id = $new_id; + $presupuestoServiciosExtraModel->insert($preimpresion); + } + + $presupuestoDireccionesModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel'); + foreach ($presupuestoDireccionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $direccion) { + $direccion->presupuesto_id = $new_id; + $presupuestoDireccionesModel->insert($direccion); + } + + $presupuestoLineaModel = model('App\Models\Presupuestos\PresupuestoLineaModel'); + $presupuestoLineaModel->duplicateLineasPresupuesto($presupuesto->id, $new_id); + + return [ + 'success' => true, + 'id' => $new_id + ]; + + } catch (\Exception $e) { + return [ + 'success' => false, + 'message' => $e->getMessage() + ]; + } + } public function allItemsSelect() { @@ -1223,11 +1305,11 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController protected function getClienteListItems($selId = null) { $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Clientes.cliente'))])]; - if (!empty($selId)) : + if (!empty($selId)): $clienteModel = model('App\Models\Clientes\ClienteModel'); $selOption = $clienteModel->where('id', $selId)->findColumn('nombre'); - if (!empty($selOption)) : + if (!empty($selOption)): $data[$selId] = $selOption[0]; endif; endif; @@ -1257,7 +1339,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController { $model = model('App\Models\Tarifas\Acabados\TarifaAcabadoModel'); $data = $model->getServiciosAcabadoCubierta(); - array_unshift($data, (object)['id' => '', 'label' => lang('Basic.global.None')]); + array_unshift($data, (object) ['id' => '', 'label' => lang('Basic.global.None')]); return $data; } @@ -1265,38 +1347,39 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController { $model = model('App\Models\Tarifas\Acabados\TarifaAcabadoModel'); $data = $model->getServiciosAcabadoSobrecubierta(); - array_unshift($data, (object)['id' => '', 'label' => lang('Basic.global.None')]); + array_unshift($data, (object) ['id' => '', 'label' => lang('Basic.global.None')]); return $data; } - public function getPapelGenerico(){ + public function getPapelGenerico() + { if ($this->request->isAJAX()) { $POD_value = $this->getPOD(); $tirada = $this->request->getGet("tirada"); - $isPOD = intval($tirada)<=intval($POD_value); + $isPOD = intval($tirada) <= intval($POD_value); $tipo_impresion_id = $this->request->getGet("tipo_impresion"); $tapa_dura = model('App\Models\Configuracion\TipoPresupuestoModel')->get_isTapaDura(intval($tipo_impresion_id)); $tipo = $this->request->getGet("tipo"); - + $uso = $this->request->getGet("uso") ?? 'interior'; $cubierta = false; - if($uso=='cubierta'){ + if ($uso == 'cubierta') { $cubierta = true; } $sobrecubierta = false; - if($uso=='sobrecubierta'){ + if ($uso == 'sobrecubierta') { $sobrecubierta = true; } $guardas = false; - if($uso=='guardas'){ + if ($uso == 'guardas') { $guardas = true; } $rotativa = false; - if($uso=='rotativa'){ + if ($uso == 'rotativa') { $rotativa = true; } @@ -1314,35 +1397,36 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController } } - public function getGramaje(){ + public function getGramaje() + { if ($this->request->isAJAX()) { $papel_generico_id = $this->request->getGet("papel_generico"); $POD_value = $this->getPOD(); $tirada = $this->request->getGet("tirada"); - $isPOD = intval($tirada)<=intval($POD_value); + $isPOD = intval($tirada) <= intval($POD_value); $tipo_impresion_id = $this->request->getGet("tipo_impresion"); $tapa_dura = model('App\Models\Configuracion\TipoPresupuestoModel')->get_isTapaDura(intval($tipo_impresion_id)); $tipo = $this->request->getGet("tipo"); - + $uso = $this->request->getGet("uso") ?? 'interior'; $cubierta = false; - if($uso=='cubierta'){ + if ($uso == 'cubierta') { $cubierta = true; } $sobrecubierta = false; - if($uso=='sobrecubierta'){ + if ($uso == 'sobrecubierta') { $sobrecubierta = true; } $guardas = false; - if($uso=='guardas'){ + if ($uso == 'guardas') { $guardas = true; } $rotativa = false; - if($uso=='rotativa'){ + if ($uso == 'rotativa') { $rotativa = true; } @@ -1361,13 +1445,13 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController } - + protected function getServiciosPreimpresion() { $model = model('App\Models\Tarifas\TarifapreimpresionModel'); $data = $model->getServiciosPreimpresionSelector(); - array_unshift($data, (object)array( + array_unshift($data, (object) array( "value" => 0, "label" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioPreimpresion'))]) )); @@ -1378,7 +1462,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController { $model = model('App\Models\Tarifas\TarifaextraModel'); $data = $model->getServiciosExtraSelector(); - array_unshift($data, (object)array( + array_unshift($data, (object) array( "value" => 0, "label" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioExtra'))]) )); @@ -1397,7 +1481,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $papelFormatoModel = model('App\Models\Configuracion\PapelFormatoModel'); $data = $papelFormatoModel->getElementsForMenu(); array_shift($data); - array_unshift($data, (object)['id' => '', 'tamanio' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papelFormatoId'))])]); + array_unshift($data, (object) ['id' => '', 'tamanio' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.papelFormatoId'))])]); return $data; } @@ -1412,7 +1496,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController { $model = model('App\Models\Tarifas\TarifaManipuladoModel'); $data = $model->getServiciosManipuladoSelector(); - array_unshift($data, (object)array( + array_unshift($data, (object) array( "value" => 0, "label" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioManipulado'))]) )); @@ -1425,25 +1509,27 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController return $model->getPOD(); } - protected function getLineasPresupuesto($presupuestoEntity){ + protected function getLineasPresupuesto($presupuestoEntity) + { $lineas = (new PresupuestoLineaModel())->getLineasPresupuesto($presupuestoEntity->id); - + $input_data = []; $input_data['presupuesto'] = $presupuestoEntity; - + return PresupuestoService::checkLineasPresupuesto($input_data, $lineas); } - protected function getLineasServicios($presupuestoEntity){ - - $serviciosPresupuesto = (object)array(); + protected function getLineasServicios($presupuestoEntity) + { + + $serviciosPresupuesto = (object) array(); $serviciosPresupuesto->serviciosAcabado = (new PresupuestoAcabadosModel())->getResource($presupuestoEntity->id)->get()->getResultObject(); $serviciosPresupuesto->serviciosPreimpresion = (new PresupuestoPreimpresionesModel())->getResource($presupuestoEntity->id)->get()->getResultObject(); $serviciosPresupuesto->serviciosEncuadernacion = (new PresupuestoEncuadernacionesModel())->getResource($presupuestoEntity->id)->get()->getResultObject(); $serviciosPresupuesto->serviciosManipulado = (new PresupuestoManipuladosModel())->getResource($presupuestoEntity->id)->get()->getResultObject(); $serviciosPresupuesto->serviciosExtra = (new PresupuestoServiciosExtraModel())->getResource($presupuestoEntity->id)->get()->getResultObject(); - + $input_data = []; $input_data['presupuesto_id'] = $presupuestoEntity->id; $input_data['tipo_impresion_id'] = $presupuestoEntity->tipo_impresion_id; @@ -1451,19 +1537,17 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $input_data['POD'] = $this->getPOD(); $input_data['paginas'] = $presupuestoEntity->paginas; $input_data['is_duplicado'] = $presupuestoEntity->is_duplicado; - - if($presupuestoEntity->papel_formato_personalizado){ - $input_data['ancho'] = $presupuestoEntity->papel_formato_ancho ; - $input_data['alto'] = $presupuestoEntity->papel_formato_alto ; - } - else{ + + if ($presupuestoEntity->papel_formato_personalizado) { + $input_data['ancho'] = $presupuestoEntity->papel_formato_ancho; + $input_data['alto'] = $presupuestoEntity->papel_formato_alto; + } else { $model = model("App\Models\Configuracion\PapelFormatoModel"); $papel = $model->find($presupuestoEntity->papel_formato_id); - if($papel){ + if ($papel) { $input_data['ancho'] = $papel->ancho; $input_data['alto'] = $papel->alto; - } - else{ + } else { $input_data['ancho'] = 0; $input_data['alto'] = 0; } @@ -1472,11 +1556,12 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController return PresupuestoService::checkLineasServicios($input_data, $serviciosPresupuesto); } - protected function getLineasDirecciones($presupuestoEntity){ + protected function getLineasDirecciones($presupuestoEntity) + { $model = model('App\Models\Presupuestos\PresupuestoDireccionesModel'); $direccionesEnvio = $model->where('presupuesto_id', $presupuestoEntity->id)->findAll(); - + return PresupuestoService::checkLineasEnvios($direccionesEnvio); } } diff --git a/ci4/app/Services/PresupuestoClienteService.php b/ci4/app/Services/PresupuestoClienteService.php index c181d990..8064173f 100644 --- a/ci4/app/Services/PresupuestoClienteService.php +++ b/ci4/app/Services/PresupuestoClienteService.php @@ -65,7 +65,7 @@ class PresupuestoClienteService extends BaseService } } - public static function obtenerCubierta($data) + public static function obtenerCubierta($data, $return_raw=false) { $uso = $data['uso']; @@ -76,7 +76,6 @@ class PresupuestoClienteService extends BaseService $isColor = $data['isColor']; $isHq = $data['isHq']; $cliente_id = $data['cliente_id']; - $paginas_color = $data['paginas_color']; $lomoRedondo = $data['lomoRedondo']; $lineas_cubierta = []; @@ -102,6 +101,14 @@ class PresupuestoClienteService extends BaseService } if (count($lineas_cubierta) > 0) { + if($return_raw){ + $lineas_cubierta = array_values(array_unique($lineas_cubierta, SORT_REGULAR)); + + return[ + 'cubierta' => $lineas_cubierta + ]; + } + usort( $lineas_cubierta, function ($a, $b) { @@ -119,7 +126,7 @@ class PresupuestoClienteService extends BaseService return $lineas_cubierta; } - public static function obtenerSobrecubierta($data) + public static function obtenerSobrecubierta($data, $return_raw=false) { $uso = $data['uso']; @@ -154,6 +161,14 @@ class PresupuestoClienteService extends BaseService } if (count($lineas_sobrecubierta) > 0) { + if($return_raw){ + $lineas_sobrecubierta = array_values(array_unique($lineas_sobrecubierta, SORT_REGULAR)); + + return[ + 'cubierta' => $lineas_sobrecubierta + ]; + } + usort( $lineas_sobrecubierta, function ($a, $b) { @@ -247,22 +262,25 @@ class PresupuestoClienteService extends BaseService $uso = $data['uso']; $tipo_impresion_id = $data['tipo_impresion_id']; $datosPedido = $data['datosPedido']; + $paginas_color = $data['paginas_color']; if ($data['papelInteriorDiferente'] == false) $papel_generico = $data['papel_generico']; else { $papel_generico = $data['papel_generico']['negro']; - $papel_generico_color = $data['papel_generico']['color']; + if($paginas_color>0) + $papel_generico_color = $data['papel_generico']['color']; } if ($data['papelInteriorDiferente'] == false) $gramaje = $data['gramaje']; else { $gramaje = $data['gramaje']['negro']; - $gramaje_color = $data['gramaje']['color']; + if($paginas_color>0) + $gramaje_color = $data['gramaje']['color']; } $isColor = $data['isColor']; $isHq = $data['isHq']; $cliente_id = $data['cliente_id']; - $paginas_color = $data['paginas_color']; + $paginas_negro = $datosPedido->paginas - $paginas_color; @@ -293,6 +311,14 @@ class PresupuestoClienteService extends BaseService } if (count($linea_negro_plana) > 0) { + /*if($return_raw){ + $linea_negro_plana = array_values(array_unique($linea_color_plana, SORT_REGULAR)); + + return[ + 'negro' => $linea_negro_plana + ]; + }*/ + usort( $linea_negro_plana, function ($a, $b) { @@ -335,6 +361,14 @@ class PresupuestoClienteService extends BaseService } if (count($linea_color_plana) > 0) { + /*if($return_raw){ + $linea_color_plana = array_values(array_unique($linea_color_plana, SORT_REGULAR)); + + return[ + 'color' => $linea_color_plana + ]; + }*/ + usort( $linea_color_plana, function ($a, $b) { @@ -349,8 +383,7 @@ class PresupuestoClienteService extends BaseService } } - // Si hay negro y color, y se hace con el mismo papel, hay que buscar la combinación - // más económica con la misma máquna + if($return_raw){ $linea_negro_plana = array_values(array_unique($linea_negro_plana, SORT_REGULAR)); $linea_color_plana = array_values(array_unique($linea_color_plana, SORT_REGULAR)); @@ -360,6 +393,8 @@ class PresupuestoClienteService extends BaseService 'color' => $linea_color_plana ]; } + // Si hay negro y color, y se hace con el mismo papel, hay que buscar la combinación + // más económica con la misma máquna if ( $paginas_negro > 0 && $paginas_color > 0 && $data['papelInteriorDiferente'] == 0 && count($linea_negro_plana) > 0 && count($linea_color_plana) > 0 @@ -500,7 +535,7 @@ class PresupuestoClienteService extends BaseService * - isHq: si es alta calidad * - paginas_color: número de páginas a color */ - private static function obtenerPresupuestoClienteInteriorRotativa($data) + public static function obtenerPresupuestoClienteInteriorRotativa($data, $return_raw = false) { $datosPedido = $data['datosPedido']; $papel_generico = $data['papel_generico']; @@ -539,6 +574,14 @@ class PresupuestoClienteService extends BaseService if (count($linea_rotativa) > 0) { + if($return_raw){ + $linea_rotativa = array_values(array_unique($linea_rotativa, SORT_REGULAR)); + + return[ + 'rotativa' => $linea_rotativa, + ]; + } + usort( $linea_rotativa, function ($a, $b) { 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 0a71c2c5..bb1e770f 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/comparador.js +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/comparador.js @@ -1,18 +1,3 @@ -/******************************* - * Eventos asociados a elementos HTML - *******************************/ - - - - - - - - -$('#compPosPaginasColor').on("keyup", function () { - computarPaginasColor(this.value); -}); - @@ -23,163 +8,6 @@ $('#compPosPaginasColor').on("keyup", function () { *******************************/ -function getRowFromLineaRot(linea) { - - $precio_impresion = isNaN(parseFloat(linea.fields.precio_impresion_horas + linea.fields.precio_click_pedido)) ? "" : - parseFloat(linea.fields.precio_impresion_horas + linea.fields.precio_click_pedido).toFixed(2); - - return { - 'tipo': 'rotativa', - 'paginas': linea.fields.paginas, - 'papel': linea.fields.papel_generico, - 'gramaje': linea.fields.gramaje, - 'marca': linea.fields.papel_impresion, - 'aFavorFibra': linea.fields.a_favor_fibra == 1 ? 'si' : 'no', - 'maquina': linea.fields.maquina, - 'numeroPliegos': isNaN(parseFloat(linea.fields.pliegos_libro)) ? "" : parseFloat(linea.fields.pliegos_libro).toFixed(2), - 'pliegosPedido': isNaN(parseFloat(linea.fields.pliegos_pedido)) ? "" : parseFloat(linea.fields.pliegos_pedido).toFixed(2), - 'precioPliego': isNaN(parseFloat(linea.fields.precios_pliegos)) ? "" : parseFloat(linea.fields.precios_pliegos).toFixed(6), - 'libro': isNaN(parseFloat(linea.fields.precio_libro)) ? "" : parseFloat(linea.fields.precio_libro).toFixed(2), - 'totalPapelPedido': isNaN(parseFloat(linea.fields.precio_pedido)) ? "" : parseFloat(linea.fields.precio_pedido).toFixed(2), - 'lomo': isNaN(parseFloat(linea.fields.mano)) ? "" : parseFloat(linea.fields.mano).toFixed(2), - 'peso': isNaN(parseFloat(linea.fields.peso)) ? "" : parseFloat(linea.fields.peso).toFixed(2), - 'horasMaquina': isNaN(parseFloat(linea.fields.horas_maquina)) ? "" : parseFloat(linea.fields.horas_maquina).toFixed(2), - 'precioImpresion': $precio_impresion, - 'precioPagNegro': isNaN(parseFloat(linea.fields.precio_pagina_negro)) ? "" : parseFloat(linea.fields.precio_pagina_negro).toFixed(6), - 'precioPagColor': isNaN(parseFloat(linea.fields.precio_pagina_color)) ? "" : parseFloat(linea.fields.precio_pagina_color).toFixed(6), - 'totalTinta': isNaN(parseFloat(linea.fields.precio_tinta)) ? "" : parseFloat(linea.fields.precio_tinta).toFixed(2), - 'totalCorte': isNaN(parseFloat(linea.fields.total_corte)) ? "" : parseFloat(linea.fields.total_corte).toFixed(2), - 'total': isNaN(parseFloat(linea.fields.total_impresion)) ? "" : (parseFloat(linea.fields.total_impresion)).toFixed(2), - 'maquinaId': linea.fields.maquina_id, - 'maquinaVelocidad': linea.fields.maquina_velocidad, - 'tiempoMaquina': linea.fields.tiempo_maquina, - 'papelGenericoId': linea.fields.papel_generico_id, - 'papelImpresionId': linea.fields.papel_impresion_id, - 'paginasColor': linea.fields.paginas_color, - 'tarifa_impresion_id': linea.fields.tarifa_impresion_id, - } -} - - - - - - - - - - - - - -function clearIntLineas(is_color) { - //$("#tableCompIntPlana").DataTable().rows( '.selected' ).deselect(); - var tabla = $('#tableCompIntPlana').DataTable(); - tabla - .rows(function (idx, data, node) { - return data['tipo'].includes(is_color ? 'color' : 'bn'); - }) - .remove() - .draw(); - //$('#tableCompIntPlana').DataTable().clear().draw(); - $('#insertarPlanaBtn').css('display', 'none'); -} - - -function clearCubierta() { - - var tabla = $('#tableCompCubierta').DataTable(); - tabla - .rows(function (idx, data, node) { - return data['tipo'] === 'cubierta'; - }) - .remove() - .draw(); - if(tabla.rows().count()==0) - $('#insertarCubiertaBtn').css('display', 'none'); -} - -function clearSobrecubierta() { - - - var tabla = $('#tableCompCubierta').DataTable(); - tabla - .rows(function (idx, data, node) { - return data['tipo'] === 'sobrecubierta'; - }) - .remove() - .draw(); - if(tabla.rows().count()==0) - $('#insertarCubiertaBtn').css('display', 'none'); -} - -function clearGuardas() { - - $('#tableCompGuardas').DataTable().clear().draw(); - $('#insertarGuardasBtn').css('display', 'none'); -} - -function clearIntRot() { - - $('#errorComRot').html(''); - $('#tableCompIntRotativa').DataTable().clear().draw(); - $('#insertarRotativaBtn').css('display', 'none'); -} - - - - -function selectIntRotLineas() { - - $("#tableCompIntRotativa").DataTable().rows('.selected').deselect(); - - let value_total = 0.00; - - if ($("#tableCompIntRotativa").DataTable().rows().count() > 0) { - - $("#tableCompIntRotativa").DataTable().row(0).nodes().to$().toggleClass('selected'); - value_total = parseFloat($("#tableCompIntRotativa").DataTable().rows(0).data()[0]['total']) - }; - - - $('#total_comp_rot').html(value_total.toFixed(2)); -} - -function selectCubiertaLineas() { - - $("#tableCompCubierta").DataTable().rows('.selected').deselect(); - - cubierta_selected = false; - sobrecubierta_selected = false; - - if ($("#tableCompCubierta").DataTable().rows().count() > 0) { - - $("#tableCompCubierta").DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) { - if (!cubierta_selected && $('#tableCompCubierta').DataTable().cell(rowIdx, 0).data() === 'cubierta') { - $("#tableCompCubierta").DataTable().row(rowIdx).nodes().to$().toggleClass('selected'); - cubierta_selected = true; - } - if (!sobrecubierta_selected && $('#tableCompCubierta').DataTable().cell(rowIdx, 0).data() === 'sobrecubierta') { - $("#tableCompCubierta").DataTable().row(rowIdx).nodes().to$().toggleClass('selected'); - sobrecubierta_selected = true; - } - }); - } - - var table = $("#tableCompCubierta").DataTable(); - var rows = table.rows('.selected').indexes(); - var data = table.rows(rows).data(); - - var value_total = 0.00; - - for (let i = 0; i < data.length; i++) { - - value_total += parseFloat(data[i]['total']) - } - - - $('#total_comp_cubierta').html(value_total.toFixed(2)); -} function selectGuardasLineas() { @@ -197,140 +25,12 @@ function selectGuardasLineas() { $('#total_comp_guardas').html(value_total.toFixed(2)); } -function getIDsComparador(is_color, is_hq) { - - if (!is_color) { - if (is_hq) { - var papel = '#compPapelNegrohq'; - var gramaje = '#compGramajeNegrohq'; - var paginas = '#compPaginasNegrohq'; - } - else { - var papel = '#compPapelNegro'; - var gramaje = '#compGramajeNegro'; - var paginas = '#compPaginasNegro'; - } - } - else { - if (is_hq) { - var papel = '#compPapelColorhq'; - var gramaje = '#compGramajeColorhq'; - var paginas = '#compPaginasColorhq'; - } - else { - var papel = '#compPapelColor'; - var gramaje = '#compGramajeColor'; - var paginas = '#compPaginasColor'; - } - } - return { - papel: papel, - gramaje: gramaje, - paginas: paginas, - } -} - -function getDimensionLibro() { - var ancho = 0; - var alto = 0; - - // 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) { - ancho = parseFloat(document.getElementById('papelFormatoAncho').value); - alto = parseFloat(document.getElementById('papelFormatoAlto').value); - } - return { - ancho: ancho, - alto: alto - } -} - -function checkInputsForRotativa() { - - // Si es color, el gramaje y el papel tiene que ser el mismo - try { - - if ($('#tipoImpresion').select2('data')[0].id == 'color') { - if ($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id && - $('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim()) { - - return true; - } - } - else if ($('#tipoImpresion').select2('data')[0].id == 'negro') { - if ($('#compPapelNegro').select2('data')[0].id.length > 0 && - $('#compGramajeNegro').select2('data')[0].text.length > 0) { - return true; - } - } - } - catch (error) { - - return false; - } - - return false; -} -function fillIntPlana(data, is_color, is_hq) { - let sorted = data.lineas.sort( - (p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? - -1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0); - sorted.forEach(function (linea) { - if (typeof linea.error == "undefined") - $('#tableCompIntPlana').DataTable().row - .add(getRowFromLineaInt(is_color ? (is_hq ? 'colorhq' : 'color') : (is_hq ? 'bnhq' : 'bn'), linea)) - .draw() - }) -} -function fillIntRot(data) { - let sorted = data.lineas.sort( - (p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? - -1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0); - sorted.forEach(function (linea) { - if (typeof linea.error == "undefined") { - $('#tableCompIntRotativa').DataTable().row - .add(getRowFromLineaRot(linea)) - .draw() - } - }) -} -function fillCubierta(data) { - - let sorted = data.lineas.sort( - (p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? - -1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0); - sorted.forEach(function (linea) { - if (typeof linea.error == "undefined") - $('#tableCompCubierta').DataTable().row - .add(getRowFromLineaInt('cubierta', linea)) - .draw() - }) -} - -function fillSobrecubierta(data) { - - let sorted = data.lineas.sort( - (p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? - -1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0); - sorted.forEach(function (linea) { - if (typeof linea.error == "undefined") - $('#tableCompCubierta').DataTable().row - .add(getRowFromLineaInt('sobrecubierta', linea)) - .draw() - }) -} function fillGuardas(data) { @@ -345,130 +45,5 @@ function fillGuardas(data) { }) } -function clearCompTable() { - - $('#insertarPlanaBtn').addClass('d-none') - $('#insertarRotativaBtn').addClass('d-none') - $('#total_comp_plana').html('0.00') - $('#total_comp_rot').html('0.00') -} - -function generateCompJSON() { - - data = {} - - if ($('#tipoImpresion').select2('data')[0].id == 'negro' || $('#tipoImpresion').select2('data')[0].id == 'color') { - try { - bn_obj = { - "bn": { - 'paginas': $('#compPaginasNegro').val(), - 'papel_id': $('#compPapelNegro').select2('data')[0].id, - 'gramaje': $('#compGramajeNegro').select2('data')[0].text.trim(), - } - } - } - catch (e) { - bn_obj = {} - } - $.extend(data, bn_obj); - } - - if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' || $('#tipoImpresion').select2('data')[0].id == 'colorhq') { - try { - bnhq_obj = { - "bnhq": { - 'paginas': $('#compPaginasNegrohq').val(), - 'papel_id': $('#compPapelNegrohq').select2('data')[0].id, - 'gramaje': $('#compGramajeNegrohq').select2('data')[0].text.trim(), - } - } - } - catch (e) { - bnhq_obj = {} - } - $.extend(data, bnhq_obj); - } - - if ($('#tipoImpresion').select2('data')[0].id == 'color') { - try { - color_obj = { - "color": { - 'paginas': $('#compPaginasColor').val(), - 'papel_id': $('#compPapelColor').select2('data')[0].id, - 'gramaje': $('#compGramajeColor').select2('data')[0].text.trim(), - }, - } - } - catch (e) { - color_obj = {} - } - $.extend(data, color_obj); - - } - if ($('#tipoImpresion').select2('data')[0].id == 'colorhq') { - try { - colorhq_obj = { - "colorhq": { - 'paginas': $('#compPaginasColorhq').val(), - 'papel_id': $('#compPapelColorhq').select2('data')[0].id, - 'gramaje': $('#compGramajeColorhq').select2('data')[0].text.trim(), - }, - } - } - catch (e) { - colorhq_obj = {} - } - $.extend(data, colorhq_obj); - } - - - try { - cubierta_obj = { - "cubierta": { - 'paginas': $('#compCarasCubierta option:selected').val(), - 'papel_id': $('#compPapelCubierta').select2('data')[0].id, - 'gramaje': $('#compGramajeCubierta').select2('data')[0].text.trim(), - }, - } - } - catch (e) { - cubierta_obj = {} - } - $.extend(data, cubierta_obj); - - try { - sobrecubierta_obj = { - "sobrecubierta": { - 'imprimir': $('#compSobrecubierta option:selected').val(), - 'papel_id': $('#compPapelSobrecubierta').select2('data')[0].id, - 'gramaje': $('#compGramajeSobrecubierta').select2('data')[0].text.trim(), - }, - } - } - catch (e) { - sobrecubierta_obj = {} - } - $.extend(data, sobrecubierta_obj); - - if($('#compCarasGuardas').length>0){ - try { - guardas_obj = { - "guardas": { - 'paginas_impresion': $('#compCarasGuardas option:selected').val(), - 'papel_id': $('#compPapelGuardas').select2('data')[0].id, - }, - } - } - catch (e) { - guardas_obj = {} - } - $.extend(data, guardas_obj); - - } - - data_str = JSON.stringify(data) - $('#comparador_json_data').val(data_str) -} - diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js index 9cc3a2a1..005a9395 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js @@ -164,6 +164,7 @@ class Comparador { this.btnInsertarCubierta = $('#insertarCubiertaBtn'); this.cargando = false; + this.comparadorPlanaRunning = false; } init() { @@ -179,18 +180,19 @@ class Comparador { initSelect2() { + this.paginasCubierta.select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + }); + if ($('#tipo_impresion_id').val() == 1 || $('#tipo_impresion_id').val() == 3 || $('#tipo_impresion_id').val() == 5 || $('#tipo_impresion_id').val() == 7) { - $('#compCarasCubierta').select2({ - allowClear: false, - minimumResultsForSearch: Infinity, - }); - $('#compPapelGuardas').select2({ + this.papelGuardas.select2({ allowClear: false, }); - $('#compCarasGuardas').select2({ + this.carasGuardas.select2({ allowClear: false, minimumResultsForSearch: Infinity, }); @@ -206,6 +208,11 @@ class Comparador { this.papelCubierta.init(); this.gramajeCubierta.init(); if (this.tipo_impresion_id != 5 && this.tipo_impresion_id != 6 && this.tipo_impresion_id != 7 && this.tipo_impresion_id != 8 && this.tipo_impresion_id != 21) { + + this.sobrecubierta.select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + }); this.papelSobrecubierta.init(); this.gramajeSobrecubierta.init(); this.papelSobrecubierta.onChange(() => this.gramajeSobrecubierta.setVal(0)) @@ -268,6 +275,12 @@ class Comparador { $('.comp_negrohq_items').on('change', this.obtenerComparadorInterior.bind(this)); $('.comp_color_items').on('change', this.obtenerComparadorInterior.bind(this)); $('.comp_colorhq_items').on('change', this.obtenerComparadorInterior.bind(this)); + + $('.comp_cubierta_items').on('change', this.obtenerComparadorExteriores.bind(this)); + if (this.tipo_impresion_id != 5 && this.tipo_impresion_id != 6 && this.tipo_impresion_id != 7 && this.tipo_impresion_id != 8 && this.tipo_impresion_id != 21) { + $('.comp_sobrecubierta_items').on('change', this.obtenerComparadorExteriores.bind(this)); + } + } #changePaginasComparador(element) { @@ -343,6 +356,7 @@ class Comparador { this.cargando = false; this.paginasNegro.trigger('change'); + this.paginasCubierta.trigger('change'); } @@ -580,6 +594,14 @@ class Comparador { updateOpcionesComparador() { + $('.comp_negro_items').off('change'); + $('.comp_negrohq_items').off('change'); + $('.comp_color_items').off('change'); + $('.comp_colorhq_items').off('change'); + + this.tableCompIntPlana.clear().draw(); + this.tableCompIntRotativa.clear().draw(); + const selValue = this.tipo_impresion.val(); const elements_negro = $('.comp-negro-selected'); const elements_negrohq = $('.comp-negrohq-selected'); @@ -597,6 +619,11 @@ class Comparador { $(element).removeClass('d-none'); }); } + else { + Array.from(elements_colorhq).forEach(element => { + $(element).addClass('d-none'); + }); + } Array.from(elements_negrohq).forEach(element => { $(element).removeClass('d-none'); }); @@ -613,11 +640,21 @@ class Comparador { $(element).removeClass('d-none'); }); } + else { + Array.from(elements_color).forEach(element => { + $(element).addClass('d-none'); + }); + } Array.from(elements_negro).forEach(element => { $(element).removeClass('d-none'); }); } + $('.comp_negro_items').on('change', this.obtenerComparadorInterior.bind(this)); + $('.comp_negrohq_items').on('change', this.obtenerComparadorInterior.bind(this)); + $('.comp_color_items').on('change', this.obtenerComparadorInterior.bind(this)); + $('.comp_colorhq_items').on('change', this.obtenerComparadorInterior.bind(this)); + if (selValue.includes('color')) { $('.pos-paginas-color').removeClass('d-none'); } @@ -714,6 +751,7 @@ class Comparador { let papel_generico = {}; let gramaje = {}; let paginasColor = 0; + let paginas = parseInt($('#paginas').val()); if (!$('#papelFormatoPersonalizado').prop('checked')) { const selectedFormat = $('#papelFormatoId').select2('data')[0].text; @@ -780,27 +818,63 @@ class Comparador { }; if (this.tipo_impresion.val().includes('color')) { + if (this.tipo_impresion.val().includes('hq')) { papel_generico.color = { id: this.papelColorhq.getVal(), nombre: this.papelColorhq.getText() }; gramaje.color = this.gramajeColorhq.getVal(); paginasColor = this.paginasColorhq.val(); } - papel_generico.negro = { id: this.papelNegrohq.getVal(), nombre: this.papelNegrohq.getText() }; - gramaje.negro = this.gramajeNegrohq.getVal(); - } - else { - if (this.tipo_impresion.val().includes('hq')) { + else { papel_generico.color = { id: this.papelColor.getVal(), nombre: this.papelColor.getText() }; gramaje.color = this.gramajeColor.getVal(); paginasColor = this.paginasColor.val(); } + + } + if (this.tipo_impresion.val().includes('hq')) { + papel_generico.negro = { id: this.papelNegrohq.getVal(), nombre: this.papelNegrohq.getText() }; + gramaje.negro = this.gramajeNegrohq.getVal(); + } + else { papel_generico.negro = { id: this.papelNegro.getVal(), nombre: this.papelNegro.getText() }; gramaje.negro = this.gramajeNegro.getVal(); } + + } + else if (uso = 'cubierta') { + if (this.papelCubierta.getVal() == 0 || this.papelCubierta.getVal() == null) { + popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador'); + return { error: true, data: {} }; + } + if (this.gramajeCubierta.getVal() == 0 || this.gramajeCubierta.getVal() == null) { + popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador'); + return { error: true, data: {} }; + } + + + papel_generico = { id: this.papelCubierta.getVal(), nombre: this.papelCubierta.getText() }; + gramaje = this.gramajeCubierta.getVal(); + paginas = this.paginasCubierta.select2('data')[0].id + } + + else if (uso = 'sobrecubierta') { + if (this.papelSobrecubierta.getVal() == 0 || this.papelSobrecubierta.getVal() == null) { + popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador'); + return { error: true, data: {} }; + } + if (this.gramajeSobrecubierta.getVal() == 0 || this.gramajeSobrecubierta.getVal() == null) { + popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador'); + return { error: true, data: {} }; + } + + papel_generico = { id: this.papelSobrecubierta.getVal(), nombre: this.papelSobrecubierta.getText() }; + gramaje = this.gramajeSobrecubierta.getVal(); + paginas = 4; + } const datosPedido = { - paginas: $('#paginas').val(), + paginas: paginas, tirada: $('#tirada').val(), merma: $('#merma').val(), ancho: ancho, @@ -826,6 +900,10 @@ class Comparador { isHq: this.tipo_impresion.val().includes('hq'), paginas_color: paginasColor } + // TO-DO + if(uso == 'cubierta'){ + datos.lomoRedondo = false; + } return { error: false, data: datos }; @@ -837,9 +915,10 @@ class Comparador { const self = this; - if (this.cargando) { + if (this.cargando || this.comparadorPlanaRunning) { return } + this.comparadorPlanaRunning = true; if (event.currentTarget.id.includes('Paginas')) { this.#changePaginasComparador(event.currentTarget.id); @@ -848,113 +927,249 @@ class Comparador { this.tableCompIntPlana.clear().draw(); this.tableCompIntRotativa.clear().draw(); this.btnInsertarPlana.addClass('d-none'); + this.btnInsertarRotativa.addClass('d-none'); $('#title_int_rot').html(window.language.Presupuestos.compInteriorRotativa); $('#title_int_plana').html(window.language.Presupuestos.compInteriorPlana); const datosComp = this.getDataForComp('interior'); if (datosComp.error) { + this.comparadorPlanaRunning = false; return; } else { + const isHq = this.tipo_impresion.val().includes('hq'); + const isColor = this.tipo_impresion.val().includes('color'); + + datosComp.data['tipo_maquina'] = 'plana'; datosComp.data[this.csrf_token] = this.csrf_hash; - new Ajax('/presupuestoadmin/comparadorplana', + new Ajax('/presupuestoadmin/comparadorinterior', datosComp.data, {}, (response) => { if (response.data.negro.length > 0) { - const isHq = response.data.negro[0].fields.tipo_linea.includes('hq'); let sorted = response.data.negro.sort( (p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? -1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0); sorted.forEach(function (linea) { if (typeof linea.error == "undefined") - $('#tableCompIntPlana').DataTable().row - .add(self.getRowFromLineaInt(isHq ? 'bnhq' : 'bn', linea)) + self.tableCompIntPlana.row + .add(self.getRowFromLinea(isHq ? 'bnhq' : 'bn', linea)) .draw() }); } if (response.data.color.length > 0) { - const isHq = response.data.color[0].fields.tipo_linea.includes('hq'); let sorted = response.data.color.sort( (p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? -1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0); sorted.forEach(function (linea) { if (typeof linea.error == "undefined") - $('#tableCompIntPlana').DataTable().row - .add(self.getRowFromLineaInt(isHq ? 'colorhq' : 'color', linea)) + self.tableCompIntPlana.row + .add(self.getRowFromLinea(isHq ? 'colorhq' : 'color', linea)) .draw() }); } - this.selectIntLineas(); + + self.selectLineas('plana'); if ($('#tableCompIntPlana').DataTable().rows().count() > 0) { $('#title_int_plana').html(window.language.Presupuestos.compInteriorPlana + ' (' + self.tableCompIntPlana.rows().count() + ')'); $('#insertarPlanaBtn').removeClass('d-none'); } - else{ + else { $('#title_int_plana').html(window.language.Presupuestos.compInteriorPlana); $('#insertarPlanaBtn').addClass('d-none'); } + + // Rotativa + if (!isHq) { + if (!isColor || (isColor && datosComp.data.papel_generico.negro.id == datosComp.data.papel_generico.color.id && + datosComp.data.gramaje.negro == datosComp.data.gramaje.color)) { + + datosComp.data['tipo_maquina'] = 'rotativa'; + datosComp.data.papel_generico.id = datosComp.data.papel_generico.negro.id; + datosComp.data.papel_generico.nombre = datosComp.data.papel_generico.negro.nombre; + datosComp.data.gramaje = datosComp.data.gramaje.negro; + new Ajax('/presupuestoadmin/comparadorinterior', + datosComp.data, + {}, + (response) => { + if (response.data.rotativa.length > 0) { + let sorted = response.data.rotativa.sort( + (p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? + -1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0); + sorted.forEach(function (linea) { + if (typeof linea.error == "undefined") + self.tableCompIntRotativa.row + .add(self.getRowFromLineaRot(linea)) + .draw() + }); + } + self.selectLineas('rotativa'); + if (self.tableCompIntRotativa.rows().count() > 0) { + self.btnInsertarRotativa.removeClass('d-none'); + $('#title_int_rot').html(window.language.Presupuestos.compInteriorRotativa + ' (' + self.tableCompIntRotativa.rows().count() + ')'); + } + else { + $('#title_int_rot').html(window.language.Presupuestos.compInteriorRotativa); + } + + self.comparadorPlanaRunning = false; + }, + (error) => { + console.log(error); + self.comparadorPlanaRunning = false; + } + ).post(); + } + else { + self.comparadorPlanaRunning = false; + } + } + else { + self.comparadorPlanaRunning = false; + } }, (error) => { console.log(error); + self.comparadorPlanaRunning = false; } ).post(); } - /* - elementos = getIDsComparador(is_color, is_hq) - - - if ($('' + elementos.papel).select2('data').length > 0 && - $('' + elementos.gramaje).select2('data').length > 0 && - parseInt($('' + elementos.paginas).val()) >= 0 && - checkDatosPedidoForComp()) { - - - getLineasIntPlana(is_color, is_hq, actualizarLineaPlana).then((result) => { - // Para rotativa, si es color el papel y el gramaje tiene que ser igual - if (!is_color) { - getLineasIntRot(is_hq, actualizarLineaRot); - } - else { - if (!is_hq) { - if ($('#compPapelNegro').select2('data').length > 0 && $('#compPapelColor').select2('data').length > 0 && - $('#compGramajeNegro').select2('data').length > 0 && $('#compGramajeColor').select2('data').length > 0) { - if (($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id && - $('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim())) { - getLineasIntRot(is_hq, actualizarLineaRot); - } - else { - $('#errorComRot').html(''); - } - } - } - } - }); - }*/ + } catch (e) { + console.log(e); + this.comparadorPlanaRunning = false; + } + } + + obtenerComparadorExteriores(event, actualizarLineaPlana = false, actualizarLineaRot = false) { + + try { + + const self = this; + + if (this.cargando) { + return + } + + this.tableCompCubierta.clear().draw(); + this.btnInsertarCubierta.addClass('d-none'); + $('#title_cubierta').html(window.language.Presupuestos.compCubiertaSobrecubierta); + + let datosComp = {}; + datosComp.cubierta = this.getDataForComp('cubierta'); + if (datosComp.cubierta.error) { + return; + } + if (this.tipo_impresion_id != 5 && this.tipo_impresion_id != 6 && this.tipo_impresion_id != 7 && this.tipo_impresion_id != 8 && this.tipo_impresion_id != 21) { + if (this.sobrecubierta.select2('data')[0].id == 1) { + datosComp.sobrecubierta = this.getDataForComp('sobrecubierta'); + if (datosComp.sobrecubierta.error) { + return; + } + } + else{ + datosComp.sobrecubierta = {}; + } + } + else{ + datosComp.sobrecubierta = {}; + } + datosComp.cubierta.data[this.csrf_token] = this.csrf_hash; + if(Object.keys(datosComp.sobrecubierta).length > 0){ + datosComp.sobrecubierta.data[this.csrf_token] = this.csrf_hash; + } + new Ajax('/presupuestoadmin/comparadorexteriores', + { + cubierta: datosComp.cubierta.data, + sobrecubierta: datosComp.sobrecubierta.data + }, + {}, + (response) => { + if (response.data.cubierta.length > 0) { + let sorted = response.data.cubierta.sort( + (p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? + -1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0); + sorted.forEach(function (linea) { + if (typeof linea.error == "undefined") + self.tableCompCubierta.row + add(self.getRowFromLinea('cubierta', linea)) + .draw() + }); + } + if (response.data.sobrecubierta) { + let sorted = response.data.sobrecubierta.sort( + (p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? + -1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0); + sorted.forEach(function (linea) { + if (typeof linea.error == "undefined") + self.tableCompCubierta.row + .add(self.getRowFromLinea('sobrecubierta', linea)) + .draw() + }); + } + + self.selectLineas('cubierta'); + if (self.tableCompCubierta.rows().count() > 0) { + $('#title_cubierta').html(window.language.Presupuestos.compCubiertaSobrecubierta + + (' (' + self.tableCompCubierta.rows().count() + ')')); + self.btnInsertarCubierta.removeClass('d-none'); + } + else { + $('#title_cubierta').html(window.language.Presupuestos.compCubiertaSobrecubierta); + self.btnInsertarCubierta.addClass('d-none'); + } + }, + (error) => { + console.log(error); + } + ).post(); + } catch (e) { console.log(e) } - - } - selectIntLineas() { - var negro_selected = false; - var color_selected = false; - $("#tableCompIntPlana").DataTable().rows('.selected').deselect(); - $("#tableCompIntPlana").DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) { - if (!negro_selected && $('#tableCompIntPlana').DataTable().cell(rowIdx, 0).data().includes('bn')) { - $("#tableCompIntPlana").DataTable().row(rowIdx).nodes().to$().toggleClass('selected'); - negro_selected = true; - } - if (!color_selected && $('#tableCompIntPlana').DataTable().cell(rowIdx, 0).data().includes('color')) { - $("#tableCompIntPlana").DataTable().row(rowIdx).nodes().to$().toggleClass('selected'); - color_selected = true; + + selectLineas(tabla) { + + let table = this.tableCompIntPlana; + let select1 = false; + let select2 = false; + let tipo1 = 'bn'; + let tipo2 = 'color'; + let total_label = '#total_comp_plana' + switch (tabla) { + case 'cubierta': + table = this.tableCompCubierta; + tipo1 = 'lp_cubierta'; + tipo2 = 'lp_sobrecubierta'; + total_label = '#total_comp_cubierta'; + break; + + case 'rotativa': + table = this.tableCompIntRotativa; + tipo1 = 'rotativa'; + total_label = '#total_comp_rot'; + break; + + default: + break; + + } + + table.rows('.selected').deselect(); + table.rows().every(function (rowIdx, tableLoop, rowLoop) { + if (!select1 && table.cell(rowIdx, 0).data().includes(tipo1)) { + table.row(rowIdx).nodes().to$().toggleClass('selected'); + select1 = true; } + if (tabla == 'plana' || tabla == 'cubierta') + if (!select2 && table.cell(rowIdx, 0).data().includes(tipo2)) { + table.row(rowIdx).nodes().to$().toggleClass('selected'); + select2 = true; + } }); - var table = $("#tableCompIntPlana").DataTable(); var rows = table.rows('.selected').indexes(); var data = table.rows(rows).data(); @@ -965,10 +1180,10 @@ class Comparador { value_total += parseFloat(data[i]['total']) } - $('#total_comp_plana').html(value_total.toFixed(2)); + $(total_label).html(value_total.toFixed(2)); } - getRowFromLineaInt(tipo, linea) { + getRowFromLinea(tipo, linea) { const precio_impresion = isNaN(parseFloat(linea.fields.precio_impresion_horas + linea.fields.margen_impresion_horas + linea.fields.precio_click_pedido)) ? "" : parseFloat(linea.fields.precio_impresion_horas + linea.fields.margen_impresion_horas + linea.fields.precio_click_pedido).toFixed(2); @@ -1002,25 +1217,165 @@ class Comparador { data['paginas_impresion'] = linea.fields.paginas_impresion; return data; } + + getRowFromLineaRot(linea) { + + const precio_impresion = isNaN(parseFloat(linea.fields.precio_impresion_horas + linea.fields.precio_click_pedido)) ? "" : + parseFloat(linea.fields.precio_impresion_horas + linea.fields.precio_click_pedido).toFixed(2); + + return { + 'tipo': 'rotativa', + 'paginas': linea.fields.paginas, + 'papel': linea.fields.papel_generico, + 'gramaje': linea.fields.gramaje, + 'marca': linea.fields.papel_impresion, + 'aFavorFibra': linea.fields.a_favor_fibra == 1 ? 'si' : 'no', + 'maquina': linea.fields.maquina, + 'numeroPliegos': isNaN(parseFloat(linea.fields.pliegos_libro)) ? "" : parseFloat(linea.fields.pliegos_libro).toFixed(2), + 'pliegosPedido': isNaN(parseFloat(linea.fields.pliegos_pedido)) ? "" : parseFloat(linea.fields.pliegos_pedido).toFixed(2), + 'precioPliego': isNaN(parseFloat(linea.fields.precios_pliegos)) ? "" : parseFloat(linea.fields.precios_pliegos).toFixed(6), + 'libro': isNaN(parseFloat(linea.fields.precio_libro)) ? "" : parseFloat(linea.fields.precio_libro).toFixed(2), + 'totalPapelPedido': isNaN(parseFloat(linea.fields.precio_pedido)) ? "" : parseFloat(linea.fields.precio_pedido).toFixed(2), + 'lomo': isNaN(parseFloat(linea.fields.mano)) ? "" : parseFloat(linea.fields.mano).toFixed(2), + 'peso': isNaN(parseFloat(linea.fields.peso)) ? "" : parseFloat(linea.fields.peso).toFixed(2), + 'horasMaquina': isNaN(parseFloat(linea.fields.horas_maquina)) ? "" : parseFloat(linea.fields.horas_maquina).toFixed(2), + 'precioImpresion': precio_impresion, + 'precioPagNegro': isNaN(parseFloat(linea.fields.precio_pagina_negro)) ? "" : parseFloat(linea.fields.precio_pagina_negro).toFixed(6), + 'precioPagColor': isNaN(parseFloat(linea.fields.precio_pagina_color)) ? "" : parseFloat(linea.fields.precio_pagina_color).toFixed(6), + 'totalTinta': isNaN(parseFloat(linea.fields.precio_tinta)) ? "" : parseFloat(linea.fields.precio_tinta).toFixed(2), + 'totalCorte': isNaN(parseFloat(linea.fields.total_corte)) ? "" : parseFloat(linea.fields.total_corte).toFixed(2), + 'total': isNaN(parseFloat(linea.fields.total_impresion)) ? "" : (parseFloat(linea.fields.total_impresion)).toFixed(2), + 'maquinaId': linea.fields.maquina_id, + 'maquinaVelocidad': linea.fields.maquina_velocidad, + 'tiempoMaquina': linea.fields.tiempo_maquina, + 'papelGenericoId': linea.fields.papel_generico_id, + 'papelImpresionId': linea.fields.papel_impresion_id, + 'paginasColor': linea.fields.paginas_color, + 'tarifa_impresion_id': linea.fields.tarifa_impresion_id, + } + } + + generateCompJSON() { + + data = {} + + if ($('#tipoImpresion').select2('data')[0].id == 'negro' || $('#tipoImpresion').select2('data')[0].id == 'color') { + try { + bn_obj = { + "bn": { + 'paginas': $('#compPaginasNegro').val(), + 'papel_id': $('#compPapelNegro').select2('data')[0].id, + 'gramaje': $('#compGramajeNegro').select2('data')[0].text.trim(), + } + } + } + catch (e) { + bn_obj = {} + } + $.extend(data, bn_obj); + } + + if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' || $('#tipoImpresion').select2('data')[0].id == 'colorhq') { + try { + bnhq_obj = { + "bnhq": { + 'paginas': $('#compPaginasNegrohq').val(), + 'papel_id': $('#compPapelNegrohq').select2('data')[0].id, + 'gramaje': $('#compGramajeNegrohq').select2('data')[0].text.trim(), + } + } + } + catch (e) { + bnhq_obj = {} + } + $.extend(data, bnhq_obj); + } + + if ($('#tipoImpresion').select2('data')[0].id == 'color') { + try { + color_obj = { + "color": { + 'paginas': $('#compPaginasColor').val(), + 'papel_id': $('#compPapelColor').select2('data')[0].id, + 'gramaje': $('#compGramajeColor').select2('data')[0].text.trim(), + }, + } + } + catch (e) { + color_obj = {} + } + $.extend(data, color_obj); + + } + + + if ($('#tipoImpresion').select2('data')[0].id == 'colorhq') { + try { + colorhq_obj = { + "colorhq": { + 'paginas': $('#compPaginasColorhq').val(), + 'papel_id': $('#compPapelColorhq').select2('data')[0].id, + 'gramaje': $('#compGramajeColorhq').select2('data')[0].text.trim(), + }, + } + } + catch (e) { + colorhq_obj = {} + } + $.extend(data, colorhq_obj); + } + + + try { + cubierta_obj = { + "cubierta": { + 'paginas': $('#compCarasCubierta option:selected').val(), + 'papel_id': $('#compPapelCubierta').select2('data')[0].id, + 'gramaje': $('#compGramajeCubierta').select2('data')[0].text.trim(), + }, + } + } + catch (e) { + cubierta_obj = {} + } + $.extend(data, cubierta_obj); + + try { + sobrecubierta_obj = { + "sobrecubierta": { + 'imprimir': $('#compSobrecubierta option:selected').val(), + 'papel_id': $('#compPapelSobrecubierta').select2('data')[0].id, + 'gramaje': $('#compGramajeSobrecubierta').select2('data')[0].text.trim(), + }, + } + } + catch (e) { + sobrecubierta_obj = {} + } + $.extend(data, sobrecubierta_obj); + + if ($('#compCarasGuardas').length > 0) { + try { + guardas_obj = { + "guardas": { + 'paginas_impresion': $('#compCarasGuardas option:selected').val(), + 'papel_id': $('#compPapelGuardas').select2('data')[0].id, + }, + } + } + catch (e) { + guardas_obj = {} + } + $.extend(data, guardas_obj); + + } + + data_str = JSON.stringify(data) + $('#comparador_json_data').val(data_str) + } } /* - $('#compSobrecubierta').on('change', function(){ - if ($('#compSobrecubierta').val()==1){ - value = false - } - else{ - value = 'disabled' - $('#compPapelSobrecubierta').val(0) - $('#compGramajeSobrecubierta').val('') - $('#compGramajeSobrecubierta').select2("destroy") - $('#compGramajeSobrecubierta').select2({allowClear: false, minimumResultsForSearch: Infinity}) - - } - $('#compPapelSobrecubierta').prop('disabled', value); - $('#compGramajeSobrecubierta').prop('disabled', value); - }) - From 77db3104d3f02010f7e8fae75d4e637606524166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Thu, 19 Dec 2024 11:12:40 +0100 Subject: [PATCH 08/89] comparador cubierta y sobrecubierta terminado --- ci4/app/Config/RBAC/permissionMatrix.php | 79 +++++-------------- ci4/app/Config/RBAC/permissions.php | 28 ++----- .../Presupuestos/Presupuestoadmin.php | 29 ++++--- ci4/app/Language/es/RolesPermisos.php | 2 +- .../Services/PresupuestoClienteService.php | 2 +- .../presupuestoAdmin/sections/comparador.js | 68 ++++++++++++---- 6 files changed, 96 insertions(+), 112 deletions(-) diff --git a/ci4/app/Config/RBAC/permissionMatrix.php b/ci4/app/Config/RBAC/permissionMatrix.php index cb1c244e..f720b8cb 100644 --- a/ci4/app/Config/RBAC/permissionMatrix.php +++ b/ci4/app/Config/RBAC/permissionMatrix.php @@ -9,18 +9,18 @@ const SK_PERMISSION_MATRIX = [ "plantilla-tarifa.edit", "plantilla-tarifa.delete", "plantilla-tarifa.menu", - "perfil.create", - "perfil.edit", - "perfil.delete", - "perfil.menu", "presupuesto.create", "presupuesto.edit", "presupuesto.delete", "presupuesto.menu", - "presupuesto-cliente.create", - "presupuesto-cliente.edit", - "presupuesto-cliente.delete", - "presupuesto-cliente.menu", + "pedidos-activos.view", + "pedidos-activos.menu", + "pedidos-finalizados.view", + "pedidos-finalizados.menu", + "pedidos-cancelados.view", + "pedidos-cancelados.menu", + "pedidos-todos.view", + "pedidos-todos.menu", "tarifa-preimpresion.create", "tarifa-preimpresion.edit", "tarifa-preimpresion.delete", @@ -41,10 +41,6 @@ const SK_PERMISSION_MATRIX = [ "tarifa-envio.edit", "tarifa-envio.delete", "tarifa-envio.menu", - "tarifa-extra.create", - "tarifa-extra.edit", - "tarifa-extra.delete", - "tarifa-extra.menu", "proveedores.create", "proveedores.edit", "proveedores.delete", @@ -61,10 +57,6 @@ const SK_PERMISSION_MATRIX = [ "paises.edit", "paises.delete", "paises.menu", - "formas-pago.create", - "formas-pago.edit", - "formas-pago.delete", - "formas-pago.menu", "maquinas.create", "maquinas.edit", "maquinas.delete", @@ -89,36 +81,12 @@ const SK_PERMISSION_MATRIX = [ "roles-permisos.edit", "roles-permisos.delete", "roles-permisos.menu", - "ubicaciones.create", - "ubicaciones.edit", - "ubicaciones.delete", - "ubicaciones.menu", - "series-facturas.create", - "series-facturas.edit", - "series-facturas.delete", - "series-facturas.menu", ], "cliente-admin" => [ - "perfil.edit", - "perfil.menu", - "direcciones.create", - "direcciones.edit", - "direcciones.delete", - "direcciones.menu", - "presupuesto-cliente.create", - "presupuesto-cliente.edit", - "presupuesto-cliente.delete", - "presupuesto-cliente.menu", + "pedidos-activos.view", + "pedidos-activos.menu", ], "cliente-editor" => [ - "perfil.create", - "perfil.edit", - "perfil.delete", - "perfil.menu", - "direcciones.create", - "direcciones.edit", - "direcciones.delete", - "direcciones.menu", "presupuesto-cliente.create", "presupuesto-cliente.edit", "presupuesto-cliente.delete", @@ -129,8 +97,15 @@ const SK_PERMISSION_MATRIX = [ "token.menu", ], "produccion" => [ - "token.token", - "token.menu", + "clientes.create", + "clientes.edit", + "clientes.menu", + "direcciones.create", + "direcciones.edit", + "direcciones.menu", + "presupuesto.create", + "presupuesto.edit", + "presupuesto.menu", ], "maquina" => [ "token.token", @@ -163,10 +138,6 @@ const SK_PERMISSION_MATRIX = [ "plantilla-tarifa.edit", "plantilla-tarifa.delete", "plantilla-tarifa.menu", - "perfil.create", - "perfil.edit", - "perfil.delete", - "perfil.menu", "presupuesto.create", "presupuesto.edit", "presupuesto.delete", @@ -195,10 +166,6 @@ const SK_PERMISSION_MATRIX = [ "tarifa-envio.edit", "tarifa-envio.delete", "tarifa-envio.menu", - "tarifa-extra.create", - "tarifa-extra.edit", - "tarifa-extra.delete", - "tarifa-extra.menu", "proveedores.create", "proveedores.edit", "proveedores.delete", @@ -239,13 +206,5 @@ const SK_PERMISSION_MATRIX = [ "roles-permisos.edit", "roles-permisos.delete", "roles-permisos.menu", - "ubicaciones.create", - "ubicaciones.edit", - "ubicaciones.delete", - "ubicaciones.menu", - "series-facturas.create", - "series-facturas.edit", - "series-facturas.delete", - "series-facturas.menu", ], ]; diff --git a/ci4/app/Config/RBAC/permissions.php b/ci4/app/Config/RBAC/permissions.php index adabcaf4..014dbd2a 100644 --- a/ci4/app/Config/RBAC/permissions.php +++ b/ci4/app/Config/RBAC/permissions.php @@ -9,10 +9,6 @@ const SK_PERMISSIONS = [ 'plantilla-tarifa.edit' => 'Can edit', 'plantilla-tarifa.delete' => 'Can delete', 'plantilla-tarifa.menu' => 'Menu shall be visualize', - 'perfil.create' => 'Can create', - 'perfil.edit' => 'Can edit', - 'perfil.delete' => 'Can delete', - 'perfil.menu' => 'Menu shall be visualize', 'direcciones.create' => 'Can create', 'direcciones.edit' => 'Can edit', 'direcciones.delete' => 'Can delete', @@ -25,6 +21,14 @@ const SK_PERMISSIONS = [ 'presupuesto-cliente.edit' => 'Can edit', 'presupuesto-cliente.delete' => 'Can delete', 'presupuesto-cliente.menu' => 'Menu shall be visualize', + 'pedidos-activos.view' => 'Can view', + 'pedidos-activos.menu' => 'Menu shall be visualize', + 'pedidos-finalizados.view' => 'Can view', + 'pedidos-finalizados.menu' => 'Menu shall be visualize', + 'pedidos-cancelados.view' => 'Can view', + 'pedidos-cancelados.menu' => 'Menu shall be visualize', + 'pedidos-todos.view' => 'Can view', + 'pedidos-todos.menu' => 'Menu shall be visualize', 'tarifa-preimpresion.create' => 'Can create', 'tarifa-preimpresion.edit' => 'Can edit', 'tarifa-preimpresion.delete' => 'Can delete', @@ -45,10 +49,6 @@ const SK_PERMISSIONS = [ 'tarifa-envio.edit' => 'Can edit', 'tarifa-envio.delete' => 'Can delete', 'tarifa-envio.menu' => 'Menu shall be visualize', - 'tarifa-extra.create' => 'Can create', - 'tarifa-extra.edit' => 'Can edit', - 'tarifa-extra.delete' => 'Can delete', - 'tarifa-extra.menu' => 'Menu shall be visualize', 'proveedores.create' => 'Can create', 'proveedores.edit' => 'Can edit', 'proveedores.delete' => 'Can delete', @@ -65,10 +65,6 @@ const SK_PERMISSIONS = [ 'paises.edit' => 'Can edit', 'paises.delete' => 'Can delete', 'paises.menu' => 'Menu shall be visualize', - 'formas-pago.create' => 'Can create', - 'formas-pago.edit' => 'Can edit', - 'formas-pago.delete' => 'Can delete', - 'formas-pago.menu' => 'Menu shall be visualize', 'maquinas.create' => 'Can create', 'maquinas.edit' => 'Can edit', 'maquinas.delete' => 'Can delete', @@ -93,12 +89,4 @@ const SK_PERMISSIONS = [ 'roles-permisos.edit' => 'Can edit', 'roles-permisos.delete' => 'Can delete', 'roles-permisos.menu' => 'Menu shall be visualize', - 'ubicaciones.create' => 'Can create', - 'ubicaciones.edit' => 'Can edit', - 'ubicaciones.delete' => 'Can delete', - 'ubicaciones.menu' => 'Menu shall be visualize', - 'series-facturas.create' => 'Can create', - 'series-facturas.edit' => 'Can edit', - 'series-facturas.delete' => 'Can delete', - 'series-facturas.menu' => 'Menu shall be visualize', ]; diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index cd73620d..d8f4ddad 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -660,7 +660,9 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController public function obtenerComparadorExteriores() { - $resultado = []; + $lineasCubierta = null; + $lineasSobrecubierta = null; + if ($this->request->isAJAX()) { $cubierta = $this->request->getPost('cubierta') ?? false; @@ -676,9 +678,9 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $datosPedido = $cubierta['datosPedido']; $papel_generico = $cubierta['papel_generico']; $gramaje = $cubierta['gramaje']; - $paginas_color = $this->request->getPost('paginas_color') ?? 0; - $tipo_impresion_id = $this->request->getPost('tipo_impresion_id'); - $uso = $this->request->getPost('uso'); + $paginas_color = $cubierta['datosPedido']['paginas'] ?? 0; + $tipo_impresion_id = $cubierta['tipo_impresion_id']; + $uso = $cubierta['uso']; $lomoRedondo = $cubierta['lomoRedondo'] ?? false; $data = array( @@ -693,8 +695,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController 'uso' => $uso, 'lomoRedondo' => $lomoRedondo ); - $lineas = PresupuestoClienteService::obtenerCubierta($data, true); - $resultado['cubierta'] = $lineas; + $lineasCubierta = PresupuestoClienteService::obtenerCubierta($data, true); } if ($sobrecubierta) { @@ -703,9 +704,9 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $datosPedido = $sobrecubierta['datosPedido']; $papel_generico = $sobrecubierta['papel_generico']; $gramaje = $sobrecubierta['gramaje']; - $paginas_color = $this->request->getPost('paginas_color') ?? 0; - $tipo_impresion_id = $this->request->getPost('tipo_impresion_id'); - $uso = $this->request->getPost('uso'); + $paginas_color = $sobrecubierta['datosPedido']['paginas'] ?? 0; + $tipo_impresion_id = $sobrecubierta['tipo_impresion_id']; + $uso = $sobrecubierta['uso']; $data = array( 'cliente_id' => $cliente_id, @@ -718,14 +719,16 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController 'tipo_impresion_id' => $tipo_impresion_id, 'uso' => $uso ); - $lineas = PresupuestoClienteService::obtenerSobrecubierta($data, true); - $resultado['sobrecubierta'] = $lineas; + $lineasSobrecubierta = PresupuestoClienteService::obtenerSobrecubierta($data, true); } - + return $this->respond( [ 'status' => 1, - 'data' => $resultado + 'data' => (object) array( + 'cubierta' => $lineasCubierta, + 'sobrecubierta' => $lineasSobrecubierta + ) ] ); } else { diff --git a/ci4/app/Language/es/RolesPermisos.php b/ci4/app/Language/es/RolesPermisos.php index 0df0eed0..cef7824a 100644 --- a/ci4/app/Language/es/RolesPermisos.php +++ b/ci4/app/Language/es/RolesPermisos.php @@ -30,7 +30,7 @@ return [ 'perfilSection' => 'Perfil', 'direccionesSection' => 'Direcciones', 'presupuestoSection' => 'Presupuestos', - 'presupuestoClienteSection' => 'Presupuestos', + 'presupuestoClienteSection' => 'Presupuestos cliente', 'pedidosActivosSection' => 'Activos', 'pedidosFinalizadosSection' => 'Finalizados', 'pedidosCanceladosSection' => 'Cancelados', diff --git a/ci4/app/Services/PresupuestoClienteService.php b/ci4/app/Services/PresupuestoClienteService.php index 8064173f..443ac44e 100644 --- a/ci4/app/Services/PresupuestoClienteService.php +++ b/ci4/app/Services/PresupuestoClienteService.php @@ -165,7 +165,7 @@ class PresupuestoClienteService extends BaseService $lineas_sobrecubierta = array_values(array_unique($lineas_sobrecubierta, SORT_REGULAR)); return[ - 'cubierta' => $lineas_sobrecubierta + 'sobrecubierta' => $lineas_sobrecubierta ]; } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js index 005a9395..25005b4b 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js @@ -240,6 +240,7 @@ class Comparador { this.papelColor.onChange(() => this.gramajeColor.setVal(0)) this.papelColorhq.onChange(() => this.gramajeColorhq.setVal(0)) this.papelCubierta.onChange(() => this.gramajeCubierta.setVal(0)) + this.papelCubierta.onChange(() => this.gramajeSobrecubierta.setVal(0)) this.tipo_impresion.select2({ @@ -841,7 +842,7 @@ class Comparador { } } - else if (uso = 'cubierta') { + else if (uso == 'cubierta') { if (this.papelCubierta.getVal() == 0 || this.papelCubierta.getVal() == null) { popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador'); return { error: true, data: {} }; @@ -857,7 +858,7 @@ class Comparador { paginas = this.paginasCubierta.select2('data')[0].id } - else if (uso = 'sobrecubierta') { + else if (uso == 'sobrecubierta') { if (this.papelSobrecubierta.getVal() == 0 || this.papelSobrecubierta.getVal() == null) { popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador'); return { error: true, data: {} }; @@ -900,15 +901,47 @@ class Comparador { isHq: this.tipo_impresion.val().includes('hq'), paginas_color: paginasColor } - // TO-DO - if(uso == 'cubierta'){ + + if (uso == 'cubierta') { + datos.datosPedido.lomo = this.getLomoLineasPresupuesto('interior'); + datos.datosPedido.solapas = $('#solapas').prop('checked') ? 1 : 0; + datos.datosPedido.solapas_ancho = $('#solapas').prop('checked') ? parseInt($('#solapas_ancho').val()) : 0; + // TO-DO datos.lomoRedondo = false; } + else if (uso == 'sobrecubierta') { + datos.datosPedido.lomo = this.getLomoLineasPresupuesto() + this.getLomoLineasPresupuesto('cubierta'); + datos.datosPedido.solapas = $('#solapas_sobrecubierta').prop('checked') ? 1 : 0; + datos.datosPedido.solapas_ancho = $('#solapas_sobrecubierta').prop('checked') ? parseInt($('#solapas_ancho_sobrecubierta').val()) : 0; + } return { error: false, data: datos }; } + getLomoLineasPresupuesto(tipo_lomo='interior') { + + let lomoTotal = 0 + try { + $('#tableLineasPresupuesto').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) { + var rowData = this.data(); + if (tipo_lomo = 'interior') { + if (rowData.row_id != 'lp_cubierta' && rowData.tipo != 'lp_sobrecubierta') + lomoTotal += parseFloat(rowData.lomo); + } + else if (tipo_lomo == 'cubierta') { + if (rowData.row_id == 'lp_cubierta') + lomoTotal += parseFloat(rowData.lomo); + } + }) + } + catch (error) { + lomoTotal = 0; + } + $('#lomo_cubierta').val(lomoTotal); + return lomoTotal; + } + obtenerComparadorInterior(event, actualizarLineaPlana = false, actualizarLineaRot = false) { try { @@ -1067,15 +1100,15 @@ class Comparador { return; } } - else{ + else { datosComp.sobrecubierta = {}; } } - else{ + else { datosComp.sobrecubierta = {}; } datosComp.cubierta.data[this.csrf_token] = this.csrf_hash; - if(Object.keys(datosComp.sobrecubierta).length > 0){ + if (Object.keys(datosComp.sobrecubierta).length > 0) { datosComp.sobrecubierta.data[this.csrf_token] = this.csrf_hash; } new Ajax('/presupuestoadmin/comparadorexteriores', @@ -1085,22 +1118,23 @@ class Comparador { }, {}, (response) => { - if (response.data.cubierta.length > 0) { - let sorted = response.data.cubierta.sort( + if (response.data.cubierta && Object.keys(response.data.cubierta).length > 0) { + let sorted = Object.values(response.data.cubierta).sort( (p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? -1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0); - sorted.forEach(function (linea) { + + sorted[0].forEach(function (linea) { if (typeof linea.error == "undefined") self.tableCompCubierta.row - add(self.getRowFromLinea('cubierta', linea)) - .draw() + .add(self.getRowFromLinea('cubierta', linea)) + .draw(); }); } - if (response.data.sobrecubierta) { - let sorted = response.data.sobrecubierta.sort( + if (response.data.sobrecubierta && Object.keys(response.data.sobrecubierta).length > 0) { + let sorted = Object.values(response.data.sobrecubierta).sort( (p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? -1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0); - sorted.forEach(function (linea) { + sorted[0].forEach(function (linea) { if (typeof linea.error == "undefined") self.tableCompCubierta.row .add(self.getRowFromLinea('sobrecubierta', linea)) @@ -1141,8 +1175,8 @@ class Comparador { switch (tabla) { case 'cubierta': table = this.tableCompCubierta; - tipo1 = 'lp_cubierta'; - tipo2 = 'lp_sobrecubierta'; + tipo1 = 'cubierta'; + tipo2 = 'sobrecubierta'; total_label = '#total_comp_cubierta'; break; From c3098b054e7a9e135eecd28d10156001e168014e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Thu, 19 Dec 2024 12:54:16 +0100 Subject: [PATCH 09/89] trabajando en lomo redondo --- ci4/app/Language/es/Presupuestos.php | 1 + .../admin/_datosPresupuestoClienteItems.php | 741 ++++++++++++------ 2 files changed, 506 insertions(+), 236 deletions(-) diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 59d13387..e7077fa8 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -143,6 +143,7 @@ return [ 'libro' => 'Libro', 'totalPapelPedido' => 'Papel pedido', 'lomo' => 'Lomo', + 'lomoRedondo' => 'Lomo redondo', 'peso' => 'Peso', 'click' => 'Click', 'totalClicks' => 'Total clicks', diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php index f17fa7a0..9f5a062e 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php @@ -1,38 +1,45 @@

-

-
+
- +
-
+
+ +
- + - - - @@ -45,7 +52,9 @@
-
+
+ +
@@ -54,13 +63,19 @@

-

+

+ +

-

+

+ +

-

+

+ +


@@ -71,17 +86,22 @@
-

+

+ +

- +
-
-
@@ -92,17 +112,22 @@
-

+

+ +

- +
-
-
@@ -113,17 +138,22 @@
-

+

+ +

- +
-
-
@@ -134,17 +164,22 @@
-

+

+ +

- +
-
-
@@ -155,98 +190,154 @@
-

-
+

+ +

+
-
- + +
+ +
+ +
+ + +
+ +
+
+ + +
+ +
+
+
+
+ + +
+
+

+ +

+
+
+ +
+
+
-

- - -
-
-

-
-
- -
-
- -
-
- -
-
-
-
-
- -
-
-

-
-
- -
-
- -
-
- -
-
-
-
+ +
+
+

+ +

+
+ +
+
+ +
+
+ +
+
+
+
+
-
+
+ +
@@ -256,7 +347,9 @@ - +
@@ -264,12 +357,15 @@ - +
-

+

+ +

@@ -278,52 +374,93 @@

-

-
+
- +
- - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
: 0.00 + + : + + 0.00
-
- - +
@@ -335,39 +472,87 @@

-

-
+
- +
- - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + @@ -375,17 +560,20 @@ - - + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
:0.00 + + : + 0.00 +
-
-
@@ -397,50 +585,91 @@

-

-
+
- +
- - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
: 0.00 + + : + + 0.00
-
@@ -450,69 +679,109 @@
- -
-
-

- -

+ +
+
+

+ +

-
-
+
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
: 0.00
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + : + + 0.00
-
- - -
+
+
+
- - +
+ +
-
- +
\ No newline at end of file From 1ccade47a3736f0e4515c63b91f686932421e911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Fri, 27 Dec 2024 18:10:35 +0100 Subject: [PATCH 10/89] trabajando en lineas presupuesto --- ci4/app/Config/Routes.php | 1 + .../Presupuestos/Presupuestoadmin.php | 62 +- .../Presupuestos/Presupuestocliente.php | 12 +- .../Services/PresupuestoClienteService.php | 10 +- .../admin/_datosPresupuestoClienteItems.php | 65 +- .../admin/_lineasPresupuestoItems.js | 277 +------ .../form/presupuestos/admin/comparador.js | 49 -- .../presupuestoAdmin/presupuestoAdminEdit.js | 10 +- .../presupuestoAdmin/sections/comparador.js | 549 ++++---------- .../presupuestoAdmin/sections/datosLibro.js | 2 +- .../sections/lineasPresupuesto.js | 689 ++++++++++++++++++ .../presupuestoCliente/presupuestoCliente.js | 14 +- 12 files changed, 974 insertions(+), 766 deletions(-) delete mode 100644 ci4/app/Views/themes/vuexy/form/presupuestos/admin/comparador.js create mode 100644 httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index b4171b03..37d0bb7c 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -582,6 +582,7 @@ $routes->group('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos $routes->get('cargar/(:any)', 'Presupuestoadmin::cargar/$1'); $routes->post('comparadorinterior', 'Presupuestoadmin::obtenerComparadorInterior'); $routes->post('comparadorexteriores', 'Presupuestoadmin::obtenerComparadorExteriores'); + $routes->post('comparadorguardas', 'Presupuestoadmin::obtenerComparadorGuardas'); $routes->get('papelgenerico', 'Presupuestoadmin::getPapelGenerico'); $routes->get('papelgramaje', 'Presupuestoadmin::getGramaje'); }); diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index 5b3d4b82..b436fe5c 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -538,6 +538,8 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $item['papel_nombre'] = $modelPapelGenerico->getNombre($item['papel_id'])['nombre']; } $data['comparador']['posPagColor'] = $presupuesto->comp_pos_paginas_color; + $data['comparador']['lomoRedondo'] = $presupuesto->lomo_redondo; + $data['comparador']['cabezada'] = $presupuesto->cabezada; /* @@ -689,8 +691,8 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController 'papel_generico' => $papel_generico, 'gramaje' => $gramaje, 'paginas_color' => $paginas_color, - 'isColor' => $isColor, - 'isHq' => $isHq, + 'isColor' => 1, // cubierta y sobre cubierta colorhq + 'isHq' => 1, // cubierta y sobre cubierta colorhq 'tipo_impresion_id' => $tipo_impresion_id, 'uso' => $uso, 'lomoRedondo' => $lomoRedondo @@ -714,8 +716,8 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController 'papel_generico' => $papel_generico, 'gramaje' => $gramaje, 'paginas_color' => $paginas_color, - 'isColor' => $isColor, - 'isHq' => $isHq, + 'isColor' => 1, // cubierta y sobre cubierta colorhq + 'isHq' => 1, // cubierta y sobre cubierta colorhq 'tipo_impresion_id' => $tipo_impresion_id, 'uso' => $uso ); @@ -737,6 +739,58 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController } + public function obtenerComparadorGuardas() + { + + if ($this->request->isAJAX()) { + + $cliente_id = $this->request->getPost('cliente_id'); + $datosPedido = $this->request->getPost('datosPedido'); + $papel_generico = $this->request->getPost('papel_generico'); + $gramaje = $this->request->getPost('gramaje'); + $paginas_color = $this->request->getPost('paginas_color'); + $isColor = $this->request->getPost('isColor'); + $isHq = $this->request->getPost('isHq'); + $tipo_impresion_id = $this->request->getPost('tipo_impresion_id'); + $uso = $this->request->getPost('uso'); + + // Para el caso de Fresado y Cosido tapa dura, las guardas son un diptico + // y hay que imprimirlas como "cosido" (dos hojas pegadas). En el caso de espiral + // o wire-o tapa dura, las guardas se imprimen como hojas sueltas + if ($tipo_impresion_id == 1 || $tipo_impresion_id == 3) { + $datosPedido['isCosido'] = true; + } else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) { + $datosPedido['isCosido'] = false; + } + + $datosPedido['paginas_impresion'] = $datosPedido['paginas']; + + $data = array( + 'cliente_id' => $cliente_id, + 'datosPedido' => (object) $datosPedido, + 'papel_generico' => $papel_generico, + 'gramaje' => $gramaje, + 'papelInteriorDiferente' => true, + 'paginas_color' => $paginas_color, + 'isColor' => $isColor, + 'isHq' => $isHq, + 'tipo_impresion_id' => $tipo_impresion_id, + 'uso' => $uso + ); + + $lineas = PresupuestoClienteService::obtenerGuardas($data, true); + return $this->respond( + [ + 'status' => 1, + 'data' => $lineas + ] + ); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function datatable() { if ($this->request->isAJAX()) { diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index 3effc193..253ce34d 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -1205,9 +1205,17 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $data['datosGenerales']['retractilado5'] = $presupuesto->retractilado5; $datos_papel = $this->obtenerDatosPapel($presupuesto->id); - $data['interior'] = $datos_papel['interior'] ? $datos_papel['interior'] : []; + if (array_key_exists('interior', $datos_papel)) { + $data['interior'] = $datos_papel['interior']; + } else { + $data['interior'] = []; + } - $data['cubierta'] = $datos_papel['cubierta'] ? $datos_papel['cubierta'] : []; + if (array_key_exists('cubierta', $datos_papel)) { + $data['cubierta'] = $datos_papel['cubierta']; + } else { + $data['cubierta'] = []; + } $data['cubierta']['tapa'] = $this->obtenerTipoTapa($presupuesto->tipo_impresion_id ?? null); $data['cubierta']['lomoRedondo'] = $presupuesto->lomo_redondo ? 1 : 0; $data['cubierta']['solapas'] = $presupuesto->solapas ? 1 : 0; diff --git a/ci4/app/Services/PresupuestoClienteService.php b/ci4/app/Services/PresupuestoClienteService.php index a4a3c491..17c4acc8 100644 --- a/ci4/app/Services/PresupuestoClienteService.php +++ b/ci4/app/Services/PresupuestoClienteService.php @@ -186,7 +186,7 @@ class PresupuestoClienteService extends BaseService return $lineas_sobrecubierta; } - public static function obtenerGuardas($data) + public static function obtenerGuardas($data, $return_raw=false) { $uso = $data['uso']; @@ -220,6 +220,14 @@ class PresupuestoClienteService extends BaseService } if (count($lineas_guardas) > 0) { + if($return_raw){ + $lineas_guardas = array_values(array_unique($lineas_guardas, SORT_REGULAR)); + + return[ + 'guardas' => $lineas_guardas + ]; + } + usort( $lineas_guardas, function ($a, $b) { diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php index 9f5a062e..eb45cbe1 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php @@ -222,27 +222,46 @@
-
+
+
-
-
- - -
+
+ + +
+
+ + +

@@ -322,9 +341,11 @@
- +
+

diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.js b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.js index 185aacd1..19e5920c 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.js +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.js @@ -652,270 +652,8 @@ function format(d) { return $(value).toArray(); } -const lastColNr_lp = $('#tableLineasPresupuesto').find("tr:first th").length - 1; -const actionBtns_lp = function(data) { - return ` - - `; -}; -var tableLineasPresupuesto = new DataTable('#tableLineasPresupuesto',{ - scrollX: true, - searching: false, - paging: false, - info: false, - ordering: true, - responsive: true, - select: false, - rowId: 'row_id', - language: { - url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" - }, - columnDefs: [ - { - targets: 0, - className: 'dt-control', - orderable: false, - data: null, - defaultContent: '' - }, - { - targets: [1,2,3,4,5,6,7,8,9], - orderable: false, - visible: false, - }, - { - targets: [11,12,13,14,15,16,17,18,19,20], - orderable: false, - }, - { - targets: [10], - orderable: true, - visible: false, - }, - { - orderable: false, - searchable: false, - targets: [lastColNr_lp] - }, - ], - columns: [ - {data: null}, - {data: 'tarifa_impresion_id'}, - {data: 'maquina_ancho'}, - {data: 'maquina_alto'}, - {data: 'maquina_impresion_ancho'}, - {data: 'maquina_impresion_alto'}, - {data: 'formas'}, - {data: 'formas_v'}, - {data: 'formas_h'}, - {data: 'formas_orientacion'}, - {data: 'position', - type: "num" , - render: function (data, type, row, meta){ - if(row.row_id.includes('_bn')){ - return 0; - } - else if(row.row_id.includes('_color')){ - return 1; - } - else if(row.row_id.includes('_cubierta')){ - return 2; - } - else if(row.row_id.includes('_sobrecubierta')){ - return 3; - } - else if(row.row_id.includes('_guardas')){ - return 4; - } - } - }, - {data: 'icon', - render: function ( data, type, row, meta ){ - return '' - } - }, - {data: 'paginas', - render: function ( data, type, row, meta ) { - if(row.row_id != "lp_cubierta" && row.row_id != "lp_sobrecubierta" && row.row_id != "lp_guardas") - return ''; - else if(row.row_id == "lp_cubierta"){ - select = '' - - return select; - } - else if(row.row_id == "lp_guardas"){ - select = '' - - return select; - - } - else{ - return ''; - } - } - }, - {data: 'papel', - render: function ( data, type, row, meta ) { - var select = $('') - .attr('id', row.row_id + '_gramaje') - .attr('name', row.row_id + '_gramaje') - .addClass('form-control form-select-sm lp-cell lp-select ' )//+ row.row_class + '-select') - .css('min-width', '40px') - - var option = ''; - select.append(option); - - return select[0].outerHTML - } - }, - {data: 'papel_impresion', - render: function ( data, type, row, meta ) { - var select = $('') - .attr('id', row.row_id + '_maquina') - .attr('name', row.row_id + '_maquina') - .addClass('form-control form-select-sm lp-cell lp-select ' + row.row_class + '-select') - .css('min-width', '110px') - - var option = ''; - select.append(option); - - return select[0].outerHTML - } - }, - {data: 'tiempo', - render: function ( data, type, row, meta ) { - return ''; - } - }, - {data: 'lomo', - render: function ( data, type, row, meta ) { - return ''; - } - }, - {data: 'peso', - render: function ( data, type, row, meta ) { - return ''; - } - }, - {data: 'total_linea', - render: function ( data, type, row, meta ) { - return ''; - } - }, - { - data: actionBtns_lp, - className: 'row-edit dt-center' - } - ], - "order": [ 10, 'asc' ] -}); tableLineasPresupuesto.on( 'draw.dt', function () { checkPaginasPresupuesto() @@ -949,20 +687,7 @@ $(document).on('click', '.btn-delete-lp', function(e) { -// Add event listener for opening and closing details -tableLineasPresupuesto.on('click', 'td.dt-control', function (e) { - let tr = e.target.closest('tr'); - let row = tableLineasPresupuesto.row(tr); - - if (row.child.isShown()) { - // This row is already open - close it - row.child.hide(); - } - else { - // Open this row - row.child(format(row.data())).show(); - } -}); + function processRowData(row, rowId, rowClass){ diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/comparador.js b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/comparador.js deleted file mode 100644 index bb1e770f..00000000 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/comparador.js +++ /dev/null @@ -1,49 +0,0 @@ - - - - - -/******************************* - * Metodos - *******************************/ - - - -function selectGuardasLineas() { - - $("#tableCompGuardas").DataTable().rows('.selected').deselect(); - - let value_total = 0.00; - - if ($("#tableCompGuardas").DataTable().rows().count() > 0) { - - $("#tableCompGuardas").DataTable().row(0).nodes().to$().toggleClass('selected'); - value_total = parseFloat($("#tableCompGuardas").DataTable().rows(0).data()[0]['total']) - }; - - - $('#total_comp_guardas').html(value_total.toFixed(2)); -} - - - - - - - - -function fillGuardas(data) { - - let sorted = data.lineas.sort( - (p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? - -1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0); - sorted.forEach(function (linea) { - if (typeof linea.error == "undefined") - $('#tableCompGuardas').DataTable().row - .add(getRowFromLineaInt('guardas', linea)) - .draw() - }) -} - - - diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js index 7dfaf2eb..0b281814 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js @@ -21,12 +21,12 @@ class PresupuestoAdminEdit { this.cosido = $("#isCosido"); this.datosGenerales = new DatosGenerales(this.domItem.find('#accordionDatosPresupuestoTip')); - this.datosLibro = new DatosLibro(this.domItem.find('#accordionDatosLibroTip', + this.datosLibro = new DatosLibro(this.domItem.find('#accordionDatosLibroTip'), { addService: this.addService, removeService: this.removeService, checkPaginasPresupuesto: this.checkPaginasPresupuesto, - })); + }); this.comparador = new Comparador(this.domItem.find('#accordionDatosPresupuestoClienteTip')); this.calcularPresupuesto = false; @@ -126,8 +126,10 @@ class PresupuestoAdminEdit { checkPaginasPresupuesto() { - cantidad_total = 0 + let cantidad_total = 0; + // TO-DO + /* 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') @@ -148,7 +150,7 @@ class PresupuestoAdminEdit {
`; } - $('#divAlarmasLineasPresupuesto').html(htmlString) + $('#divAlarmasLineasPresupuesto').html(htmlString)*/ } getDimensionLibro() { diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js index 25005b4b..61c553f2 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js @@ -145,13 +145,28 @@ class Comparador { [this.csrf_token]: this.csrf_hash, tipo_impresion: this.tipo_impresion_id, tirada: () => $('#tirada').val(), - tipo: 'guardas', + tipo: 'colorhq', + uso: 'guardas', + }); + this.gramajeGuardas = new ClassSelect($('#compGramajeGuardas'), + '/presupuestoadmin/papelgramaje', 'Seleccione gramaje', false, + { + [this.csrf_token]: this.csrf_hash, + papel_generico: () => this.papelCubierta.getVal(), + tipo_impresion: this.tipo_impresion_id, + tirada: () => $('#tirada').val(), + tipo: 'colorhq', + uso: 'guardas', }); this.carasGuardas = $('#compCarasGuardas'); - this.gramajeGuardas = $('#compGramajeGuardas'); this.btnInsertarGuardas = $('#insertarGuardasBtn'); } + if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3){ + this.lomoRedondo = $('#compLomoRedondo'); + this.cabezada = $('#cabezada'); + } + this.posPagColor = $('#compPosPaginasColor'); this.calculatedColorPages = $('#compCalPaginasColor'); @@ -188,9 +203,7 @@ class Comparador { if ($('#tipo_impresion_id').val() == 1 || $('#tipo_impresion_id').val() == 3 || $('#tipo_impresion_id').val() == 5 || $('#tipo_impresion_id').val() == 7) { - this.papelGuardas.select2({ - allowClear: false, - }); + this.papelGuardas.init(); this.carasGuardas.select2({ allowClear: false, @@ -207,6 +220,18 @@ class Comparador { this.gramajeColorhq.init(); this.papelCubierta.init(); this.gramajeCubierta.init(); + + if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3){ + this.lomoRedondo.select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + }); + this.cabezada.select2({ + allowClear: false, + minimumResultsForSearch: Infinity, + }); + } + if (this.tipo_impresion_id != 5 && this.tipo_impresion_id != 6 && this.tipo_impresion_id != 7 && this.tipo_impresion_id != 8 && this.tipo_impresion_id != 21) { this.sobrecubierta.select2({ @@ -233,6 +258,8 @@ class Comparador { if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) { this.papelGuardas.init(); + this.gramajeGuardas.init(); + this.papelGuardas.onChange(() => this.gramajeGuardas.setVal(0)) } this.papelNegro.onChange(() => this.gramajeNegro.setVal(0)) @@ -282,6 +309,10 @@ class Comparador { $('.comp_sobrecubierta_items').on('change', this.obtenerComparadorExteriores.bind(this)); } + if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) { + $('.comp_guardas_items').on('change', this.obtenerComparadorGuardas.bind(this)); + } + } #changePaginasComparador(element) { @@ -349,8 +380,18 @@ class Comparador { this.papelSobrecubierta.setOption(datos.json_data.sobrecubierta.papel_id, datos.json_data.sobrecubierta.papel_nombre); this.gramajeSobrecubierta.setOption(datos.json_data.sobrecubierta.gramaje, datos.json_data.sobrecubierta.gramaje); } + if (datos.json_data.guardas) { + this.carasGuardas.val(datos.json_data.guardas.paginas).trigger('change'); + this.papelGuardas.setOption(datos.json_data.guardas.papel_id, datos.json_data.guardas.papel_nombre); + this.gramajeGuardas.setOption(datos.json_data.guardas.gramaje, datos.json_data.guardas.gramaje); + } - if (datos.posPagColor.length > 0) { + if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3){ + this.lomoRedondo.val(datos.lomoRedondo?1:0).trigger('change'); + this.cabezada.val(datos.cabezada).trigger('change'); + } + + if (datos.posPagColor != null && datos.posPagColor.length > 0) { this.posPagColor.val(datos.posPagColor); this.#computarPaginasColor(datos.posPagColor); } @@ -358,6 +399,10 @@ class Comparador { this.cargando = false; this.paginasNegro.trigger('change'); this.paginasCubierta.trigger('change'); + if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) { + this.carasGuardas.trigger('change'); + } + } @@ -743,6 +788,9 @@ class Comparador { $('#total_comp_plana').html("0.00"); } } + + if(!this.cargando) + $('#paginas').trigger('change'); } getDataForComp(uso = 'interior') { @@ -874,6 +922,22 @@ class Comparador { } + else if (uso == 'guardas') { + if (this.papelGuardas.getVal() == 0 || this.papelGuardas.getVal() == null) { + popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador'); + return { error: true, data: {} }; + } + if (this.gramajeGuardas.getVal() == 0 || this.gramajeGuardas.getVal() == null) { + popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador'); + return { error: true, data: {} }; + } + + papel_generico = { id: this.papelGuardas.getVal(), nombre: this.papelGuardas.getText() }; + gramaje = this.gramajeGuardas.getVal(); + paginas = this.carasGuardas.val(); + + } + const datosPedido = { paginas: paginas, tirada: $('#tirada').val(), @@ -906,20 +970,24 @@ class Comparador { datos.datosPedido.lomo = this.getLomoLineasPresupuesto('interior'); datos.datosPedido.solapas = $('#solapas').prop('checked') ? 1 : 0; datos.datosPedido.solapas_ancho = $('#solapas').prop('checked') ? parseInt($('#solapas_ancho').val()) : 0; - // TO-DO - datos.lomoRedondo = false; + datos.lomoRedondo = this.lomoRedondo.val(); } else if (uso == 'sobrecubierta') { datos.datosPedido.lomo = this.getLomoLineasPresupuesto() + this.getLomoLineasPresupuesto('cubierta'); datos.datosPedido.solapas = $('#solapas_sobrecubierta').prop('checked') ? 1 : 0; datos.datosPedido.solapas_ancho = $('#solapas_sobrecubierta').prop('checked') ? parseInt($('#solapas_ancho_sobrecubierta').val()) : 0; } + else if (uso == 'guardas') { + datos.datosPedido.isCosido = 1; + datos.datosPedido.isHq = 1; + datos.paginas_color = datos.datosPedido.paginas; + } return { error: false, data: datos }; } - getLomoLineasPresupuesto(tipo_lomo='interior') { + getLomoLineasPresupuesto(tipo_lomo = 'interior') { let lomoTotal = 0 try { @@ -1163,6 +1231,66 @@ class Comparador { } } + obtenerComparadorGuardas(event, actualizarLineaPlana = false, actualizarLineaRot = false) { + + try { + + const self = this; + + if (this.cargando) { + return + } + + this.tableCompGuardas.clear().draw(); + this.btnInsertarGuardas.addClass('d-none'); + $('#title_guardas').html(window.language.Presupuestos.Guardas); + + let datosComp = {}; + datosComp = this.getDataForComp('guardas'); + if (datosComp.error) { + return; + } + + datosComp.data[this.csrf_token] = this.csrf_hash; + + new Ajax('/presupuestoadmin/comparadorguardas', + datosComp.data, + {}, + (response) => { + if (response.data && Object.keys(response.data).length > 0) { + let sorted = Object.values(response.data).sort( + (p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? + -1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0); + + sorted[0].forEach(function (linea) { + if (typeof linea.error == "undefined") + self.tableCompGuardas.row + .add(self.getRowFromLinea('guardas', linea)) + .draw(); + }); + } + + self.selectLineas('guardas'); + if (self.tableCompGuardas.rows().count() > 0) { + $('#title_guardas').html(window.language.Presupuestos.Guardas + + (' (' + self.tableCompGuardas.rows().count() + ')')); + self.btnInsertarGuardas.removeClass('d-none'); + } + else { + $('#title_guardas').html(window.language.Presupuestos.Guardas); + self.btnInsertarGuardas.addClass('d-none'); + } + }, + (error) => { + console.log(error); + } + ).post(); + + } catch (e) { + console.log(e) + } + } + selectLineas(tabla) { @@ -1173,6 +1301,12 @@ class Comparador { let tipo2 = 'color'; let total_label = '#total_comp_plana' switch (tabla) { + case 'guardas': + table = this.tableCompGuardas; + tipo1 = 'guardas'; + total_label = '#total_comp_guardas'; + break; + case 'cubierta': table = this.tableCompCubierta; tipo1 = 'cubierta'; @@ -1407,402 +1541,7 @@ class Comparador { data_str = JSON.stringify(data) $('#comparador_json_data').val(data_str) } -} -/* - - - - - function checkComparadorGuardas(actualizarLinea = false){ - - if ($('#compPapelGuardas').select2('data')[0].id > 0 ){ - - const dimension = getDimensionLibro(); - - let datos = { - tipo_impresion_id: , - type: 'guardas', - paginas: 8, - paginas_impresion: parseInt($('#compCarasGuardas').select2('data')[0].id), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - color: 1, - hq: 1, - ancho: dimension.ancho, - alto: dimension.alto, - papel_generico_id: $('#compPapelGuardas').select2('data')[0].id, - papel_generico: $('#compPapelGuardas').select2('data')[0].text.trim(), - gramaje: parseInt($('#compGramajeGuardas').val()), - cliente_id: $('#clienteId').find(":selected").val(), - : v - }; - - $.ajax({ - type: "POST", - url: "/presupuestoadmin/datatable", - data: datos, - success: function (data) { - - clearGuardas(); - - if(data.lineas.length >0){ - fillGuardas(data); - selectGuardasLineas(); - $('#title_guardas').html('' + ' (' + tableCompGuardas.rows().count() + ')'); - $('#insertarGuardasBtn').removeClass('d-none') - if(actualizarLinea){ - var rows = $("#tableCompCubierta").DataTable().rows( '.selected' ).data().toArray(); - for(row of rows){ - fill_lp_guardas(row, true); - } - } - } - else{ - $('#title_guardas').html(''); - $('#insertarGuardasBtn').addClass('d-none') - $('#total_comp_guardas').html('0.00') - - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - } - - else{ - clearGuardas(); - } - } +} - $('.comp_guardas_items').on('change', function (e) { - - checkComparadorGuardas(false); - }); - - - - async function getLineasIntPlana(is_color, is_hq, actualizarLinea){ - - const dimension = getDimensionLibro(); - - let datos = { - tipo_impresion_id: , - type: 'interior', - color: is_color?1:0, - hq: is_hq?1:0, - paginas: parseInt($(''+ elementos.paginas).val()), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#merma').val()), - ancho: dimension.ancho, - alto: dimension.alto, - papel_generico_id: $(''+ elementos.papel).select2('data')[0].id, - papel_generico: $(''+ elementos.papel).select2('data')[0].text.trim(), - gramaje: $(''+ elementos.gramaje).select2('data')[0].text.trim() , - cliente_id: $('#clienteId').find(":selected").val(), - : v - }; - - $.ajax({ - type: "POST", - url: "/presupuestoadmin/datatable", - data: datos, - success: function (data) { - - clearIntLineas(is_color); - - if(data.lineas.length >0){ - - fillIntPlana(data, is_color, is_hq); - selectIntLineas(); - $('#title_int_plana').html('' + ' (' + tableCompIntPlana.rows().count() + ')'); - $('#insertarPlanaBtn').removeClass('d-none') - if(actualizarLinea){ - var rows = $("#tableCompIntPlana").DataTable().rows( '.selected' ).data().toArray(); - for(row of rows){ - - if(row['tipo'] =='bn' && !is_color && !is_hq){ - if($('#lp_bn').css('display')!='none') - fill_lp_bn(row, true); - } - else if(row['tipo'] =='bnhq' && !is_color && is_hq){ - if($('#lp_bnhq').css('display')!='none') - fill_lp_bnhq(row, true); - } - else if(row['tipo'] =='color' && is_color && !is_hq){ - if($('#lp_color').css('display')!='none') - fill_lp_color(row, true); - } - else if(row['tipo'] =='colorhq' && is_color && is_hq){ - if($('#lp_colorhq').css('display')!='none') - fill_lp_colorhq(row, true); - } - } - } - } - else{ - $('#title_int_plana').html(''); - $('#insertarPlanaBtn').addClass('d-none') - $('#total_comp_plana').html('0.00'); - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - return false; - } - - async function getLineasIntRot(is_hq, actualizarLinea=false){ - - const dimension = getDimensionLibro(); - - // Rotativa solo negro o color (no hq) - if ( is_hq==false){ - - if(checkInputsForRotativa()){ - - let datos = { - tipo_impresion_id: , - type: 'interior_rot', - paginas: parseInt($('#paginas').val()), - paginas_negro: parseInt($('#compPaginasNegro').val()), - paginas_color: parseInt($('#compPaginasColor').val()), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#merma').val()), - ancho: dimension.ancho, - alto: dimension.alto, - // el papel y el gramaje se coge del negro (siempre estará) - papel_generico_id: $('#compPapelNegro').select2('data')[0].id, - papel_generico: $('#compPapelNegro').select2('data')[0].text.trim(), - gramaje: $('#compGramajeNegro').select2('data')[0].text.trim() , - cliente_id: $('#clienteId').find(":selected").val(), - : v - }; - - $.ajax({ - type: "POST", - url: "/presupuestoadmin/datatable", - data: datos, - success: function (data) { - - clearIntRot(); - - if(data.lineas.length >0){ - - fillIntRot(data); - selectIntRotLineas(); - $('#title_int_rot').html('' + ' (' + tableCompIntRotativa.rows().count() + ')'); - $('#insertarRotativaBtn').removeClass('d-none') - if(actualizarLinea){ - var rows = $("#tableCompIntRotativa").DataTable().rows( '.selected' ).data().toArray(); - for(row of rows){ - if(row['paginasColor'] ==0){ - if($('#lp_rot_bn').css('display')!='none') - fill_lp_rot_bn(row, true); - } - else if(row['paginasColor'] >0){ - if($('#lp_rot_color').css('display')!='none') - fill_lp_rot_color(row, true); - } - } - } - } - else{ - $('#title_int_rot').html(''); - $('#insertarRotativaBtn').addClass('d-none') - $('#total_comp_rot').html('0.00') - - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - } - } - return false; - } - - $('.comp_cubierta_items').on('change', function (){ - - checkComparadorCubierta() - }); - - - function checkComparadorCubierta(actualizarLinea = false){ - - if ($('#compCarasCubierta option:selected').val().length > 0 && - $('#compPapelCubierta').select2('data').length > 0 && - $('#compGramajeCubierta').select2('data').length > 0 ){ - - const dimension = getDimensionLibro(); - - let datos = { - tipo_impresion_id: , - type: 'cubierta', - paginas: parseInt($('#compCarasCubierta option:selected').val()), - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - color: 1, - ancho: dimension.ancho, - alto: dimension.alto, - lomo: getLomoLineasPresupuesto(), - solapas: $('#solapas').is(':checked')?1:0, - solapas_ancho: $('#solapas').is(':checked')?parseInt($('#solapas_ancho').val()):0, - papel_generico_id: $('#compPapelCubierta').select2('data')[0].id, - papel_generico: $('#compPapelCubierta').select2('data')[0].text.trim(), - gramaje: $('#compGramajeCubierta').select2('data')[0].text.trim() , - cliente_id: $('#clienteId').find(":selected").val(), - : v - }; - - $.ajax({ - type: "POST", - url: "/presupuestoadmin/datatable", - data: datos, - success: function (data) { - - clearCubierta(); - - if(data.lineas.length >0){ - fillCubierta(data); - selectCubiertaLineas(); - tableCompCubierta.order([0, 'asc']).draw() - $('#title_cubierta').html('' + (tableCompCubierta.rows().count()>0 ?(' (' + tableCompCubierta.rows().count() + ')'):'')); - $('#insertarCubiertaBtn').removeClass('d-none') - if(actualizarLinea){ - var rows = $("#tableCompCubierta").DataTable().rows( '.selected' ).data().toArray(); - for(row of rows){ - if (row.tipo=='cubierta') - fill_lp_cubierta(row, true); - } - } - } - else{ - $('#title_cubierta').html('' + (tableCompCubierta.rows().count()>0 ?(' (' + tableCompCubierta.rows().count() + ')'):'')); - if(tableCompCubierta.rows().count()==0){ - $('#insertarCubiertaBtn').addClass('d-none') - $('#total_comp_cubierta').html('0.00') - } - else{ - selectCubiertaLineas(); - } - - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - } - - else{ - clearCubierta(); - } - } - - $('.comp_sobrecubierta_items').on('change', function (){ - - checkComparadorSobrecubierta() - }); - - - function checkComparadorSobrecubierta(actualizarLinea = false){ - - if ($('#compSobrecubierta option:selected').val() == 1 && - $('#compPapelSobrecubierta').select2('data').length > 0 && - $('#compGramajeSobrecubierta').select2('data').length > 0 ){ - - - const dimension = getDimensionLibro(); - - let datos = { - tipo_impresion_id: , - type: 'sobrecubierta', - paginas: 4, - tirada: parseInt($('#tirada').val()), - merma: parseInt($('#mermacubierta').val()), - color: 1, - ancho: dimension.ancho, - alto: dimension.alto, - lomo: getLomoLineasPresupuesto() + getLomoCubiertaLineasPresupuesto(), - solapas: $('#solapas_sobrecubierta').is(':checked')?1:0, - solapas_ancho: $('#solapas_sobrecubierta').is(':checked')?parseInt($('#solapas_ancho_sobrecubierta').val()):0, - papel_generico_id: $('#compPapelSobrecubierta').select2('data')[0].id, - papel_generico: $('#compPapelSobrecubierta').select2('data')[0].text.trim(), - gramaje: $('#compGramajeSobrecubierta').select2('data')[0].text.trim() , - cliente_id: $('#clienteId').find(":selected").val(), - : v - }; - - $.ajax({ - type: "POST", - url: "/presupuestoadmin/datatable", - data: datos, - success: function (data) { - - clearSobrecubierta(); - - if(data.lineas.length >0){ - - fillSobrecubierta(data); - selectCubiertaLineas(); - tableCompCubierta.order([ [0, 'asc'],[15, 'asc'] ]).draw() - $('#title_cubierta').html('' + (tableCompCubierta.rows().count()>0 ?(' (' + tableCompCubierta.rows().count() + ')'):'')); - $('#insertarCubiertaBtn').removeClass('d-none') - if(actualizarLinea){ - var rows = $("#tableCompCubierta").DataTable().rows( '.selected' ).data().toArray(); - for(row of rows){ - if (row.tipo=='sobrecubierta') - fill_lp_sobrecubierta(row, true); - } - } - } - else{ - $('#title_cubierta').html('' + (tableCompCubierta.rows().count()>0 ?(' (' + tableCompCubierta.rows().count() + ')'):'')); - if(tableCompCubierta.rows().count()==0){ - $('#insertarCubiertaBtn').addClass('d-none') - $('#total_comp_cubierta').html('0.00') - } - else{ - selectCubiertaLineas(); - } - - } - yeniden(data.); - return true; - }, - error: function(e){ - return false; - } - }) - } - - else{ - clearSobrecubierta(); - } - } - - - - - - $('#tipoImpresion').on("select2:close", function () { - - $('#paginas').change() - }) - - - -*/ export default Comparador; \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js index fb852a7c..65637230 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js @@ -228,7 +228,7 @@ class DatosLibro { if(window.location.href.includes('edit')){ - checkPaginasPresupuesto() + this.checkPaginasPresupuesto(); // Si es negro o color if ($('#tipoImpresion').select2('data')[0].id == 'negro' || diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js new file mode 100644 index 00000000..1e655a47 --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js @@ -0,0 +1,689 @@ +import Ajax from "../../../components/ajax"; +import ClassSelect from "../../../components/select2"; + + +class LineasPresupuesto { + + constructor(domItem, functions = {}) { + this.domItem = domItem; + this.functions = functions; + + this.table = null; + + this.addLineaManual = this.domItem.find("#btn_addLinea"); + } + + init() { + this.#initTable(); + + this.addLineaManual.on('click', + } + + #initTable() { + + const lastColNr_lp = $('#tableLineasPresupuesto').find("tr:first th").length - 1; + + const actionBtns_lp = function (data) { + return ` + + `; + }; + + this.table = new DataTable('#tableLineasPresupuesto', { + scrollX: true, + searching: false, + paging: false, + info: false, + ordering: true, + responsive: true, + select: false, + rowId: 'row_id', + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + columnDefs: [ + { + targets: 0, + className: 'dt-control', + orderable: false, + data: null, + defaultContent: '' + }, + { + targets: [1, 2, 3, 4, 5, 6, 7, 8, 9], + orderable: false, + visible: false, + }, + { + targets: [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + orderable: false, + }, + { + targets: [10], + orderable: true, + visible: false, + }, + { + orderable: false, + searchable: false, + targets: [lastColNr_lp] + }, + ], + columns: [ + { data: null }, + { data: 'tarifa_impresion_id' }, + { data: 'maquina_ancho' }, + { data: 'maquina_alto' }, + { data: 'maquina_impresion_ancho' }, + { data: 'maquina_impresion_alto' }, + { data: 'formas' }, + { data: 'formas_v' }, + { data: 'formas_h' }, + { data: 'formas_orientacion' }, + { + data: 'position', + type: "num", + render: function (data, type, row, meta) { + if (row.row_id.includes('_bn')) { + return 0; + } + else if (row.row_id.includes('_color')) { + return 1; + } + else if (row.row_id.includes('_cubierta')) { + return 2; + } + else if (row.row_id.includes('_sobrecubierta')) { + return 3; + } + else if (row.row_id.includes('_guardas')) { + return 4; + } + } + }, + { + data: 'icon', + render: function (data, type, row, meta) { + return '' + } + }, + { + data: 'paginas', + render: function (data, type, row, meta) { + if (row.row_id != "lp_cubierta" && row.row_id != "lp_sobrecubierta" && row.row_id != "lp_guardas") + return ''; + else if (row.row_id == "lp_cubierta") { + select = '' + + return select; + } + else if (row.row_id == "lp_guardas") { + select = '' + + return select; + + } + else { + return ''; + } + } + }, + { + data: 'papel', + render: function (data, type, row, meta) { + var select = $('') + .attr('id', row.row_id + '_gramaje') + .attr('name', row.row_id + '_gramaje') + .addClass('form-control form-select-sm lp-cell lp-select ')//+ row.row_class + '-select') + .css('min-width', '40px') + + var option = ''; + select.append(option); + + return select[0].outerHTML + } + }, + { + data: 'papel_impresion', + render: function (data, type, row, meta) { + var select = $('') + .attr('id', row.row_id + '_maquina') + .attr('name', row.row_id + '_maquina') + .addClass('form-control form-select-sm lp-cell lp-select ' + row.row_class + '-select') + .css('min-width', '110px') + + var option = ''; + select.append(option); + + return select[0].outerHTML + } + }, + { + data: 'tiempo', + render: function (data, type, row, meta) { + return ''; + } + }, + { + data: 'lomo', + render: function (data, type, row, meta) { + return ''; + } + }, + { + data: 'peso', + render: function (data, type, row, meta) { + return ''; + } + }, + { + data: 'total_linea', + render: function (data, type, row, meta) { + return ''; + } + }, + { + data: actionBtns_lp, + className: 'row-edit dt-center' + } + ], + "order": [10, 'asc'] + }); + + this.table.on('click', 'td.dt-control', function (e) { + let tr = e.target.closest('tr'); + let row = tableLineasPresupuesto.row(tr); + + if (row.child.isShown()) { + // This row is already open - close it + row.child.hide(); + } + else { + // Open this row + row.child(format(row.data())).show(); + } + }); + } + + #insertLineaManual() { + + let dataRows = this.table.rows().data(); + + switch ($('#addLineasPresupuesto').val()) { + // Se chequean todas las lineas de negro y todas las de color + // (solo una de cada en interior) + + case 'lp_bn': + var hayLinea = false + for (let number = 0; number < dataRows.length; number++) { + if (dataRows[number].row_id == 'lp_bn' || + dataRows[number].row_id == 'lp_bnhq' || + dataRows[number].row_id == 'lp_rot_bn') { + hayLinea = true + continue + } + } + + if (hayLinea) { + popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto'); + break + } + + var data = processRowData({ tipo_maquina: 'toner' }, 'lp_bn', 'lp-bn'); + tableLineasPresupuesto.row.add(data).draw() + eventos_lp_bn() + break + + case 'lp_bnhq': + var hayLinea = false + for (let number = 0; number < dataRows.length; number++) { + if (dataRows[number].row_id == 'lp_bn' || + dataRows[number].row_id == 'lp_bnhq' || + dataRows[number].row_id == 'lp_rot_bn') { + hayLinea = true + continue + } + } + + if (hayLinea) { + popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto'); + break + } + + var data = processRowData({ tipo_maquina: 'toner' }, 'lp_bnhq', 'lp-bnhq'); + tableLineasPresupuesto.row.add(data).draw() + eventos_lp_bnhq() + break + + case 'lp_color': + var hayLinea = false + for (let number = 0; number < dataRows.length; number++) { + if (dataRows[number].row_id == 'lp_color' || + dataRows[number].row_id == 'lp_colorhq' || + dataRows[number].row_id == 'lp_rot_color') { + hayLinea = true + continue + } + } + + if (hayLinea) { + popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto'); + break + } + + var data = processRowData({ tipo_maquina: 'toner' }, 'lp_color', 'lp-color'); + tableLineasPresupuesto.row.add(data).draw() + eventos_lp_color() + break + + case 'lp_colorhq': + var hayLinea = false + for (let number = 0; number < dataRows.length; number++) { + if (dataRows[number].row_id == 'lp_color' || + dataRows[number].row_id == 'lp_colorhq' || + dataRows[number].row_id == 'lp_rot_color') { + hayLinea = true + continue + } + } + + if (hayLinea) { + popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto'); + break + } + + var data = processRowData({ tipo_maquina: 'toner' }, 'lp_colorhq', 'lp-colorhq'); + tableLineasPresupuesto.row.add(data).draw() + eventos_lp_colorhq() + break + + case 'lp_rot_bn': + var hayLinea = false + for (let number = 0; number < dataRows.length; number++) { + if (dataRows[number].row_id == 'lp_bn' || + dataRows[number].row_id == 'lp_bnhq' || + dataRows[number].row_id == 'lp_rot_bn') { + hayLinea = true + continue + } + } + + if (hayLinea) { + popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto'); + break + } + + var data = processRowData({ tipo_maquina: 'toner' }, 'lp_rot_bn', 'lp-rot-bn'); + tableLineasPresupuesto.row.add(data).draw() + eventos_lp_rot_bn() + break + + case 'lp_rot_color': + var hayLinea = false + for (let number = 0; number < dataRows.length; number++) { + if (dataRows[number].row_id == 'lp_color' || + dataRows[number].row_id == 'lp_colorhq' || + dataRows[number].row_id == 'lp_rot_color') { + hayLinea = true + continue + } + } + + if (hayLinea) { + popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto'); + break + } + + var data = processRowData({ tipo_maquina: 'toner' }, 'lp_rot_color', 'lp-rot-color'); + tableLineasPresupuesto.row.add(data).draw() + eventos_lp_rot_color() + break + + case 'lp_cubierta': + var hayLinea = false + for (let number = 0; number < dataRows.length; number++) { + if (dataRows[number].row_id == 'lp_cubierta') { + hayLinea = true + continue + } + } + + if (hayLinea) { + popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto'); + break + } + + var data = processRowData({ tipo_maquina: 'toner' }, 'lp_cubierta', 'lp-cubierta'); + tableLineasPresupuesto.row.add(data).draw() + eventos_lp_cubierta() + break + + case 'lp_sobrecubierta': + var hayLinea = false + for (let number = 0; number < dataRows.length; number++) { + if (dataRows[number].row_id == 'lp_sobrecubierta') { + hayLinea = true + continue + } + } + + if (hayLinea) { + popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto'); + break + } + + var data = processRowData({ tipo_maquina: 'toner' }, 'lp_sobrecubierta', 'lp-sobrecubierta'); + tableLineasPresupuesto.row.add(data).draw() + eventos_lp_sobrecubierta() + break + + case 'lp_guardas': + var hayLinea = false + for (let number = 0; number < dataRows.length; number++) { + if (dataRows[number].row_id == 'lp_guardas') { + hayLinea = true + continue + } + } + + if (hayLinea) { + popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto'); + break + } + + var data = processRowData({ tipo_maquina: 'toner' }, 'lp_guardas', 'lp-guardas'); + tableLineasPresupuesto.row.add(data).draw() + $('#lp_guardas_gramaje').empty() + var o = new Option("170", "170"); + $('#lp_guardas_gramaje').append(o) + eventos_lp_guardas() + servicioGuardas(true) + break + default: + break + } + $("#tableLineasPresupuesto").DataTable().columns.adjust(); + } + + #processRowData(row, rowId, rowClass) { + + var icon = "" + if (rowId == 'lp_bn') { + if (row.tipo_maquina == 'toner') + icon = '' + else + icon = '' + } + + else if (rowId == 'lp_bnhq') { + if (row.tipo_maquina == 'toner') + icon = '' + else + icon = '' + } + else if (rowId == 'lp_color') { + if (row.tipo_maquina == 'toner') + icon = '' + else + icon = '' + } + else if (rowId == 'lp_colorhq') { + if (row.tipo_maquina == 'toner') + icon = '' + else + icon = '' + } + + else if (rowId == 'lp_cubierta') + icon = '' + else if (rowId == 'lp_sobrecubierta') + icon = '' + else if (rowId == 'lp_guardas') + icon = '' + else if (rowId == 'lp_rot_bn') + icon = '' + else if (rowId == 'lp_rot_color') + icon = '' + + const blank_line = (typeof row.tarifa_impresion_id === 'undefined') ? 1 : 0; + var data = { + 'row_id': rowId, + 'row_class': rowClass, + + 'tarifa_impresion_id': blank_line ? 0 : isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id), + 'maquina_ancho': blank_line ? 0 : isNaN(parseFloat(row.dimensiones_maquina[0])) ? "" : parseFloat(row.dimensiones_maquina[0]), + 'maquina_alto': blank_line ? 0 : isNaN(parseFloat(row.dimensiones_maquina[1])) ? "" : parseFloat(row.dimensiones_maquina[1]), + 'maquina_impresion_ancho': blank_line ? 0 : isNaN(parseFloat(row.dimensiones_maquina_impresion[0])) ? "" : parseFloat(row.dimensiones_maquina_impresion[0]), + 'maquina_impresion_alto': blank_line ? 0 : isNaN(parseFloat(row.dimensiones_maquina_impresion[1])) ? "" : parseFloat(row.dimensiones_maquina_impresion[1]), + 'formas': blank_line ? 0 : isNaN(parseInt(row.num_formas.value)) ? 0 : parseInt(row.num_formas.value), + 'formas_v': blank_line ? 0 : isNaN(parseInt(row.num_formas.num_formas_verticales)) ? 0 : parseInt(row.num_formas.num_formas_verticales), + 'formas_h': blank_line ? 0 : isNaN(parseInt(row.num_formas.num_formas_horizontales)) ? 0 : parseInt(row.num_formas.num_formas_horizontales), + 'formas_orientacion': blank_line ? 0 : row.num_formas.posicion_formas, + + 'icon': icon, + 'paginas': blank_line ? 0 : row.paginas, + 'paginas_impresion': rowId == 'lp_guardas' ? row.paginas_impresion : 0, + 'papel': blank_line ? "" : row.papel_generico_id, + 'gramaje': blank_line ? "" : row.gramaje, + 'papel_impresion': blank_line ? "" : row.papel_impresion, + 'papel_impresion_id': blank_line ? "" : row.papel_impresion_id, + 'maquina': blank_line ? "" : row.maquina, + 'maquina_id': blank_line ? "" : row.maquina_id, + + 'tiempo': blank_line ? "" : row.tiempo_maquina, + 'lomo': isNaN(parseFloat(row.mano)) ? "" : parseFloat(row.mano).toFixed(2), + 'peso': isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2), + + 'total_linea': isNaN(parseFloat(row.total_impresion)) ? "" : parseFloat(row.total_impresion).toFixed(2), + + 'numeroPliegos': isNaN(parseFloat(row.pliegos_libro)) ? "" : parseFloat(row.pliegos_libro).toFixed(0), + 'pliegosPedido': isNaN(parseFloat(row.pliegos_pedido)) ? "" : parseFloat(row.pliegos_pedido).toFixed(0), + 'precioPliego': isNaN(parseFloat(row.precios_pliegos)) ? "" : parseFloat(row.precios_pliegos).toFixed(6), + 'libro': isNaN(parseFloat(row.precio_libro)) ? "" : parseFloat(row.precio_libro).toFixed(2), + 'totalPapelPedido': isNaN(parseFloat(row.precio_pedido)) ? "" : parseFloat(row.precio_pedido).toFixed(2), + 'margenPapelPedido': isNaN(parseFloat(row.margen_papel_pedido)) ? "" : parseFloat(row.margen_papel_pedido).toFixed(2), + 'click': isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6), + 'totalClicks': isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2), + 'margenClicks': isNaN(parseFloat(row.margen_click_pedido)) ? "" : parseFloat(row.margen_click_pedido).toFixed(2), + 'horasMaquina': isNaN(parseFloat(row.horas_maquina)) ? "" : parseFloat(row.horas_maquina).toFixed(4), + 'precioHora': isNaN(parseFloat(row.precio_hora)) ? "" : parseFloat(row.precio_hora).toFixed(2), + 'precioImpresion': isNaN(parseFloat(row.precio_impresion_horas)) ? "" : parseFloat(row.precio_impresion_horas).toFixed(2), + 'margenImpresion': isNaN(parseFloat(row.margen_impresion_horas)) ? "" : parseFloat(row.margen_impresion_horas).toFixed(2), + 'maquinaTipo': row.tipo_maquina, + 'check_papel_total': row.check_papel_total, + 'check_impresion_total': row.check_impresion_total, + } + + if (row.tipo_maquina == 'inkjet') { + + data.numPagColor = row.paginas_color + data.aFavorFibra = row.a_favor_fibra + data.cobNegro = isNaN(parseFloat(row.datosTipologias.negro)) ? "" : parseFloat(row.datosTipologias.negro).toFixed(2) + data.cobCyan = isNaN(parseFloat(row.datosTipologias.cyan)) ? "" : parseFloat(row.datosTipologias.cyan).toFixed(2) + data.cobMagenta = isNaN(parseFloat(row.datosTipologias.magenta)) ? "" : parseFloat(row.datosTipologias.magenta).toFixed(2) + data.cobAmarillo = isNaN(parseFloat(row.datosTipologias.amarillo)) ? "" : parseFloat(row.datosTipologias.amarillo).toFixed(2) + data.gotaNegro = isNaN(parseFloat(row.datosTipologias.gota_negro)) ? "" : parseFloat(row.datosTipologias.gota_negro).toFixed(2) + data.gotaColor = isNaN(parseFloat(row.datosTipologias.gota_color)) ? "" : parseFloat(row.datosTipologias.gota_color).toFixed(2) + + data.resolucion = isNaN(parseFloat(row.resolucion)) ? "" : parseFloat(row.resolucion).toFixed(0) + data.areaPaginas = isNaN(parseFloat(row.superficie)) ? "" : parseFloat(row.superficie).toFixed(2) + + data.gotasNegro = isNaN(parseFloat(row.num_gotas_negro)) ? "" : parseFloat(row.num_gotas_negro).toFixed(0) + data.gotasCyan = isNaN(parseFloat(row.num_gotas_cyan)) ? "" : parseFloat(row.num_gotas_cyan).toFixed(0) + data.gotasMagenta = isNaN(parseFloat(row.num_gotas_magenta)) ? "" : parseFloat(row.num_gotas_magenta).toFixed(0) + data.gotasAmarillo = isNaN(parseFloat(row.num_gotas_amarillo)) ? "" : parseFloat(row.num_gotas_amarillo).toFixed(0) + data.precioPagNegro = isNaN(parseFloat(row.precio_pagina_negro)) ? "" : parseFloat(row.precio_pagina_negro).toFixed(6) + data.precioPagColor = isNaN(parseFloat(row.precio_pagina_color)) ? "" : parseFloat(row.precio_pagina_color).toFixed(6) + data.factorAltura = isNaN(parseFloat(row.factor_altura)) ? "" : parseFloat(row.factor_altura).toFixed(2) + data.factorAnchura = isNaN(parseFloat(row.factor_anchura)) ? "" : parseFloat(row.factor_anchura).toFixed(2) + data.paginasPliego = isNaN(parseFloat(row.paginas_por_pliego)) ? "" : parseFloat(row.paginas_por_pliego).toFixed(2) + + if (rowId.includes('rot')) { + data.metrosMinuto = isNaN(parseFloat(row.maquina_velocidad)) ? "" : parseFloat(row.maquina_velocidad).toFixed(2) + data.metrosPapelLibro = isNaN(parseFloat(row.metros_papel_libro)) ? "" : parseFloat(row.metros_papel_libro).toFixed(2) + data.metrosPapelTotal = isNaN(parseFloat(row.metros_papel_total)) ? "" : parseFloat(row.metros_papel_total).toFixed(2) + data.velocidadCorte = isNaN(parseFloat(row.velocidad_corte)) ? "" : parseFloat(row.velocidad_corte).toFixed(2) + data.precioHoraCorte = isNaN(parseFloat(row.precio_hora_corte)) ? "" : parseFloat(row.precio_hora_corte).toFixed(2) + data.tiempoCorte = isNaN(parseFloat(row.tiempo_corte)) ? "" : parseFloat(row.tiempo_corte).toFixed(2) + data.totalCorte = isNaN(parseFloat(row.total_corte)) ? "" : parseFloat(row.total_corte).toFixed(2) + } + else { + data.totalCorte = 0 + } + + data.clicksLibro = isNaN(parseFloat(row.clicks_libro)) ? "" : parseFloat(row.clicks_libro).toFixed(0) + data.gTintaNegro = isNaN(parseFloat(row.peso_gotas_negro)) ? "" : parseFloat(row.peso_gotas_negro).toFixed(2) + data.gTintaCyan = isNaN(parseFloat(row.peso_gotas_cyan)) ? "" : parseFloat(row.peso_gotas_cyan).toFixed(2) + data.gTintaMagenta = isNaN(parseFloat(row.peso_gotas_magenta)) ? "" : parseFloat(row.peso_gotas_magenta).toFixed(2) + data.gTintaAmarillo = isNaN(parseFloat(row.peso_gotas_amarillo)) ? "" : parseFloat(row.peso_gotas_amarillo).toFixed(2) + data.clicksPedido = isNaN(parseFloat(row.clicks_pedido)) ? "" : parseFloat(row.clicks_pedido).toFixed(0) + data.totalClicksPedido = isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2) + data.totalTinta = isNaN(parseFloat(row.precio_tinta)) ? "" : parseFloat(row.precio_tinta).toFixed(2) + + data.totalImpresion = isNaN(parseFloat(row.precio_click_pedido + row.precio_tinta + data.totalCorte)) ? "" : parseFloat(row.precio_click_pedido + row.precio_tinta + data.totalCorte).toFixed(2) + + data.gTintaNegroPed = isNaN(parseFloat(row.peso_gotas_negro_pedido)) ? "" : parseFloat(row.peso_gotas_negro_pedido).toFixed(2) + data.gTintaCyanPed = isNaN(parseFloat(row.peso_gotas_cyan_pedido)) ? "" : parseFloat(row.peso_gotas_cyan_pedido).toFixed(2) + data.gTintaMagentaPed = isNaN(parseFloat(row.peso_gotas_magenta_pedido)) ? "" : parseFloat(row.peso_gotas_magenta_pedido).toFixed(2) + data.gTintaAmarilloPed = isNaN(parseFloat(row.peso_gotas_amarillo_pedido)) ? "" : parseFloat(row.peso_gotas_amarillo_pedido).toFixed(2) + + if (!rowId.includes('rot')) { + data.cobCG = isNaN(parseFloat(row.datosTipologias.cg)) ? "" : parseFloat(row.datosTipologias.cg).toFixed(2) + data.gotasCG = isNaN(parseFloat(row.num_gotas_cg)) ? "" : parseFloat(row.num_gotas_cg).toFixed(2) + data.gTintaCG = isNaN(parseFloat(row.peso_gotas_cg)) ? "" : parseFloat(row.peso_gotas_cg).toFixed(2) + data.gTintaCGPed = isNaN(parseFloat(row.peso_gotas_cg_pedido)) ? "" : parseFloat(row.peso_gotas_cg_pedido).toFixed(2) + } + + + data.alto_click = row.alto_click + } + + return data + } + + #addEventosLineas(tipoLinea, isInkjet = false) { + + $('#' + tipoLinea + '_papel').on("change", change_papelGenerico_lp_bn); + $('#' + tipoLinea + '_gramaje').on("focus", { mantenerSeleccion: true }, set_lp_bn_gramaje); + $('#' + tipoLinea + '_gramaje').on('change', function () { + var previous = $(this).data('val'); + const selected = $("select#lp_bn_gramaje option:selected"); + if (selected.text() != previous) { + clear_lp_bn(true) + } + }); + $('#' + tipoLinea + '_papelImpresion').on("focus", set_lp_bn_papelImpresion); + $('#' + tipoLinea + '_maquina').on("focus", set_lp_bn_maquina); + $('#' + tipoLinea + '_maquina').on("change", change_lp_bn_maquina); + $('#' + tipoLinea + '_vercalculos').on("click", { rowId: 'lp_bn' }, verCalculosInkjet); + + if (isInkjet) { + $('.' + tipoLinea + '-tipologia').on("change", change_lp_bn_tipologia); + $('#' + tipoLinea + '_defecto').on("click", por_defecto_lp_bn); + $('#' + tipoLinea + '_aFavorFibra').on("change", change_lp_bn_aFavorFibra); + } + } +} + +export default LineasPresupuesto; \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js index 577190f2..b096a520 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js @@ -780,8 +780,18 @@ class PresupuestoCliente { self.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales); - self.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente); - self.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta); + try{ + self.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente); + } + catch(e){ + console.log("Error al cargar diseño interior: " + e); + } + try{ + self.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta); + } + catch(e){ + console.log("Error al cargar diseño cubierta: " + e); + } setTimeout(() => { From 2231e943c766a1ee159641159fbfd15fe0a4978a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Tue, 31 Dec 2024 12:37:16 +0100 Subject: [PATCH 11/89] trabajando en lineas presupuesto eventos --- ci4/app/Config/Routes.php | 3 + .../Presupuestos/Presupuestoadmin.php | 414 +++++--- ci4/app/Models/Configuracion/MaquinaModel.php | 4 +- .../Configuracion/PapelImpresionModel.php | 32 +- ci4/app/Services/PresupuestoService.php | 4 +- .../admin/viewPresupuestoadminForm.php | 1 + .../assets/js/safekat/components/select2.js | 7 +- .../presupuestoAdmin/presupuestoAdminEdit.js | 15 +- .../presupuestoAdmin/sections/comparador.js | 12 +- .../presupuestoAdmin/sections/datosLibro.js | 14 +- .../sections/lineasPresupuesto.js | 900 +++++++++++++++--- 11 files changed, 1130 insertions(+), 276 deletions(-) diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 37d0bb7c..fd475aec 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -585,6 +585,9 @@ $routes->group('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos $routes->post('comparadorguardas', 'Presupuestoadmin::obtenerComparadorGuardas'); $routes->get('papelgenerico', 'Presupuestoadmin::getPapelGenerico'); $routes->get('papelgramaje', 'Presupuestoadmin::getGramaje'); + $routes->get('papelimpresion', 'Presupuestoadmin::getPapelImpresion'); + $routes->get('maquinas', 'Presupuestoadmin::getMaquinas'); + $routes->post('getlinea', 'Presupuestoadmin::getLineaPresupuesto'); }); $routes->resource('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestoadmin', 'except' => 'show,new,create,update']); diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index b436fe5c..9fc72223 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -481,6 +481,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $data['lsc'] = $presupuesto->lomo_sobrecubierta; $data['tipo_impresion'] = $presupuesto->tipo_impresion_id; $data['cosido'] = $presupuesto->cosido; + $data['POD'] = $this->getPOD(); $data['datosGenerales']['id'] = $presupuesto->id; $data['datosGenerales']['state'] = intval($presupuesto->estado_id); @@ -623,8 +624,8 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $papel_generico = $this->request->getPost('papel_generico'); $gramaje = $this->request->getPost('gramaje'); $paginas_color = $this->request->getPost('paginas_color'); - $isColor = $this->request->getPost('isColor'); - $isHq = $this->request->getPost('isHq'); + $isColor = $this->request->getPost('isColor')?1:0; + $isHq = $this->request->getPost('isHq')?1:0; $tipo_impresion_id = $this->request->getPost('tipo_impresion_id'); $uso = $this->request->getPost('uso'); @@ -867,140 +868,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController endif; endforeach; - } else { - - $isColor = $reqData['color'] ?? false; - $isHq = $reqData['hq'] ?? false; - - $datosPedido = (object) array( - 'paginas' => intval($reqData['paginas']) ?? 0, - 'tirada' => intval($reqData['tirada']) ?? 0, - 'merma' => intval($reqData['merma']) ?? 0, - 'ancho' => intval($reqData['ancho']) ?? 100000, - 'alto' => intval($reqData['alto']) ?? 100000, - 'a_favor_fibra' => $reqData['a_favor_fibra'] ?? 1, - 'isCosido' => (new TipoPresupuestoModel())->get_isCosido($tipo_impresion_id), // JJO esto es custom por cada tipo de presupuesto - ); - - $papel_generico = [ - 'id' => $reqData['papel_generico_id'] ?? 0, - 'nombre' => $reqData['papel_generico'] ?? "", - ]; - - $gramaje = $reqData['gramaje'] ?? 0; - - $cliente_id = $reqData['cliente_id'] ?? -1; - - $resourceData = []; - - if ($type == 'interior' || $type == 'guardas') { - - $datosTipolog = $reqData['negro'] ?? null; - if (!is_null($datosTipolog)) { - $datosTipolog = []; - $data = (object) array( - 'negro' => floatval($reqData['negro']) ?? 0, - 'cyan' => floatval($reqData['cyan']) ?? 0, - 'magenta' => floatval($reqData['magenta']) ?? 0, - 'amarillo' => floatval($reqData['amarillo']) ?? 0, - 'cg' => floatval($reqData['cg']) ?? 0, - 'gota_negro' => floatval($reqData['gota_negro']) ?? 0, - 'gota_color' => floatval($reqData['gota_color']) ?? 0, - ); - array_push($datosTipolog, $data); - } - - if ($type == 'guardas') { - - $datosPedido->paginas_impresion = intval($reqData['paginas_impresion']) ?? 0; - // Para el caso de Fresado y Cosido tapa dura, las guardas son un diptico - // y hay que imprimirlas como "cosido" (dos hojas pegadas). En el caso de espiral - // o wire-o tapa dura, las guardas se imprimen como hojas sueltas - if ($tipo_impresion_id == 1 || $tipo_impresion_id == 3) { - $datosPedido->isCosido = true; - } else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) { - $datosPedido->isCosido = false; - } - } - - $a_favor_fibra = $reqData['a_favor_fibra'] ?? false; - - $input_data = array( - 'uso' => $type, - 'tipo_impresion_id' => $tipo_impresion_id, - 'datosPedido' => $datosPedido, - 'papel_generico' => $papel_generico, - 'gramaje' => $gramaje, - 'isColor' => $isColor, - 'isHq' => $isHq, - 'cliente_id' => $cliente_id, - 'datosTipolog' => $datosTipolog, - 'a_favor_fibra' => $a_favor_fibra - ); - - $resourceData = PresupuestoService::obtenerComparadorPlana($input_data); - - } else if ($type == 'interior_rot') { - - $paginas = (object) array( - 'negro' => intval($reqData['paginas_negro'] ?? 0), - 'color' => intval($reqData['paginas_color'] ?? 0), - ); - - $datosTipolog = $reqData['negro'] ?? null; - if (!is_null($datosTipolog)) { - $datosTipolog = []; - $data = (object) array( - 'negro' => floatval($reqData['negro']) ?? 0, - 'cyan' => floatval($reqData['cyan']) ?? 0, - 'magenta' => floatval($reqData['magenta']) ?? 0, - 'amarillo' => floatval($reqData['amarillo']) ?? 0, - 'gota_negro' => floatval($reqData['gota_negro']) ?? 0, - 'gota_color' => floatval($reqData['gota_color']) ?? 0, - ); - array_push($datosTipolog, $data); - } - - $input_data = [ - 'datosPedido' => $datosPedido, - 'papel_generico' => $papel_generico, - 'gramaje' => $gramaje, - 'paginas' => $paginas, - 'cliente_id' => $cliente_id, - 'datosTipolog' => $datosTipolog - ]; - - $resourceData = PresupuestoService::obtenerComparadorRotativa($input_data); - - } else if ($type == 'cubierta' || $type == 'sobrecubierta') { - - $datosPedido->solapas = $reqData['solapas']; - $datosPedido->solapas_ancho = $reqData['solapas_ancho']; - $datosPedido->lomo = $reqData['lomo']; - - $input_data = array( - 'uso' => $type, - 'tipo_impresion_id' => $tipo_impresion_id, - 'datosPedido' => $datosPedido, - 'papel_generico' => $papel_generico, - 'gramaje' => $gramaje, - 'isColor' => 1, // Cubierta y sobrecubierta siempre color HQ - 'isHq' => 1, - 'cliente_id' => $cliente_id, - ); - - $resourceData = PresupuestoService::obtenerComparadorPlana($input_data); - } - - $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); - $data = [ - 'lineas' => $resourceData, - $csrfTokenName => $newTokenHash - ]; - - return $this->respond($data); - } + } return $this->respond(Collection::datatable( $resourceData, @@ -1013,6 +881,154 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController } + public function getLineaPresupuesto() + { + if ($this->request->isAJAX()) { + + $reqData = $this->request->getPost(); + + $type = $reqData['type'] ?? null; + // por defecto, se deja cosido tapa blanda por ahora JJO + $tipo_impresion_id = $reqData['tipo_impresion_id'] ?? 4; + + $isColor = $reqData['color'] ?? false; + $isHq = $reqData['hq'] ?? false; + + $datosPedido = (object) array( + 'paginas' => intval($reqData['paginas']) ?? 0, + 'tirada' => intval($reqData['tirada']) ?? 0, + 'merma' => intval($reqData['merma']) ?? 0, + 'ancho' => intval($reqData['ancho']) ?? 100000, + 'alto' => intval($reqData['alto']) ?? 100000, + 'a_favor_fibra' => $reqData['a_favor_fibra'] ?? 1, + 'isCosido' => (new TipoPresupuestoModel())->get_isCosido($tipo_impresion_id), // JJO esto es custom por cada tipo de presupuesto + ); + + $papel_generico = [ + 'id' => $reqData['papel_generico_id'] ?? 0, + 'nombre' => $reqData['papel_generico'] ?? "", + ]; + + $gramaje = $reqData['gramaje'] ?? 0; + + $cliente_id = $reqData['cliente_id'] ?? -1; + + $resourceData = []; + + if ($type == 'interior' || $type == 'guardas') { + + $datosTipolog = $reqData['negro'] ?? null; + if (!is_null($datosTipolog)) { + $datosTipolog = []; + $data = (object) array( + 'negro' => floatval($reqData['negro']) ?? 0, + 'cyan' => floatval($reqData['cyan']) ?? 0, + 'magenta' => floatval($reqData['magenta']) ?? 0, + 'amarillo' => floatval($reqData['amarillo']) ?? 0, + 'cg' => floatval($reqData['cg']) ?? 0, + 'gota_negro' => floatval($reqData['gota_negro']) ?? 0, + 'gota_color' => floatval($reqData['gota_color']) ?? 0, + ); + array_push($datosTipolog, $data); + } + + if ($type == 'guardas') { + + $datosPedido->paginas_impresion = intval($reqData['paginas_impresion']) ?? 0; + // Para el caso de Fresado y Cosido tapa dura, las guardas son un diptico + // y hay que imprimirlas como "cosido" (dos hojas pegadas). En el caso de espiral + // o wire-o tapa dura, las guardas se imprimen como hojas sueltas + if ($tipo_impresion_id == 1 || $tipo_impresion_id == 3) { + $datosPedido->isCosido = true; + } else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) { + $datosPedido->isCosido = false; + } + } + + $a_favor_fibra = $reqData['a_favor_fibra'] ?? false; + + $input_data = array( + 'uso' => $type, + 'tipo_impresion_id' => $tipo_impresion_id, + 'datosPedido' => $datosPedido, + 'papel_generico' => $papel_generico, + 'gramaje' => $gramaje, + 'isColor' => $isColor, + 'isHq' => $isHq, + 'cliente_id' => $cliente_id, + 'datosTipolog' => $datosTipolog, + 'a_favor_fibra' => $a_favor_fibra + ); + + $resourceData = PresupuestoService::obtenerComparadorPlana($input_data); + + } else if ($type == 'interior_rot') { + + $paginas = (object) array( + 'negro' => intval($reqData['paginas_negro'] ?? 0), + 'color' => intval($reqData['paginas_color'] ?? 0), + ); + + $datosTipolog = $reqData['negro'] ?? null; + if (!is_null($datosTipolog)) { + $datosTipolog = []; + $data = (object) array( + 'negro' => floatval($reqData['negro']) ?? 0, + 'cyan' => floatval($reqData['cyan']) ?? 0, + 'magenta' => floatval($reqData['magenta']) ?? 0, + 'amarillo' => floatval($reqData['amarillo']) ?? 0, + 'gota_negro' => floatval($reqData['gota_negro']) ?? 0, + 'gota_color' => floatval($reqData['gota_color']) ?? 0, + ); + array_push($datosTipolog, $data); + } + + $input_data = [ + 'datosPedido' => $datosPedido, + 'papel_generico' => $papel_generico, + 'gramaje' => $gramaje, + 'paginas' => $paginas, + 'cliente_id' => $cliente_id, + 'datosTipolog' => $datosTipolog + ]; + + $resourceData = PresupuestoService::obtenerComparadorRotativa($input_data); + + } else if ($type == 'cubierta' || $type == 'sobrecubierta') { + + $datosPedido->solapas = $reqData['solapas']; + $datosPedido->solapas_ancho = $reqData['solapas_ancho']; + $datosPedido->lomo = $reqData['lomo']; + + $input_data = array( + 'uso' => $type, + 'tipo_impresion_id' => $tipo_impresion_id, + 'datosPedido' => $datosPedido, + 'papel_generico' => $papel_generico, + 'gramaje' => $gramaje, + 'isColor' => 1, // Cubierta y sobrecubierta siempre color HQ + 'isHq' => 1, + 'cliente_id' => $cliente_id, + ); + + $resourceData = PresupuestoService::obtenerComparadorPlana($input_data); + } + + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data = [ + 'lineas' => $resourceData, + $csrfTokenName => $newTokenHash + ]; + + return $this->respond($data); + + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + public function datatable_2() { if ($this->request->isAJAX()) { @@ -1502,6 +1518,132 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController } + public function getPapelImpresion() + { + + if ($this->request->isAJAX()) { + + $papel_generico_id = $this->request->getGet('papel_generico'); + $gramaje = $this->request->getGet('gramaje'); + + $tipo_impresion_id = $this->request->getGet("tipo_impresion"); + $tapa_dura = model('App\Models\Configuracion\TipoPresupuestoModel')->get_isTapaDura(intval($tipo_impresion_id)); + + $tipo = $this->request->getGet("tipo"); + + $uso = $this->request->getGet("uso") ?? 'interior'; + + $model = model('App\Models\Configuracion\PapelImpresionModel'); + $query = $model->getPapelesImpresionForMenu( + $papel_generico_id, + $gramaje, + $tipo, + $uso, + $tapa_dura, + false + ); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("lg_papel_impresion.nombre", $this->request->getGet("q")) + ->groupEnd(); + } + + return $this->response->setJSON($query->orderBy("t1.nombre", "asc")->get()->getResultObject()); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + + + public function getMaquinas() + { + + if ($this->request->isAJAX()) { + + $ancho = $this->request->getGet('ancho'); + $alto = $this->request->getGet('alto'); + $tirada = $this->request->getGet('tirada'); + $merma = $this->request->getGet('merma'); + $tipo_impresion_id = $this->request->getGet('tipo_impresion'); + $isCosido = (new TipoPresupuestoModel())->get_isCosido($tipo_impresion_id); + $papel_impresion_id = $this->request->getGet('papel_impresion'); + $tarifa_tipo = $this->request->getGet("tarifa_tipo"); // negro, color, negrohq, colorhq + $uso_tarifa = $this->request->getGet("uso_tarifa") ?? 'interior'; // interior, cubierta, sobrecubierta + $is_rotativa = $this->request->getGet('is_rotativa') ?? 0; + $lomo_redondo = $this->request->getGet('lomo_redondo'); + $lomo = $this->request->getGet('lomo'); + $solapas = $this->request->getGet('solapas'); + $solapas_ancho = $this->request->getGet('solapas_ancho'); + + $model = model('App\Models\Configuracion\MaquinaModel'); + $query = $model->getMaquinaImpresionForPresupuesto( + $is_rotativa, + $tarifa_tipo, + $uso_tarifa, + intval($tirada) + intval($merma), + $papel_impresion_id + ); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("lg_maquinas.nombre", $this->request->getGet("q")) + ->groupEnd(); + } + $data = $query->orderBy("t1.nombre", "asc")->get()->getResultObject(); + + $query = $model->db->getLastQuery(); + $datosPedido = ((object) array( + 'ancho' => $ancho, + 'alto' => $alto, + 'isCosido' => $isCosido, + 'lomo' => $lomo, + 'solapas' => $solapas, + 'solapas_ancho' => $solapas_ancho, + )); + + for ($i = 0; $i < count($data); $i++) { + + if ($is_rotativa) { + + $has_error = true; + for ($f = 0; $f < 2; $f++) { + + $parametrosRotativa = (object) array( + 'a_favor_fibra' => $f, + ); + $values = []; + [$values['ancho'], $values['alto']] = PresupuestoService::calculoDimForma($datosPedido, $parametrosRotativa); + + $factor_anchura = round($data[$i]->ancho_impresion / $values['ancho'], 2); + + if (floor($factor_anchura) != 0) { + $has_error = false; + } + } + if ($has_error) { + unset($data[$i]); + } + } else { + + if ($uso_tarifa != 'interior') { + $datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($uso_tarifa, $tipo_impresion_id, $datosPedido, $data[$i]->maquina_id, $lomo_redondo); + $datosPedido->altoExteriores = PresupuestoService::getAltoTotalExteriores($uso_tarifa, $tipo_impresion_id, $datosPedido); + } + + $ancho_calculo = ($uso_tarifa == 'cubierta' || $uso_tarifa == 'sobrecubierta') ? $datosPedido->anchoExteriores : $datosPedido->ancho; + $alto_calculo = ($uso_tarifa == 'cubierta' || $uso_tarifa == 'sobrecubierta') ? $datosPedido->altoExteriores : $datosPedido->alto; + $formas = PresupuestoService::getNumFormasPlana($uso_tarifa, $data[$i], $ancho_calculo, $alto_calculo, $datosPedido->isCosido); + if ($formas['num_formas']['posicion_formas'] == 'n/a') { + unset($data[$i]); + } + } + } + + return $this->response->setJSON($data); + } else { + return $this->failUnauthorized('Invalid request', 403); + } + } + protected function getServiciosPreimpresion() diff --git a/ci4/app/Models/Configuracion/MaquinaModel.php b/ci4/app/Models/Configuracion/MaquinaModel.php index be6f7d01..b2f269e8 100755 --- a/ci4/app/Models/Configuracion/MaquinaModel.php +++ b/ci4/app/Models/Configuracion/MaquinaModel.php @@ -330,7 +330,7 @@ class MaquinaModel extends \App\Models\BaseModel ->table($this->table . " t1") ->distinct('t1.id') ->select( - "t1.id AS maquina_id, t1.nombre AS maquina, t1.ancho_impresion AS ancho_impresion, + "t1.id AS id, t1.id AS maquina_id, t1.nombre AS maquina, t1.nombre AS nombre, t1.ancho_impresion AS ancho_impresion, t1.alto_impresion AS alto_impresion, t1.ancho AS ancho, t1.alto AS alto, t1.is_rotativa AS is_rotativa, t1.is_inkjet AS is_inkjet, t1.alto_click AS alto_click, t1.velocidad AS velocidad, t1.precio_tinta_negro AS precio_tinta_negro, t1.precio_tinta_color AS precio_tinta_color, t1.precio_tinta_cg AS precio_tinta_cg, @@ -361,7 +361,7 @@ class MaquinaModel extends \App\Models\BaseModel $builder->where("t2.uso", $uso_tarifa); } - return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); + return $builder; } diff --git a/ci4/app/Models/Configuracion/PapelImpresionModel.php b/ci4/app/Models/Configuracion/PapelImpresionModel.php index de9473b9..3625daa7 100755 --- a/ci4/app/Models/Configuracion/PapelImpresionModel.php +++ b/ci4/app/Models/Configuracion/PapelImpresionModel.php @@ -279,8 +279,15 @@ class PapelImpresionModel extends \App\Models\BaseModel //tipo: negro, negrohq, color, colorhq //uso: interior, rotativa, cubierta, sobrecubierta - public function getPapelesImpresionForMenu($papel_generico = null, $gramaje = null, $tipo = null, $uso = "") - { + public function getPapelesImpresionForMenu( + $papel_generico = null, + $gramaje = null, + $tipo = null, + $uso = "", + $tapaDura = false, + $forInkjet = false + ) { + $builder = $this->db ->table($this->table . " t1") ->distinct("t1.id") @@ -289,7 +296,7 @@ class PapelImpresionModel extends \App\Models\BaseModel ->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left") ->join("lg_maquinas_tarifas_impresion t5", "t4.id = t5.maquina_id", "left") ->select( - "t1.id AS id, t1.nombre AS text" + "t1.id AS id, t1.nombre AS nombre" ); $builder->where("t1.is_deleted", 0); @@ -304,24 +311,31 @@ class PapelImpresionModel extends \App\Models\BaseModel $builder->where("t2.id", $papel_generico); $builder->where("t1.gramaje", $gramaje); - if ($uso == 'cubierta') + if ($uso == 'cubierta') { + if ($tapaDura) + $builder->where("t1.use_for_tapa_dura", 1); $builder->where("t1.cubierta", 1); - else if ($uso == 'sobrecubierta') + } else if ($uso == 'sobrecubierta') $builder->where("t1.sobrecubierta", 1); else if ($uso == 'guardas') $builder->where("t1.guardas", 1); else { + $builder->where("t1.interior", 1); if ($tipo == 'negro' || $tipo == 'negrohq') $builder->where("t1.bn", 1); else if ($tipo == 'color' || $tipo == 'colorhq') $builder->where("t1.color", 1); } - if ($uso == 'rotativa') + if ($uso == 'rotativa') { $builder->where("t1.rotativa", 1); - else + $builder->where("t4.is_rotativa", 1); + } else $builder->where("t1.rotativa", 0); - return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); + if ($forInkjet) + $builder->where("t1.inkjet", 1); + + return $builder; } public function getNombre($id) @@ -355,5 +369,5 @@ class PapelImpresionModel extends \App\Models\BaseModel return ""; } - + } diff --git a/ci4/app/Services/PresupuestoService.php b/ci4/app/Services/PresupuestoService.php index a9495780..39120a3b 100755 --- a/ci4/app/Services/PresupuestoService.php +++ b/ci4/app/Services/PresupuestoService.php @@ -1687,7 +1687,7 @@ class PresupuestoService extends BaseService uso_tarifa: $uso, tirada: $datosPedido->tirada + $datosPedido->merma, papel_impresion_id: $papel->id, - ); + )->orderBy("t1.id", "asc")->get()->getResultObject(); $data['uso'] = $uso; $data['tipo'] = $tipo; @@ -1775,7 +1775,7 @@ class PresupuestoService extends BaseService uso_tarifa: ($uso == 'guardas') ? 'interior' : $uso, tirada: $datosPedido->tirada + $datosPedido->merma, papel_impresion_id: $papel->id, - ); + )->orderBy("t1.id", "asc")->get()->getResultObject(); // Se recorren las máquinas y se calcula el coste de linea por cada una foreach ($maquinas as $maquina) { diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php index 120cb0e9..016f4cac 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php @@ -19,6 +19,7 @@ getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> + diff --git a/httpdocs/assets/js/safekat/components/select2.js b/httpdocs/assets/js/safekat/components/select2.js index febfa86c..06bca1f8 100644 --- a/httpdocs/assets/js/safekat/components/select2.js +++ b/httpdocs/assets/js/safekat/components/select2.js @@ -4,15 +4,16 @@ * @param {String} url * @param {String} placeholder */ -let ClassSelect = function (domItem, url, placeholder, allowClear = false, params = {}) { +let ClassSelect = function (domItem, url, placeholder, allowClear = false, params = {}, dropdownParent = "") { this.url = url; this.item = domItem; this.params = params; - + this.dropdownParent = dropdownParent; + this.config = { placeholder: placeholder, allowClear: allowClear, - dropdownParent: domItem.parent(), + dropdownParent: dropdownParent!=""?dropdownParent:domItem.parent(), language: "es", ajax: { url: () => { diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js index 0b281814..2d4b041c 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js @@ -4,6 +4,7 @@ import Ajax from '../../components/ajax.js'; import DatosGenerales from './sections/datosGenerales.js'; import DatosLibro from './sections/datosLibro.js'; import Comparador from './sections/comparador.js'; +import LineasPresupuesto from './sections/lineasPresupuesto.js'; class PresupuestoAdminEdit { @@ -19,6 +20,7 @@ class PresupuestoAdminEdit { this.cosido = $("#isCosido"); this.tipo_impresion = $("#tipo_impresion_id"); this.cosido = $("#isCosido"); + this.POD = $("#POD"); this.datosGenerales = new DatosGenerales(this.domItem.find('#accordionDatosPresupuestoTip')); this.datosLibro = new DatosLibro(this.domItem.find('#accordionDatosLibroTip'), @@ -28,6 +30,10 @@ class PresupuestoAdminEdit { checkPaginasPresupuesto: this.checkPaginasPresupuesto, }); this.comparador = new Comparador(this.domItem.find('#accordionDatosPresupuestoClienteTip')); + this.lineasPresupuesto = new LineasPresupuesto(this.domItem.find('#accordionLineasPresupuestoTip'), + { + getDimensionLibro: this.getDimensionLibro, + }); this.calcularPresupuesto = false; } @@ -42,6 +48,7 @@ class PresupuestoAdminEdit { this.datosGenerales.init(); this.datosLibro.init(); this.comparador.init(); + this.lineasPresupuesto.init(); if (window.location.href.includes("edit")) { @@ -74,6 +81,7 @@ class PresupuestoAdminEdit { self.lsc.val(parseFloat(response.data.lsc).toFixed(2)); self.cosido.val(response.data.cosido); self.tipo_impresion.val(response.data.tipo_impresion); + self.POD.val(response.data.POD); self.calcularPresupuesto = false; @@ -164,8 +172,11 @@ class PresupuestoAdminEdit { alto = parseFloat($('#papelFormatoAlto').val()); } else { - ancho = parseFloat($('#papelFormatoId').getText().trim().split(" x ")[0]); - alto = parseFloat($('#papelFormatoId').getText().trim().split(" x ")[1]); + const selectedText = $('#papelFormatoId').find('option:selected').text(); + if (selectedText.length > 0) { + ancho = parseFloat(selectedText.trim().split(" x ")[0]); + alto = parseFloat(selectedText.trim().split(" x ")[1]); + } } return { diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js index 61c553f2..60cf5a34 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js @@ -961,8 +961,8 @@ class Comparador { cliente_id: $('#clienteId').select2('data')[0].id, papel_generico: papel_generico, gramaje: gramaje, - isColor: this.tipo_impresion.val().includes('color'), - isHq: this.tipo_impresion.val().includes('hq'), + isColor: this.tipo_impresion.val().includes('color')?1:0, + isHq: this.tipo_impresion.val().includes('hq')?1:0, paginas_color: paginasColor } @@ -970,7 +970,9 @@ class Comparador { datos.datosPedido.lomo = this.getLomoLineasPresupuesto('interior'); datos.datosPedido.solapas = $('#solapas').prop('checked') ? 1 : 0; datos.datosPedido.solapas_ancho = $('#solapas').prop('checked') ? parseInt($('#solapas_ancho').val()) : 0; - datos.lomoRedondo = this.lomoRedondo.val(); + if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3){ + datos.lomoRedondo = this.lomoRedondo.val(); + } } else if (uso == 'sobrecubierta') { datos.datosPedido.lomo = this.getLomoLineasPresupuesto() + this.getLomoLineasPresupuesto('cubierta'); @@ -1039,8 +1041,8 @@ class Comparador { } else { - const isHq = this.tipo_impresion.val().includes('hq'); - const isColor = this.tipo_impresion.val().includes('color'); + const isHq = this.tipo_impresion.val().includes('hq')?1:0; + const isColor = this.tipo_impresion.val().includes('color')?1:0; datosComp.data['tipo_maquina'] = 'plana'; datosComp.data[this.csrf_token] = this.csrf_hash; diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js index 65637230..fe29d3e1 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js @@ -289,15 +289,16 @@ class DatosLibro { calcular_mermas(){ - const tirada = parseInt($('#tirada').val()) - var merma = 0 - htmlString = '' + const tirada = parseInt($('#tirada').val()); + const POD = parseInt($('#POD').val()); + let merma = 0; + let htmlString = ''; - if(tirada> parseInt($('#POD').val())){ - merma = tirada*0.1<=30 ? tirada*0.1 : 30 + if(tirada> POD){ + merma = tirada*0.1<=POD ? tirada*0.1 : POD; } else{ - merma_lineas = [] + let merma_lineas = [] tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) { var rowData = this.data(); if(rowData.row_id != 'lp_guardas' && rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta'){ @@ -342,6 +343,7 @@ class DatosLibro { this.paginas.val(datos.paginas); this.tirada.val(datos.tirada); + this.calcular_mermas(); if (datos.papelFormatoPersonalizado) { this.tamanioPersonalizado.prop('checked', true); $(".tamanio-personalizado").removeClass('d-none'); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js index 1e655a47..869655af 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js @@ -1,26 +1,62 @@ -import Ajax from "../../../components/ajax"; -import ClassSelect from "../../../components/select2"; +import ClassSelect from '../../../components/select2.js'; +import { getToken } from '../../../common/common.js'; +import Ajax from '../../../components/ajax.js'; + class LineasPresupuesto { constructor(domItem, functions = {}) { this.domItem = domItem; - this.functions = functions; + this.getDimensionLibro = functions.getDimensionLibro; this.table = null; + this.csrf_token = getToken(); + this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val(); + this.addLineaManual = this.domItem.find("#btn_addLinea"); } init() { + const self = this; + this.#initTable(); - this.addLineaManual.on('click', + this.addLineaManual.on('click', this.#insertLineaManual.bind(this)); + + // Botones de borrar de las lineas de presupuesto + $(document).on('click', '.btn-delete-lp', function (e) { + + const row = $(this).closest('tr'); + const data = self.table.row(row).data() + self.table.row(row) + .remove() + .draw(); + + // TO-DO + /*updatePresupuesto({ + update_lineas: false, + update_servicios: true, + update_envios: true, + update_resumen: true, + update_tiradas_alternativas: true + }) + if (data.row_id == 'lp_guardas') + servicioGuardas(false) + */ + + // Si existe cubierta, hay que actualizar con el valor del lomo + if (self.table.row('#lp_cubierta').length > 0) { + self.obtenerLinea('lp_cubierta', false, false); + } + }); } #initTable() { + const self = this; + const lastColNr_lp = $('#tableLineasPresupuesto').find("tr:first th").length - 1; const actionBtns_lp = function (data) { @@ -113,7 +149,7 @@ class LineasPresupuesto { if (row.row_id != "lp_cubierta" && row.row_id != "lp_sobrecubierta" && row.row_id != "lp_guardas") return ''; else if (row.row_id == "lp_cubierta") { - select = '' if (data == 2) { select += ''; + select.append(option); } return select[0].outerHTML @@ -223,8 +251,10 @@ class LineasPresupuesto { .addClass('form-control form-select-sm lp-cell lp-select ')//+ row.row_class + '-select') .css('min-width', '40px') - var option = ''; - select.append(option); + if (data) { + var option = ''; + select.append(option); + } return select[0].outerHTML } @@ -238,8 +268,10 @@ class LineasPresupuesto { .addClass('form-control form-select-sm lp-cell lp-select ' + row.row_class + '-select') .css('min-width', '150px') - var option = ''; - select.append(option); + if (data) { + var option = ''; + select.append(option); + } return select[0].outerHTML } @@ -253,8 +285,10 @@ class LineasPresupuesto { .addClass('form-control form-select-sm lp-cell lp-select ' + row.row_class + '-select') .css('min-width', '110px') - var option = ''; - select.append(option); + if (data) { + var option = ''; + select.append(option); + } return select[0].outerHTML } @@ -288,12 +322,12 @@ class LineasPresupuesto { className: 'row-edit dt-center' } ], - "order": [10, 'asc'] + "order": [10, 'asc'], }); this.table.on('click', 'td.dt-control', function (e) { let tr = e.target.closest('tr'); - let row = tableLineasPresupuesto.row(tr); + let row = self.table.row(tr); if (row.child.isShown()) { // This row is already open - close it @@ -301,7 +335,7 @@ class LineasPresupuesto { } else { // Open this row - row.child(format(row.data())).show(); + row.child(self.formatRow(row.data())).show(); } }); } @@ -320,20 +354,20 @@ class LineasPresupuesto { if (dataRows[number].row_id == 'lp_bn' || dataRows[number].row_id == 'lp_bnhq' || dataRows[number].row_id == 'lp_rot_bn') { - hayLinea = true - continue + hayLinea = true; + continue; } } if (hayLinea) { popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto'); - break + break; } - var data = processRowData({ tipo_maquina: 'toner' }, 'lp_bn', 'lp-bn'); - tableLineasPresupuesto.row.add(data).draw() - eventos_lp_bn() - break + var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_bn', 'lp-bn'); + this.table.row.add(data).draw(); + this.#addEventosLineas('lp_bn', false); + break; case 'lp_bnhq': var hayLinea = false @@ -351,9 +385,9 @@ class LineasPresupuesto { break } - var data = processRowData({ tipo_maquina: 'toner' }, 'lp_bnhq', 'lp-bnhq'); - tableLineasPresupuesto.row.add(data).draw() - eventos_lp_bnhq() + var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_bnhq', 'lp-bnhq'); + this.table.row.add(data).draw() + this.#addEventosLineas('lp_bnhq', false); break case 'lp_color': @@ -362,19 +396,19 @@ class LineasPresupuesto { if (dataRows[number].row_id == 'lp_color' || dataRows[number].row_id == 'lp_colorhq' || dataRows[number].row_id == 'lp_rot_color') { - hayLinea = true - continue + hayLinea = true; + continue; } } if (hayLinea) { popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto'); - break + break; } - var data = processRowData({ tipo_maquina: 'toner' }, 'lp_color', 'lp-color'); - tableLineasPresupuesto.row.add(data).draw() - eventos_lp_color() + var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_color', 'lp-color'); + this.table.row.add(data).draw(); + this.#addEventosLineas('lp_color', false); break case 'lp_colorhq': @@ -390,13 +424,13 @@ class LineasPresupuesto { if (hayLinea) { popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto'); - break + break; } - var data = processRowData({ tipo_maquina: 'toner' }, 'lp_colorhq', 'lp-colorhq'); - tableLineasPresupuesto.row.add(data).draw() - eventos_lp_colorhq() - break + var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_colorhq', 'lp-colorhq'); + this.table.row.add(data).draw(); + this.#addEventosLineas('lp_colorhq', false); + break; case 'lp_rot_bn': var hayLinea = false @@ -404,19 +438,19 @@ class LineasPresupuesto { if (dataRows[number].row_id == 'lp_bn' || dataRows[number].row_id == 'lp_bnhq' || dataRows[number].row_id == 'lp_rot_bn') { - hayLinea = true - continue + hayLinea = true; + continue; } } if (hayLinea) { popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto'); - break + break; } - var data = processRowData({ tipo_maquina: 'toner' }, 'lp_rot_bn', 'lp-rot-bn'); - tableLineasPresupuesto.row.add(data).draw() - eventos_lp_rot_bn() + var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_rot_bn', 'lp-rot-bn'); + this.table.row.add(data).draw(); + this.#addEventosLineas('lp_rot_bn', false); break case 'lp_rot_color': @@ -425,85 +459,82 @@ class LineasPresupuesto { if (dataRows[number].row_id == 'lp_color' || dataRows[number].row_id == 'lp_colorhq' || dataRows[number].row_id == 'lp_rot_color') { - hayLinea = true - continue + hayLinea = true; + continue; } } if (hayLinea) { popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto'); - break + break; } - var data = processRowData({ tipo_maquina: 'toner' }, 'lp_rot_color', 'lp-rot-color'); - tableLineasPresupuesto.row.add(data).draw() - eventos_lp_rot_color() - break + var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_rot_color', 'lp-rot-color'); + this.table.row.add(data).draw() + this.#addEventosLineas('lp_rot_color', false); + break; case 'lp_cubierta': var hayLinea = false for (let number = 0; number < dataRows.length; number++) { if (dataRows[number].row_id == 'lp_cubierta') { - hayLinea = true - continue + hayLinea = true; + continue; } } if (hayLinea) { popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto'); - break + break; } - var data = processRowData({ tipo_maquina: 'toner' }, 'lp_cubierta', 'lp-cubierta'); - tableLineasPresupuesto.row.add(data).draw() - eventos_lp_cubierta() + var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_cubierta', 'lp-cubierta'); + this.table.row.add(data).draw(); + this.#addEventosLineas('lp_cubierta', false); break case 'lp_sobrecubierta': var hayLinea = false for (let number = 0; number < dataRows.length; number++) { if (dataRows[number].row_id == 'lp_sobrecubierta') { - hayLinea = true - continue + hayLinea = true; + continue; } } if (hayLinea) { popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto'); - break + break; } - var data = processRowData({ tipo_maquina: 'toner' }, 'lp_sobrecubierta', 'lp-sobrecubierta'); - tableLineasPresupuesto.row.add(data).draw() - eventos_lp_sobrecubierta() + var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_sobrecubierta', 'lp-sobrecubierta'); + this.table.row.add(data).draw(); + this.#addEventosLineas('lp_sobrecubierta', false); break case 'lp_guardas': var hayLinea = false for (let number = 0; number < dataRows.length; number++) { if (dataRows[number].row_id == 'lp_guardas') { - hayLinea = true - continue + hayLinea = true; + continue; } } if (hayLinea) { popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto'); - break + break; } - var data = processRowData({ tipo_maquina: 'toner' }, 'lp_guardas', 'lp-guardas'); - tableLineasPresupuesto.row.add(data).draw() - $('#lp_guardas_gramaje').empty() - var o = new Option("170", "170"); - $('#lp_guardas_gramaje').append(o) - eventos_lp_guardas() - servicioGuardas(true) + var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_guardas', 'lp-guardas'); + this.table.row.add(data).draw() + this.#addEventosLineas('lp_guardas', false); + servicioGuardas(true); break default: break } - $("#tableLineasPresupuesto").DataTable().columns.adjust(); + this.table.columns.adjust(); } #processRowData(row, rowId, rowClass) { @@ -511,40 +542,40 @@ class LineasPresupuesto { var icon = "" if (rowId == 'lp_bn') { if (row.tipo_maquina == 'toner') - icon = '' + icon = '/themes/vuexy/img/safekat/presupuestos/icon_bn.png' else - icon = '' + icon = '/themes/vuexy/img/safekat/presupuestos/icon_inkjet_bn.png'; } else if (rowId == 'lp_bnhq') { if (row.tipo_maquina == 'toner') - icon = '' + icon = '/themes/vuexy/img/safekat/presupuestos/icon_bnhq.png'; else - icon = '' + icon = '/themes/vuexy/img/safekat/presupuestos/icon_inkjet_bn.png'; } else if (rowId == 'lp_color') { if (row.tipo_maquina == 'toner') - icon = '' + icon = '/themes/vuexy/img/safekat/presupuestos/icon_color.png'; else - icon = '' + icon = '/themes/vuexy/img/safekat/presupuestos/icon_inkjet_color.png'; } else if (rowId == 'lp_colorhq') { if (row.tipo_maquina == 'toner') - icon = '' + icon = '/themes/vuexy/img/safekat/presupuestos/icon_colorhq.png'; else - icon = '' + icon = '/themes/vuexy/img/safekat/presupuestos/icon_inkjet_color.png'; } else if (rowId == 'lp_cubierta') - icon = '' + icon = '/themes/vuexy/img/safekat/presupuestos/icon_cubierta.png'; else if (rowId == 'lp_sobrecubierta') - icon = '' + icon = '/themes/vuexy/img/safekat/presupuestos/icon_sobrecubierta.png'; else if (rowId == 'lp_guardas') - icon = '' + icon = '/themes/vuexy/img/safekat/presupuestos/icon_guardas.png'; else if (rowId == 'lp_rot_bn') - icon = '' + icon = '/themes/vuexy/img/safekat/presupuestos/icon_rotativa_bn.png'; else if (rowId == 'lp_rot_color') - icon = '' + icon = '/themes/vuexy/img/safekat/presupuestos/icon_rotativa_color.png'; const blank_line = (typeof row.tarifa_impresion_id === 'undefined') ? 1 : 0; var data = { @@ -565,6 +596,7 @@ class LineasPresupuesto { 'paginas': blank_line ? 0 : row.paginas, 'paginas_impresion': rowId == 'lp_guardas' ? row.paginas_impresion : 0, 'papel': blank_line ? "" : row.papel_generico_id, + 'papel_nombre': blank_line ? "" : row.papel_generico, 'gramaje': blank_line ? "" : row.gramaje, 'papel_impresion': blank_line ? "" : row.papel_impresion, 'papel_impresion_id': blank_line ? "" : row.papel_impresion_id, @@ -662,28 +694,674 @@ class LineasPresupuesto { return data } - #addEventosLineas(tipoLinea, isInkjet = false) { + formatRow(d) { + + var value = ''+ + ''+ + ''+ + ''+ + '
' + + '
' + + window.language.Presupuestos.numeroPliegos + + ''+ + '
'+ + '
' + + window.language.Presupuestos.pliegosPedido + + ''+ + '
'+ + '
' + + window.language.Presupuestos.precioPliego + + ''+ + '
'+ + '
' + + window.language.Presupuestos.libro + + ''+ + '
'+ + '
' + + window.language.Presupuestos.totalPapelPedido + + ''+ + '
'+ + '' + + '
' + + '' + + '
'+ + '
' + + window.language.Presupuestos.click + + ''+ + '
'+ + '
' + + window.language.Presupuestos.totalClicks + + ''+ + '
'+ + '
' + + window.language.Presupuestos.horas + + ''+ + '
'+ + '
' + + window.language.Presupuestos.precioHora + + ''+ + '
'+ + '
' + + window.language.Presupuestos.precioImpresion + + ''+ + '
'+ + '
' + + '' + + '
'+ + '' + + '' + + '
' + + '' + + + + + value += '' + + if(d.maquinaTipo=='inkjet'){ + value += + ''+ + ''+ + ''+ + ''+ + '
' + + '
' + + '' + + '
'+ + '
' + + window.language.Presupuestos.numPagColor + + '' + + '
' + + ((d.row_id.includes('rot'))?'
' + + window.language.Presupuestos.saturacion + + '' + + '
':'') + + '
' + + window.language.Presupuestos.cobNegro + + '' + + '
' + + '
' + + window.language.Presupuestos.cobCyan + + '' + + '
' + + '
' + + window.language.Presupuestos.cobMagenta + + '' + + '
' + + '
' + + window.language.Presupuestos.cobAmarillo + + '' + + '
' + + ((!d.row_id.includes('rot'))? + '
' + + window.language.Presupuestos.cobCG + + '' + + '
':'') + + '
' + + window.language.Presupuestos.gotaNegro + + '' + + '
' + + '
' + + window.language.Presupuestos.gotaColor + + '' + + '
' + + '
' + + window.language.Presupuestos.aFavorFibra + + '' + + '
' + + '
' + + '' + + '
' + + '
' + + + '' + + '' + + ''+ + ''+ + ''+ + ''+ + '
' + + ((!d.row_id.includes('rot'))? + '
' + + window.language.Presupuestos.factorAltura + + '' + + '
' + + '
' + + window.language.Presupuestos.factorAnchura + + '' + + '
':'') + + (d.row_id.includes('rot')?'
': '' + + + (d.row_id.includes('rot')?'
' + + window.language.Presupuestos.resolucion + + '' + + '
':'') + + (d.row_id.includes('rot')?'
' + + window.language.Presupuestos.areaPaginas + + '' + + '
':'') + + '
' + + window.language.Presupuestos.gotasNegro + + '' + + '
' + + '
' + + window.language.Presupuestos.gotasCyan + + '' + + '
' + + '
' + + window.language.Presupuestos.gotasMagenta + + '' + + '
' + + '
' + + window.language.Presupuestos.gotasAmarillo + + '' + + '
' + + (!(d.row_id.includes('rot'))?'
' + + window.language.Presupuestos.gotasCG + + '' + + '
':'') + + '
' + + window.language.Presupuestos.precioPagNegro + + '' + + '
' + + '
' + + window.language.Presupuestos.precioPagColor + + '' + + '
' + + (d.row_id.includes('rot')? + '
' + + window.language.Presupuestos.factorAltura + + '' + + '
' + + '
' + + window.language.Presupuestos.factorAnchura + + '' + + '
':'') + + (d.row_id.includes('rot')?'
' + + window.language.Presupuestos.paginasPliego + + '' + + '
':'') + + '
' + + '' + + '' + + ''+ + ''+ + ''+ + ''+ + '
' + + (d.row_id.includes('rot')?'
': '' + + (d.row_id.includes('rot')?'
': '' + + (d.row_id.includes('rot')?'
' + + window.language.Presupuestos.clicksLibro + + '' + + '
':'') + + ((!d.row_id.includes('rot'))?'
' + + window.language.Presupuestos.saturacion + + '' + + '
':'') + + ((!d.row_id.includes('rot'))?'
' + + window.language.Presupuestos.paginasPliego + + '' + + '
':'') + + '
' + + window.language.Presupuestos.gTintaNegro + + '' + + '
' + + '
' + + window.language.Presupuestos.gTintaCyan + + '' + + '
' + + '
' + + window.language.Presupuestos.gTintaMagenta + + '' + + '
' + + '
' + + window.language.Presupuestos.gTintaAmarillo + + '' + + '
' + + (!(d.row_id.includes('rot'))?'
' + + window.language.Presupuestos.gTintaCG + + '' + + '
':'') + + ((!d.row_id.includes('rot'))?'
' + + window.language.Presupuestos.clicksLibro + + '' + + '
':'') + + '
' + + window.language.Presupuestos.clicksPedido + + '' + + '
' + + '
' + + window.language.Presupuestos.totalClicks + + '' + + '
' + + '
' + + window.language.Presupuestos.totalTinta + + '' + + '
' + + (d.row_id.includes('rot')?'
': '' + + '
' + + window.language.Presupuestos.totalImpresion + + '' + + '
' + + '
' + + '' + + '' + + ''+ + ''+ + ''+ + ''+ + '
' + + ((!d.row_id.includes('rot'))?'
' + + window.language.Presupuestos.resolucion + + '' + + '
':'') + + ((!d.row_id.includes('rot'))?'
' + + window.language.Presupuestos.areaPaginas + + '' + + '
':'') + + (d.row_id.includes('rot')?'
': '' + + (d.row_id.includes('rot')?'
': '' + + (d.row_id.includes('rot')?'
': '' + + '
' + + window.language.Presupuestos.gTintaNegroPed + + '' + + '
' + + '
' + + window.language.Presupuestos.gTintaCyanPed + + '' + + '
' + + '
' + + window.language.Presupuestos.gTintaMagentaPed + + '' + + '
' + + '
' + + window.language.Presupuestos.gTintaAmarilloPed + + ''+ + '
' + + (!(d.row_id.includes('rot'))?'
' + + window.language.Presupuestos.gTintaCGPed + + ''+ + '
':'') + + '
' + + '' + + '' + } + + return $(value).toArray(); + } - $('#' + tipoLinea + '_papel').on("change", change_papelGenerico_lp_bn); - $('#' + tipoLinea + '_gramaje').on("focus", { mantenerSeleccion: true }, set_lp_bn_gramaje); - $('#' + tipoLinea + '_gramaje').on('change', function () { - var previous = $(this).data('val'); - const selected = $("select#lp_bn_gramaje option:selected"); - if (selected.text() != previous) { - clear_lp_bn(true) + + getLomoInterior() { + let lomo = 0; + this.table.rows().every(function (rowIdx, tableLoop, rowLoop) { + if (this.data().row_id != 'lp_cubierta' && this.data().row_id != 'lp_sobrecubierta' && this.data().row_id != 'lp_guardas' && this.data().row_id != 'lp_rot_bn' && this.data().row_id != 'lp_fajas') { + lomo += parseFloat(this.data().mano); } }); - $('#' + tipoLinea + '_papelImpresion').on("focus", set_lp_bn_papelImpresion); - $('#' + tipoLinea + '_maquina').on("focus", set_lp_bn_maquina); - $('#' + tipoLinea + '_maquina').on("change", change_lp_bn_maquina); - $('#' + tipoLinea + '_vercalculos').on("click", { rowId: 'lp_bn' }, verCalculosInkjet); + return lomo; + } + + getLomoCubierta() { + this.table.rows().every(function (rowIdx, tableLoop, rowLoop) { + if (this.data().row_id == 'lp_cubierta') { + return parseFloat(this.data().mano); + } + }); + return 0; + } + + + obtenerLinea(linea = 'lp_bn', fromComparador = false, updatedTipologias = false, input_data = {}) { + + const self = this; + const dimension = this.getDimensionLibro(); + + if (Object.keys(input_data).length == 0) { + + input_data = { + paginas: parseInt($('#' + linea + '_paginas').val()), + papel_generico_id: $('#' + linea +'_papel option:selected').val(), + papel_generico: $('#' + linea + '_papel option:selected').text().trim(), + gramaje: $('#' + linea + '_gramaje option:selected').text().trim(), + maquina_id: $('#' + linea + '_maquina option:selected').val(), + papel_impresion_id: $('#' + linea + '_papelImpresion option:selected').val() + } + } + + + if(input_data.maquina_id == undefined || input_data.maquina_id == '') { + return; + } + if(linea != 'lp_guardas' && linea != 'lp_sobrecubierta' && linea != 'lp_faja' ) { + if(input_data.paginas == 0 ) + return; + } + + let uso = 'interior'; + switch (linea) { + case 'lp_cubierta': + uso = 'cubierta'; + break; + case 'lp_sobrecubierta': + uso = 'sobrecubierta'; + break; + case 'lp_guardas': + uso = 'guardas'; + break; + case 'lp_rot_bn': + case 'lp_rot_color': + uso = 'interior_rot'; + break; + } + + let color = 1; + if (linea == 'lp_bn' || linea == 'lp_bnhq' || linea == 'lp_rot_bn') { + color = 0; + } + let hq = 1; + if (linea == 'lp_bn' || linea == 'lp_color' || linea == 'lp_rot_bn' || linea == 'lp_rot_color') { + hq = 0; + } + + + var datos = { + tipo_impresion_id: $('#tipo_impresion_id').val(), + type: uso, + color: color, + hq: hq, + paginas: input_data.paginas, + tirada: parseInt($('#tirada').val()), + merma: parseInt($('#merma').val()), + ancho: dimension.ancho, + alto: dimension.alto, + papel_generico_id: input_data.papel_generico_id, + papel_generico: input_data.papel_generico, + gramaje: input_data.gramaje, + cliente_id: $('#clienteId').find(":selected").val(), + }; + datos = Object.assign(datos, window.token_ajax); + + // Si es inkjet, existe este check + if ($('#lp_bn_aFavorFibra').length) { + datos.a_favor_fibra = $('#lp_bn_aFavorFibra').prop('checked') + } + + if (updatedTipologias && $('#lp_bn_gotaNegro').length) { + datos.gota_negro = $('#lp_bn_gotaNegro').val() + datos.gota_color = $('#lp_bn_gotaColor').val() + datos.negro = $('#lp_bn_cobNegro').val() + datos.cyan = $('#lp_bn_cobCyan').val() + datos.magenta = $('#lp_bn_cobMagenta').val() + datos.amarillo = $('#lp_bn_cobAmarillo').val() + if ($('#lp_bn_cobCG').length) { + datos.cg = $('#lp_bn_cobCG').val() + } + } + + new Ajax('/presupuestoadmin/getlinea', + datos, + {}, + (response) =>{ + if(response.lineas.length >0){ + + $.each(response.lineas, function(key, value) { + // Se cogen los valores de la linea con los datos correspondientes + if(value.fields.maquina_id === input_data.maquina_id && + value.fields.papel_generico_id === input_data.papel_generico_id && + value.fields.papel_impresion_id === input_data.papel_impresion_id) { + + // Si viene del comparador + if(Object.keys(input_data).length == 0){ + value.fields.check_papel_total = $('#'+ linea + '_checkPapel').is(":checked")?1:0 + value.fields.check_impresion_total = $('#'+ linea + '_checkClicks').is(":checked")?1:0 + + } + else{ + value.fields.check_papel_total = 1 + value.fields.check_impresion_total = 1 + } + self.rellenarDatosLinea(linea,value.fields); + + return false; + } + }); + } + else{ + let pags = $("#" + linea + "_paginas" ).val() + $("." + linea +"-input" ).val("0") + $("#"+ linea +"_paginas" ).val(pags) + + } + }, + (error) =>{ + console.error(error); + } + ).post(); + + } + + rellenarDatosLinea(linea, row, fromComparator=false){ + + + if(fromComparator){ + + var input_data = { + paginas: row.paginas, + papel_generico_id: row.papelGenericoId, + gramaje: row.gramaje, + papel_impresion_id: row.papelImpresionId, + maquina_id: row.maquinaId, + } + this.obtenerLinea(linea, fromComparator, input_data) + } + else{ + // Se guarda el estado de "ver calculos" + const mostrar_calculos = ($( ".calculos_"+ linea).css('display') == 'table-row') + + // Si viene de hacerlo a mano... + let data = this.#processRowData(row, linea, linea.replace('_', '-')); + + let currentRow = this.table.row('#' + linea); + if(currentRow.length>0) + this.table.row('#' + linea).data(data).draw() + else{ + this.table.row.add(data).draw() + currentRow = this.table.row('#' + linea); + } + currentRow.child(this.formatRow(currentRow.data())).show(); + + this.#addEventosLineas(linea, data.maquinaTipo=='inkjet'?true:false); + + + $('#'+ linea + '_checkPapel').trigger('change'); + + + /* TO-DO + calcular_mermas() + + updatePresupuesto({ + update_lineas: false, + update_servicios: true, + update_envios: true, + update_resumen: true, + update_tiradas_alternativas: true + }) + */ + + // Si existe cubierta, hay que actualizar con el valor del lomo + if (this.table.row('#lp_cubierta').length > 0) { + this.obtenerLinea('lp_cubierta', false, false); + } + if(mostrar_calculos){ + $( ".calculos_" + linea).css('display','table-row') + } + } + + this.table.columns.adjust(); + + } + + #addEventosLineas(tipoLinea, isInkjet = false) { + + const self = this; + + let tipo = 'negro'; + let uso = 'interior'; + switch (tipoLinea) { + case 'lp_negrohq': + tipo = 'negrohq'; + break; + case 'lp_rot_color': + case 'lp_color': + tipo = 'color'; + break; + case 'lp_colorhq': + case 'lp_guardas': + case 'lp_cubierta': + case 'lp_sobrecubierta': + tipo = 'colorhq'; + break + default: + break; + } + + switch (tipoLinea) { + case 'lp_cubierta': + uso = 'cubierta'; + break; + case 'lp_sobrecubierta': + uso = 'sobrecubierta'; + break; + case 'lp_guardas': + uso = 'guardas'; + break; + case 'lp_rot_bn': + case 'lp_rot_color': + uso = 'rotativa'; + break; + default: + break; + } + + let select_papel = new ClassSelect($('#' + tipoLinea + '_papel'), + '/presupuestoadmin/papelgenerico', 'Seleccione papel', false, + { + [this.csrf_token]: this.csrf_hash, + tipo_impresion: () => $("#tipo_impresion_id").val(), + tirada: () => $('#tirada').val(), + tipo: tipo, + uso: uso, + }, $('body')); + select_papel.init(); + + + let select_gramaje = new ClassSelect($('#' + tipoLinea + '_gramaje'), + '/presupuestoadmin/papelgramaje', 'Seleccione gramaje', false, + { + [this.csrf_token]: this.csrf_hash, + papel_generico: () => select_papel.getVal(), + tipo_impresion: () => $("#tipo_impresion_id").val(), + tirada: () => $('#tirada').val(), + tipo: tipo, + uso: uso, + }, $('body')); + select_gramaje.init(); + + let papel_impresion = new ClassSelect($('#' + tipoLinea + '_papelImpresion'), + '/presupuestoadmin/papelimpresion', 'Seleccione papel', false, + { + [this.csrf_token]: this.csrf_hash, + papel_generico: () => select_papel.getVal(), + gramaje: () => select_gramaje.getVal(), + tipo_impresion: () => $("#tipo_impresion_id").val(), + tipo: tipo, + uso: uso, + }, $('body')); + papel_impresion.init(); + + let merma = uso == 'interior' ? $('#merma').val() : $('#mermacubierta').val(); + uso = ((uso == 'guardas') ? 'cubierta' : uso); + + let maquinas = new ClassSelect($('#' + tipoLinea + '_maquina'), + '/presupuestoadmin/maquinas', 'Seleccione maquina', false, + { + [this.csrf_token]: this.csrf_hash, + ancho: () => this.getDimensionLibro().ancho, + alto: () => this.getDimensionLibro().alto, + solapas: () => uso == 'cubierta' ? $('#solapas').prop('checked') : $('#solapas_sobrecubierta').prop('checked'), + solapas_ancho: () => uso == 'cubierta' ? $('#solapas_ancho').val() : $('#solapas_ancho_sobrecubierta').val(), + tirada: () => $('#tirada').val(), + merma: merma, + papel_impresion: () => papel_impresion.getVal(), + tipo_impresion: () => $("#tipo_impresion_id").val(), + tarifa_tipo: tipo, + uso_tarifa: uso == 'rotativa' ? 'interior' : uso, + is_rotativa: () => tipoLinea.includes('rot') ? 1 : 0, + lomo_redondo: () => (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3) ? $('#compLomoRedondo').val() : 0, + lomo: () => uso == 'sobrecubierta' ? this.getLomoCubierta() : this.getLomoInterior(), + }, $('body')); + maquinas.init(); + + + $('#' + tipoLinea + '_papel').on("change", () => { + select_gramaje.reset(); + papel_impresion.reset(); + maquinas.reset(); + }); + $('#' + tipoLinea + '_gramaje').on('change', () => { + papel_impresion.reset(); + maquinas.reset(); + }); + $('#' + tipoLinea + '_papelImpresion').on("change", () => { maquinas.reset(); }); + + $('#' + tipoLinea + '_maquina').on("change", function (event) { + self.obtenerLinea(tipoLinea, false, false, {}, event); // Pasamos explícitamente 'tipoLinea' + }.bind(this)); + $('#' + tipoLinea + '_paginas').on("change", function (event) { + if(tipoLinea != 'lp_sobrecubierta') { + self.obtenerLinea(tipoLinea, false, false, {}, event); // Pasamos explícitamente 'tipoLinea' + } + }.bind(this)); + $('#' + tipoLinea + '_vercalculos').on("click", ()=> self.verCalculosInkjet(tipoLinea)); + /* TO-DO if (isInkjet) { $('.' + tipoLinea + '-tipologia').on("change", change_lp_bn_tipologia); $('#' + tipoLinea + '_defecto').on("click", por_defecto_lp_bn); $('#' + tipoLinea + '_aFavorFibra').on("change", change_lp_bn_aFavorFibra); - } + }*/ } + + + verCalculosInkjet(linea){ + if($( ".calculos_" + linea ).css('display') == 'none') + $( ".calculos_" + linea ).css('display', 'table-row') + else{ + $( ".calculos_" + linea ).css('display', 'none') + } + }; } export default LineasPresupuesto; \ No newline at end of file From e9d4b0971bb8c8a397b92b2ae502a4bcb092512c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Thu, 2 Jan 2025 17:33:23 +0100 Subject: [PATCH 12/89] trabajando en guardar presupuesto hasta las lineas de presupuesto --- .../Presupuestos/Presupuestoadmin.php | 11 +- .../Presupuestos/PresupuestoLineaModel.php | 3 +- .../admin/_lineasPresupuestoItems.js | 4015 ----------------- .../presupuestoAdmin/presupuestoAdminEdit.js | 2 +- .../presupuestoAdmin/sections/comparador.js | 2 +- .../sections/lineasPresupuesto.js | 1187 +++-- 6 files changed, 800 insertions(+), 4420 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index 9fc72223..473253b8 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -344,7 +344,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $this->viewData['acabadosSobrecubierta'] = $this->getAcabadosSobrecubierta(); // Lineas Presupuesto - [$cambios_lineas, $this->viewData['lineasPresupuesto']] = $this->getLineasPresupuesto($presupuestoEntity); + [$cambios_lineas, $this->viewData['lineasPresupuesto']] = $this->loadLineasPresupuesto($presupuestoEntity); $this->viewData['presupuestoEntity']->cambios_lineas = $cambios_lineas; // Servicios @@ -542,6 +542,8 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $data['comparador']['lomoRedondo'] = $presupuesto->lomo_redondo; $data['comparador']['cabezada'] = $presupuesto->cabezada; + $data['lineasPresupuesto'] = $this->loadLineasPresupuesto($presupuesto); + /* @@ -909,6 +911,11 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController 'nombre' => $reqData['papel_generico'] ?? "", ]; + if($papel_generico['id'] != 0 && $papel_generico['nombre'] == ""){ + $modelPapelGenerico = new PapelGenericoModel(); + $papel_generico['nombre'] = $modelPapelGenerico->getNombre($papel_generico['id'])['nombre']; + } + $gramaje = $reqData['gramaje'] ?? 0; $cliente_id = $reqData['cliente_id'] ?? -1; @@ -1707,7 +1714,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController return model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value; } - protected function getLineasPresupuesto($presupuestoEntity) + protected function loadLineasPresupuesto($presupuestoEntity) { $lineas = (new PresupuestoLineaModel())->getLineasPresupuesto($presupuestoEntity->id); diff --git a/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php b/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php index 6a34a602..47e6ec82 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php @@ -330,8 +330,9 @@ class PresupuestoLineaModel extends \App\Models\BaseModel $builder = $this->db ->table($this->table . " t1") ->select( - "*" + "*, t2.nombre AS papel_generico" ) + ->join("lg_papel_generico t2", "t1.papel_id = t2.id", "left") ->where("t1.presupuesto_id", $presupuesto_id); return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.js b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.js index 19e5920c..dc99b9d2 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.js +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.js @@ -333,325 +333,6 @@ function change_focus(){ } -// Formatting function for row details - modify as you need -function format(d) { - - var value = ''+ - ''+ - ''+ - ''+ - '
' + - '
' + - window.Presupuestos.numeroPliegos + - ''+ - '
'+ - '
' + - window.Presupuestos.pliegosPedido + - ''+ - '
'+ - '
' + - window.Presupuestos.precioPliego + - ''+ - '
'+ - '
' + - window.Presupuestos.libro + - ''+ - '
'+ - '
' + - window.Presupuestos.totalPapelPedido + - ''+ - '
'+ - '' + - '
' + - '' + - '
'+ - '
' + - window.Presupuestos.click + - ''+ - '
'+ - '
' + - window.Presupuestos.totalClicks + - ''+ - '
'+ - '
' + - window.Presupuestos.horas + - ''+ - '
'+ - '
' + - window.Presupuestos.precioHora + - ''+ - '
'+ - '
' + - window.Presupuestos.precioImpresion + - ''+ - '
'+ - '
' + - '' + - '
'+ - '' + - '' + - '
' + - '' - - - - - value += '' - - if(d.maquinaTipo=='inkjet'){ - value += - ''+ - ''+ - ''+ - ''+ - '
' + - '
' + - '' + - '
'+ - '
' + - window.Presupuestos.numPagColor + - '' + - '
' + - ((d.row_id.includes('rot'))?'
' + - window.Presupuestos.saturacion + - '' + - '
':'') + - '
' + - window.Presupuestos.cobNegro + - '' + - '
' + - '
' + - window.Presupuestos.cobCyan + - '' + - '
' + - '
' + - window.Presupuestos.cobMagenta + - '' + - '
' + - '
' + - window.Presupuestos.cobAmarillo + - '' + - '
' + - ((!d.row_id.includes('rot'))? - '
' + - window.Presupuestos.cobCG + - '' + - '
':'') + - '
' + - window.Presupuestos.gotaNegro + - '' + - '
' + - '
' + - window.Presupuestos.gotaColor + - '' + - '
' + - '
' + - window.Presupuestos.aFavorFibra + - '' + - '
' + - '
' + - '' + - '
' + - '
' + - - '' + - '' + - ''+ - ''+ - ''+ - ''+ - '
' + - ((!d.row_id.includes('rot'))? - '
' + - window.Presupuestos.factorAltura + - '' + - '
' + - '
' + - window.Presupuestos.factorAnchura + - '' + - '
':'') + - (d.row_id.includes('rot')?'
': '' + - - (d.row_id.includes('rot')?'
' + - window.Presupuestos.resolucion + - '' + - '
':'') + - (d.row_id.includes('rot')?'
' + - window.Presupuestos.areaPaginas + - '' + - '
':'') + - '
' + - window.Presupuestos.gotasNegro + - '' + - '
' + - '
' + - window.Presupuestos.gotasCyan + - '' + - '
' + - '
' + - window.Presupuestos.gotasMagenta + - '' + - '
' + - '
' + - window.Presupuestos.gotasAmarillo + - '' + - '
' + - (!(d.row_id.includes('rot'))?'
' + - window.Presupuestos.gotasCG + - '' + - '
':'') + - '
' + - window.Presupuestos.precioPagNegro + - '' + - '
' + - '
' + - window.Presupuestos.precioPagColor + - '' + - '
' + - (d.row_id.includes('rot')? - '
' + - window.Presupuestos.factorAltura + - '' + - '
' + - '
' + - window.Presupuestos.factorAnchura + - '' + - '
':'') + - (d.row_id.includes('rot')?'
' + - window.Presupuestos.paginasPliego + - '' + - '
':'') + - '
' + - '' + - '' + - ''+ - ''+ - ''+ - ''+ - '
' + - (d.row_id.includes('rot')?'
': '' + - (d.row_id.includes('rot')?'
': '' + - (d.row_id.includes('rot')?'
' + - window.Presupuestos.clicksLibro + - '' + - '
':'') + - ((!d.row_id.includes('rot'))?'
' + - window.Presupuestos.saturacion + - '' + - '
':'') + - ((!d.row_id.includes('rot'))?'
' + - window.Presupuestos.paginasPliego + - '' + - '
':'') + - '
' + - window.Presupuestos.gTintaNegro + - '' + - '
' + - '
' + - window.Presupuestos.gTintaCyan + - '' + - '
' + - '
' + - window.Presupuestos.gTintaMagenta + - '' + - '
' + - '
' + - window.Presupuestos.gTintaAmarillo + - '' + - '
' + - (!(d.row_id.includes('rot'))?'
' + - window.Presupuestos.gTintaCG + - '' + - '
':'') + - ((!d.row_id.includes('rot'))?'
' + - window.Presupuestos.clicksLibro + - '' + - '
':'') + - '
' + - window.Presupuestos.clicksPedido + - '' + - '
' + - '
' + - window.Presupuestos.totalClicks + - '' + - '
' + - '
' + - window.Presupuestos.totalTinta + - '' + - '
' + - (d.row_id.includes('rot')?'
': '' + - '
' + - window.Presupuestos.totalImpresion + - '' + - '
' + - '
' + - '' + - '' + - ''+ - ''+ - ''+ - ''+ - '
' + - ((!d.row_id.includes('rot'))?'
' + - window.Presupuestos.resolucion + - '' + - '
':'') + - ((!d.row_id.includes('rot'))?'
' + - window.Presupuestos.areaPaginas + - '' + - '
':'') + - (d.row_id.includes('rot')?'
': '' + - (d.row_id.includes('rot')?'
': '' + - (d.row_id.includes('rot')?'
': '' + - '
' + - window.Presupuestos.gTintaNegroPed + - '' + - '
' + - '
' + - window.Presupuestos.gTintaCyanPed + - '' + - '
' + - '
' + - window.Presupuestos.gTintaMagentaPed + - '' + - '
' + - '
' + - window.Presupuestos.gTintaAmarilloPed + - ''+ - '
' + - (!(d.row_id.includes('rot'))?'
' + - window.Presupuestos.gTintaCGPed + - ''+ - '
':'') + - '
' + - '' + - '' - } - - return $(value).toArray(); -} - @@ -687,3699 +368,3 @@ $(document).on('click', '.btn-delete-lp', function(e) { - - -function processRowData(row, rowId, rowClass){ - - var icon = "" - if(rowId=='lp_bn'){ - if(row.tipo_maquina=='toner') - icon = '' - else - icon = '' - } - - else if(rowId=='lp_bnhq'){ - if(row.tipo_maquina=='toner') - icon = '' - else - icon = '' - } - else if(rowId=='lp_color'){ - if(row.tipo_maquina=='toner') - icon = '' - else - icon = '' - } - else if(rowId=='lp_colorhq'){ - if(row.tipo_maquina=='toner') - icon = '' - else - icon = '' - } - - else if(rowId=='lp_cubierta') - icon = '' - else if(rowId=='lp_sobrecubierta') - icon = '' - else if(rowId=='lp_guardas') - icon = '' - else if(rowId=='lp_rot_bn') - icon = '' - else if(rowId=='lp_rot_color') - icon = '' - - const blank_line = (typeof row.tarifa_impresion_id === 'undefined')?1:0; - var data = { - 'row_id': rowId, - 'row_class': rowClass, - - 'tarifa_impresion_id': blank_line?0:isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id), - 'maquina_ancho': blank_line?0:isNaN(parseFloat(row.dimensiones_maquina[0])) ? "" : parseFloat(row.dimensiones_maquina[0]), - 'maquina_alto': blank_line?0:isNaN(parseFloat(row.dimensiones_maquina[1])) ? "" : parseFloat(row.dimensiones_maquina[1]), - 'maquina_impresion_ancho': blank_line?0:isNaN(parseFloat(row.dimensiones_maquina_impresion[0])) ? "" : parseFloat(row.dimensiones_maquina_impresion[0]), - 'maquina_impresion_alto': blank_line?0:isNaN(parseFloat(row.dimensiones_maquina_impresion[1])) ? "" : parseFloat(row.dimensiones_maquina_impresion[1]), - 'formas': blank_line?0:isNaN(parseInt(row.num_formas.value)) ? 0 : parseInt(row.num_formas.value), - 'formas_v': blank_line?0:isNaN(parseInt(row.num_formas.num_formas_verticales)) ? 0 : parseInt(row.num_formas.num_formas_verticales), - 'formas_h': blank_line?0:isNaN(parseInt(row.num_formas.num_formas_horizontales)) ? 0 : parseInt(row.num_formas.num_formas_horizontales), - 'formas_orientacion': blank_line?0:row.num_formas.posicion_formas, - - 'icon': icon, - 'paginas': blank_line?0:row.paginas, - 'paginas_impresion': rowId=='lp_guardas'?row.paginas_impresion:0, - 'papel': blank_line?"":row.papel_generico_id, - 'gramaje': blank_line?"":row.gramaje, - 'papel_impresion': blank_line?"":row.papel_impresion, - 'papel_impresion_id': blank_line?"":row.papel_impresion_id, - 'maquina': blank_line?"":row.maquina, - 'maquina_id': blank_line?"":row.maquina_id, - - 'tiempo': blank_line?"":row.tiempo_maquina, - 'lomo': isNaN(parseFloat(row.mano)) ? "" : parseFloat(row.mano).toFixed(2), - 'peso': isNaN(parseFloat(row.peso)) ? "" : parseFloat(row.peso).toFixed(2), - - 'total_linea': isNaN(parseFloat(row.total_impresion)) ? "" : parseFloat(row.total_impresion).toFixed(2), - - 'numeroPliegos':isNaN(parseFloat(row.pliegos_libro)) ? "" : parseFloat(row.pliegos_libro).toFixed(0), - 'pliegosPedido': isNaN(parseFloat(row.pliegos_pedido)) ? "" : parseFloat(row.pliegos_pedido).toFixed(0), - 'precioPliego': isNaN(parseFloat(row.precios_pliegos)) ? "" : parseFloat(row.precios_pliegos).toFixed(6), - 'libro': isNaN(parseFloat(row.precio_libro)) ? "" : parseFloat(row.precio_libro).toFixed(2), - 'totalPapelPedido': isNaN(parseFloat(row.precio_pedido)) ? "" : parseFloat(row.precio_pedido).toFixed(2), - 'margenPapelPedido': isNaN(parseFloat(row.margen_papel_pedido)) ? "": parseFloat(row.margen_papel_pedido).toFixed(2), - 'click': isNaN(parseFloat(row.precio_click)) ? "" : parseFloat(row.precio_click).toFixed(6), - 'totalClicks': isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2), - 'margenClicks': isNaN(parseFloat(row.margen_click_pedido)) ? "" : parseFloat(row.margen_click_pedido).toFixed(2), - 'horasMaquina': isNaN(parseFloat(row.horas_maquina)) ? "" : parseFloat(row.horas_maquina).toFixed(4), - 'precioHora': isNaN(parseFloat(row.precio_hora)) ? "" : parseFloat(row.precio_hora).toFixed(2), - 'precioImpresion': isNaN(parseFloat(row.precio_impresion_horas)) ? "" : parseFloat(row.precio_impresion_horas).toFixed(2), - 'margenImpresion': isNaN(parseFloat(row.margen_impresion_horas)) ? "" : parseFloat(row.margen_impresion_horas).toFixed(2), - 'maquinaTipo': row.tipo_maquina, - 'check_papel_total': row.check_papel_total, - 'check_impresion_total': row.check_impresion_total, - } - - if(row.tipo_maquina=='inkjet'){ - - data.numPagColor = row.paginas_color - data.aFavorFibra = row.a_favor_fibra - data.cobNegro = isNaN(parseFloat(row.datosTipologias.negro)) ? "" : parseFloat(row.datosTipologias.negro).toFixed(2) - data.cobCyan = isNaN(parseFloat(row.datosTipologias.cyan)) ? "" : parseFloat(row.datosTipologias.cyan).toFixed(2) - data.cobMagenta = isNaN(parseFloat(row.datosTipologias.magenta)) ? "" : parseFloat(row.datosTipologias.magenta).toFixed(2) - data.cobAmarillo = isNaN(parseFloat(row.datosTipologias.amarillo)) ? "" : parseFloat(row.datosTipologias.amarillo).toFixed(2) - data.gotaNegro = isNaN(parseFloat(row.datosTipologias.gota_negro)) ? "" : parseFloat(row.datosTipologias.gota_negro).toFixed(2) - data.gotaColor = isNaN(parseFloat(row.datosTipologias.gota_color)) ? "" : parseFloat(row.datosTipologias.gota_color).toFixed(2) - - data.resolucion = isNaN(parseFloat(row.resolucion)) ? "" : parseFloat(row.resolucion).toFixed(0) - data.areaPaginas = isNaN(parseFloat(row.superficie)) ? "" : parseFloat(row.superficie).toFixed(2) - - data.gotasNegro = isNaN(parseFloat(row.num_gotas_negro)) ? "" : parseFloat(row.num_gotas_negro).toFixed(0) - data.gotasCyan = isNaN(parseFloat(row.num_gotas_cyan)) ? "" : parseFloat(row.num_gotas_cyan).toFixed(0) - data.gotasMagenta = isNaN(parseFloat(row.num_gotas_magenta)) ? "" : parseFloat(row.num_gotas_magenta).toFixed(0) - data.gotasAmarillo = isNaN(parseFloat(row.num_gotas_amarillo)) ? "" : parseFloat(row.num_gotas_amarillo).toFixed(0) - data.precioPagNegro = isNaN(parseFloat(row.precio_pagina_negro)) ? "" : parseFloat(row.precio_pagina_negro).toFixed(6) - data.precioPagColor = isNaN(parseFloat(row.precio_pagina_color)) ? "" : parseFloat(row.precio_pagina_color).toFixed(6) - data.factorAltura = isNaN(parseFloat(row.factor_altura)) ? "" : parseFloat(row.factor_altura).toFixed(2) - data.factorAnchura = isNaN(parseFloat(row.factor_anchura)) ? "" : parseFloat(row.factor_anchura).toFixed(2) - data.paginasPliego = isNaN(parseFloat(row.paginas_por_pliego)) ? "" : parseFloat(row.paginas_por_pliego).toFixed(2) - - if(rowId.includes('rot')){ - data.metrosMinuto = isNaN(parseFloat(row.maquina_velocidad)) ? "" : parseFloat(row.maquina_velocidad).toFixed(2) - data.metrosPapelLibro = isNaN(parseFloat(row.metros_papel_libro)) ? "" : parseFloat(row.metros_papel_libro).toFixed(2) - data.metrosPapelTotal = isNaN(parseFloat(row.metros_papel_total)) ? "" : parseFloat(row.metros_papel_total).toFixed(2) - data.velocidadCorte = isNaN(parseFloat(row.velocidad_corte)) ? "" : parseFloat(row.velocidad_corte).toFixed(2) - data.precioHoraCorte = isNaN(parseFloat(row.precio_hora_corte)) ? "" : parseFloat(row.precio_hora_corte).toFixed(2) - data.tiempoCorte = isNaN(parseFloat(row.tiempo_corte)) ? "" : parseFloat(row.tiempo_corte).toFixed(2) - data.totalCorte = isNaN(parseFloat(row.total_corte)) ? "" : parseFloat(row.total_corte).toFixed(2) - } - else{ - data.totalCorte = 0 - } - - data.clicksLibro = isNaN(parseFloat(row.clicks_libro)) ? "" : parseFloat(row.clicks_libro).toFixed(0) - data.gTintaNegro = isNaN(parseFloat(row.peso_gotas_negro)) ? "" : parseFloat(row.peso_gotas_negro).toFixed(2) - data.gTintaCyan = isNaN(parseFloat(row.peso_gotas_cyan)) ? "" : parseFloat(row.peso_gotas_cyan).toFixed(2) - data.gTintaMagenta = isNaN(parseFloat(row.peso_gotas_magenta)) ? "" : parseFloat(row.peso_gotas_magenta).toFixed(2) - data.gTintaAmarillo = isNaN(parseFloat(row.peso_gotas_amarillo)) ? "" : parseFloat(row.peso_gotas_amarillo).toFixed(2) - data.clicksPedido = isNaN(parseFloat(row.clicks_pedido)) ? "" : parseFloat(row.clicks_pedido).toFixed(0) - data.totalClicksPedido = isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2) - data.totalTinta = isNaN(parseFloat(row.precio_tinta)) ? "" : parseFloat(row.precio_tinta).toFixed(2) - - data.totalImpresion = isNaN(parseFloat(row.precio_click_pedido+row.precio_tinta+data.totalCorte)) ? "" : parseFloat(row.precio_click_pedido+row.precio_tinta+data.totalCorte).toFixed(2) - - data.gTintaNegroPed = isNaN(parseFloat(row.peso_gotas_negro_pedido)) ? "" : parseFloat(row.peso_gotas_negro_pedido).toFixed(2) - data.gTintaCyanPed = isNaN(parseFloat(row.peso_gotas_cyan_pedido)) ? "" : parseFloat(row.peso_gotas_cyan_pedido).toFixed(2) - data.gTintaMagentaPed = isNaN(parseFloat(row.peso_gotas_magenta_pedido)) ? "" : parseFloat(row.peso_gotas_magenta_pedido).toFixed(2) - data.gTintaAmarilloPed = isNaN(parseFloat(row.peso_gotas_amarillo_pedido)) ? "" : parseFloat(row.peso_gotas_amarillo_pedido).toFixed(2) - - if(!rowId.includes('rot')){ - data.cobCG = isNaN(parseFloat(row.datosTipologias.cg)) ? "" : parseFloat(row.datosTipologias.cg).toFixed(2) - data.gotasCG = isNaN(parseFloat(row.num_gotas_cg)) ? "" : parseFloat(row.num_gotas_cg).toFixed(2) - data.gTintaCG = isNaN(parseFloat(row.peso_gotas_cg)) ? "" : parseFloat(row.peso_gotas_cg).toFixed(2) - data.gTintaCGPed = isNaN(parseFloat(row.peso_gotas_cg_pedido)) ? "" : parseFloat(row.peso_gotas_cg_pedido).toFixed(2) - } - - - data.alto_click = row.alto_click - } - - return data -} - - - -$('.paginas-lp').on('change', function(){ - checkPaginasPresupuesto() -}) - - -function verCalculosInkjet(e){ - if($( ".calculos_" + e.data.rowId ).css('display') == 'none') - $( ".calculos_" + e.data.rowId ).css('display', 'table-row') - else{ - $( ".calculos_" + e.data.rowId ).css('display', 'none') - } -}; - - - -function clear_interior(row_id = ''){ - switch(row_id) { - case 'lp_bn': - clear_lp_bn(true); - break; - case 'lp_color': - clear_lp_color(true); - break; - case 'lp_bnhq': - clear_lp_bnhq(true); - break; - case 'lp_colorhq': - clear_lp_colorhq(true); - break; - default: - clear_lp_bn(true); - clear_lp_color(true); - clear_lp_bnhq(true); - clear_lp_colorhq(true); - break; - } - if(row_id.length>0) - tableLineasPresupuesto.row( row_id ) - .remove() - .draw(); - else{ - tableLineasPresupuesto.row( '#lp_bn' ) - .remove().draw() - tableLineasPresupuesto.row( '#lp_bnhq' ) - .remove().draw() - tableLineasPresupuesto.row( '#lp_color' ) - .remove().draw() - tableLineasPresupuesto.row( '#lp_colorhq' ) - .remove().draw() - } -} - - -function clear_rotativa(row_id = ''){ - switch(row_id) { - case 'lp_rot_bn': - clear_lp_rot_bn(true); - break; - case 'lp_rot_color': - clear_lp_rot_color(true); - break; - default: - clear_lp_rot_bn(true); - clear_lp_rot_color(true); - break; - } - if(row_id.length>0) - tableLineasPresupuesto.row( row_id ) - .remove() - .draw(); - else{ - tableLineasPresupuesto.row( '#lp_rot_bn' ) - .remove().draw() - tableLineasPresupuesto.row( '#lp_rot_color' ) - .remove().draw() - } -} - - -function clear_cubierta(){ - clear_lp_cubierta(true); -} - -function clear_sobrecubierta(){ - clear_lp_sobrecubierta(true); -} - - -$('.insertarLinea').on("click", function (e) { - - if(e.target.id.includes("Plana")){ - - clear_interior(); - clear_rotativa(); - - var rows = $("#tableCompIntPlana").DataTable().rows( '.selected' ).data().toArray(); - - for(row of rows){ - if(row['tipo'] =='bn'){ - fill_lp_bn(row, true); - } - else if(row['tipo'] =='bnhq'){ - fill_lp_bnhq(row, true); - } - else if(row['tipo'] =='color'){ - fill_lp_color(row, true); - } - else if(row['tipo'] =='colorhq'){ - fill_lp_colorhq(row, true); - } - } - } - if(e.target.id.includes("Rotativa")){ - - clear_rotativa(); - clear_interior(); - - var rows = $("#tableCompIntRotativa").DataTable().rows( '.selected' ).data().toArray(); - for(row of rows){ - if(row['paginasColor'] ==0){ - fill_lp_rot_bn(row, true); - } - else if(row['paginasColor'] >0){ - fill_lp_rot_color(row, true); - } - } - } - - if(e.target.id.includes("Cubierta")){ - - clear_cubierta(); - - var rows = $("#tableCompCubierta").DataTable().rows( '.selected' ).data().toArray(); - for(row of rows){ - if(row.tipo == 'cubierta'){ - fill_lp_cubierta(row, true); - if($('#acabado_cubierta_id').val() > 0) - insertar_acabado_exterior($('#acabado_cubierta_id').val(), window.Presupuestos.cubierta) - } - } - - clear_sobrecubierta(); - - for(row of rows){ - if(row.tipo == 'sobrecubierta'){ - fill_lp_sobrecubierta(row, true); - if($('#acabado_sobrecubierta_id').val() > 0) - insertar_acabado_exterior($('#acabado_sobrecubierta_id').val(), window.Presupuestos.sobrecubierta) - } - } - } - - if(e.target.id.includes("Guardas")){ - - clear_guardas(); - - var rows = $("#tableCompGuardas").DataTable().rows( '.selected' ).data().toArray(); - for(row of rows){ - fill_lp_guardas(row, true); - } - servicioGuardas(true) - } - - - updatePresupuesto({ - update_lineas: false, - update_servicios: true, - update_envios: false, - update_resumen: true, - update_tiradas_alternativas: true}) - - -}); - - -$('#btn_addLinea').on("click", function (e) { - - var dataRows = tableLineasPresupuesto - .rows() - .data(); - - switch($('#addLineasPresupuesto').val()){ - // Se chequean todas las lineas de negro y todas las de color - // (solo una de cada en interior) - - case 'lp_bn': - var hayLinea = false - for(let number=0;number', {'value':data.menu[item].id, 'text':data.menu[item].text}) - $('#lp_bn_gramaje').append(option); - }); - if(mantenerSeleccion){ - $('#lp_bn_gramaje option').filter(function() { - return $(this).html() == previous; - }).prop('selected', true); - } - else{ - $('#lp_bn_gramaje').val('') - } - - } - }); -} - - - -async function set_lp_bn_papelImpresion(){ - - var datos = { - tipo: 'papelImpresion', - uso: 'negro', - datos: $('#lp_bn_papel option:selected').val() , - gramaje: $('#lp_bn_gramaje option:selected').text().trim() , - tipoLinea: "negro", - }; - datos = Object.assign(datos, window.token_ajax); - - await $.ajax({ - type: 'post', - url: window.routes_lp.menuItemsOfPresupuestoAdmin, - beforeSend: function() { - $('#lp_bn_papelImpresion').empty() - $('#lp_bn_maquina').empty() - clear_lp_bn(false) - }, - data: datos, - dataType: 'json', - success: function (data) { - yeniden(data[window.csrf_token]); - $.each(data.menu, function(item){ - var option = $('
diff --git a/httpdocs/assets/js/safekat/components/preview.js b/httpdocs/assets/js/safekat/components/preview.js index 8f3744dc..543f68ef 100644 --- a/httpdocs/assets/js/safekat/components/preview.js +++ b/httpdocs/assets/js/safekat/components/preview.js @@ -207,7 +207,7 @@ class previewFormas { case 'rot_bn': case 'rot_color': // Conditional assignements depending on rotation of the printing shape - if (this.pvObj.orientacionFormas == 'v') { + if (this.pvObj.orientacionFormas != 'h') { let auxReg = this.pvObj.altoForma; this.pvObj.altoForma = this.pvObj.anchoForma; this.pvObj.anchoForma = auxReg; @@ -223,7 +223,7 @@ class previewFormas { case 'color': case 'colorhq': // Conditional assignements depending on rotation of the printing shape - if (this.pvObj.orientacionFormas == 'v') { + if (this.pvObj.orientacionFormas != 'h') { let auxReg = this.pvObj.altoForma; this.pvObj.altoForma = this.pvObj.anchoForma; this.pvObj.anchoForma = auxReg; diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js index 3418bfea..3888600a 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js @@ -1503,7 +1503,7 @@ class LineasPresupuesto { // Si es inkjet, existe este check if ($('#' + linea + '_aFavorFibra').length) { - datos.a_favor_fibra = $('#' + linea + '_aFavorFibra').prop('checked') + datos.a_favor_fibra = $('#' + linea + '_aFavorFibra').prop('checked') ? 1: 0; } if (updatedTipologias && $('#' + linea + '_gotaNegro').length) { diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js index f06dee7a..67e673bd 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js @@ -63,7 +63,6 @@ class DisenioCubierta { this.divGramajeCubierta = this.domItem.find("#divGramajeCubierta"); this.acabadoCubierta = this.domItem.find("#acabadoCubierta"); - this.cubiertaRetractilado = this.domItem.find("#retractilado"); this.configuracionSobrecubierta = this.domItem.find(".config-sobrecubierta"); this.sobrecubierta = this.domItem.find("#addSobrecubierta"); @@ -222,12 +221,6 @@ class DisenioCubierta { this.acabadoCubierta.setOption(datosCubierta.acabado.id, datosCubierta.acabado.text); - if (datosCubierta.retractilado) { - setTimeout(() => { - this.cubiertaRetractilado.trigger('click'); - }, 0); - } - if (datosSobrecubierta && datosSobrecubierta.papel) { this.sobrecubierta.trigger('click'); this.papelSobrecubierta.val(datosSobrecubierta.papel.code + "_" + datosSobrecubierta.gramaje).trigger('change'); From e87e278dd037641b50a8256ee8a3ca5d79932028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Tue, 28 Jan 2025 18:47:20 +0100 Subject: [PATCH 76/89] modificados todos los buscadores de papeles y gramajes para ver el alto y el ancho (admin y cliente) --- .../Configuracion/Papelesgenericos.php | 22 ++++- .../Presupuestos/Presupuestoadmin.php | 38 ++++++++- .../Configuracion/PapelGenericoModel.php | 84 +++++++++++++++---- .../presupuestoAdmin/presupuestoAdminEdit.js | 6 +- .../presupuestoAdmin/sections/comparador.js | 64 +++++++++++++- .../presupuestoAdmin/sections/datosLibro.js | 1 + .../presupuestoCliente/disenioCubierta.js | 25 +++++- .../presupuestoCliente/disenioInterior.js | 34 ++++++++ 8 files changed, 249 insertions(+), 25 deletions(-) diff --git a/ci4/app/Controllers/Configuracion/Papelesgenericos.php b/ci4/app/Controllers/Configuracion/Papelesgenericos.php index 1792dd93..7196d9ba 100755 --- a/ci4/app/Controllers/Configuracion/Papelesgenericos.php +++ b/ci4/app/Controllers/Configuracion/Papelesgenericos.php @@ -314,8 +314,15 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController $cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0; $tapa_dura = goSanitize($this->request->getGet('tapa_dura'))[0] ?? null; - $menu = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, false, $POD); - $menu2 = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, true, $POD); + $ancho = floatval($this->request->getGet('ancho') ?? 0); + $alto = floatval($this->request->getGet('alto') ?? 0); + $solapas = floatval($this->request->getGet('solapas') ?? 0); + $lomo = floatval($this->request->getGet('lomo') ?? 0); + + $anchoLibro = 2* $ancho + 2 * $solapas + $lomo; + + $menu = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, false, $POD, $anchoLibro, $alto, $tirada); + $menu2 = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada); $newTokenHash = csrf_hash(); $csrfTokenName = csrf_token(); @@ -349,8 +356,17 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController } $tipo = goSanitize($this->request->getGet('tipo'))[0]; $cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0; + + $ancho = floatval($this->request->getGet('ancho') ?? 0); + $alto = floatval($this->request->getGet('alto') ?? 0); + $solapas = floatval($this->request->getGet('solapas') ?? 0); + $lomo = floatval($this->request->getGet('lomo') ?? 0); - $items = $this->model->getPapelCliente($tipo, $cubierta, null, true, $POD); + $tapa_dura = $this->request->getGet('tapa_dura') ?? 0; + + $anchoLibro = 2* $ancho + 2 * $solapas + $lomo; + + $items = $this->model->getPapelCliente($tipo, $cubierta, null, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada); $items = array_map(function ($item) { return [ 'id' => $item->id, diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index 5872c216..377e874e 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -1062,6 +1062,13 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $tipo_impresion_id = $this->request->getGet("tipo_impresion"); $tapa_dura = model('App\Models\Configuracion\TipoPresupuestoModel')->get_isTapaDura(intval($tipo_impresion_id)); + $ancho = $this->request->getGet('ancho') ?? 0; + $alto = $this->request->getGet('alto') ?? 0; + $solapas = $this->request->getGet('solapas') ?? 0; + $lomo = $this->request->getGet('lomo') ?? 0; + + $anchoLibro = 2* $ancho + 2 * $solapas + $lomo; + $tipo = $this->request->getGet("tipo"); $uso = $this->request->getGet("uso") ?? 'interior'; @@ -1083,7 +1090,17 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController } $model = model('App\Models\Configuracion\PapelGenericoModel'); - $query = $model->getPapelForComparador($tipo, $cubierta, $sobrecubierta, $rotativa, $guardas, $tapa_dura, $isPOD); + $query = $model->getPapelForComparador( + $tipo, + $cubierta, + $sobrecubierta, + $rotativa, + $guardas, + $tapa_dura, + $isPOD, + $anchoLibro, + $alto, + $tirada); if ($this->request->getGet("q")) { $query->groupStart() ->orLike("lg_papel_generico.nombre", $this->request->getGet("q")) @@ -1106,6 +1123,13 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $tirada = $this->request->getGet("tirada"); $isPOD = intval($tirada) <= intval($POD_value); + $ancho = $this->request->getGet('ancho') ?? 0; + $alto = $this->request->getGet('alto') ?? 0; + $solapas = $this->request->getGet('solapas') ?? 0; + $lomo = $this->request->getGet('lomo') ?? 0; + + $anchoLibro = 2* $ancho + 2 * $solapas + $lomo; + $tipo_impresion_id = $this->request->getGet("tipo_impresion"); $tapa_dura = model('App\Models\Configuracion\TipoPresupuestoModel')->get_isTapaDura(intval($tipo_impresion_id)); @@ -1130,7 +1154,17 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController } $model = model('App\Models\Configuracion\PapelGenericoModel'); - $query = $model->getGramajeForComparador($tipo, $papel_generico_id, $cubierta, $sobrecubierta, $rotativa, $guardas, $tapa_dura, $isPOD); + $query = $model->getGramajeForComparador($tipo, + $papel_generico_id, + $cubierta, + $sobrecubierta, + $rotativa, + $guardas, + $tapa_dura, + $isPOD, + $anchoLibro, + $alto, + $tirada); if ($this->request->getGet("q")) { $query->groupStart() ->orLike("lg_papel_impresion.gramaje", $this->request->getGet("q")) diff --git a/ci4/app/Models/Configuracion/PapelGenericoModel.php b/ci4/app/Models/Configuracion/PapelGenericoModel.php index 739ccf6d..b97c2c8e 100755 --- a/ci4/app/Models/Configuracion/PapelGenericoModel.php +++ b/ci4/app/Models/Configuracion/PapelGenericoModel.php @@ -129,16 +129,16 @@ class PapelGenericoModel extends \App\Models\BaseModel return empty($search) ? $builder : $builder - ->groupStart() - ->like("t1.id", $search) - ->orLike("t1.nombre", $search) - ->orLike("t1.code", $search) - ->orLike("t1.code_ot", $search) - ->orLike("t1.id", $search) - ->orLike("t1.nombre", $search) - ->orLike("t1.code", $search) - ->orLike("t1.code_ot", $search) - ->groupEnd(); + ->groupStart() + ->like("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.code", $search) + ->orLike("t1.code_ot", $search) + ->orLike("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.code", $search) + ->orLike("t1.code_ot", $search) + ->groupEnd(); } @@ -149,7 +149,10 @@ class PapelGenericoModel extends \App\Models\BaseModel $rotativa = false, $is_guardas = false, $tapa_dura = false, - $POD = false + $POD = false, + $ancho = 0, + $alto = 0, + $tirada = 0 ) { /* 1.-> Tipo impresion @@ -183,6 +186,8 @@ class PapelGenericoModel extends \App\Models\BaseModel ->where("t3.active", 1) ->where("t4.is_deleted", 0) ->where("t4.tipo", "impresion") + ->where("t4.min <= ", $tirada) + ->where("t4.max >= ", $tirada) ->where("t5.is_deleted", 0) ->where("t5.tipo", $tipo) ->distinct('t1.id'); @@ -196,6 +201,17 @@ class PapelGenericoModel extends \App\Models\BaseModel ->where("t3_inner.active", 1); }); + $builder->groupStart() + ->groupStart() + ->where("t4.ancho_impresion >", $ancho) + ->where("t4.alto_impresion >", $alto) + ->groupEnd() + ->orGroupStart() + ->where("t4.ancho_impresion >", $alto) + ->where("t4.alto_impresion >", $ancho) + ->groupEnd() + ->groupEnd(); + if ($is_cubierta == true) { $builder->where("t2.cubierta", 1); $builder->where("t5.uso", 'cubierta'); @@ -236,7 +252,10 @@ class PapelGenericoModel extends \App\Models\BaseModel $rotativa = false, $is_guardas = false, $tapa_dura = false, - $POD = false + $POD = false, + $ancho = 0, + $alto = 0, + $tirada = 0 ) { if ($POD == true && ($tipo == 'color' || $tipo == 'negro')) { if ($tipo == 'color') @@ -264,6 +283,8 @@ class PapelGenericoModel extends \App\Models\BaseModel ->where("t2.isActivo", 1) ->where("t3.active", 1) ->where("t4.is_deleted", 0) + ->where("t4.min <= ", $tirada) + ->where("t4.max >= ", $tirada) ->where("t4.tipo", "impresion") ->where("t5.is_deleted", 0) ->where("t5.tipo", $tipo) @@ -278,6 +299,17 @@ class PapelGenericoModel extends \App\Models\BaseModel ->where("t3_inner.active", 1); }); + $builder->groupStart() + ->groupStart() + ->where("t4.ancho_impresion >", $ancho) + ->where("t4.alto_impresion >", $alto) + ->groupEnd() + ->orGroupStart() + ->where("t4.ancho_impresion >", $alto) + ->where("t4.alto_impresion >", $ancho) + ->groupEnd() + ->groupEnd(); + if ($is_cubierta == true) { $builder->where("t2.cubierta", 1); $builder->where("t5.uso", 'cubierta'); @@ -370,8 +402,17 @@ class PapelGenericoModel extends \App\Models\BaseModel } - public function getPapelCliente($tipo, $is_cubierta = false, $selected_papel_id = null, $tapa_dura = null, $papel_especial = false, $POD = null) - { + public function getPapelCliente( + $tipo, + $is_cubierta = false, + $selected_papel_id = null, + $tapa_dura = null, + $papel_especial = false, + $POD = null, + $ancho = 0, + $alto = 0, + $tirada = 0 + ) { /* 1.-> Tipo impresion 2.-> Maquina @@ -406,6 +447,8 @@ class PapelGenericoModel extends \App\Models\BaseModel ->where("t2.use_in_client", 1) ->where("t3.active", 1) ->where("t4.is_deleted", 0) + ->where("t4.min <= ", $tirada) + ->where("t4.max >= ", $tirada) ->where("t4.tipo", "impresion") ->where("t5.is_deleted", 0) ->where("t5.tipo", $tipo) @@ -429,6 +472,8 @@ class PapelGenericoModel extends \App\Models\BaseModel ->where("t2.use_in_client", 1) ->where("t3.active", 1) ->where("t4.is_deleted", 0) + ->where("t4.min <= ", $tirada) + ->where("t4.max >= ", $tirada) ->where("t4.tipo", "impresion") ->where("t5.is_deleted", 0) ->where("t5.tipo", $tipo) @@ -443,6 +488,17 @@ class PapelGenericoModel extends \App\Models\BaseModel ->where("t3_inner.active", 1); }); + $builder->groupStart() + ->groupStart() + ->where("t4.ancho_impresion >", $ancho) + ->where("t4.alto_impresion >", $alto) + ->groupEnd() + ->orGroupStart() + ->where("t4.ancho_impresion >", $alto) + ->where("t4.alto_impresion >", $ancho) + ->groupEnd() + ->groupEnd(); + if ($is_cubierta == true) { $builder->where("t2.cubierta", 1); $builder->where("t5.uso", 'cubierta'); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js index c2414539..16d75732 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js @@ -32,8 +32,12 @@ class PresupuestoAdminEdit { this.datosLibro = new DatosLibro(this.domItem.find('#accordionDatosLibroTip'), { checkPaginasPresupuesto: this.checkPaginasPresupuesto, + getDimensionLibro: this.getDimensionLibro, + }); + this.comparador = new Comparador(this.domItem.find('#accordionDatosPresupuestoClienteTip'), + { + getDimensionLibro: this.getDimensionLibro, }); - this.comparador = new Comparador(this.domItem.find('#accordionDatosPresupuestoClienteTip')); this.lineasPresupuesto = new LineasPresupuesto(this.domItem.find('#accordionLineasPresupuestoTip'), { getDimensionLibro: this.getDimensionLibro, diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js index 57db6fdc..4e39be5a 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js @@ -4,10 +4,12 @@ import Ajax from '../../../components/ajax.js'; class Comparador { - constructor(domItem) { + constructor(domItem, functions = {}) { this.domItem = domItem; + this.getDimensionLibro = functions.getDimensionLibro; + this.tipo_impresion_id = parseInt($('#tipo_impresion_id').val()); this.csrf_token = getToken(); @@ -23,6 +25,10 @@ class Comparador { [this.csrf_token]: this.csrf_hash, tipo_impresion: this.tipo_impresion_id, tirada: () => $('#tirada').val(), + ancho: () => this.getDimensionLibro().ancho, + alto: () => this.getDimensionLibro().alto, + sopalas: 0, + lomo: 0, tipo: 'negro', }); @@ -33,6 +39,10 @@ class Comparador { papel_generico: () => this.papelNegro.getVal(), tipo_impresion: this.tipo_impresion_id, tirada: () => $('#tirada').val(), + ancho: () => this.getDimensionLibro().ancho, + alto: () => this.getDimensionLibro().alto, + sopalas: 0, + lomo: 0, tipo: 'negro', }); this.paginasColor = $('#compPaginasColor'); @@ -42,6 +52,10 @@ class Comparador { [this.csrf_token]: this.csrf_hash, tipo_impresion: this.tipo_impresion_id, tirada: () => $('#tirada').val(), + ancho: () => this.getDimensionLibro().ancho, + alto: () => this.getDimensionLibro().alto, + sopalas: 0, + lomo: 0, tipo: 'color', }); @@ -52,6 +66,10 @@ class Comparador { papel_generico: () => this.papelColor.getVal(), tipo_impresion: this.tipo_impresion_id, tirada: () => $('#tirada').val(), + ancho: () => this.getDimensionLibro().ancho, + alto: () => this.getDimensionLibro().alto, + sopalas: 0, + lomo: 0, tipo: 'color', }); @@ -62,6 +80,10 @@ class Comparador { [this.csrf_token]: this.csrf_hash, tipo_impresion: this.tipo_impresion_id, tirada: () => $('#tirada').val(), + ancho: () => this.getDimensionLibro().ancho, + alto: () => this.getDimensionLibro().alto, + sopalas: 0, + lomo: 0, tipo: 'negrohq', }); @@ -72,6 +94,10 @@ class Comparador { papel_generico: () => this.papelNegrohq.getVal(), tipo_impresion: this.tipo_impresion_id, tirada: () => $('#tirada').val(), + ancho: () => this.getDimensionLibro().ancho, + alto: () => this.getDimensionLibro().alto, + sopalas: 0, + lomo: 0, tipo: 'negrohq', }); @@ -82,6 +108,10 @@ class Comparador { [this.csrf_token]: this.csrf_hash, tipo_impresion: this.tipo_impresion_id, tirada: () => $('#tirada').val(), + ancho: () => this.getDimensionLibro().ancho, + alto: () => this.getDimensionLibro().alto, + sopalas: 0, + lomo: 0, tipo: 'colorhq', }); @@ -92,6 +122,10 @@ class Comparador { papel_generico: () => this.papelColorhq.getVal(), tipo_impresion: this.tipo_impresion_id, tirada: () => $('#tirada').val(), + ancho: () => this.getDimensionLibro().ancho, + alto: () => this.getDimensionLibro().alto, + sopalas: 0, + lomo: 0, tipo: 'colorhq', }); @@ -102,6 +136,10 @@ class Comparador { [this.csrf_token]: this.csrf_hash, tipo_impresion: this.tipo_impresion_id, tirada: () => $('#tirada').val(), + ancho: () => this.getDimensionLibro().ancho, + alto: () => this.getDimensionLibro().alto, + sopalas: () => $('#solapas').prop('checked') ? $('#solapas_ancho').val() : 0, + lomo: () => $('#lomo_cubierta').val(), tipo: 'colorhq', uso: 'cubierta', }); @@ -112,6 +150,10 @@ class Comparador { papel_generico: () => this.papelCubierta.getVal(), tipo_impresion: this.tipo_impresion_id, tirada: () => $('#tirada').val(), + ancho: () => this.getDimensionLibro().ancho, + alto: () => this.getDimensionLibro().alto, + sopalas: () => $('#solapas').prop('checked') ? $('#solapas_ancho').val() : 0, + lomo: () => $('#lomo_cubierta').val(), tipo: 'colorhq', uso: 'cubierta', }); @@ -123,6 +165,10 @@ class Comparador { [this.csrf_token]: this.csrf_hash, tipo_impresion: this.tipo_impresion_id, tirada: () => $('#tirada').val(), + ancho: () => this.getDimensionLibro().ancho, + alto: () => this.getDimensionLibro().alto, + sopalas: () => $('#solapas').prop('checked') ? $('#solapas_ancho').val() : 0, + lomo: () => $('#lomo_sobrecubierta').val(), tipo: 'colorhq', uso: 'sobrecubierta', }); @@ -133,6 +179,10 @@ class Comparador { papel_generico: () => this.papelSobrecubierta.getVal(), tipo_impresion: this.tipo_impresion_id, tirada: () => $('#tirada').val(), + ancho: () => this.getDimensionLibro().ancho, + alto: () => this.getDimensionLibro().alto, + sopalas: () => $('#solapas').prop('checked') ? $('#solapas_ancho').val() : 0, + lomo: () => $('#lomo_sobrecubierta').val(), tipo: 'colorhq', uso: 'sobrecubierta', }); @@ -145,6 +195,10 @@ class Comparador { [this.csrf_token]: this.csrf_hash, tipo_impresion: this.tipo_impresion_id, tirada: () => $('#tirada').val(), + ancho: () => this.getDimensionLibro().ancho, + alto: () => this.getDimensionLibro().alto, + sopalas: 0, + lomo: 0, tipo: 'colorhq', uso: 'guardas', }); @@ -155,6 +209,10 @@ class Comparador { papel_generico: () => this.papelCubierta.getVal(), tipo_impresion: this.tipo_impresion_id, tirada: () => $('#tirada').val(), + ancho: () => this.getDimensionLibro().ancho, + alto: () => this.getDimensionLibro().alto, + sopalas: 0, + lomo: 0, tipo: 'colorhq', uso: 'guardas', }); @@ -245,7 +303,7 @@ class Comparador { this.papelSobrecubierta.onChange(() => self.gramajeSobrecubierta.empty()); this.sobrecubierta.on('change', () => { if (this.sobrecubierta.select2('data')[0].id == 1) { - if($('#solapas_sobrecubierta').prop('checked') == false){ + if ($('#solapas_sobrecubierta').prop('checked') == false) { this.sobrecubierta.val(0); popErrorAlert(window.language.Presupuestos.errores.error_sobrecubierta_sin_solapas, 'divAlarmasComparador') } @@ -1492,7 +1550,7 @@ class Comparador { } } catch (e) { - + } $.extend(data, bn_obj); } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js index a9f56ea5..8bd7c1bc 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js @@ -8,6 +8,7 @@ class DatosLibro { this.domItem = domItem; this.checkPaginasPresupuesto = functions.checkPaginasPresupuesto; + this.getDimensionLibro = functions.getDimensionLibro; this.csrf_token = getToken(); this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val(); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js index 67e673bd..8361a299 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js @@ -33,6 +33,12 @@ class DisenioCubierta { [this.csrf_token]: this.csrf_hash, tipo: 'colorhq', cubierta: 1, + ancho: () => {return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho}, + alto: () => {return this.presupuestoCliente.datosGenerales.getDimensionLibro().alto}, + solapas: () => {return $('#solapas_cubierta').hasClass("d-none") ? 0 : $('#solapas_cubierta').val()}, + lomo: () => {return $('#lc').val()}, + tapa_dura: () => {return this.tapaBlanda.hasClass("selected") ? 0 : 1}, + tirada: this.presupuestoCliente.datosGenerales.getTiradas()[0], } ); @@ -758,7 +764,12 @@ class DisenioCubierta { [this.csrf_token]: this.csrf_hash, tipo: 'colorhq', cubierta: 1, - tapa_dura: tapa_dura + ancho: this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho, + alto: this.presupuestoCliente.datosGenerales.getDimensionLibro().alto, + solapas: $('#solapas_cubierta').hasClass("d-none") ? 0 : $('#solapas_cubierta').val(), + lomo: $('#lc').val(), + tapa_dura: tapa_dura, + tirada: this.presupuestoCliente.datosGenerales.getTiradas()[0], }, {}, (response) => { this.fillPapeles(response); }, @@ -780,7 +791,12 @@ class DisenioCubierta { papel: this.papelCubierta, tipo: 'colorhq', cubierta: 1, + ancho: this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho, + alto: this.presupuestoCliente.datosGenerales.getDimensionLibro().alto, + solapas: $('#solapas_cubierta').hasClass("d-none") ? 0 : $('#solapas_cubierta').val(), + lomo: $('#lc').val(), tapa_dura: tapa_dura, + tirada: this.presupuestoCliente.datosGenerales.getTiradas()[0], }, {}, this.fillGramajes.bind(context), @@ -907,7 +923,12 @@ class DisenioCubierta { papel: papel, tipo: 'colorhq', cubierta: 1, - tapa_dura: tapa_dura + ancho: this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho, + alto: this.presupuestoCliente.datosGenerales.getDimensionLibro().alto, + solapas: $('#solapas_cubierta').hasClass("d-none") ? 0 : $('#solapas_cubierta').val(), + lomo: $('#lc').val(), + tapa_dura: tapa_dura, + tirada: this.presupuestoCliente.datosGenerales.getTiradas()[0], }, {}, this.fillGramajes.bind(context), diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js index c7af7bcf..d378c229 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js @@ -57,6 +57,11 @@ class DisenioInterior { { [this.csrf_token]: this.csrf_hash, tipo: this.getTipoImpresion(), + tirada: () => {return $('#tirada').val()}, + ancho: () => {return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho}, + alto: () => {return this.presupuestoCliente.datosGenerales.getDimensionLibro().alto}, + solapas: 0, + lomo: 0, cubierta: 0, } ); @@ -67,6 +72,11 @@ class DisenioInterior { { [this.csrf_token]: this.csrf_hash, tipo: this.getTipoImpresionColor(), + tirada: () => {return $('#tirada').val()}, + ancho: () => {return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho}, + alto: () => {return this.presupuestoCliente.datosGenerales.getDimensionLibro().alto}, + solapas: 0, + lomo: 0, cubierta: 0, } ); @@ -116,6 +126,10 @@ class DisenioInterior { [this.csrf_token]: this.csrf_hash, tirada: $('#tirada').val(), tipo: this.getTipoImpresion(), + ancho: this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho, + alto: this.presupuestoCliente.datosGenerales.getDimensionLibro().alto, + solapas: 0, + lomo: 0, cubierta: 0, }, {}, @@ -131,6 +145,10 @@ class DisenioInterior { [this.csrf_token]: this.csrf_hash, tirada: $('#tirada').val(), tipo: this.getTipoImpresion(), + ancho: this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho, + alto: this.presupuestoCliente.datosGenerales.getDimensionLibro().alto, + solapas: 0, + lomo: 0, cubierta: 0, }, {}, @@ -888,6 +906,10 @@ class DisenioInterior { tirada: $('#tirada').val(), papel: papel, tipo: tipo, + ancho: this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho, + alto: this.presupuestoCliente.datosGenerales.getDimensionLibro().alto, + solapas: 0, + lomo: 0, cubierta: 0, }, {}, @@ -916,6 +938,10 @@ class DisenioInterior { tirada: $('#tirada').val(), papel: this.papelInterior, tipo: tipo, + ancho: this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho, + alto: this.presupuestoCliente.datosGenerales.getDimensionLibro().alto, + solapas: 0, + lomo: 0, cubierta: 0, }, {}, @@ -962,6 +988,10 @@ class DisenioInterior { tirada: $('#tirada').val(), papel: papel, tipo: tipo, + ancho: this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho, + alto: this.presupuestoCliente.datosGenerales.getDimensionLibro().alto, + solapas: 0, + lomo: 0, cubierta: 0, }, {}, @@ -986,6 +1016,10 @@ class DisenioInterior { tirada: $('#tirada').val(), papel: this.papelInterior, tipo: tipo, + ancho: this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho, + alto: this.presupuestoCliente.datosGenerales.getDimensionLibro().alto, + solapas: 0, + lomo: 0, cubierta: 0, }, {}, From bf49d601cff2398fb1de0a5e76c13ef018d3e2ec Mon Sep 17 00:00:00 2001 From: amazuecos Date: Tue, 28 Jan 2025 20:27:15 +0100 Subject: [PATCH 77/89] fix dropzone when presupuesto is borrador --- ci4/app/Language/es/Presupuestos.php | 2 +- .../themes/vuexy/components/dropzone.php | 1 + .../admin/viewPresupuestoadminForm.php | 4 +- .../safekat/components/alerts/sweetAlert.js | 3 +- .../components/forms/fileUploadDropzone.js | 77 +++++++++++-------- .../presupuestoAdmin/presupuestoAdminEdit.js | 8 +- 6 files changed, 59 insertions(+), 36 deletions(-) diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 868494dc..18e5f56b 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -332,7 +332,7 @@ return [ 'actualizacionSolapasCubierta' => 'El tamaño de las solapas de la cubierta se ha actualizado debido a que supera el máximo permitido (este valor depende del ancho del libro y del número de páginas).', 'actualizacionSolapasSobrecubierta' => 'El tamaño de las solapas de la sobrecubierta se ha actualizado debido a que supera el máximo permitido (este valor depende del ancho del libro y del número de páginas).', - 'files' => 'Documentos', + 'files' => 'Ficheros', 'titulos' => [ 'libroFresadoTapaDura' => 'Rústica Fresado tapa dura', 'libroFresadoTapaBlanda' => 'Rústica Fresado tapa blanda', diff --git a/ci4/app/Views/themes/vuexy/components/dropzone.php b/ci4/app/Views/themes/vuexy/components/dropzone.php index b6a4348e..886d4d24 100644 --- a/ci4/app/Views/themes/vuexy/components/dropzone.php +++ b/ci4/app/Views/themes/vuexy/components/dropzone.php @@ -12,6 +12,7 @@
+
Arrastre aquí los ficheros o haga click
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php index 83775def..5d95c2f2 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php @@ -41,7 +41,9 @@ $presupuestoId,"type" => "presupuesto"]) ?> - 'dropzone-presupuesto-admin-files','modelId' => $presupuestoId]) ?> + estado_id == 2) : ?> + 'dropzone-presupuesto-admin-files','modelId' => $presupuestoId]) ?> + diff --git a/httpdocs/assets/js/safekat/components/alerts/sweetAlert.js b/httpdocs/assets/js/safekat/components/alerts/sweetAlert.js index 338c1d60..fec7c8c7 100644 --- a/httpdocs/assets/js/safekat/components/alerts/sweetAlert.js +++ b/httpdocs/assets/js/safekat/components/alerts/sweetAlert.js @@ -25,6 +25,7 @@ export const alertSuccessMessage = (title,type="primary") => { showConfirmButton : false, title: title, text: title, - icon: "success" + icon: "success", + timer : 2000 }) } \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/components/forms/fileUploadDropzone.js b/httpdocs/assets/js/safekat/components/forms/fileUploadDropzone.js index 2099793a..172c7933 100644 --- a/httpdocs/assets/js/safekat/components/forms/fileUploadDropzone.js +++ b/httpdocs/assets/js/safekat/components/forms/fileUploadDropzone.js @@ -38,25 +38,37 @@ class FileUploadDropzone { } init() { - this.btnSubmitFile.on('click', this._handleUploadFiles.bind(this)) - this.btnSelectFiles.on('click', () => { - this.jqElement.trigger('click') - }) + if (this.jqElement.length > 0) { + this.btnSubmitFile.on('click', this._handleUploadFiles.bind(this)) + this.btnSelectFiles.on('click', () => { + this.jqElement.trigger('click') + }) - this.dropzone = new Dropzone(this.domElement, { - url: this.postUri, - addRemoveLinks: true, - previewTemplate: PREVIEW_TEMPLATE, - paramName: "file", - uploadMultiple: true, - parallelUploads: 4, // Ajusta este número al máximo número de archivos que esperas subir a la vez - maxFiles: 5, // Ajusta este número al máximo número de archivos que esperas subir a la vez - autoProcessQueue: true, - dictRemoveFile: "Eliminar", - acceptedFiles: 'image/*, application/pdf', - maxFilesize: 5e+7, // Bytes - init: this._handleGetFiles.bind(this) - }); + this.dropzone = new Dropzone(this.domElement, { + url: this.postUri, + addRemoveLinks: true, + previewTemplate: PREVIEW_TEMPLATE, + paramName: "file", + uploadMultiple: true, + parallelUploads: 4, // Ajusta este número al máximo número de archivos que esperas subir a la vez + maxFiles: 5, // Ajusta este número al máximo número de archivos que esperas subir a la vez + autoProcessQueue: true, + dictRemoveFile: "Eliminar", + acceptedFiles: 'image/*, application/pdf', + maxFilesize: 5e+7, // Bytes + init: this._handleGetFiles.bind(this) + }); + this.dropzone.on("addedfile", function (file) { + if (file.hash) { + var viewButton = Dropzone.createElement("Ver"); + file.previewElement.appendChild(viewButton); + // Listen to the view button click event + viewButton.addEventListener("click", function (e) { + window.open(window.location.protocol + "//" + window.location.host + "/sistema/intranet/presupuestos/" + file.hash, '_blank'); + }); + } + }); + } } _getDropzoneFilesFormData() { @@ -82,6 +94,7 @@ class FileUploadDropzone { return formData; } _handleUploadFiles() { + $("#loader").modal('show') let ajax = new Ajax(this.postUri, this._getDropzoneFilesFormData(), null, @@ -91,12 +104,13 @@ class FileUploadDropzone { } _handleUploadFilesSuccess(response) { + this.dropZoneClean() + this._handleGetFiles() alertSuccessMessage(response?.message ?? "Archivos subidos correctamente"); } _handleUploadFilesError(errors) { } _handleGetFiles() { - const ajax = new Ajax( this.getUri, this.dataPost, @@ -108,26 +122,27 @@ class FileUploadDropzone { ajax.post() } _handelGetFilesSuccess(response) { - const files = JSON.parse(response) - this.dropZoneUpdateFiles(files) + try { + $("#loader").modal('hide') + const files = JSON.parse(response) + this.dropZoneUpdateFiles(files) + } catch (error) { + $("#loader").modal('hide') + } } dropZoneUpdateFiles(files) { - this.dropzone.on("addedfile", function (file) { - if (file.hash) { - var viewButton = Dropzone.createElement("Ver"); - file.previewElement.appendChild(viewButton); - // Listen to the view button click event - viewButton.addEventListener("click", function (e) { - window.open(window.location.protocol + "//" + window.location.host + "/sistema/intranet/presupuestos/" + file.hash, '_blank'); - }); - } - }); + files.forEach(file => { this.dropZoneAddFile(file) }); } + dropZoneClean() { + this.dropzone.files.forEach(file => { + this.dropzone.removeFile(file); + }) + } dropZoneAddFile(mockFile) { this.dropzone.files.push(mockFile); // add to files array this.dropzone.emit("addedfile", mockFile); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js index 0b09983d..5cf763c8 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js @@ -61,7 +61,9 @@ class PresupuestoAdminEdit { getUri: '/presupuestos/presupuestocliente/get_files', postUri: '/presupuestos/presupuestocliente/upload_files' } - this.fileUploadDropzone = new FileUploadDropzone(this.configUploadDropzone) + if ($(this.configUploadDropzone.domElement).length > 0) { + this.fileUploadDropzone = new FileUploadDropzone(this.configUploadDropzone) + } } init() { @@ -128,7 +130,9 @@ class PresupuestoAdminEdit { $('#lomo_cubierta').on('change', this.datosLibro.changeAnchoSolapasCubierta); $('#lomo_sobrecubierta').on('change', this.datosLibro.changeAnchoSolapasSobrecubierta); - this.fileUploadDropzone.init() + if ($(this.configUploadDropzone.domElement).length > 0) { + this.fileUploadDropzone.init() + } } From 2af5a0155c525b6dcedfc4c87b12b87ea0e176ca Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Wed, 29 Jan 2025 09:43:34 +0100 Subject: [PATCH 78/89] corregido error en papeles especiales --- ci4/app/Controllers/Presupuestos/Presupuestoadmin.php | 2 ++ .../vuexy/form/presupuestos/admin/_datosPresupuestoItems.php | 5 +++++ .../js/safekat/pages/presupuestoCliente/disenioCubierta.js | 2 +- .../js/safekat/pages/presupuestoCliente/disenioInterior.js | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index 377e874e..b5e98455 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -148,6 +148,8 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $this->viewData['incReiList'] = array('incidencia' => lang('Presupuestos.incidencia'), 'reimpresion' => lang('Presupuestos.reimpresion'), 'sin_cargo' => lang('Presupuestos.sinCargo')); $this->viewData['POD'] = $this->getPOD(); + $this->viewData['pais_default_id'] = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_pais_defecto')->value; + $this->viewData['pais_default'] = model('App\Models\Configuracion\PaisModel')->find($this->viewData['pais_default_id'])->nombre; $this->viewData['formAction'] = route_to('createPresupuestoAdmin', $tipo_impresion_id); diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoItems.php index f044e4f9..f99d60a1 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoItems.php @@ -125,6 +125,11 @@
diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js index 8361a299..95b391de 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js @@ -38,7 +38,7 @@ class DisenioCubierta { solapas: () => {return $('#solapas_cubierta').hasClass("d-none") ? 0 : $('#solapas_cubierta').val()}, lomo: () => {return $('#lc').val()}, tapa_dura: () => {return this.tapaBlanda.hasClass("selected") ? 0 : 1}, - tirada: this.presupuestoCliente.datosGenerales.getTiradas()[0], + tirada: () => {return this.presupuestoCliente.datosGenerales.getTiradas()[0]}, } ); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js index d378c229..0dad4b2a 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js @@ -57,7 +57,7 @@ class DisenioInterior { { [this.csrf_token]: this.csrf_hash, tipo: this.getTipoImpresion(), - tirada: () => {return $('#tirada').val()}, + tirada: () => {{return this.presupuestoCliente.datosGenerales.getTiradas()[0]}}, ancho: () => {return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho}, alto: () => {return this.presupuestoCliente.datosGenerales.getDimensionLibro().alto}, solapas: 0, From 5b89cc0c1d93f84466a8de76dd10ea44e1c278cf Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Wed, 29 Jan 2025 09:49:52 +0100 Subject: [PATCH 79/89] =?UTF-8?q?a=C3=B1adido=20que=20solo=20compruebe=20e?= =?UTF-8?q?l=20ancho=20en=20vertical=20si=20es=20rotativa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Configuracion/PapelGenericoModel.php | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/ci4/app/Models/Configuracion/PapelGenericoModel.php b/ci4/app/Models/Configuracion/PapelGenericoModel.php index b97c2c8e..41aa10d7 100755 --- a/ci4/app/Models/Configuracion/PapelGenericoModel.php +++ b/ci4/app/Models/Configuracion/PapelGenericoModel.php @@ -129,16 +129,16 @@ class PapelGenericoModel extends \App\Models\BaseModel return empty($search) ? $builder : $builder - ->groupStart() - ->like("t1.id", $search) - ->orLike("t1.nombre", $search) - ->orLike("t1.code", $search) - ->orLike("t1.code_ot", $search) - ->orLike("t1.id", $search) - ->orLike("t1.nombre", $search) - ->orLike("t1.code", $search) - ->orLike("t1.code_ot", $search) - ->groupEnd(); + ->groupStart() + ->like("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.code", $search) + ->orLike("t1.code_ot", $search) + ->orLike("t1.id", $search) + ->orLike("t1.nombre", $search) + ->orLike("t1.code", $search) + ->orLike("t1.code_ot", $search) + ->groupEnd(); } @@ -210,6 +210,10 @@ class PapelGenericoModel extends \App\Models\BaseModel ->where("t4.ancho_impresion >", $alto) ->where("t4.alto_impresion >", $ancho) ->groupEnd() + ->orGroupStart() + ->where("t4.ancho_impresion >", $alto) + ->where("t4.is_rotativa", 1) + ->groupEnd() ->groupEnd(); if ($is_cubierta == true) { @@ -308,6 +312,10 @@ class PapelGenericoModel extends \App\Models\BaseModel ->where("t4.ancho_impresion >", $alto) ->where("t4.alto_impresion >", $ancho) ->groupEnd() + ->orGroupStart() + ->where("t4.ancho_impresion >", $alto) + ->where("t4.is_rotativa", 1) + ->groupEnd() ->groupEnd(); if ($is_cubierta == true) { @@ -497,6 +505,10 @@ class PapelGenericoModel extends \App\Models\BaseModel ->where("t4.ancho_impresion >", $alto) ->where("t4.alto_impresion >", $ancho) ->groupEnd() + ->orGroupStart() + ->where("t4.ancho_impresion >", $alto) + ->where("t4.is_rotativa", 1) + ->groupEnd() ->groupEnd(); if ($is_cubierta == true) { From 1ef49490bd0346c5aec57514967a736e1774043d Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Wed, 29 Jan 2025 10:19:25 +0100 Subject: [PATCH 80/89] arreglado el problema de coger el tipo de impresion y tirada --- .../js/safekat/pages/presupuestoCliente/disenioInterior.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js index 0dad4b2a..f0e25efd 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js @@ -56,7 +56,7 @@ class DisenioInterior { false, { [this.csrf_token]: this.csrf_hash, - tipo: this.getTipoImpresion(), + tipo: () => {return this.getTipoImpresion()}, tirada: () => {{return this.presupuestoCliente.datosGenerales.getTiradas()[0]}}, ancho: () => {return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho}, alto: () => {return this.presupuestoCliente.datosGenerales.getDimensionLibro().alto}, @@ -71,8 +71,8 @@ class DisenioInterior { false, { [this.csrf_token]: this.csrf_hash, - tipo: this.getTipoImpresionColor(), - tirada: () => {return $('#tirada').val()}, + tipo: () => {return this.getTipoImpresion()}, + tirada: () => {{return this.presupuestoCliente.datosGenerales.getTiradas()[0]}}, ancho: () => {return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho}, alto: () => {return this.presupuestoCliente.datosGenerales.getDimensionLibro().alto}, solapas: 0, From 287132698955a1bb8c2eb95ee57cbc0fe006b5a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Wed, 29 Jan 2025 20:42:19 +0100 Subject: [PATCH 81/89] arreglados multiples fallos de presupuesto admin y problema en los forms de las tarifas --- .../presupuestos/admin/_datosLibroItems.php | 52 ++++++------ .../tarifas/acabado/viewTarifaAcabadoForm.php | 3 +- .../manipulado/viewTarifaManipuladoForm.php | 3 +- .../viewTarifapreimpresionForm.php | 20 +---- .../presupuestoAdmin/presupuestoAdminEdit.js | 76 +++++++++++++++++- .../presupuestoAdmin/sections/datosLibro.js | 27 ++++++- .../pages/presupuestoAdmin/sections/envios.js | 15 ++-- .../presupuestoAdmin/sections/servicios.js | 79 ++++++++++++++++--- .../presupuestoCliente/presupuestoCliente.js | 2 +- 9 files changed, 202 insertions(+), 75 deletions(-) diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php index c442c76c..d2149259 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php @@ -107,7 +107,18 @@ for="solapas">
- +
+
+
+ + +
+ Entre 60 y 120 mm +
+
@@ -122,6 +133,19 @@
+
+
+ + +
+ Entre 60 y 120 mm +
+
+
@@ -138,32 +162,6 @@
- -
- -
-
- - -
-
- -
-
- - -
- -
- -
diff --git a/ci4/app/Views/themes/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php b/ci4/app/Views/themes/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php index ced61c74..4e42b95a 100644 --- a/ci4/app/Views/themes/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php +++ b/ci4/app/Views/themes/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php @@ -258,8 +258,7 @@ paging: true, info: false, stateSave: false, - dom: '<"mt-4"><"float-end"B><"float-start"l> - <"mt-4 mb-3"p>', + dom: '<"mt-4"><"float-end"B><"float-start"l><"mt-4 mb-3"p>', ajax : $.fn.dataTable.pipeline( { url: '', data: { diff --git a/ci4/app/Views/themes/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php b/ci4/app/Views/themes/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php index 47bbb8ce..f07210b3 100644 --- a/ci4/app/Views/themes/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php +++ b/ci4/app/Views/themes/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php @@ -173,8 +173,7 @@ searching: false, paging: true, info: false, - dom: '<"mt-4"><"float-end"B><"float-start"l> - <"mt-4 mb-3"p>', + dom: '<"mt-4"><"float-end"B><"float-start"l><"mt-4 mb-3"p>', ajax : $.fn.dataTable.pipeline( { url: '', data: { diff --git a/ci4/app/Views/themes/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionForm.php b/ci4/app/Views/themes/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionForm.php index 8eb895fa..a3f3f0dc 100644 --- a/ci4/app/Views/themes/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionForm.php +++ b/ci4/app/Views/themes/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionForm.php @@ -1,4 +1,5 @@ include("themes/_commonPartialsBs/select2bs5") ?> +include("themes/_commonPartialsBs/datatables") ?> include("themes/_commonPartialsBs/sweetalert") ?> extend('themes/vuexy/main/defaultlayout') ?> section("content") ?> @@ -26,25 +27,6 @@
- -
-
-

- -

-
-
- "tarifa_maquina_component", "tarifaId" => $tarifapreimpresionEntity?->id]) ?> -
-
-
-
- -endSection() ?> -section("additionalExternalJs") ?> - endSection() ?> \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js index 5cf763c8..8b9e7cf3 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js @@ -382,14 +382,35 @@ class PresupuestoAdminEdit { ).get(); } + /* + calcularSolapas() { + + + this.#getDatos(false, true); + if (Object.values(this.datos).every(this.#isValidDataForm)) { + new Ajax('/presupuestocliente/calcularsolapas', + this.datos, + {}, + (response) => { + if (response === null || response === undefined || response === "") { + console.error("Error en el calculo máximo de solapas."); + return; + } + this.disenioCubierta.tamanioSolapasCubierta.attr('max', response); + this.disenioCubierta.solapasSobrecubierta.attr('max', response); + this.disenioCubierta.textoSolapasCubierta.text("Entre 60 y " + response + " mm"); + this.disenioCubierta.textoSolapasSobrecubierta.text("Entre 60 y " + response + " mm"); + }, + () => { } + ).post(); + } + }*/ checkPaginasPresupuesto() { let cantidad_total = 0; - // TO-DO - /* - tableLineasPresupuesto.rows().every(function (rowIdx, tableLoop, rowLoop) { + this.lineasPresupuesto.table.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) @@ -409,7 +430,54 @@ class PresupuestoAdminEdit {
`; } - $('#divAlarmasLineasPresupuesto').html(htmlString)*/ + $('#divAlarmasLineasPresupuesto').html(htmlString) + } + + + getPaginasColor(){ + + let paginasColor = 0; + this.lineasPresupuesto.table.rows().every(function (rowIdx, tableLoop, rowLoop) { + var rowData = this.data(); + if (rowData.row_id === 'lp_color' || rowData.row_id === 'lp_colorhq') { + return parseInt(rowData.paginas); + } + if(rowData.row_id === 'lp_rot_color'){ + return parseInt(rowData.numPagColor); + } + }); + return paginasColor; + } + + calcularSolapas() { + + let datos = { + cliente_id: this.datosGenerales.cliente.getVal(), + tirada: this.datosGenerales.tirada.val(), + tamanio: this.getDimensionLibro(), + paginas: this.datosLibro.paginas.val(), + //paginasColor: + + + } + + /*if (Object.values(this.datos).every(this.#isValidDataForm)) { + new Ajax('/presupuestocliente/calcularsolapas', + this.datos, + {}, + (response) => { + if (response === null || response === undefined || response === "") { + console.error("Error en el calculo máximo de solapas."); + return; + } + this.disenioCubierta.tamanioSolapasCubierta.attr('max', response); + this.disenioCubierta.solapasSobrecubierta.attr('max', response); + this.disenioCubierta.textoSolapasCubierta.text("Entre 60 y " + response + " mm"); + this.disenioCubierta.textoSolapasSobrecubierta.text("Entre 60 y " + response + " mm"); + }, + () => { } + ).post(); + }*/ } getDimensionLibro() { diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js index 8bd7c1bc..099f08d0 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js @@ -225,7 +225,7 @@ class DatosLibro { }, 100); // para que se actualice el comparador - $('paginas').trigger('change'); + this.updateComparador(); } changeAnchoSolapasCubierta(){ @@ -238,7 +238,7 @@ class DatosLibro { } // para que se actualice el comparador - $('paginas').trigger('change'); + this.updateComparador(); } @@ -269,7 +269,7 @@ class DatosLibro { } // para que se actualice el comparador - $('paginas').trigger('change'); + this.updateComparador(); } @@ -332,10 +332,29 @@ class DatosLibro { } } + updateComparador(){ + + if($("#compPaginasNegro").hasClass('d-none')){ + $('#compPaginasNegrohq').trigger('change'); + } + else{ + $('#compPaginasNegro').trigger('change'); + } + $('#compCarasCubierta').trigger('change'); + + if($('#compSobrecubierta').length){ + $('#compSobrecubierta').trigger('change'); + } + if($('#compCarasGuardas').length){ + $('#compCarasGuardas').trigger('change'); + } + } changeTirada(update_tiradas_alternativas = true) { - this.calcular_mermas() + this.calcular_mermas(); + + this.updateComparador(); const url2 = window.location.href; const url_parts2 = url2.split('/'); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/envios.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/envios.js index e4126ce3..4217cc10 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/envios.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/envios.js @@ -108,7 +108,7 @@ class Envios { $("#costeEnvios").text(total.toFixed(2) + "€" || "0€"); - self.check_unidades_enviadas(); + self.check_unidades_enviadas(null, self.recogerTaller.prop('checked')); } }); @@ -169,11 +169,10 @@ class Envios { self.modalYesNo.init(); self.modalYesNo.show(() => { self.table.clear().draw(); - self.check_unidades_enviadas(); + self.check_unidades_enviadas(null, true); self.recogerTaller.prop('checked', true); - self.modalYesNo.hide(); self.insertarEnvio.addClass('d-none'); - + self.modalYesNo.hide(); }); } else { @@ -641,7 +640,11 @@ class Envios { } } - check_unidades_enviadas() { + check_unidades_enviadas(event, recogerTaller = null) { + + if(recogerTaller === null) { + recogerTaller = this.recogerTaller.prop('checked'); + } let cantidad_total = 0 this.table.rows().every(function (rowIdx, tableLoop, rowLoop) { @@ -650,7 +653,7 @@ class Envios { const tirada = parseInt($('#tirada').val()); let htmlString = ''; - if (cantidad_total < tirada && this.recogerTaller.prop('checked') === false) { + if (cantidad_total < tirada && recogerTaller === false) { htmlString = ` `; - } + } $('#divAlarmasLineasPresupuesto').html(htmlString) } - getPaginasColor(){ + getPaginasColor() { let paginasColor = 0; this.lineasPresupuesto.table.rows().every(function (rowIdx, tableLoop, rowLoop) { @@ -442,42 +421,51 @@ class PresupuestoAdminEdit { if (rowData.row_id === 'lp_color' || rowData.row_id === 'lp_colorhq') { return parseInt(rowData.paginas); } - if(rowData.row_id === 'lp_rot_color'){ + if (rowData.row_id === 'lp_rot_color') { return parseInt(rowData.numPagColor); } }); - return paginasColor; + return paginasColor; } calcularSolapas() { - let datos = { - cliente_id: this.datosGenerales.cliente.getVal(), - tirada: this.datosGenerales.tirada.val(), - tamanio: this.getDimensionLibro(), - paginas: this.datosLibro.paginas.val(), - //paginasColor: + let anchoTotal = 2*this.getDimensionLibro().ancho; + let maxSolapas = 120; + let mano = 0; + this.lineasPresupuesto.table.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' || rowData.row_id === 'lp_faja' + ) { + mano += parseInt(rowData.mano); + } + }); + if (mano > 0) { + anchoTotal += 6 + 5; // dobleces + sangre + maxSolapas = Math.min(Math.floor((865-anchoTotal)/2), 0.75*this.getDimensionLibro().ancho); } - - /*if (Object.values(this.datos).every(this.#isValidDataForm)) { - new Ajax('/presupuestocliente/calcularsolapas', - this.datos, - {}, - (response) => { - if (response === null || response === undefined || response === "") { - console.error("Error en el calculo máximo de solapas."); - return; - } - this.disenioCubierta.tamanioSolapasCubierta.attr('max', response); - this.disenioCubierta.solapasSobrecubierta.attr('max', response); - this.disenioCubierta.textoSolapasCubierta.text("Entre 60 y " + response + " mm"); - this.disenioCubierta.textoSolapasSobrecubierta.text("Entre 60 y " + response + " mm"); - }, - () => { } - ).post(); - }*/ + else{ + maxSolapas = 0.75*this.getDimensionLibro().ancho; + } + if($('#solapas_ancho').length>0 && $('#solapas_ancho').attr('max') != maxSolapas){ + $('#solapas_ancho').attr('max', maxSolapas); + $('#solapas_ancho').trigger('change'); + $('#solapas_ancho').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm'); + } + if($('#solapas_ancho_sobrecubierta').length>0 && $('#solapas_ancho_sobrecubierta').attr('max') != maxSolapas){ + $('#solapas_ancho_sobrecubierta').attr('max', maxSolapas); + $('#solapas_ancho_sobrecubierta').trigger('change'); + $('#solapas_ancho_sobrecubierta').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm'); + } + if($('#solapas_ancho_faja').length>0 && $('#solapas_ancho_faja').attr('max') != maxSolapas){ + $('#solapas_ancho_faja').attr('max', maxSolapas); + $('#solapas_ancho_faja').trigger('change'); + $('#solapas_ancho_faja').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm'); + } + console.log('maxSolapas', maxSolapas); } getDimensionLibro() { diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js index 099f08d0..b14e3026 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js @@ -95,6 +95,24 @@ class DatosLibro { this.paginas.on('change', this.changePaginas.bind(this)); this.tirada.on('change', this.changeTirada.bind(this)); + + this.anchoSolapasCubierta.on('focusout', this.checkSolapasMax.bind(this)); + this.anchoSolapasSobrecubierta.on('focusout', this.checkSolapasMax.bind(this)); + } + } + + checkSolapasMax(event) { + const el = event.target; + if (el.value != "") { + if (parseInt(el.value) < parseInt(el.min)) { + el.value = el.min; + } + if (parseInt(el.value) > parseInt(el.max)) { + el.value = el.max; + } + } + else{ + el.value = el.min; } } @@ -172,8 +190,8 @@ class DatosLibro { this.checkPaginasPresupuesto(); $(document).trigger('update-presupuesto', { - update_lineas : true, - update_servicios : true, + update_lineas: true, + update_servicios: true, update_envios: true, update_resumen: true, update_tiradas_alternativas: true @@ -199,10 +217,10 @@ class DatosLibro { $("#label_papelFormatoId").text( window.language.Presupuestos.papelFormatoId + '*'); } - + $(document).trigger('update-presupuesto', { - update_lineas : true, - update_servicios : false, + update_lineas: true, + update_servicios: false, update_envios: false, update_resumen: false, update_tiradas_alternativas: false @@ -228,12 +246,12 @@ class DatosLibro { this.updateComparador(); } - changeAnchoSolapasCubierta(){ + changeAnchoSolapasCubierta() { - if(this.checkSolapasGrandes('cubierta')){ + if (this.checkSolapasGrandes('cubierta')) { $(document).trigger('add-servicio-lineas', 'solapas_grandes_cubierta'); } - else{ + else { $(document).trigger('remove-servicio-lineas', 'solapas_grandes_cubierta'); } @@ -259,12 +277,12 @@ class DatosLibro { } - changeAnchoSolapasSobrecubierta(){ + changeAnchoSolapasSobrecubierta() { - if(this.checkSolapasGrandes('cubierta')){ + if (this.checkSolapasGrandes('cubierta')) { $(document).trigger('add-servicio-lineas', 'solapas_grandes_sobrecubierta'); } - else{ + else { $(document).trigger('remove-servicio-lineas', 'solapas_grandes_sobrecubierta'); } @@ -274,24 +292,24 @@ class DatosLibro { } checkSolapasGrandes(elemento) { - + const ancho_libro = 2 * this.getDimensionLibro().ancho; let ancho_solapas = 0.0; let lomo = 0.0; - if(elemento == 'cubierta'){ - ancho_solapas = 2 * parseFloat($('solapas_ancho').val()); - lomo = parseFloat($('lomo_cubierta').val()); + if (elemento == 'cubierta') { + ancho_solapas = 2 * parseFloat($('solapas_ancho').val()); + lomo = parseFloat($('lomo_cubierta').val()); } - else if (elemento == 'sobrecubierta'){ - ancho_solapas = 2 * parseFloat($('solapas_ancho_sobrecubierta').val()); - lomo = parseFloat($('lomo_sobrecubierta').val()); + else if (elemento == 'sobrecubierta') { + ancho_solapas = 2 * parseFloat($('solapas_ancho_sobrecubierta').val()); + lomo = parseFloat($('lomo_sobrecubierta').val()); } - else + else return false; - if (ancho_libro + ancho_solapas + lomo > 630) + if (ancho_libro + ancho_solapas + lomo > 630) return true; - else + else return false } @@ -320,32 +338,32 @@ class DatosLibro { $('#compPaginasNegrohq').trigger('change'); } - + $(document).trigger('update-presupuesto', { - update_lineas : true, - update_servicios : true, + update_lineas: true, + update_servicios: true, update_envios: true, update_resumen: true, update_tiradas_alternativas: true }); - + } } - updateComparador(){ + updateComparador() { - if($("#compPaginasNegro").hasClass('d-none')){ + if ($("#compPaginasNegro").hasClass('d-none')) { $('#compPaginasNegrohq').trigger('change'); } - else{ + else { $('#compPaginasNegro').trigger('change'); } $('#compCarasCubierta').trigger('change'); - - if($('#compSobrecubierta').length){ + + if ($('#compSobrecubierta').length) { $('#compSobrecubierta').trigger('change'); } - if($('#compCarasGuardas').length){ + if ($('#compCarasGuardas').length) { $('#compCarasGuardas').trigger('change'); } } @@ -361,13 +379,13 @@ class DatosLibro { if (url_parts2[url_parts2.length - 2] == 'edit') { $(document).trigger('update-presupuesto', { - update_lineas : true, - update_servicios : false, + update_lineas: true, + update_servicios: false, update_envios: false, update_resumen: false, update_tiradas_alternativas: false }); - + $(document).trigger('ckeck-lineas-envios'); } } From 31f7f924488f974a25ab6b06b91cb417c21aba5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Fri, 31 Jan 2025 10:14:47 +0100 Subject: [PATCH 83/89] trabajando en eventos de lineas --- ci4/app/Language/es/Presupuestos.php | 4 +- .../presupuestos/admin/_datosLibroItems.php | 41 ++++ .../admin/_datosPresupuestoClienteItems.php | 212 +++++++++++++--- .../admin/_resumenPresupuestoItems.php | 2 +- .../presupuestoAdmin/presupuestoAdminAdd.js | 1 + .../presupuestoAdmin/presupuestoAdminEdit.js | 83 ++++--- .../presupuestoAdmin/sections/comparador.js | 230 +++++++++++++++++- .../presupuestoAdmin/sections/datosLibro.js | 42 ++-- .../sections/lineasPresupuesto.js | 112 +++++++-- .../sections/tiradasAlternativas.js | 2 +- 10 files changed, 603 insertions(+), 126 deletions(-) diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 18e5f56b..4a8f06c5 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -166,6 +166,7 @@ return [ 'solapasSobrecubierta' => 'Solapas sobrecub.', 'solapasAnchoCubierta' => 'Ancho solapas cub.', 'solapasAnchoSobrecubierta' => 'Ancho solapas sobrecub.', + 'sinImpresion' => 'Sin impresion', 'unaCara' => '1 cara', 'dosCaras' => '2 caras', @@ -387,7 +388,8 @@ return [ 'noInterior' => 'No se hay resultados para el interior', 'noCubiertaSobrecubierta' => 'No se hay resultados para cubierta/sobrecubierta', 'errorPresupuesto' => 'Se ha producido un error al calcular el presupuesto. Póngase en contacto con el administrador', - 'error_sobrecubierta_sin_solapas' => 'Debe seleccionar "sobrecubierta" en los datos del libro para introducir el ancho de solapa' + 'error_sobrecubierta_sin_solapas' => 'Debe seleccionar "sobrecubierta" en los datos del libro para introducir el ancho de solapa', + 'error_faja_sin_solapas' => 'Debe seleccionar "faja" en los datos del libro para introducir el ancho de solapa' ], ]; diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php index d2149259..c8172bbe 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php @@ -162,6 +162,47 @@
+ +
+ +
+
+
+
+ + +
+
+
+ +
+
+ + +
+ Entre 50 y 120 mm +
+
+
+
+
+ + +
+ Entre 60 y 120 mm +
+
+
+ +
+
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php index eb45cbe1..b8ad40ff 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php @@ -222,46 +222,46 @@
-
-
+
+
-
- - -
-
- - -
+
+ + +
+
+ + +

@@ -345,13 +345,49 @@ class="form-control select2bs2 comp_guardas_items" style="width: 100%;">
- +

+
+
+

+ +

+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
@@ -799,6 +835,102 @@
+
+
+

+ +

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + : + + 0.00
+ +
+ +
+ +
+
+
+
+ diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_resumenPresupuestoItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_resumenPresupuestoItems.php index 1ecd5e1f..4eb6c8a2 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_resumenPresupuestoItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_resumenPresupuestoItems.php @@ -82,7 +82,7 @@ estado_id == 2): ?>
-
' + + '' + + '' + } + if (d.maquinaTipo == 'inkjet') { value += '' + @@ -1389,6 +1405,22 @@ class LineasPresupuesto { const self = this; const dimension = this.getDimensionLibro(); + if (linea == 'lp_faja') { + if (Object.keys(input_data).length == 0) { + let altoSelected = parseInt($('#' + linea + '_altoFaja').val()); + if(altoSelected == 0 || isNaN(altoSelected) || altoSelected == '' || altoSelected < 50){ + altoSelected = 50; + } + else if(altoSelected > dimension.alto){ + altoSelected = dimension.alto; + } + dimension.alto = altoSelected; + } + else{ + dimension.alto = parseInt($('#faja_alto').val()); + } + } + const dataFromComparador = fromComparador; if (Object.keys(input_data).length == 0) { @@ -1406,7 +1438,7 @@ class LineasPresupuesto { if (linea == 'lp_cubierta') { input_data.paginas = parseInt($('#lp_cubierta_paginas option:selected').val()); } - else if (linea == 'lp_sobrecubierta') { + else if (linea == 'lp_sobrecubierta' || linea == 'lp_faja') { input_data.paginas = 4; } else if (linea == 'lp_guardas') { @@ -1433,6 +1465,7 @@ class LineasPresupuesto { uso = 'cubierta'; break; case 'lp_sobrecubierta': + case 'lp_faja': uso = 'sobrecubierta'; break; case 'lp_guardas': @@ -1453,7 +1486,6 @@ class LineasPresupuesto { hq = 0; } - var datos = { tipo_impresion_id: $('#tipo_impresion_id').val(), type: uso, @@ -1496,6 +1528,11 @@ class LineasPresupuesto { datos.solapas_ancho = $('#solapas_sobrecubierta').is(':checked') ? parseInt($('#solapas_ancho_sobrecubierta').val()) : 0; datos.lomo = $('#lomo_sobrecubierta').val(); } + else if (linea == 'lp_faja') { + datos.solapas = 1; + datos.solapas_ancho = parseInt($('#faja_solapas_ancho').val()); + datos.lomo = $('#lomo_sobrecubierta').val(); + } else if (linea == 'lp_guardas') { datos.paginas_impresion = input_data.paginas_impresion; } @@ -1503,7 +1540,7 @@ class LineasPresupuesto { // Si es inkjet, existe este check if ($('#' + linea + '_aFavorFibra').length) { - datos.a_favor_fibra = $('#' + linea + '_aFavorFibra').prop('checked') ? 1: 0; + datos.a_favor_fibra = $('#' + linea + '_aFavorFibra').prop('checked') ? 1 : 0; } if (updatedTipologias && $('#' + linea + '_gotaNegro').length) { @@ -1549,6 +1586,9 @@ class LineasPresupuesto { response.lineas[$i].fields.check_papel_total = 1; response.lineas[$i].fields.check_impresion_total = 1; } + if (linea == 'lp_faja') { + response.lineas[$i].fields.alto_faja = dimension.alto; + } self.rellenarDatosLinea(linea, response.lineas[$i].fields); return true; @@ -1583,7 +1623,7 @@ class LineasPresupuesto { papel_impresion_id: row.papelImpresionId, maquina_id: row.maquinaId, } - if(linea.includes('guardas')) { + if (linea.includes('guardas')) { input_data.paginas_impresion = parseInt($('#compCarasGuardas').select2('data')[0].id); } this.obtenerLinea(linea, fromComparator, false, input_data) @@ -1602,7 +1642,13 @@ class LineasPresupuesto { this.table.row.add(data).draw() currentRow = this.table.row('#' + linea); } - currentRow.child(this.formatRow(currentRow.data())).show(); + + let datosLinea = currentRow.data(); + if(linea == 'lp_faja') { + datosLinea.alto_faja = row.alto_faja; + } + + currentRow.child(this.formatRow(datosLinea)).show(); this.#addEventosLineas(linea, data.maquinaTipo == 'inkjet' ? true : false); @@ -1615,16 +1661,16 @@ class LineasPresupuesto { */ $(document).trigger('update-presupuesto', { - update_lineas : false, - update_servicios : true, + update_lineas: false, + update_servicios: true, update_envios: true, update_resumen: true, update_tiradas_alternativas: true }); - + // Si existe cubierta, hay que actualizar con el valor del lomo - if (linea != 'lp_cubierta' && linea != 'lp_sobrecubierta' && this.table.row('#lp_cubierta').length > 0) { + if (linea != 'lp_cubierta' && linea != 'lp_sobrecubierta' && linea != 'lp_faja' && this.table.row('#lp_cubierta').length > 0) { this.obtenerLinea('lp_cubierta', false, false); } if (mostrar_calculos) { @@ -1666,6 +1712,7 @@ class LineasPresupuesto { uso = 'cubierta'; break; case 'lp_sobrecubierta': + case 'lp_faja': uso = 'sobrecubierta'; break; case 'lp_guardas': @@ -1765,6 +1812,12 @@ class LineasPresupuesto { $('#' + tipoLinea + '_defecto').on("click", () => { this.lp_por_defecto(tipoLinea); }); $('#' + tipoLinea + '_aFavorFibra').on("change", () => { this.change_aFavorFibra(tipoLinea); }); } + + if(tipoLinea == 'lp_faja') { + $('#' + tipoLinea + '_altoFaja').on("change", function (event) { + self.obtenerLinea(tipoLinea, false, false, {}, event); // Pasamos explícitamente 'tipoLinea' + }.bind(this)); + } } @@ -1922,19 +1975,36 @@ class LineasPresupuesto { } } self.table.draw(); - + var rows = $("#tableCompGuardas").DataTable().rows('.selected').data().toArray(); for (const row of rows) { this.rellenarDatosLinea('lp_guardas', row, true); } - + $(document).trigger('add-servicio-lineas', 'plegado_guardas'); } + else if (e.target.id.includes("Faja")) { + + for (let i = self.table.rows().data().length - 1; i >= 0; i--) { + let row = self.table.row(i).data(); // Obtener datos de la fila actual + + if (row.row_id.includes('lp_faja')) { + self.table.row(i).remove(); // Eliminar fila + } + } + self.table.draw(); + + var rows = $("#tableCompFaja").DataTable().rows('.selected').data().toArray(); + for (const row of rows) { + this.rellenarDatosLinea('lp_faja', row, true); + } + } + $(document).trigger('update-presupuesto', { - update_lineas : false, - update_servicios : true, + update_lineas: false, + update_servicios: true, update_envios: true, update_resumen: true, update_tiradas_alternativas: true diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/tiradasAlternativas.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/tiradasAlternativas.js index 897566d1..f2c327ce 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/tiradasAlternativas.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/tiradasAlternativas.js @@ -147,7 +147,7 @@ class TiradasAlernativas { const self = this; const id = window.location.href.split('/').pop(); - const tirada = tiradaExterna === null ? parseInt(this.tirada.val()) : tiradaExterna; + const tirada = tiradaExterna === null || isNaN(tiradaExterna) ? parseInt(this.tirada.val()) : tiradaExterna; const tirada_ejemplo = parseInt($('#tirada').val()); const POD = parseInt($('#POD').val()); From a75ef4eae6909486c5251b26b7b5aa6205fce877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Sat, 1 Feb 2025 10:43:49 +0100 Subject: [PATCH 84/89] guardado faja datos libro --- .../Presupuestos/Presupuestoadmin.php | 7 +++-- .../Presupuestos/PresupuestoEntity.php | 8 +++-- .../Models/Presupuestos/PresupuestoModel.php | 4 ++- ci4/app/Services/PresupuestoService.php | 2 +- .../presupuestos/admin/_datosLibroItems.php | 4 +-- .../admin/_lineasPresupuestoItems.php | 1 + .../presupuestoAdmin/presupuestoAdminEdit.js | 26 +++++++++++----- .../presupuestoAdmin/sections/datosLibro.js | 23 ++++++++++++-- .../sections/lineasPresupuesto.js | 30 +++++++++++++++---- .../presupuestoAdmin/sections/resumen.js | 30 +++++++++---------- 10 files changed, 96 insertions(+), 39 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index b5e98455..a2d6acb0 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -478,6 +478,10 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $data['datosLibro']['solapasSobrecubierta'] = $presupuesto->solapas_sobrecubierta; $data['datosLibro']['solapasCubiertaAncho'] = $presupuesto->solapas_ancho; $data['datosLibro']['solapasSobrecubiertaAncho'] = $presupuesto->solapas_ancho_sobrecubierta; + $data['datosLibro']['fajaColor'] = $presupuesto->faja_color; + $data['datosLibro']['fajaColorSolapasAncho'] = $presupuesto->solapas_ancho_faja_color; + $data['datosLibro']['fajaColorAlto'] = $presupuesto->alto_faja_color; + $modelAcabado = model("App\Models\Tarifas\Acabados\TarifaAcabadoModel"); $data['datosLibro']['acabadoCubierta']['id'] = $presupuesto->acabado_cubierta_id; if ($presupuesto->acabado_cubierta_id == 0) { @@ -497,8 +501,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $data['datosLibro']['marcapaginas'] = $presupuesto->marcapaginas; $data['datosLibro']['retractilado'] = $presupuesto->retractilado; $data['datosLibro']['retractilado5'] = $presupuesto->retractilado5; - $data['datosLibro']['fajaColor'] = $presupuesto->faja_color; - + $data['comparador']['tipo_impresion'] = $presupuesto->comp_tipo_impresion; $data['comparador']['json_data'] = json_decode($presupuesto->comparador_json_data, true); if ($data['comparador']['json_data'] != null) { diff --git a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php index 7d736a94..92eca96c 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php @@ -31,7 +31,6 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity "retractilado" => false, "retractilado5" => false, "guardas" => false, - "faja_color" => false, "recoger_en_taller" => false, "ferro" => false, "ferro_digital" => false, @@ -53,6 +52,9 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity "solapas_ancho" => 0.0, "solapas_sobrecubierta" => false, "solapas_ancho_sobrecubierta" => 0.0, + "faja_color" => false, + "solapas_ancho_faja_color" => 0.0, + "alto_faja_color" => 0.0, "cosido" => false, "sobrecubiertas" => false, "sobrecubiertas_ancho" => 0.0, @@ -121,7 +123,6 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity "retractilado" => "boolean", "retractilado5" => "boolean", "guardas" => "boolean", - "faja_color" => "boolean", "recoger_en_taller" => "boolean", "ferro" => "boolean", "ferro_digital" => "boolean", @@ -137,6 +138,9 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity "solapas_ancho" => "float", "solapas_sobrecubierta" => "boolean", "solapas_ancho_sobrecubierta" => "float", + "faja_color" => "boolean", + "solapas_ancho_faja_color" => "float", + "alto_faja_color" => "float", "cosido" => "boolean", "sobrecubiertas" => "boolean", "sobrecubiertas_ancho" => "float", diff --git a/ci4/app/Models/Presupuestos/PresupuestoModel.php b/ci4/app/Models/Presupuestos/PresupuestoModel.php index 4a80cd50..f515e833 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoModel.php @@ -54,7 +54,6 @@ class PresupuestoModel extends \App\Models\BaseModel "retractilado", "retractilado5", "guardas", - "faja_color", "recoger_en_taller", "ferro", "ferro_digital", @@ -76,6 +75,9 @@ class PresupuestoModel extends \App\Models\BaseModel "solapas_ancho", "solapas_sobrecubierta", "solapas_ancho_sobrecubierta", + "solapas_ancho_faja_color", + "faja_color", + "alto_faja_color", "cosido", "sobrecubiertas", "sobrecubiertas_ancho", diff --git a/ci4/app/Services/PresupuestoService.php b/ci4/app/Services/PresupuestoService.php index 255b2cad..b508d9f2 100755 --- a/ci4/app/Services/PresupuestoService.php +++ b/ci4/app/Services/PresupuestoService.php @@ -945,7 +945,7 @@ class PresupuestoService extends BaseService $alto_total += (7 + 2 * self::SANGRE_FORMAS); } // Tapa dura (espiral y wire-0) - if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) { + else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) { // Sólo se le añade los 20mm de sangre por cada lado $alto_total += (2 * self::SANGRE_FORMAS_CUBIERTA); } diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php index c8172bbe..8a479ee5 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php @@ -182,7 +182,7 @@ * + step="1" class="form-control" min="50" value="50">
Entre 50 y 120 mm
@@ -194,7 +194,7 @@ * + maxLength="8" step="1" min="60" class="form-control" value="60">
Entre 60 y 120 mm
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.php index cda116b4..22da692e 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_lineasPresupuestoItems.php @@ -60,6 +60,7 @@ +
diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js index 35ec8dab..57f1d357 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js @@ -34,6 +34,7 @@ class PresupuestoAdminEdit { { checkPaginasPresupuesto: this.checkPaginasPresupuesto, getDimensionLibro: this.getDimensionLibro, + calcularSolapas: this.calcularSolapas.bind(this) }); this.comparador = new Comparador(this.domItem.find('#accordionDatosPresupuestoClienteTip'), { @@ -198,15 +199,15 @@ class PresupuestoAdminEdit { ...datos, ...{ paginas: this.datosLibro.paginas.val(), tirada: this.datosLibro.tirada.val(), - papel_formato_id: this.datosLibro.tamanio.item.hasClass('d-none') ? 0 : this.datosLibro.tamanio.getVal(), - papel_formato_personalizado: this.datosLibro.tamanio.item.hasClass('d-none') ? 1 : 0, + papel_formato_id: this.datosLibro.tamanioPersonalizado.prop('checked') ? 0 : this.datosLibro.tamanio.getVal(), + papel_formato_personalizado: this.datosLibro.tamanioPersonalizado.prop('checked') ? 1 : 0, merma: this.datosLibro.merma.val(), merma_cubierta: this.datosLibro.mermaCubierta.val() } } - if (datos.papel_formato_personalizado) { + if (this.datosLibro.tamanioPersonalizado.prop('checked')) { datos.papel_formato_ancho = this.datosLibro.anchoPersonalizado.val(), - datos.papel_formato_alto = this.datosLibro.altoPersonalizado.val() + datos.papel_formato_alto = this.datosLibro.altoPersonalizado.val() } datos.selectedTirada = this.datosLibro.tirada.val(); datos.acabado_cubierta_id = this.datosLibro.acabadoCubierta.getVal(); @@ -244,6 +245,10 @@ class PresupuestoAdminEdit { datos.solapas_sobrecubierta = this.datosLibro.solapasSobrecubierta.is(':checked') ? 1 : 0; datos.solapas_ancho_sobrecubierta = this.datosLibro.anchoSolapasSobrecubierta.val(); + datos.faja_color = this.datosLibro.faja.prop('checked') ? 1: 0; + datos.solapas_ancho_faja_color = this.datosLibro.fajaSolapasAncho.val(); + datos.alto_faja_color = this.datosLibro.fajaAlto.val(); + datos.entrega_taller = this.envios.recogerTaller.is(':checked') ? 1 : 0; if (parseInt(this.cosido.val())) { @@ -377,6 +382,11 @@ class PresupuestoAdminEdit { }, 0); this.calcularSolapas(); + if ($('#faja_alto').length > 0 && $('#faja_alto').attr('max') != this.getDimensionLibro().alto) { + $('#faja_alto').attr('max', this.getDimensionLibro().alto); + $('#faja_alto').trigger('change'); + $('#faja_alto').closest('.mb-1').find('.form-text').text('Entre 50 y ' + this.getDimensionLibro().alto + ' mm'); + } // Funciones para detectar cambios en el formulario this.#checkChangesPresupuesto(); @@ -470,10 +480,10 @@ class PresupuestoAdminEdit { $('#solapas_ancho_sobrecubierta').trigger('change'); $('#solapas_ancho_sobrecubierta').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm'); } - if ($('#solapas_ancho_faja').length > 0 && $('#solapas_ancho_faja').attr('max') != maxSolapas) { - $('#solapas_ancho_faja').attr('max', maxSolapas); - $('#solapas_ancho_faja').trigger('change'); - $('#solapas_ancho_faja').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm'); + if ($('#faja_solapas_ancho').length > 0 && $('#faja_solapas_ancho').attr('max') != maxSolapas) { + $('#faja_solapas_ancho').attr('max', maxSolapas); + $('#faja_solapas_ancho').trigger('change'); + $('#faja_solapas_ancho').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm'); } } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js index e34d08fe..183556d9 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js @@ -9,6 +9,7 @@ class DatosLibro { this.checkPaginasPresupuesto = functions.checkPaginasPresupuesto; this.getDimensionLibro = functions.getDimensionLibro; + this.calcularSolapas = functions.calcularSolapas; this.csrf_token = getToken(); this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val(); @@ -101,8 +102,10 @@ class DatosLibro { this.paginas.on('change', this.changePaginas.bind(this)); this.tirada.on('change', this.changeTirada.bind(this)); - this.anchoSolapasCubierta.on('focusout', this.checkSolapaAncho.bind(this)); - this.anchoSolapasSobrecubierta.on('focusout', this.checkSolapaAncho.bind(this)); + this.anchoSolapasCubierta.on('focusout', this.checkMinMaxInput.bind(this)); + this.anchoSolapasSobrecubierta.on('focusout', this.checkMinMaxInput.bind(this)); + this.fajaSolapasAncho.on('focusout', this.checkMinMaxInput.bind(this)); + this.fajaAlto.on('focusout', this.checkMinMaxInput.bind(this)); this.faja.on('change', this.changeFaja.bind(this)); } @@ -120,7 +123,7 @@ class DatosLibro { } } - checkSolapaAncho(event) { + checkMinMaxInput(event) { const el = event.target; if (el.value != "") { @@ -200,6 +203,13 @@ class DatosLibro { this.checkPaginasPresupuesto(); + this.calcularSolapas(); + if ($('#faja_alto').length > 0 && $('#faja_alto').attr('max') != this.getDimensionLibro().alto) { + $('#faja_alto').attr('max', this.getDimensionLibro().alto); + $('#faja_alto').trigger('change'); + $('#faja_alto').closest('.mb-1').find('.form-text').text('Entre 50 y ' + this.getDimensionLibro().alto + ' mm'); + } + $(document).trigger('update-presupuesto', { update_lineas: true, update_servicios: true, @@ -500,6 +510,13 @@ class DatosLibro { $('#div_solapas_ancho_sobrecubierta').addClass('d-none'); } + this.faja.prop('checked', datos.fajaColor); + if(datos.fajaColor){ + this.div_faja.removeClass('d-none'); + this.fajaAlto.val(datos.fajaColorAlto).trigger('change'); + this.fajaSolapasAncho.val(datos.fajaColorSolapasAncho).trigger('change'); + } + this.acabadoCubierta.setOption(datos.acabadoCubierta.id, datos.acabadoCubierta.text); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js index 167d85b9..09fb7842 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js @@ -862,6 +862,25 @@ class LineasPresupuesto { this.#addEventosLineas('lp_sobrecubierta', false); break + case 'lp_faja': + var hayLinea = false + for (let number = 0; number < dataRows.length; number++) { + if (dataRows[number].row_id == 'lp_faja') { + hayLinea = true; + continue; + } + } + + if (hayLinea) { + popErrorAlert(window.language.Presupuestos.errores.lineaDuplicada, 'divAlarmasLineasPresupuesto'); + break; + } + + var data = this.#processRowData({ tipo_maquina: 'toner' }, 'lp_faja', 'lp-faja'); + this.table.row.add(data).draw(); + this.#addEventosLineas('lp_faja', false); + break + case 'lp_guardas': var hayLinea = false for (let number = 0; number < dataRows.length; number++) { @@ -1408,15 +1427,15 @@ class LineasPresupuesto { if (linea == 'lp_faja') { if (Object.keys(input_data).length == 0) { let altoSelected = parseInt($('#' + linea + '_altoFaja').val()); - if(altoSelected == 0 || isNaN(altoSelected) || altoSelected == '' || altoSelected < 50){ + if (altoSelected == 0 || isNaN(altoSelected) || altoSelected == '' || altoSelected < 50) { altoSelected = 50; } - else if(altoSelected > dimension.alto){ + else if (altoSelected > dimension.alto) { altoSelected = dimension.alto; } dimension.alto = altoSelected; } - else{ + else { dimension.alto = parseInt($('#faja_alto').val()); } } @@ -1644,7 +1663,7 @@ class LineasPresupuesto { } let datosLinea = currentRow.data(); - if(linea == 'lp_faja') { + if (linea == 'lp_faja') { datosLinea.alto_faja = row.alto_faja; } @@ -1701,6 +1720,7 @@ class LineasPresupuesto { case 'lp_guardas': case 'lp_cubierta': case 'lp_sobrecubierta': + case 'lp_faja': tipo = 'colorhq'; break default: @@ -1813,7 +1833,7 @@ class LineasPresupuesto { $('#' + tipoLinea + '_aFavorFibra').on("change", () => { this.change_aFavorFibra(tipoLinea); }); } - if(tipoLinea == 'lp_faja') { + if (tipoLinea == 'lp_faja') { $('#' + tipoLinea + '_altoFaja').on("change", function (event) { self.obtenerLinea(tipoLinea, false, false, {}, event); // Pasamos explícitamente 'tipoLinea' }.bind(this)); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/resumen.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/resumen.js index b76dc98e..b62fcbd8 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/resumen.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/resumen.js @@ -311,29 +311,29 @@ class Resumen { getData(){ let data = { - 'total_coste_papel': $('#totalCostePapel').attr('val').replace('€', ''), - 'total_margen_papel': $('#margenPapel').attr('val').replace('€', ''), + 'total_coste_papel': $('#totalCostePapel').text().replace('€', ''), + 'total_margen_papel': $('#margenPapel').text().replace('€', ''), 'total_margenPercent_papel': $('#porcentajeMargenPapel').text().replace('%', ''), - 'total_coste_impresion': $('#totalCosteImpresion').attr('val').replace('€', ''), - 'total_margen_impresion': $('#margenImpresion').attr('val').replace('€', ''), + 'total_coste_impresion': $('#totalCosteImpresion').text().replace('€', ''), + 'total_margen_impresion': $('#margenImpresion').text().replace('€', ''), 'total_margenPercent_impresion': $('#porcentajeMargenImpresion').text().replace('%', ''), - 'total_coste_servicios': $('#totalServicios').attr('val').replace('€', ''), - 'total_margen_servicios': $('#margenServicios').attr('val').replace('€', ''), + 'total_coste_servicios': $('#totalServicios').text().replace('€', ''), + 'total_margen_servicios': $('#margenServicios').text().replace('€', ''), 'total_margenPercent_servicios': $('#porcentajeMargenServicios').text().replace('%', ''), - 'total_coste_envios': $('#totalEnvios').attr('val').replace('€', ''), - 'total_margen_envios': $('#margenEnvios').attr('val').replace('€', ''), + 'total_coste_envios': $('#totalEnvios').text().replace('€', ''), + 'total_margen_envios': $('#margenEnvios').text().replace('€', ''), - 'total_costes': $('#totalCostes').attr('val').replace('€', ''), - 'total_margenes': $('#totalMargenes').attr('val').replace('€', ''), + 'total_costes': $('#totalCostes').text().replace('€', ''), + 'total_margenes': $('#totalMargenes').text().replace('€', ''), - 'total_antes_descuento': $('#totalAntesDescuento').attr('val').replace('€', ''), - 'total_descuento': $('#descuentoTotal').attr('val').replace('€', ''), + 'total_antes_descuento': $('#totalAntesDescuento').text().replace('€', ''), + 'total_descuento': $('#descuentoTotal').text().replace('€', ''), 'total_descuentoPercent': $('#total_descuentoPercent').val().replace('€', ''), - 'total_presupuesto': $('#totalDespuesDecuento').attr('val').replace('€', ''), - 'total_precio_unidad': $('#precioUnidadPresupuesto').attr('val').replace('€', ''), + 'total_presupuesto': $('#totalDespuesDecuento').text().replace('€', ''), + 'total_precio_unidad': $('#precioUnidadPresupuesto').text().replace('€', ''), 'total_factor': $('#factor').text().replace(/,/g, '.'), 'total_factor_ponderado': $('#factor_ponderado').text().replace(/,/g, '.'), @@ -341,7 +341,7 @@ class Resumen { if($('#confirmar_presupuesto').prop('checked')){ data.confirmar = '1'; - data.total_aceptado = $('#totalDespuesDecuento').attr('val').replace('€', ''); + data.total_aceptado = $('#totalDespuesDecuento').text().replace('€', ''); } return data; From b29b061f743d1dd270e3e0bb35696675324dfca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Sat, 1 Feb 2025 10:45:28 +0100 Subject: [PATCH 85/89] fix problem --- ci4/app/Services/PresupuestoService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci4/app/Services/PresupuestoService.php b/ci4/app/Services/PresupuestoService.php index 255b2cad..b508d9f2 100755 --- a/ci4/app/Services/PresupuestoService.php +++ b/ci4/app/Services/PresupuestoService.php @@ -945,7 +945,7 @@ class PresupuestoService extends BaseService $alto_total += (7 + 2 * self::SANGRE_FORMAS); } // Tapa dura (espiral y wire-0) - if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) { + else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) { // Sólo se le añade los 20mm de sangre por cada lado $alto_total += (2 * self::SANGRE_FORMAS_CUBIERTA); } From c7491db102821883faaeabe435128a02c4ac2c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Sat, 1 Feb 2025 10:55:52 +0100 Subject: [PATCH 86/89] error cambiado ancho por alto personalizado al cargar --- ci4/app/Services/PresupuestoService.php | 2 +- .../js/safekat/pages/presupuestoAdmin/sections/datosLibro.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci4/app/Services/PresupuestoService.php b/ci4/app/Services/PresupuestoService.php index b508d9f2..204f577a 100755 --- a/ci4/app/Services/PresupuestoService.php +++ b/ci4/app/Services/PresupuestoService.php @@ -931,7 +931,7 @@ class PresupuestoService extends BaseService if ($datosPedido) { $alto_total = floatval($datosPedido->alto); $sangre_cubierta = self::SANGRE_FORMAS_CUBIERTA; - if ($datosPedido->alto >= 297) { + if ($datosPedido->alto >= 267) { $sangre_cubierta = 10; } // Tapa dura (cosido y fresado) diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js index b14e3026..7633b468 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js @@ -451,8 +451,8 @@ class DatosLibro { 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); + this.anchoPersonalizado.val(datos.papelFormatoAncho); + this.altoPersonalizado.val(datos.papelFormatoAlto); } else { $(".tamanio-personalizado").addClass('d-none'); From e17e72f46de1f8beb5eefab23f09e72d8438d7c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Sat, 1 Feb 2025 13:28:38 +0100 Subject: [PATCH 87/89] terminada faja en presu admin a falta de preview --- .../Presupuestos/Presupuestoadmin.php | 6 ++- ci4/app/Services/PresupuestoService.php | 36 +++++++++++------- .../assets/js/safekat/components/preview.js | 10 ++--- .../presupuestoAdmin/sections/comparador.js | 21 ++++++++++ .../sections/lineasPresupuesto.js | 4 +- .../img/safekat/presupuestos/icon_faja.png | Bin 0 -> 6300 bytes 6 files changed, 55 insertions(+), 22 deletions(-) create mode 100644 httpdocs/themes/vuexy/img/safekat/presupuestos/icon_faja.png diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index a2d6acb0..d3b2986e 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -666,7 +666,9 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $gramaje = $sobrecubierta['gramaje']; $paginas_color = $sobrecubierta['datosPedido']['paginas'] ?? 0; $tipo_impresion_id = $sobrecubierta['tipo_impresion_id']; - $uso = $sobrecubierta['uso']; + $faja = intval($sobrecubierta['faja'] ?? 0); + $uso = $faja==1? 'faja' : $sobrecubierta['uso']; + $data = array( 'cliente_id' => $cliente_id, @@ -960,7 +962,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $resourceData = PresupuestoService::obtenerComparadorRotativa($input_data); - } else if ($type == 'cubierta' || $type == 'sobrecubierta') { + } else if ($type == 'cubierta' || $type == 'sobrecubierta' || $type == 'faja') { $datosPedido->solapas = $reqData['solapas']; $datosPedido->solapas_ancho = $reqData['solapas_ancho']; diff --git a/ci4/app/Services/PresupuestoService.php b/ci4/app/Services/PresupuestoService.php index b508d9f2..24d404a3 100755 --- a/ci4/app/Services/PresupuestoService.php +++ b/ci4/app/Services/PresupuestoService.php @@ -83,8 +83,13 @@ class PresupuestoService extends BaseService $parametrosInkjet->rotativa_cg = $datosTipologias[0]->cg; } + $uso_tarifa = $uso; + if($uso == 'guardas') + $uso_tarifa = 'interior'; + else if ($uso == 'faja') + $uso_tarifa = 'sobrecubierta'; $tarifamodel = new \App\Models\Configuracion\MaquinasTarifasImpresionModel(); - $datos_tarifa = $tarifamodel->getTarifa($maquina->maquina_id, ($uso == 'guardas') ? 'interior' : $uso, $tipo); + $datos_tarifa = $tarifamodel->getTarifa($maquina->maquina_id, $uso_tarifa, $tipo); if (count($datos_tarifa) > 0) { $tarifaId = $datos_tarifa[0]; $tarifa = $datos_tarifa[1]; @@ -128,7 +133,7 @@ class PresupuestoService extends BaseService $clientePreciosModel = new \App\Models\Clientes\ClientePreciosModel(); $config = (object) [ - "tipo" => ($uso == 'guardas') ? 'interior' : $uso, + "tipo" => $uso_tarifa, "tipo_maquina" => $maquina->is_inkjet ? 'inkjet' : 'toner', "tipo_impresion" => $tipo ]; @@ -334,8 +339,8 @@ class PresupuestoService extends BaseService if ($uso != 'rotativa') { - $ancho_calculo = ($uso == 'cubierta' || $uso == 'sobrecubierta') ? $datosPedido->anchoExteriores : $datosPedido->ancho; - $alto_calculo = ($uso == 'cubierta' || $uso == 'sobrecubierta') ? $datosPedido->altoExteriores : $datosPedido->alto; + $ancho_calculo = ($uso == 'cubierta' || $uso == 'sobrecubierta' || $uso == 'faja') ? $datosPedido->anchoExteriores : $datosPedido->ancho; + $alto_calculo = ($uso == 'cubierta' || $uso == 'sobrecubierta' || $uso == 'faja') ? $datosPedido->altoExteriores : $datosPedido->alto; $formas = PresupuestoService::getNumFormasPlana($uso, $maquina, $ancho_calculo, $alto_calculo, $datosPedido->isCosido, $forzar_a_favor_fibra); $response['fields'] = $formas; } @@ -366,10 +371,12 @@ class PresupuestoService extends BaseService $margen_click = $tarifa * ($tarifa_margen / 100.0); //interior (bn o color) - if ($cubierta == 0 && $sobrecubierta == 0 && $rotativa == 0) { + if ($cubierta == 0 && $sobrecubierta == 0 && $rotativa == 0 || $uso == 'faja') { // precio papel - $pliegos_libro = ceil(($datosPedido->paginas / 2.0) / $response['fields']['num_formas']['value']); - if ($pliegos_libro < 1) + $pliegos_libro = ($datosPedido->paginas / 2.0) / $response['fields']['num_formas']['value']; + if($uso != 'faja') + $pliegos_libro = ceil($pliegos_libro); + if ($uso != 'faja' && $pliegos_libro < 1) // faja pueden entrar más de una forma $pliegos_libro = 1; $pliegos_pedido = $pliegos_libro * ($datosPedido->tirada + $datosPedido->merma); $precio_libro = $pliegos_libro * ($precio_pliego_impresion + $margen_pliego_impresion); @@ -693,7 +700,7 @@ class PresupuestoService extends BaseService $h2_temp = 0; // El ancho si es cosido es el doble - if ($uso != 'cubierta' && $uso != 'sobrecubierta') { + if ($uso != 'cubierta' && $uso != 'sobrecubierta' && $uso != 'faja') { $anchoForCalculo = $isCosido ? $ancho * 2 : $ancho; } else { $anchoForCalculo = $ancho; @@ -931,7 +938,7 @@ class PresupuestoService extends BaseService if ($datosPedido) { $alto_total = floatval($datosPedido->alto); $sangre_cubierta = self::SANGRE_FORMAS_CUBIERTA; - if ($datosPedido->alto >= 297) { + if ($datosPedido->alto >= 267) { $sangre_cubierta = 10; } // Tapa dura (cosido y fresado) @@ -1761,7 +1768,8 @@ class PresupuestoService extends BaseService $tipo = $isColor ? ($isHq ? 'colorhq' : 'color') : ($isHq ? 'negrohq' : 'negro'); - $opciones_papel = PresupuestoService::get_opciones_papel($uso, $isColor); + $uso_papel = $uso == 'faja' ? 'sobrecubierta': $uso; + $opciones_papel = PresupuestoService::get_opciones_papel($uso_papel, $isColor); // Se obtienen los papeles disponibles $papelimpresionmodel = new PapelImpresionModel(); @@ -1779,7 +1787,7 @@ class PresupuestoService extends BaseService $maquinas = $maquinamodel->getMaquinaImpresionForPresupuesto( is_rotativa: 0, tarifa_tipo: $tipo, - uso_tarifa: ($uso == 'guardas') ? 'interior' : $uso, + uso_tarifa: ($uso == 'guardas') ? 'interior' : $uso_papel, tirada: $datosPedido->tirada + $datosPedido->merma, papel_impresion_id: $papel->id, )->orderBy("t1.id", "asc")->get()->getResultObject(); @@ -1787,10 +1795,10 @@ class PresupuestoService extends BaseService // Se recorren las máquinas y se calcula el coste de linea por cada una foreach ($maquinas as $maquina) { - if ($uso == 'cubierta' || $uso == 'sobrecubierta') { + if ($uso == 'cubierta' || $uso == 'sobrecubierta' || $uso == 'faja') { - $datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($uso, $tipo_impresion_id, $datosPedido, $maquina->maquina_id, $lomoRedondo); - $datosPedido->altoExteriores = PresupuestoService::getAltoTotalExteriores($uso, $tipo_impresion_id, $datosPedido); + $datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($uso_papel, $tipo_impresion_id, $datosPedido, $maquina->maquina_id, $lomoRedondo); + $datosPedido->altoExteriores = PresupuestoService::getAltoTotalExteriores($uso_papel, $tipo_impresion_id, $datosPedido); } $data['uso'] = $uso; diff --git a/httpdocs/assets/js/safekat/components/preview.js b/httpdocs/assets/js/safekat/components/preview.js index 543f68ef..bcd53382 100644 --- a/httpdocs/assets/js/safekat/components/preview.js +++ b/httpdocs/assets/js/safekat/components/preview.js @@ -148,7 +148,7 @@ class previewFormas { let anchoPliegue = parseFloat(7); // mm let altoPliegue = parseFloat(7); // mm let sangre = parseFloat(20); // mm - if (this.isTapaDura && (this.ancho() >= 210 || this.alto() >= 297)) { + if (this.isTapaDura && (this.ancho() >= 210 || this.alto() >= 267)) { sangre = parseFloat(10); // mm } this.pvObj.anchoForma = ((2 * this.pvObj.anchoLibro) + (2 * anchoPliegue) + (2 * sangre) + this.pvObj.lomoLibro); @@ -201,7 +201,7 @@ class previewFormas { $(pvName + '_pg').attr("href", $(pvName + '_pg').attr('sk-url') + rowData.papel); $(pvName + '_pi').attr("href", $(pvName + '_pi').attr('sk-url') + rowData.papel_impresion_id); $(pvName + '_mi').attr("href", $(pvName + '_mi').attr('sk-url') + rowData.maquina_id); - $('#pv_ec_lomo').text(this.pvObj.lomoLibro); + $('#pv_ec_lomo').text(parseFloat(this.pvObj.lomoLibro).toFixed(1)); break; case 'rot_bn': @@ -482,7 +482,7 @@ class previewFormas { altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px } else { anchoSangrado = 750; // px - altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px + altoSangrado = (anchoSangrado * 0.6 > 650) ? 650 : anchoSangrado * 0.6; // px } altoLibro = altoSangrado * 0.97; @@ -497,7 +497,7 @@ class previewFormas { altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px } else { anchoSangrado = 750; // px - altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px + altoSangrado = (anchoSangrado * 0.6 > 650) ? 650 : anchoSangrado * 0.6; // px } altoLibro = altoSangrado * 0.95; anchoLibro = anchoSangrado * 0.28; @@ -676,7 +676,7 @@ 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 >= 267) { sangradoValor = parseFloat(10); // mm sangradoTexto = "Sangrado 10 mm"; } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js index c9fffc26..b541b546 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/comparador.js @@ -530,6 +530,11 @@ class Comparador { this.papelGuardas.setOption(datos.json_data.guardas.papel_id, datos.json_data.guardas.papel_nombre); this.gramajeGuardas.setOption(datos.json_data.guardas.gramaje, datos.json_data.guardas.gramaje); } + if (datos.json_data.faja) { + this.faja.val(1).trigger('change'); + this.papelFaja.setOption(datos.json_data.faja.papel_id, datos.json_data.faja.papel_nombre); + this.gramajeFaja.setOption(datos.json_data.faja.gramaje, datos.json_data.faja.gramaje); + } if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3) { this.lomoRedondo.val(datos.lomoRedondo ? 1 : 0).trigger('change'); @@ -1504,6 +1509,7 @@ class Comparador { let datosComp = {}; datosComp.sobrecubierta = this.getDataForComp('faja'); + datosComp.sobrecubierta.data['faja'] = 1; // se indica que es faja para el calculo de formas datosComp.sobrecubierta.data[this.csrf_token] = this.csrf_hash; @@ -1862,6 +1868,21 @@ class Comparador { } + if (parseInt($('#compFaja').val()) == 1) { + let faja_obj = {}; + try { + faja_obj = { + "faja": { + 'papel_id': $('#compPapelFaja').select2('data')[0].id, + 'gramaje': $('#compGramajeFaja').select2('data')[0].text.trim(), + }, + } + } + catch (e) { + } + $.extend(data, faja_obj); + } + const data_str = JSON.stringify(data) $('#comparador_json_data').val(data_str) } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js index 09fb7842..48c754b2 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js @@ -1484,9 +1484,11 @@ class LineasPresupuesto { uso = 'cubierta'; break; case 'lp_sobrecubierta': - case 'lp_faja': uso = 'sobrecubierta'; break; + case 'lp_faja': + uso = 'faja'; + break; case 'lp_guardas': uso = 'guardas'; break; diff --git a/httpdocs/themes/vuexy/img/safekat/presupuestos/icon_faja.png b/httpdocs/themes/vuexy/img/safekat/presupuestos/icon_faja.png new file mode 100644 index 0000000000000000000000000000000000000000..bd2572caaa5bc5201db4f0de5ae5dae90202a486 GIT binary patch literal 6300 zcmeHKdo+}5+aJX!p(D{w#?ZMrW6T(Ykwc9pA(ZmW%rj%k9Lx*`IdpPLk=SZW>Lo?m z(Lq9FM`)Kww4EZ7N{r)|L-anQ^ZMSkzSUaa`(LxxGtYgv?%#D?zw3A3>$#)pj<#wl z%T!=6n3}yE)d_kd<=9WqtXcg+$Z6z8G^+8jAT(?eB%Z0$p>me9 zTIfgE@Us1^daZI(n*02iwfo<~U@0W2S?R$MSaw zY^>~c?`ljOvr z$21ibgCe}G`_b&<<2yaGtgb(BzP=iM=?^etu`e!pkH+k)1Hcl6El300_N{Eq>jODg zgWqNr9v#{sE3sIgv1AK;jM}MHuXa>=Na|nzgd|%W>F(|n^*DO9Y9V4!{~4IvZj!uQ zQ_B9QDzhj0UO6M{Xg8V-TCY5-cYICurg5tp@W`+x=cWgzFL-Dvd|tCdMDLAF@pl&` z*jXNqC9k{mmsO(wu_cSSFesujQ{p z^7`U%h}?NMmgP@{__SPEeD|a3F0M}4mAMZ?5}v>IKB4dB^;KhLaYkr?UIUu1_lSEM%`4x`j=$iJYKJLD-jzmQduH~$?U~uFu;Aw5NrmF4 zqH-|!aU7&Oe=ejiH`*35Q@}$5ECB;VOL;;_crX~nLMjB9`#=eT0dlx}Go-Aj6p7%n z%#b^bXjq!i8uaGc1&P4zL5|MMpnXgd3u$4lLXnao03Ij-5K^8GUrd&oA!l&OP+LBX zK_X^MB>T*eZZtZ=S|9=uhG;`H7G)#l`s0!2DhP^*#U?vZH+_bHdS*y(i9|@oU;+XH z&;bOrK*Yh|NF)*li^t&cD98dO4&+M!DT*)FmqUEQpn_tih%1zE1$=}Y6JQAZBxXn? zG>`ZaA5Tc5eTC>8=*iJz(g4u zgKQLlV_{KjBL>NYK_VEMuncFQBy}#IB?u6In{wvz z!0i%1P8*I$Fd<+`CPXaJm|%i8`DWw_io}rQQm?7oSBIJ-?r)kiJVgV9>3P?c68y0Uw z#^T5XoHN#hY=k3YiR+;*_B(q4i^~rDzpUlk2SNE%bUUsX@*g-e^l49R2Yo;FK6QP# zGn)y4nAsLk6+fjQ2K+(ROq>wbrzxg4z~_L_`SDq>U&gurK@0?AJOMOjvQSJc5mJN^ zn*fOcWT0?Z77M@{69_EqCp~>d7Yo>u06+vq2{B)f!q0p`vHmxIpX>17 zbb&zpa`IFB{-Wy_T|dRZPZ|GG*Dtz$ih-Xp{-v(}H@Z~5U8X=j^aT_EU6pJf`_Z6l z7M!u!mO69cf{j}jg+Z;kLOXXc3^s4E{851YaYhRoRF>G&Y?R+9=qeLbnj}k1V6Zv1 z_Ebw}w|f=I!NSCDjr(CeQzbP2#a70LH!5bY(&Fo#>Wp$l9aq)Zwt3r5BQOWqtmkHm z;&Bu;vhzK-gHFr!{j%wFjoXKhr~c9QfknhXl;z-M)Y}BVb2czrCkUs=f{}k(4EIdhvW>!a7x_ zZ!mA=%HWHh!q7*ZDT4kf4}}f8MJ;c38Vgd>l9KM6yKvL*h63HjWt*a+>bdYJgY>%B zMO_Xt&pbn$R&K4C>fa?>KYMH(vvjH9{-HOz=KDw=(o4Fgq7J&uQ_0qBKty$fX)aJ) zsE}x9(i)$nIFZtfNkeOe2bRGxFqt2XF4D>hcrSD}yEm3I{!kB_Y!q|C>4 zn5b`3BQ%j~rbmYsvNPSY=n6<04LvzczsqD}NgVs&3 z+T7M%E8Ite)s2Y0EeXL-eoGZO08_0bam}64-yb**RL{HnKzW5py1%VwQnr#yjt9G@ zApU;l?1!g(aV^A>`|plo{z8yGLQC>+zlHGyA{l7%Qfj|)Q`%@yl(y+cDefXkFO9bZY$y%RE*d%?xn=a^R!^(D&N>-AR0^DA9qqiM{^a5pgThk_ z;35CR#c#vg(6{Ef4*D$0`<;%gxu&+$M3#2t)Vo;|<(XX*2zbJEuy@iz_`bj0!qa8A z&a%%a-ie}lPgU3cN#9CSmiMCBo92K==o%9_46~yixs9FcI@VUO@K#m^ly2$9*UmN6 zh8?ltQ4dA$b-hphtC4dRKF1{_IvS_7(QvN)(j>%@`(6#5fnFLLR_sMxIxwwO5o~VB zIM@|f)$#BT=Ln5$=WksNh-uk>={D6RFZ9s-#BQQ9?jR1%)G*Y}aD<2JjX8D!I!YR7 zi&m@Sezh61)RCRKb{|f0aZyhi8~Y0a>x$ns=Ib9Q8+)gmR=qbVKAHMlda_GRZNnMg zh3WHbuf4m9@rt!JAtuuetgQA|sYftJCoh?|M$y*k^US;7PG(GaY`N{wT+y17W9J=S zJxhTLYo$k(98!KAQlP?IUV`H-voSs}d~1h7)O@_oLcO`ghX(Q|NTtSst2pqStsLSS zrUQ>}u$)gzU14em-?(WL{J1`)K%`V*!;E_Ms`g3q@(;F_szKLME+I=guz0UWF>pmg zOM68Z7lOg+i|8bcZmOV9)|-CgMj{Ys9XME#Y%<2xM|SAB8MK|aGU4>pYj^F&;dI-y znB)P+T$#cNYlG#}|CssT=uxAk6j-=>)9b0ovi?G{d2>-*Q}QFWG<3!J_ zug&SqsHR?v%-dHPX&B1LZA3CY@RyE+Q5PuYBt%u%l`}?0S9G1e__4fKa3|8&Ail(Y zxZ-N8r)<`xQCGcd4`gYJo^G2H8Cl!VWJ!DE_-EmSO6)dD@50``mD+L4Skn2%7`00; zHjmx*!z7F(94@agSta!OIHEKj_(((JSuq2)>Nv*TG&48X=HSzeiJP;I9iweIO*!x` z_!(k2xomr{c0!7^!TOW*s+ENLmHPK8e9QcF@c5}kEEX%b@1B|E@9-wS_yY@-lu9ob zk7p`)d>G-Bx(zg^2wc`1Pt}eQ9DAZyXG^EDN`;<}EbX+KFKTYL==FiOoXFsGD$Kvp zn4Za2uCPfTukKu_Ws7BC?*q;+qS_kvJ#*9{=CA3`fIanT+GQFtaipEHKZ9o#lV#gn zgw1|fG`$Qd^Raz;-VC#amwBP6cTJmTo5U}mzM;*Avtwy$YN|xy|D>+L-e7&CHUZ6; znizfe&mCob^YGWTXQ<}BdlH2bq!ZodjU-rY`?9n3k)ywgzG6&>?*L)V4EnvPUEOGC?y1E%-9tT+WVb%ehi z1pE1Ig-acu|26t;rZ#hbd^2Y zXVXeM$Nj>lJN6an?3uh52u|hwb0(uFiKw#|y= Date: Sat, 1 Feb 2025 18:31:31 +0100 Subject: [PATCH 88/89] guardado de linea faja --- .../Presupuestos/Presupuestoadmin.php | 3 + ci4/app/Language/es/Presupuestos.php | 1 + .../form/presupuestos/admin/_previewItems.php | 150 ++++++++++-------- .../sections/lineasPresupuesto.js | 8 +- .../sections/previewFormasAdmin.js | 7 + 5 files changed, 99 insertions(+), 70 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index d3b2986e..91b2b751 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -1623,6 +1623,9 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $modelPapel = new PapelGenericoModel(); foreach ($lineas as $linea) { $linea->papel_generico = (new PapelGenericoModel())->find($linea->papel_id)->nombre; + if($linea->tipo == 'lp_faja'){ + $linea->alto_faja = $presupuestoEntity->alto_faja_color; + } } $input_data = []; diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 4a8f06c5..0bdac190 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -283,6 +283,7 @@ return [ 'previewMaquinaRotativa' => 'Configuración del papel: Rotativa', 'previewCubierta' => 'Configuración del papel: Cubierta', 'previewSobrecubierta' => 'Configuración del papel: Sobrecubierta', + 'previewFaja' => 'Configuración del papel: Faja', 'previewPapelGenerico' => 'Papel Genérico', 'previewPapelCompra' => 'Papel de Compra', 'previewAreaImpresion' => 'Área de Impresión', diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_previewItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_previewItems.php index 28f57423..8f6f7cc5 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_previewItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_previewItems.php @@ -934,6 +934,87 @@
+
+
+
+
+ + + +
+ + +
+
+
+
TBD
+ +
+
TBD
+ +
+
TBD
+ +
+
TBDxTBD
+ +
+
TBDxTBD
+ +
+
TBDxTBD
+ +
+
TBD
+ +
+
TBD
+
+
+
+ +
+
+ +
+ +
+
+
+ +
+
+
+
+
@@ -942,72 +1023,3 @@
- - - -section("additionalInlineJs") ?> -/* - -$('#tab-pv-bn').on( "click", function() { - -previewInteriorPlana('bn', , ); - -} ); - -$('#tab-pv-bnhq').on( "click", function() { - -previewInteriorPlana('bnhq', , ); - -} ); - -$('#tab-pv-color').on( "click", function() { - -previewInteriorPlana('color', , ); - -} ); - -$('#tab-pv-colorhq').on( "click", function() { - - -previewInteriorPlana('colorhq', , ); - -} ); - -$('#tab-pv-rot-bn').on( "click", function() { - -previewRotativa('rot_bn', , ); - -} ); - -$('#tab-pv-rot-color').on( "click", function() { - -previewRotativa('rot_color', , ); - -} ); - -$('#tab-pv-guardas').on( "click", function() { - -previewInteriorPlana('guardas', , ); - -} ); - -$('#tab-pv-cubierta').on( "click", function() { - -previewInteriorPlana('cubierta', , ); - -} ); - -$('#tab-pv-esquema-cubierta').on( "click", function() { - -previewEsquemaCubierta('ec', , ); - -} ); - -$('#tab-pv-sobrecubierta').on( "click", function() { - -previewInteriorPlana('sobrecubierta', , ); - -} ); -*/ - -endSection() ?> \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js index 48c754b2..41121d9f 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js @@ -980,7 +980,7 @@ class LineasPresupuesto { 'total_linea': isNaN(parseFloat(row.total_impresion)) ? "" : parseFloat(row.total_impresion).toFixed(2), - 'numeroPliegos': isNaN(parseFloat(row.pliegos_libro)) ? "" : parseFloat(row.pliegos_libro).toFixed(0), + 'numeroPliegos': isNaN(parseFloat(row.pliegos_libro)) ? "" : parseFloat(row.pliegos_libro).toFixed(2), 'pliegosPedido': isNaN(parseFloat(row.pliegos_pedido)) ? "" : parseFloat(row.pliegos_pedido).toFixed(0), 'precioPliego': isNaN(parseFloat(row.precios_pliegos)) ? "" : parseFloat(row.precios_pliegos).toFixed(6), 'libro': isNaN(parseFloat(row.precio_libro)) ? "" : parseFloat(row.precio_libro).toFixed(2), @@ -1062,6 +1062,10 @@ class LineasPresupuesto { data.alto_click = row.alto_click } + if (rowId == 'lp_faja'){ + data.alto_faja = row.alto_faja; + } + return data } @@ -2031,6 +2035,8 @@ class LineasPresupuesto { update_resumen: true, update_tiradas_alternativas: true }); + + showBreadCrumbSaveButton(true); } } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/previewFormasAdmin.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/previewFormasAdmin.js index ff202546..1b24a85d 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/previewFormasAdmin.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/previewFormasAdmin.js @@ -80,6 +80,13 @@ class PreviewFormasAdmin{ self.preview.previewInteriorPlana('sobrecubierta', self.isCosido, self.tipoTapa.includes("dura")?1:0); } ); + + $('#tab-pv-faja').on( "click", function() { + + self.preview.setData(self.data); + self.preview.previewInteriorPlana('sobrecubierta', self.isCosido, self.tipoTapa.includes("dura")?1:0); + + } ); } } From 5984f53bad7459f130b04b391195cda6865ab1a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Sat, 1 Feb 2025 19:11:05 +0100 Subject: [PATCH 89/89] terminada faja en admin --- ci4/app/Language/es/Presupuestos.php | 1 + .../form/presupuestos/admin/_previewItems.php | 14 +++++++++- .../assets/js/safekat/components/preview.js | 26 ++++++++++++++++--- .../sections/lineasPresupuesto.js | 2 +- .../sections/previewFormasAdmin.js | 2 +- 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 0bdac190..cc5f99b8 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -277,6 +277,7 @@ return [ 'previewConfiguracionGuardas' => 'Configuración de guardas', 'previewConfiguracionCubierta' => 'Configuración de cubierta', 'previewConfiguracionSobrecubierta' => 'Configuración de sobrecubierta', + 'previewConfiguracionFaja' => 'Configuración de faja', 'previewEsquemaCubierta' => 'Esquema de cubierta', 'previewConfiguracionEsquemaCubierta' => 'Configuración esquema de cubierta', 'previewMaquinaPlana' => 'Configuración del papel: Plana', diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_previewItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_previewItems.php index 8f6f7cc5..b691a92b 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_previewItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_previewItems.php @@ -133,6 +133,18 @@ +
@@ -1004,7 +1016,7 @@
-
+
diff --git a/httpdocs/assets/js/safekat/components/preview.js b/httpdocs/assets/js/safekat/components/preview.js index bcd53382..9aa9dec2 100644 --- a/httpdocs/assets/js/safekat/components/preview.js +++ b/httpdocs/assets/js/safekat/components/preview.js @@ -74,6 +74,7 @@ class previewFormas { case 'rot_color': case 'guardas': case 'sobrecubierta': + case 'faja': if (lineaPresupuestoId === lpName) { rowData = this.data(); } @@ -107,7 +108,7 @@ class previewFormas { anchoMaquina: parseFloat(rowData.maquina_ancho), altoImpresion: parseFloat(rowData.maquina_impresion_alto), anchoImpresion: parseFloat(rowData.maquina_impresion_ancho), - altoLibro: this.alto(), + altoLibro: lpName=='faja'? parseFloat(rowData.alto_faja).toFixed(0):this.alto(), anchoLibro: this.ancho(), offsetSolapa: 0 }; @@ -186,10 +187,10 @@ class previewFormas { let anchoPliegue = parseFloat(7); // mm let altoPliegue = parseFloat(7); // mm this.pvObj.anchoForma = ((2 * this.pvObj.anchoLibro) + (2 * anchoPliegue) + (2 * (anchoSolapaSobrecubierta + this.pvObj.offsetSolapa)) + (2 * sangre) + this.pvObj.lomoLibroSobrecubierta); - this.pvObj.altoForma += altoPliegue + (2 * sangre); + this.pvObj.altoForma += altoPliegue + parseFloat(2 * sangre); } else { this.pvObj.anchoForma = ((2 * this.pvObj.anchoLibro) + (2 * (anchoSolapaSobrecubierta + this.pvObj.offsetSolapa)) + (2 * sangre) + this.pvObj.lomoLibroSobrecubierta); - this.pvObj.altoForma += (2 * sangre); + this.pvObj.altoForma += parseFloat(2 * sangre); } // Update labels @@ -197,6 +198,25 @@ class previewFormas { anchoSolapaSobrecubierta != 0 ? $('.pv-solapas').show() : $('.pv-solapas').hide(); $(pvName + '_forma').text(this.pvObj.anchoForma + "x" + this.pvObj.altoForma); break; + + case 'faja': + let sangreFaja = parseFloat(5); // mm + let anchoSolapaFaja = $('#faja').is(':checked') ? parseFloat($('#faja_solapas_ancho').val()) : parseFloat(0); // mm + if (_isTapaDura) { + let anchoPliegue = parseFloat(7); // mm + let altoPliegue = parseFloat(7); // mm + this.pvObj.anchoForma = ((2 * this.pvObj.anchoLibro) + (2 * anchoPliegue) + (2 * (anchoSolapaFaja + this.pvObj.offsetSolapa)) + (2 * sangreFaja) + this.pvObj.lomoLibroSobrecubierta); + this.pvObj.altoForma += altoPliegue + parseFloat(2 * sangreFaja); + } else { + this.pvObj.anchoForma = ((2 * this.pvObj.anchoLibro) + (2 * (anchoSolapaFaja + this.pvObj.offsetSolapa)) + (2 * sangreFaja) + this.pvObj.lomoLibroSobrecubierta); + this.pvObj.altoForma = parseFloat(this.pvObj.altoForma) + parseFloat(2 * sangreFaja); + } + + // Update labels + $(pvName + '_solapas').text(anchoSolapaFaja); + anchoSolapaFaja != 0 ? $('.pv-solapas').show() : $('.pv-solapas').hide(); + $(pvName + '_forma').text(this.pvObj.anchoForma + "x" + this.pvObj.altoForma); + break; case 'ec': $(pvName + '_pg').attr("href", $(pvName + '_pg').attr('sk-url') + rowData.papel); $(pvName + '_pi').attr("href", $(pvName + '_pi').attr('sk-url') + rowData.papel_impresion_id); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js index 41121d9f..47765b9b 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/lineasPresupuesto.js @@ -653,7 +653,7 @@ class LineasPresupuesto { const lpName = this.data().row_id.replace('lp_', ''); const tabName = lpName.replace('_', '-'); - if (['bn', 'bnhq', 'color', 'colorhq', 'rot_bn', 'rot_color', 'guardas', 'cubierta', 'sobrecubierta'].includes(lpName)) { + if (['bn', 'bnhq', 'color', 'colorhq', 'rot_bn', 'rot_color', 'guardas', 'cubierta', 'sobrecubierta', 'faja'].includes(lpName)) { $(`#tab-pv-${tabName}`).show(); if (lpName === 'cubierta') { $(`#tab-pv-${tabName}`).show(); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/previewFormasAdmin.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/previewFormasAdmin.js index 1b24a85d..6f452df3 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/previewFormasAdmin.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/previewFormasAdmin.js @@ -84,7 +84,7 @@ class PreviewFormasAdmin{ $('#tab-pv-faja').on( "click", function() { self.preview.setData(self.data); - self.preview.previewInteriorPlana('sobrecubierta', self.isCosido, self.tipoTapa.includes("dura")?1:0); + self.preview.previewInteriorPlana('faja', self.isCosido, self.tipoTapa.includes("dura")?1:0); } ); }