From c19d1ffae861480baf4fe299140d877a111af083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Thu, 14 Nov 2024 20:43:13 +0100 Subject: [PATCH] muchos cambios (y no los papeles) --- .../Presupuestos/Presupuestocliente.php | 38 +++- .../Models/Presupuestos/PresupuestoModel.php | 8 +- .../viewClienteplantillapreciosForm.php | 28 ++- .../form/presupuestos/cliente/disenioLibro.js | 8 +- .../cliente/items/_datosGenerales.php | 52 ++++-- .../cliente/viewPresupuestoclienteForm.php | 174 +++--------------- .../cosidotapablanda/_datosServiciosItems.js | 2 +- ci4/builds:Zone.Identifier | 3 - ci4/spark:Zone.Identifier | 3 - .../presupuestoCliente/datosGenerales.js | 74 ++++++++ .../presupuestoCliente/presupuestoCliente.js | 94 +++++++++- 11 files changed, 277 insertions(+), 207 deletions(-) delete mode 100644 ci4/builds:Zone.Identifier delete mode 100644 ci4/spark:Zone.Identifier diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index 93aa8a42..58310480 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -296,7 +296,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $faja = $reqData['faja'] ?? []; $excluirRotativa = $reqData['excluirRotativa'] ?? 0; $excluirRotativa = intval($excluirRotativa); - $ivaReducido = intval($reqData['ivaReducido']) ?? 0; $direcciones = $reqData['direcciones'] ?? []; @@ -401,7 +400,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $coste_direccion = $this->getCosteEnvio( $direccion['id'], $return_data['peso'][$i], - !$primer_envio? intval($tirada[$i]) : $direccion['unidades'], + !$primer_envio ? intval($tirada[$i]) : $direccion['unidades'], $direccion['entregaPalets'] == 'true' ? 1 : 0 )[0]; @@ -654,6 +653,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $isHq = intval($reqData['isHq']) ?? 0; $prototipo = intval($reqData['prototipo']) ?? 0; + $ferro = intval($reqData['ferro']) ?? 0; + $ferroDigital = intval($reqData['ferroDigital']) ?? 0; + $marcapaginas = intval($reqData['marcapaginas']) ?? 0; + $retractilado = intval($reqData['retractilado']) ?? 0; + $retractilado5 = intval($reqData['retractilado5']) ?? 0; $interior = $reqData['interior'] ?? []; $cubierta = $reqData['cubierta'] ?? []; @@ -857,6 +861,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController } $datos_presupuesto['prototipo'] = $prototipo; + $datos_presupuesto['ferro'] = $ferro; + $datos_presupuesto['ferro_digital'] = $ferroDigital; + $datos_presupuesto['marcapaginas'] = $marcapaginas; + $datos_presupuesto['retractilado'] = $retractilado; + $datos_presupuesto['retractilado5'] = $retractilado5; $id = $model_presupuesto->insertarPresupuestoCliente( $id, @@ -970,6 +979,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $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'] : []; @@ -1832,13 +1846,19 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController */ $serviciosAutomaticos = []; $servicios = []; - if ($datos_entrada['cubierta']['acabadosCubierta']['retractilado'] === 'true') + if ($datos_entrada['servicios']['retractilado']) // acabado array_push($servicios, 3); - if ($datos_entrada['servicios']['prototipo']) + if ($datos_entrada['servicios']['retractilado5']) // acabado + array_push($servicios, 98); + if ($datos_entrada['servicios']['prototipo']) // extra array_push($servicios, 9); + if ($datos_entrada['servicios']['ferro']) // extra + array_push($servicios, 30); + /*if ($datos_entrada['servicios']['ferroDigital']) + array_push($servicios, 29);*/ // Es gratis foreach ($servicios as $servicio) { - if (intval($servicio) == 3) { + if (intval($servicio) == 3 || intval($servicio) == 98) { // Servicios acabado $resultado = PresupuestoCLienteService::getServiciosAcabados([ 'tarifa_id' => $servicio, @@ -1853,7 +1873,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $errorModel->insertError( $datos_entrada['id'], auth()->user()->id, - 'No se puede obtener servicio con id 3', + 'No se puede obtener servicio con id ' . ((string)$servicio), $input_data ); $return_data = [ @@ -1869,8 +1889,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $totalServicios += floatval($resultado[0]->total); $margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0; } - } else if (intval($servicio) == 9) { - // Prototipo + } else if (intval($servicio) == 9 || intval($servicio) == 30 || intval($servicio) == 29) { + // Extra $resultado = PresupuestoCLienteService::getServiciosExtra([ 'tarifa_id' => $servicio, ]); @@ -1881,7 +1901,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $errorModel->insertError( $datos_entrada['id'], auth()->user()->id, - 'No se puede obtener servicio con id 9', + 'No se puede obtener servicio con id ' . ((string)$servicio), $input_data ); $return_data = [ diff --git a/ci4/app/Models/Presupuestos/PresupuestoModel.php b/ci4/app/Models/Presupuestos/PresupuestoModel.php index f242d25e..dc73bd25 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoModel.php @@ -404,11 +404,13 @@ class PresupuestoModel extends \App\Models\BaseModel 'cliente_id' => $data['clienteId'], 'tipo_impresion_id' => $data['tipo_impresion_id'], 'pais_id' => 1, - 'retractilado' => in_array("RETR", $data['cubierta']['acabadosCubierta']) ? 1 : 0, - 'retractilado5' => in_array(5, $data['servicios']) ? 1 : 0, + 'retractilado' => $data['retractilado'] ? 1 : 0, + 'retractilado5' => $data['retractilado5'] ? 1 : 0, 'guardas' => in_array(62, $data['servicios']) ? 1 : 0, 'faja_color' => in_array(16, $data['servicios']) ? 1 : 0, - 'ferro' => in_array(24, $data['servicios']) ? 1 : 0, + 'ferro' => $data['ferro'] ? 1 : 0, + 'ferro_digital' => $data['ferro_digital'] ? 1 : 0, + 'marcapaginas' => $data['marcapaginas'] ? 1 : 0, 'prototipo' => $data['prototipo'] ? 1 : 0, 'papel_formato_id' => is_null($papel_formato_id) ? 0 : $papel_formato_id->id, 'papel_formato_personalizado' => !$papel_formato_id ? 1 : 0, diff --git a/ci4/app/Views/themes/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosForm.php b/ci4/app/Views/themes/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosForm.php index 0407597d..d2c26e2f 100644 --- a/ci4/app/Views/themes/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosForm.php +++ b/ci4/app/Views/themes/vuexy/form/clientes/plantillaprecios/viewClienteplantillapreciosForm.php @@ -278,14 +278,26 @@ language: { url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" }, - buttons: [ { - className: 'btn btn-primary me-sm-3 me-1', - extend: "createInline", - editor: editor, - formOptions: { - submitTrigger: -1, - submitHtml: '' - } + buttons: [ + { + extend: 'collection', + text: 'Exportar', + buttons:[ + 'copy', 'csv', 'excel', 'print', { + extend: 'pdfHtml5', + orientation: 'landscape', + pageSize: 'A4' + } + ] + }, + { + className: 'btn btn-primary me-sm-3 me-1', + extend: "createInline", + editor: editor, + formOptions: { + submitTrigger: -1, + submitHtml: '' + } } ] } ); diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/disenioLibro.js b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/disenioLibro.js index 31c46e6a..11d9093a 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/disenioLibro.js +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/disenioLibro.js @@ -684,7 +684,7 @@ async function calcularPresupuesto() { datos = Object.assign(datos, window.token_ajax) - $('#divTiradasPrecio').empty(); + $('.divTiradasPrecio').empty(); $('#loader').show(); $.ajax({ @@ -741,7 +741,7 @@ async function calcularPresupuesto() { $('#loader').hide(); - $('#divTiradasPrecio').empty(); + $('.divTiradasPrecio').empty(); if(!error){ @@ -768,7 +768,7 @@ async function calcularPresupuesto() { html += ''; html += ''; - $('#divTiradasPrecio').append(html); + $('.divTiradasPrecio').append(html); } } @@ -783,7 +783,7 @@ async function calcularPresupuesto() { }, error: function (error) { $('#loader').hide(); - $('#divTiradasPrecio').empty(); + $('.divTiradasPrecio').empty(); } }); } \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php index 666b1ffc..37b01331 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_datosGenerales.php @@ -49,13 +49,12 @@ -
" > -
-
+
class="step active titulos-menu" data-target="#datos-generales">
-
+
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.js b/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.js index 788b269f..130adab0 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.js +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.js @@ -777,7 +777,7 @@ function convertirTiempo(horas){ // se convierte a formato hh:mm:ss const h = Math.floor(seconds / 3600); const minutos = Math.floor((seconds % 3600) / 60); - const segundos = seconds % 60; + const segundos = round(seconds % 60, 0); return h + ':' + minutos + ':' + segundos; } else{ diff --git a/ci4/builds:Zone.Identifier b/ci4/builds:Zone.Identifier deleted file mode 100644 index 76699924..00000000 --- a/ci4/builds:Zone.Identifier +++ /dev/null @@ -1,3 +0,0 @@ -[ZoneTransfer] -ZoneId=3 -ReferrerUrl=C:\Users\jjime\Downloads\safekat-dev-presu_cliente_v2.zip diff --git a/ci4/spark:Zone.Identifier b/ci4/spark:Zone.Identifier deleted file mode 100644 index 76699924..00000000 --- a/ci4/spark:Zone.Identifier +++ /dev/null @@ -1,3 +0,0 @@ -[ZoneTransfer] -ZoneId=3 -ReferrerUrl=C:\Users\jjime\Downloads\safekat-dev-presu_cliente_v2.zip diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js index f03ed4a3..727a2a4e 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js @@ -55,6 +55,11 @@ class DatosGenerales { this.ivaReducido = this.domItem.find("#ivaReducido"); this.excluirRotativa = this.domItem.find("#excluirRotativa"); this.prototipo = this.domItem.find("#prototipo"); + this.ferro = this.domItem.find("#ferro"); + this.ferroDigital = this.domItem.find("#ferroDigital"); + this.marcapaginas = this.domItem.find("#marcapaginas"); + this.retractilado = this.domItem.find("#retractilado"); + this.retractilado5 = this.domItem.find("#retractilado5"); this.rl_datos_generales = $(".rl-datos-generales"); this.rl_tipo = $("#rl_tipo"); @@ -65,6 +70,11 @@ class DatosGenerales { this.rl_servicios_extra = $(".rl-servicios-extra"); this.rl_prototipo = $("#rl_prototipo"); + this.rl_ferro = $("#rl_ferro"); + this.rl_ferroDigital = $("#rl_ferroDigital"); + this.rl_marcapaginas = $("#rl_marcapaginas"); + this.rl_retractilado = $("#rl_retractilado"); + this.rl_retractilado5 = $("#rl_retractilado5"); this.initValidation(); } @@ -93,6 +103,9 @@ class DatosGenerales { this.altoPersonalizado.on("change", this.#checkValue.bind(this)); this.titulo.on('change', () => { $(".titulo").html(this.titulo.val()); }); + + this.retractilado.on('change', this.#eventRetractilado.bind(this)); + this.retractilado5.on('change', this.#eventRetractilado.bind(this)); } initValidation() { @@ -466,6 +479,47 @@ class DatosGenerales { else{ this.rl_prototipo.addClass('d-none'); } + + if(this.ferro.is(':checked')){ + this.rl_ferro.removeClass("d-none"); + menu_off = false; + } + else{ + this.rl_ferro.addClass('d-none'); + } + + if(this.ferroDigital.is(':checked')){ + this.rl_ferroDigital.removeClass("d-none"); + menu_off = false; + } + else{ + this.rl_ferroDigital.addClass('d-none'); + } + + if(this.marcapaginas.is(':checked')){ + this.rl_marcapaginas.removeClass("d-none"); + menu_off = false; + } + else{ + this.rl_marcapaginas.addClass('d-none'); + } + + if(this.retractilado.is(':checked')){ + this.rl_retractilado.removeClass("d-none"); + menu_off = false; + } + else{ + this.rl_retractilado.addClass('d-none'); + } + + if(this.retractilado5.is(':checked')){ + this.rl_retractilado5.removeClass("d-none"); + menu_off = false; + } + else{ + this.rl_retractilado5.addClass('d-none'); + } + if(!menu_off){ this.rl_servicios_extra.removeClass('d-none'); } @@ -534,6 +588,12 @@ class DatosGenerales { } this.prototipo.prop('checked', datos.prototipo); + this.ferro.prop('checked', datos.ferro); + this.ferroDigital.prop('checked', datos.ferroDigital); + this.marcapaginas.prop('checked', datos.marcapaginas); + this.retractilado.prop('checked', datos.retractilado); + this.retractilado5.prop('checked', datos.retractilado5); + this.ivaReducido.val(datos.ivaReducido ? 1 : 0).trigger('change'); } @@ -612,6 +672,20 @@ class DatosGenerales { } } + #eventRetractilado(event) { + let target = event.target; + if (target.id == 'retractilado') { + if (this.retractilado5.is(':checked')) { + this.retractilado5.prop('checked', false); + } + } + else { + if (this.retractilado.is(':checked')) { + this.retractilado.prop('checked', false); + } + } + } + #handleTipolibro(event) { // Accede al ID del elemento que disparó el evento diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js index 949af64e..10d03e88 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js @@ -11,6 +11,38 @@ import tarjetaTiradasPrecio from './tarjetaTiradasPrecio.js'; class PresupuestoCliente { constructor() { + /* + // Seleccionar el header y el contenedor del offcanvas + var stepperHeader = document.querySelector('#sharedStepper'); + var offcanvasBody = document.querySelector('#menu-offcanvas .offcanvas-body'); + + // Función para verificar el tamaño de la pantalla y mover el contenido + function adjustStepperLocation() { + if (window.innerWidth < 768) { + // Si es un dispositivo móvil o tablet, mover el stepper al offcanvas + if (offcanvasBody && stepperHeader) { + // Verificar si el stepper ya está en el offcanvas + if (!offcanvasBody.contains(stepperHeader)) { + offcanvasBody.appendChild(stepperHeader); // Mover al offcanvas + } + } + } else { + // Si es un dispositivo grande, dejar el stepper en su lugar original + var originalContainer = document.querySelector('.bs-stepper-header').parentNode; + if (originalContainer && !originalContainer.contains(stepperHeader)) { + originalContainer.appendChild(stepperHeader); // Mover de vuelta al contenedor original + } + } + } + + // Llamar a la función para ajustar la ubicación al cargar + adjustStepperLocation(); + + // También ejecutar la función cuando cambie el tamaño de la ventana + window.addEventListener('resize', function () { + adjustStepperLocation(); + }); + */ this.clientePresupuestoWizard = document.querySelector('#wizard-presupuesto-cliente'); this.validationStepper = new Stepper(this.clientePresupuestoWizard, { @@ -37,7 +69,7 @@ class PresupuestoCliente { this.direcciones = new Direcciones($("#direcciones-libro"), this.clientePresupuestoWizard, this.validationStepper); this.resumen = new Resumen($("#resumen-libro"), this.datosGenerales, this.disenioInterior, this.disenioCubierta, this.direcciones); - this.divTiradasPrecios = $("#divTiradasPrecio"); + this.divTiradasPrecios = $(".divTiradasPrecio"); this.titulosMenu = $(".titulos-menu"); @@ -50,7 +82,7 @@ class PresupuestoCliente { this.actualizarTiradasEnvio = false; this.calcularPresupuesto = false; - if(!window.location.href.includes("edit")) { + if (!window.location.href.includes("edit")) { this.#processResumenLateral(); } } @@ -167,7 +199,7 @@ class PresupuestoCliente { this.actualizarTiradasEnvio = false; if (!this.direcciones.calcularPresupuesto) { - + $('#loader').modal('hide'); return; } @@ -226,9 +258,9 @@ class PresupuestoCliente { else { this.#goToForm(nextElement); } - if(!nextElement.includes('resumen-libro')) + if (!nextElement.includes('resumen-libro')) this.#processResumenLateral(); - else{ + else { $(".rl-item").addClass('d-none'); } } @@ -259,7 +291,6 @@ class PresupuestoCliente { default: break; } - $('html, body').animate({ scrollTop: 0 }, 'slow'); } @@ -380,7 +411,7 @@ class PresupuestoCliente { } } - #printPresupuesto(){ + #printPresupuesto() { window.open('/printpresupuestos/generar/' + window.location.href.split("/").pop(), '_blank'); } @@ -392,7 +423,7 @@ class PresupuestoCliente { total_unidades += parseInt(element.tirada.val()); }); - if(total_unidades != parseInt(this.direcciones.getSelectedTirada())){ + if (total_unidades != parseInt(this.direcciones.getSelectedTirada())) { popErrorAlert("No se puede confirmar el presupuesto. La suma de las unidades enviadas no coincide con la tirada seleccionada."); return; } @@ -500,7 +531,7 @@ class PresupuestoCliente { response.precio_u[i] ); - if (this.actualizarTiradasEnvio){ + if (this.actualizarTiradasEnvio) { this.direcciones.insertTirada(tiradas[i]); } @@ -595,7 +626,13 @@ class PresupuestoCliente { paginasCuadernillo: this.datosGenerales.paginasCuadernillo.val(), tipo: this.datosGenerales.tiposLibro.filter('.selected').attr('id'), + prototipo: this.datosGenerales.prototipo.is(':checked') ? 1 : 0, + ferro: this.datosGenerales.ferro.is(':checked') ? 1 : 0, + ferroDigital: this.datosGenerales.ferroDigital.is(':checked') ? 1 : 0, + marcapaginas: this.datosGenerales.marcapaginas.is(':checked') ? 1 : 0, + retractilado: this.datosGenerales.retractilado.is(':checked') ? 1 : 0, + retractilado5: this.datosGenerales.retractilado5.is(':checked') ? 1 : 0, isColor: this.datosGenerales.getIsColor() ? 1 : 0, isHq: this.disenioInterior.getIsHq() ? 1 : 0, @@ -623,6 +660,11 @@ class PresupuestoCliente { ivaReducido: this.datosGenerales.ivaReducido.find('option:selected').val(), servicios: { 'prototipo': this.datosGenerales.prototipo.is(':checked') ? 1 : 0, + 'ferro': this.datosGenerales.ferro.is(':checked') ? 1 : 0, + 'ferroDigital': this.datosGenerales.ferroDigital.is(':checked') ? 1 : 0, + 'marcapaginas': this.datosGenerales.marcapaginas.is(':checked') ? 1 : 0, + 'retractilado': this.datosGenerales.retractilado.is(':checked') ? 1 : 0, + 'retractilado5': this.datosGenerales.retractilado5.is(':checked') ? 1 : 0, }, }; let lomoRedondo = 0; @@ -766,9 +808,40 @@ function initialize(translations) { presupuestoCliente.init(); } - document.addEventListener('DOMContentLoaded', function () { + function moveStepperHeader() { + if ($(window).width() < 768) { // Dispositivos pequeños (menos de 768px) + if (!$('.bs-stepper-header').parent().hasClass('offcanvas-body')) { + $('.bs-stepper-header').appendTo('.offcanvas-body'); + } + } else { // Dispositivos medianos y grandes (768px o más) + if ($('.bs-stepper-header').parent().hasClass('offcanvas-body')) { + $('.bs-stepper-header').insertBefore('.offcanvas-body'); + } + } + } + + // Ejecutar la función al cargar la página + moveStepperHeader(); + + // Ejecutar la función al cambiar el tamaño de la ventana + window.addEventListener('resize', function () { + moveStepperHeader(); + }); + + function moveStepperHeader() { + if ($(window).width() < 768) { // Dispositivos pequeños (menos de 768px) + if (!$('.bs-stepper-header').parent().hasClass('offcanvas-body')) { + $('.bs-stepper-header').appendTo('.offcanvas-body'); + } + } else { // Dispositivos medianos y grandes (768px o más) + if ($('.bs-stepper-header').parent().hasClass('offcanvas-body')) { + $('.bs-stepper-header').insertAfter('#menu-offcanvas'); + } + } + } + const locale = document.querySelector('meta[name="locale"]').getAttribute('content'); new Ajax('/translate/getTranslation', { locale: locale, translationFile: 'Presupuestos' }, {}, @@ -780,3 +853,4 @@ document.addEventListener('DOMContentLoaded', function () { }); +