From 83c86286454bda80b9cf99ac363c5120771eb111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Thu, 31 Oct 2024 08:42:41 +0100 Subject: [PATCH] presupuesto cliente para perfil cliente --- .../Presupuestos/Presupuestocliente.php | 1 + .../cliente/items/_datosGenerales.php | 32 ++++++--- .../presupuestoCliente/datosGenerales.js | 20 ++++-- .../pages/presupuestoCliente/direcciones.js | 2 +- .../presupuestoCliente/presupuestoCliente.js | 72 +++---------------- 5 files changed, 50 insertions(+), 77 deletions(-) diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index cb6faeae..b0d20702 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -99,6 +99,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController // Se obtiene el cliente ID a partir del usuario de la sesion $model_user = model('App\Models\Usuarios\UserModel'); + $user = $model_user->find(auth()->user()->id); $clienteId = $user->cliente_id; 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 4640397b..aff8e501 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 @@ -16,14 +16,15 @@ - +
@@ -32,35 +33,44 @@ - +
- -
+ +
-
- - + user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))? " hidden" : "" ?> + class="calcular-presupuesto form-check-input" type="checkbox" id="excluirPortada" + name="excluir_portada" value="1"> +
diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js index c58c2bc7..99a0b0cd 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js @@ -64,7 +64,9 @@ class DatosGenerales { // Selects this.formatoLibro.init(); - this.cliente.init(); + if (this.excluirRotativa.length != 0) { + this.cliente.init(); + } // Inicializa el tipo de impresion this.#handlePaginas(); @@ -100,6 +102,8 @@ class DatosGenerales { message: window.translations["validation"].cliente, callback: function (input) { // Get the selected options + if(this.excluirRotativa.length == 0) + return true; const options = $("#clienteId").select2('data'); const hasValidOption = options.some(option => parseInt(option.id) > 0); return options !== null && options.length > 0 && hasValidOption; @@ -382,9 +386,11 @@ class DatosGenerales { this.coleccion.val(datos.coleccion); this.referenciaCliente.val(datos.referenciaCliente); - this.cliente.setOption(datos.clienteId, datos.clienteNombre); - this.cliente.setVal(datos.clienteId); - $(this.cliente).trigger('change'); + if (this.excluirRotativa.length != 0) { + this.cliente.setOption(datos.clienteId, datos.clienteNombre); + this.cliente.setVal(datos.clienteId); + $(this.cliente).trigger('change'); + } if (datos.excluirRotativa) { this.excluirRotativa.prop('checked', true); @@ -434,6 +440,12 @@ class DatosGenerales { this.ivaReducido.val(datos.ivaReducido ? 1 : 0).trigger('change'); } + getCliente(){ + if (this.excluirRotativa.length == 0) + return $('#clienteId').val(); + return this.cliente.getVal(); + } + getDimensionLibro() { let ancho = 0; diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js index ce9cc8b5..286cae3a 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js @@ -37,7 +37,7 @@ class Direcciones { init() { - $("#clienteId").on('change', this.handleChangeCliente.bind(this)); + $("#clienteId").on('change', this.handleChangeCliente.bind(this)); this.direccionesCliente.init(); this.btnAdd.on('click', this.#insertDireccion.bind(this)); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js index 02560fd3..f1941b80 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js @@ -62,6 +62,11 @@ class PresupuestoCliente { this.disenioCubierta.init(); this.direcciones.init(); + if(this.datosGenerales.excluirRotativa.length == 0){ + + this.direcciones.direccionesCliente.setParams({ 'cliente_id': $("#clienteId").val() }) + } + this.btnNext.on('click', this.#nextStep.bind(this)); this.btnPrev.on('click', this.#prevtStep.bind(this)); @@ -189,63 +194,6 @@ class PresupuestoCliente { } - - /*RELLENAR_PRESUPUESTO(finalizar) { - - if (finalizar) { - - $("#titulo").val("Titulo del libro"); - $("#titulo").trigger('change'); - - const clienteId = $("#clienteId"); - const newOption = new Option("Cliente Potencial", "1817", true, true); - clienteId.append(newOption).trigger('change'); - - const papelFormatoId = $("#papelFormatoId"); - const newOption2 = new Option("148 x 210", "1", true, true); - papelFormatoId.append(newOption2).trigger('change'); - - - $("#paginasColor").val("6"); - $("#paginasColor").trigger('change'); - - $("#fresado").trigger("click"); - - - $("#colorPremium").trigger("click"); - $("#offsetBlanco").trigger("click"); - - setTimeout(function () { - $("#gramaje90").trigger("click"); - }, 0); - - setTimeout(function () { - $("#tapaDura").trigger("click"); - }, 0); - - - setTimeout(function () { - $("#btnNext").trigger("click"); - }, 0); - setTimeout(function () { - $("#btnNext").trigger("click"); - }, 0); - setTimeout(function () { - $("#btnNext").trigger("click"); - }, 0); - - - setTimeout(function () { - $("#unidadesEnvio").val("50"); - }, 0); - - } - else { - $("#titulo").trigger('change'); - } - }*/ - - #handleTitulosMenu(event) { $('.titulos-menu').removeClass('crossed'); @@ -266,7 +214,7 @@ class PresupuestoCliente { } #goToForm(form) { - + switch (form) { case '#datos-generales': this.validationStepper.to(1); @@ -439,7 +387,7 @@ class PresupuestoCliente { } } else { - if(response.error){ + if (response.error) { popErrorAlert("No se ha podido guardar el presupuesto. Por favor, póngase en contacto con el departamento comercial."); } else @@ -546,7 +494,7 @@ class PresupuestoCliente { this.datos = { - clienteId: this.datosGenerales.cliente.getVal(), + clienteId: this.datosGenerales.getCliente(), tamanio: this.datosGenerales.getDimensionLibro(), tirada: this.datosGenerales.getTiradas(), @@ -651,7 +599,9 @@ class PresupuestoCliente { this.calcularPresupuesto = false; this.datosGenerales.cargarDatos(response.data.datosGenerales); - this.direcciones.handleChangeCliente(); + if (this.datosGenerales.excluirRotativa.length !== 0) { + this.direcciones.handleChangeCliente(); + } this.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente); this.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta); this.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);