diff --git a/ci4/app/Controllers/Configuracion/Papelesgenericos.php b/ci4/app/Controllers/Configuracion/Papelesgenericos.php index 861131df..391e5ee8 100755 --- a/ci4/app/Controllers/Configuracion/Papelesgenericos.php +++ b/ci4/app/Controllers/Configuracion/Papelesgenericos.php @@ -276,7 +276,7 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController $onlyActiveOnes = false; $columns2select = [$reqId ?? 'id', $reqText ?? 'nombre']; $onlyActiveOnes = false; - $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr); + $menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr, true); $nonItem = new \stdClass; $nonItem->id = ''; $nonItem->text = '- ' . lang('Basic.global.None') . ' -'; diff --git a/ci4/app/Controllers/Configuracion/Papelesimpresion.php b/ci4/app/Controllers/Configuracion/Papelesimpresion.php index d3da2fad..fb3a0363 100755 --- a/ci4/app/Controllers/Configuracion/Papelesimpresion.php +++ b/ci4/app/Controllers/Configuracion/Papelesimpresion.php @@ -417,7 +417,7 @@ class Papelesimpresion extends \App\Controllers\BaseResourceController if (!empty($selId)) : $papelGenericoModel = model('App\Models\Configuracion\PapelGenericoModel'); - $selOption = $papelGenericoModel->where('id', $selId)->findColumn('nombre'); + $selOption = $papelGenericoModel->where('is_deleted', 0)->where('id', $selId)->findColumn('nombre'); if (!empty($selOption)) : $data[$selId] = $selOption[0]; endif; diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index fe1fa816..e37f22d1 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -1127,7 +1127,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController [$data['datosGenerales']['paginasNegro'], $data['datosGenerales']['paginasColor']] = $this->getPaginas($lineas); - if (intval($presupuesto->envios_recoge_cliente) == 1) { + if (intval($presupuesto->recoger_en_taller) == 1) { $data['direcciones']['entrega_taller'] = 1; } else { $data['direcciones']['entrega_taller'] = 0; @@ -1913,7 +1913,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController foreach ($servDefectoEnc as $servicio) { if ($servicio->total <= 0) { - $input_data['servicios'] = $servDefecto; + $input_data['servicios'] = $servDefectoEnc; $errorModel = new ErrorPresupuesto(); $errorModel->insertError( $datos_entrada['id'], @@ -1948,7 +1948,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController foreach ($servDefectoMan as $servicio) { if ($servicio->total <= 0) { - $input_data['servicios'] = $servDefecto; + $input_data['servicios'] = $servDefectoMan; $errorModel = new ErrorPresupuesto(); $errorModel->insertError( $datos_entrada['id'], diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index e7077fa8..b48b477b 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -362,7 +362,7 @@ return [ 'sin_gramaje' => "Seleccione gramaje", 'tipo_cubierta' => 'Seleccione tipo de cubierta', 'opcion_solapas' => 'Seleccione la opción para las solapas', - 'paginas_cosido' => 'El número de páginas para cosido debe ser múltiplo de 4', + 'paginas_multiplo_4' => 'El número de páginas para cosido o grapado debe ser múltiplo de 4', 'paginas_pares' => 'El número de páginas debe ser par', ], diff --git a/ci4/app/Models/Configuracion/MaquinaModel.php b/ci4/app/Models/Configuracion/MaquinaModel.php index 650162e6..be6f7d01 100755 --- a/ci4/app/Models/Configuracion/MaquinaModel.php +++ b/ci4/app/Models/Configuracion/MaquinaModel.php @@ -15,7 +15,7 @@ class MaquinaModel extends \App\Models\BaseModel const SORTABLE = [ 0 => "t1.id", - 1 => "t2.nombre", + 1 => "t1.nombre", 2 => "t1.tipo", 3 => "t1.ancho_impresion", 4 => "t1.alto_impresion", diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js index 5cb58bd9..a65a2863 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js @@ -330,17 +330,19 @@ class DatosGenerales { divTipoLibro.find('.fv-plugins-message-container').remove(); if ($('.tipo-libro.selected').length > 0) { - if ($('#cosido').hasClass('selected')) { + if ($('#cosido').hasClass('selected') || $('#grapado').hasClass('selected')) { const value = parseInt($("#paginas").val()); if (value % 4 != 0) { divTipoLibro.append(`
- ${window.translations["validation"].paginas_cosido} + ${window.translations["validation"].paginas_multiplo_4}
`); + return false; } + return true; } return true; @@ -353,8 +355,9 @@ class DatosGenerales { `); + return false; } - return false; + }, } } @@ -583,6 +586,10 @@ class DatosGenerales { this.tiposLibro.removeClass('selected'); this.tiposLibro.find('.image-presupuesto').removeClass('selected'); this.domItem.find('#' + datos.tipo).addClass('selected'); + + if(datos.tipo == 'cosido'){ + this.divPaginasCuaderillo.removeClass('d-none'); + } } this.prototipo.prop('checked', datos.prototipo); @@ -726,6 +733,8 @@ class DatosGenerales { } } + this.checkPaginasMultiplo4(); + // Para recalcular el presupuesto $('#divGramajeInterior').empty(); $('#divGramajeInteriorColor').empty(); @@ -789,6 +798,29 @@ class DatosGenerales { this.divPaginasColorConsecutivas.removeClass('d-none'); this.divPosPaginasColor.removeClass('d-none'); } + + this.checkPaginasMultiplo4(); + } + + checkPaginasMultiplo4(){ + + const divTipoLibro = $('#divTipoLibro'); // Selecciona el div + divTipoLibro.find('.fv-plugins-message-container').remove(); + + if ($('#cosido').hasClass('selected') || $('#grapado').hasClass('selected')) { + const value = parseInt($("#paginas").val()); + if (value % 4 != 0) { + divTipoLibro.append(` +
+
+ ${window.translations["validation"].paginas_multiplo_4} +
+
+ `); + return false; + } + } + return true; } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js index c3a67490..6e6288b3 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js @@ -30,6 +30,8 @@ class Direcciones { this.direcciones = []; + this.tiradaSeleccionada = null; + this.direcciones.calcularPresupuesto = false; this.initValidation(); @@ -42,14 +44,14 @@ class Direcciones { $("#clienteId").on('change', this.handleChangeCliente.bind(this)); this.recogidaTaller.on('change', () => { - + if (this.recogidaTaller.is(':checked')) { this.divDirecciones.empty(); this.direcciones = []; $('.div-direcciones').addClass('d-none'); } - else{ + else { $('.div-direcciones').removeClass('d-none'); } }); @@ -88,6 +90,7 @@ class Direcciones { if (datos.entrega_taller == 1) { this.recogidaTaller.prop('checked', true); + this.recogidaTaller.trigger('change'); } else { @@ -103,13 +106,7 @@ class Direcciones { let id = datos[i].id; let unidades = datos[i].unidades; let entregaPalets = datos[i].palets; - let divId = "dirEnvio-1"; - let direccionesActuales = this.divDirecciones.find('.direccion-cliente'); - if (direccionesActuales.length > 0) { - // the the lass item - let last = direccionesActuales[direccionesActuales.length - 1]; - divId = "dirEnvio-" + (parseInt(last.id.split('-')[1]) + 1); - } + if (id == null || id <= 0 || id == undefined) return; @@ -118,6 +115,13 @@ class Direcciones { let peticion = new Ajax('/misdirecciones/getDireccionPresupuesto/' + id, {}, {}, (response) => { + let divId = "dirEnvio-1"; + let direccionesActuales = this.divDirecciones.find('.direccion-cliente'); + if (direccionesActuales.length > 0) { + // the the lass item + let last = direccionesActuales[direccionesActuales.length - 1]; + divId = "dirEnvio-" + (parseInt(last.id.split('-')[1]) + 1); + } let tarjeta = new tarjetaDireccion(this.divDirecciones, divId, response.data[0]); tarjeta.setUnidades(unidades); tarjeta.setEntregaPalets(entregaPalets); @@ -214,7 +218,7 @@ class Direcciones { let customOption = tarjeta.card.find('.check-tirada-envio'); customOption.on('click', function () { - self.#handleTiradaEnvio(customOption); + self.#handleTiradaEnvio(customOption, self); }); } @@ -255,7 +259,7 @@ class Direcciones { dialog.init(); } - #handleTiradaEnvio(customOption) { + #handleTiradaEnvio(customOption, self) { const el = customOption[0]; @@ -268,6 +272,7 @@ class Direcciones { }) } el.closest('.custom-option').classList.add('checked') + self.tiradaSeleccionada = parseInt(el.getAttribute('tirada')); } else { el.closest('.custom-option').classList.remove('checked') } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js index 674176cf..764e19eb 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js @@ -211,11 +211,19 @@ class PresupuestoCliente { let datos_to_check = this.#prepareData(); if (Object.values(datos_to_check).every(this.#isValidDataForm)) { + try { + if (!this.datosGenerales.checkPaginasMultiplo4()) { + popErrorAlert("Compruebe que todos los campos son correctos."); + return; + } + setTimeout(function () { $('#loader').modal('show'); }, 0); + + // Si se está ejecutando la petición, abortar la petición anterior this.ajax_calcular.abort(); @@ -453,6 +461,12 @@ class PresupuestoCliente { return; } + if (!this.datosGenerales.checkPaginasMultiplo4()) { + popErrorAlert("Compruebe que todos los campos son correctos."); + $('#loader').modal('hide'); + return; + } + this.#getDatos(true); if (confirmar) { @@ -536,10 +550,11 @@ class PresupuestoCliente { } } + this.lc.val(parseFloat(response.info.lomo_cubierta).toFixed(2)); this.lsc.val(parseFloat(response.info.lomo_sobrecubierta).toFixed(2)); setTimeout(() => { - $(`#containerTiradasEnvios .tirada-envio input[tirada="${response.tiradas[0]}"]`).trigger('click'); + $(`#containerTiradasEnvios .tirada-envio input[tirada="${this.direcciones.tiradaSeleccionada}"]`).trigger('click'); }, 0); } $('#loader').modal('hide'); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/resumen.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/resumen.js index cb2b523a..62fae0d8 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/resumen.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/resumen.js @@ -301,10 +301,8 @@ class Resumen { return parseInt($(this).find('.tarjeta-tiradas-precios-tirada').attr('data')) == unidades; }); - let precio_u_text = tarjetaPrecio.find('.tarjeta-tiradas-precios-precio-unidad').text(); - precio_u_text = precio_u_text.replace('€/u', ''); - precio_u_text = this.#changeDecimalFormat(precio_u_text); + precio_u_text = precio_u_text.replace('€/ud', ''); const base = tarjetaPrecio.find('.tarjeta-tiradas-precios-precio').attr('data'); let base_text = this.#changeDecimalFormat(base);