From b5924dceb5043f5a0953505742da30fc30ed9f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Wed, 16 Oct 2024 03:45:10 +0200 Subject: [PATCH] falta preview resumen --- ci4/app/Config/Routes.php | 2 + .../Clientes/Clientedirecciones.php | 33 +++- .../Presupuestos/Presupuestocliente.php | 24 ++- .../Clientes/ClienteDireccionesModel.php | 2 +- .../Services/PresupuestoClienteService.php | 54 +++++- .../components/modals/modalDireccion.php | 114 ++++++++++++ .../cliente/items/_direcciones.php | 11 +- .../items/_presupuestoDireccionesForm.php | 143 ++++++++++++++ .../presupuestos/cliente/items/_resumen.php | 174 ++++++++++++++++++ .../cliente/viewPresupuestoclienteForm.php | 18 +- .../js/safekat/components/modalDireccion.js | 94 ++++++++++ .../pages/presupuestoCliente/direcciones.js | 118 +++++++++++- .../presupuestoCliente/disenioCubierta.js | 93 +++++++--- .../presupuestoCliente/disenioInterior.js | 29 ++- .../presupuestoCliente/presupuestoCliente.js | 96 +++++++--- .../pages/presupuestoCliente/resumen.js | 143 ++++++++++++++ .../presupuestoCliente/selectorTiradaEnvio.js | 79 ++++---- .../tarjetaTiradasPrecio.js | 14 +- .../themes/vuexy/css/presupuestoCliente.css | 17 ++ 19 files changed, 1132 insertions(+), 126 deletions(-) create mode 100644 ci4/app/Views/themes/vuexy/components/modals/modalDireccion.php create mode 100644 ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_presupuestoDireccionesForm.php create mode 100644 ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_resumen.php create mode 100644 httpdocs/assets/js/safekat/components/modalDireccion.js create mode 100644 httpdocs/assets/js/safekat/pages/presupuestoCliente/resumen.js diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 09c44b34..d7a8d790 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -410,6 +410,8 @@ $routes->group('clienteusuarios', ['namespace' => 'App\Controllers\Clientes'], f $routes->group('misdirecciones', ['namespace' => 'App\Controllers\Clientes'], function ($routes) { $routes->get('', 'Clientedirecciones::index', ['as' => 'clientedireccionesIndex']); $routes->get('get/(:num)', 'Clientedirecciones::get/$1', ['as' => 'get']); + $routes->post('add', 'Clientedirecciones::add', ['as' => 'newClientedirecciones']); + $routes->get('getSelect2', 'Clientedirecciones::getSelect2', ['as' => 'listaClientedirecciones']); }); diff --git a/ci4/app/Controllers/Clientes/Clientedirecciones.php b/ci4/app/Controllers/Clientes/Clientedirecciones.php index ff8b38d9..5553987a 100755 --- a/ci4/app/Controllers/Clientes/Clientedirecciones.php +++ b/ci4/app/Controllers/Clientes/Clientedirecciones.php @@ -82,7 +82,7 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController $att = $reqData['att'] ?? ""; $email = $reqData['email'] ?? ""; $direccion = $reqData['direccion'] ?? ""; - $pais_id = $reqData['paisId'] ?? -1; + $pais_id = $reqData['pais_id'] ?? -1; $provincia = $reqData['provincia'] ?? ""; $municipio = $reqData['municipio'] ?? ""; $cp = $reqData['cp'] ?? ""; @@ -103,11 +103,8 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController ]; $response = $this->model->insert($data); - $newTokenHash = csrf_hash(); - $csrfTokenName = csrf_token(); $data_ret = [ 'data' => $response, - $csrfTokenName => $newTokenHash ]; return $this->respond($data_ret); } else { @@ -140,6 +137,34 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController } + public function getSelect2() + { + if ($this->request->isAJAX()) { + + $cliente_id = $this->request->getGet('cliente_id'); + + + $query = $this->model->builder()->select( + [ + "id", + "alias as name" + ] + ) + ->where("cliente_id", $cliente_id) + ->orderBy("alias", "asc"); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("clientes.nombre", $this->request->getGet("q")) + ->groupEnd(); + } + + return $this->response->setJSON($query->get()->getResultObject()); + } 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 449934ab..66a4c512 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -320,7 +320,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $tipo = $reqData['tipo']; $paginasCuadernillo = $reqData['paginasCuadernillo'] ?? null; - $papelInteriorDiferente = $reqData['papelInteriorDiferente'] ?? null; + $papelInteriorDiferente = intval($reqData['papelInteriorDiferente']) ?? null; $isColor = intval($reqData['isColor']) ?? 0; $isHq = intval($reqData['isHq']) ?? 0; @@ -331,16 +331,26 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController $guardas = $reqData['guardas'] ?? []; $faja = $reqData['faja'] ?? []; $excluirRotativa = $reqData['excluirRotativa'] ?? 0; - $ivaReducido = $reqData['ivaReducido'] ?? 0; + $ivaReducido = intval($reqData['ivaReducido']) ?? 0; $direcciones = $reqData['direcciones'] ?? []; $tipo_impresion_id = $this->getTipoImpresion($tipo, $cubierta['tipoCubierta']); + if($papelInteriorDiferente){ + $papel['negro'] = $modelPapelGenerico->getIdFromCode($interior['papelInterior']['negro']); + $papel['color'] = $modelPapelGenerico->getIdFromCode($interior['papelInterior']['color']); + $gramaje['negro'] = intval($interior['gramajeInterior']['negro']); + $gramaje['color'] = intval($interior['gramajeInterior']['color']); + } + else{ + $papel = $modelPapelGenerico->getIdFromCode($interior['papelInterior']); + $gramaje = intval($interior['gramajeInterior']); + } // Interior $interior = [ - 'papel_generico' => $modelPapelGenerico->getIdFromCode($interior['papelInterior']), - 'gramaje' => intval($interior['gramajeInterior']), + 'papel_generico' => $papel, + 'gramaje' => $gramaje, 'excluirRotativa' => $excluirRotativa == "false" ? false : true, 'paginas' => $paginas, 'paginas_color' => $paginas_color, @@ -396,7 +406,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController ); $return_data = $this->calcular_presupuesto($datos_presupuesto, 0, false); //TRUE FOR DEBUG - + if(array_key_exists('exception', $return_data)){ + return $this->failServerError( + $return_data['exception'] . ' - ' . + $return_data['file'] . ' - ' . $return_data['line']); + } if(count($direcciones) > 1){ for ($i=0; $i [ "label" => "ClienteDirecciones.email", - "rules" => "trim|max_length[100]|valid_email", + "rules" => "trim|max_length[100]", ], "cp" => [ "label" => "ClienteDirecciones.cp", diff --git a/ci4/app/Services/PresupuestoClienteService.php b/ci4/app/Services/PresupuestoClienteService.php index 0fc911de..46ca2fd9 100644 --- a/ci4/app/Services/PresupuestoClienteService.php +++ b/ci4/app/Services/PresupuestoClienteService.php @@ -24,7 +24,6 @@ class PresupuestoClienteService extends BaseService $total_plana = -1; $hay_plana = false; - $papelInteriorDiferente = $data['papelInteriorDiferente']; if ($data['isColor']) { if ($data['datosPedido']->paginas == $data['paginas_color']) $total_plana += floatval($plana[1]['total_impresion']); @@ -297,8 +296,6 @@ class PresupuestoClienteService extends BaseService return $result; } ); - $linea_negro_plana = $linea_negro_plana[0]['fields']; - $linea_negro_plana['tipo_linea'] = $isHq ? 'lp_bnhq' : 'lp_bn'; } } @@ -308,6 +305,10 @@ class PresupuestoClienteService extends BaseService $datosPedido->paginas = $paginas_color; for ($i = 0; $i < 2; $i++) { + if ($data['papelInteriorDiferente'] == true){ + $papel_generico = $papel_generico_color; + $gramaje = $gramaje_color; + } $lineas = PresupuestoService::obtenerComparadorPlana([ 'uso' => $uso, 'tipo_impresion_id' => $tipo_impresion_id, @@ -337,10 +338,57 @@ class PresupuestoClienteService extends BaseService return $result; } ); + } + } + + // 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 + ) { + $mejor_combinacion = null; + $coste_menor = PHP_INT_MAX; + // Iteramos ambos arrays + foreach ($linea_color_plana as $color_item) { + foreach ($linea_negro_plana as $negro_item) { + // Comparar si tienen el mismo 'maquina_id' + if ($color_item['fields']['maquina_id'] == $negro_item['fields']['maquina_id']) { + // Sumar los 'total_impresion' de ambas líneas + $costo_total = $color_item['fields']['total_impresion'] + $negro_item['fields']['total_impresion']; + + // Verificar si es la combinación más barata hasta ahora + if ($costo_total < $coste_menor) { + $coste_menor = $costo_total; + $mejor_combinacion = [ + 'maquina_id' => $color_item['fields']['maquina_id'], + 'costo_total' => $costo_total, + 'color_item' => $color_item, + 'negro_item' => $negro_item, + ]; + } + } + } + + // Retornar la mejor combinación encontrada + if ($mejor_combinacion !== null) { + return [$mejor_combinacion['negro_item']['fields'], $mejor_combinacion['color_item']['fields']]; + } else { + return []; + } + } + } + else{ + if (count($linea_negro_plana) > 0) { + $linea_negro_plana = $linea_negro_plana[0]['fields']; + $linea_negro_plana['tipo_linea'] = $isHq ? 'lp_bnhq' : 'lp_bn'; + } + if (count($linea_color_plana) > 0) { $linea_color_plana = $linea_color_plana[0]['fields']; $linea_color_plana['tipo_linea'] = $isHq ? 'lp_colorhq' : 'lp_color'; } } + return [$linea_negro_plana, $linea_color_plana]; } diff --git a/ci4/app/Views/themes/vuexy/components/modals/modalDireccion.php b/ci4/app/Views/themes/vuexy/components/modals/modalDireccion.php new file mode 100644 index 00000000..b85c7ef7 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/components/modals/modalDireccion.php @@ -0,0 +1,114 @@ + diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_direcciones.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_direcciones.php index 2e208438..67af53db 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_direcciones.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_direcciones.php @@ -10,7 +10,7 @@
-
+
@@ -47,6 +47,15 @@
+
+
+ +
+
+ +
+
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_presupuestoDireccionesForm.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_presupuestoDireccionesForm.php new file mode 100644 index 00000000..475222d1 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_presupuestoDireccionesForm.php @@ -0,0 +1,143 @@ + + + + + +section("additionalExternalJs") ?> + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_resumen.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_resumen.php new file mode 100644 index 00000000..a434d5bf --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_resumen.php @@ -0,0 +1,174 @@ +
+ +

Resumen del presupuesto

+
+ +
+
Precio unidad:
+

Total base: € +

Iva (%): € +

Total: € +

+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Datos generales
TituloAlbert Cook
Tipo libro
Formato
Páginas negro
Páginas color
Páginas en total
Tirada
Prototipo
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Interior
Impresion
Papel
Gramaje
Papel B&N
Gramaje B&N
Papel Color
Gramaje Color
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Cubierta
Tipo
Caras impresas
Papel
Gramaje
Solapas
Papel de guardas
Guardas impresas
Cabezada
Acabados
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
Sobrecubierta
PapelEstucado Mate
Gramaje
Tamaño solapas
Plastificado
+
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoclienteForm.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoclienteForm.php index c281186c..2f3436d0 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoclienteForm.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoclienteForm.php @@ -9,6 +9,7 @@ +
@@ -60,6 +61,15 @@
+
+ +
+
@@ -70,8 +80,6 @@
- -
@@ -97,6 +105,12 @@
+
+
+ +
+
+ diff --git a/httpdocs/assets/js/safekat/components/modalDireccion.js b/httpdocs/assets/js/safekat/components/modalDireccion.js new file mode 100644 index 00000000..0d8cd9c8 --- /dev/null +++ b/httpdocs/assets/js/safekat/components/modalDireccion.js @@ -0,0 +1,94 @@ +class Direccionmodal { + constructor(modal, saveCallback) { + this.modal = modal; + this.saveCallback = saveCallback; + + this.alias = $(this.modal.find('#add_alias')); + this.att = $(this.modal.find('#add_att')); + this.email = $(this.modal.find('#add_email')); + this.direccion = $(this.modal.find('#add_direccion')); + this.pais = $(this.modal.find('#add_pais_id')); + this.municipio = $(this.modal.find('#add_municipio')); + this.provincia = $(this.modal.find('#add_provincia')); + this.cp = $(this.modal.find('#add_cp')); + this.telefono = $(this.modal.find('#add_telefono')); + + this.btnCancel = $(this.modal.find('#cancelAdd')); + this.btnSave = $(this.modal.find('#saveAdd')); + + this.error = $(this.modal.find('.texto-error')); + } + + init() { + this.btnCancel.on('click', () => { + + this.modal.modal("hide"); + }); + + this.modal.on('hidden.bs.modal', () => { + this.error.addClass('d-none'); + this.alias.val(""); + this.att.val(""); + this.email.val(""); + this.direccion.val(""); + this.pais.val("").trigger('change'); + this.municipio.val(""); + this.provincia.val(""); + this.cp.val(""); + this.telefono.val(""); + this.btnSave.off('click'); + }); + + this.pais.on('change', () => { + var nombre_pais = $("#add_pais_id option:selected").text().trim(); + if (nombre_pais.localeCompare('España') == 0) { + $('#divPais').removeClass('col-lg-12').addClass('col-lg-6') + $('#divMunicipio').removeClass('col-lg-12').addClass('col-lg-6') + $('.spain-data').css('display', 'inline') + } + else { + $('.spain-data').css('display', 'none') + $('#divPais').removeClass('col-lg-6').addClass('col-lg-12') + $('#divMunicipio').removeClass('col-lg-6').addClass('col-lg-12') + } + }); + + this.btnSave.on('click', () => { + if (this.#validatemodal()) { + this.saveCallback(); + } + else { + $(this.modal.find('.texto-error')).removeClass('d-none'); + } + + }); + + this.modal.modal('show'); + } + + #validatemodal() { + + if(this.alias.val() == "" || this.att.val() == "" || this.direccion.val() == "" || this.municipio.val() == "" || this.cp.val() == "" ){ + return false; + } + if(this.pais.children("option:selected").val() < 1) + return false; + return true; + } + + getData() { + return { + alias: this.alias.val(), + att: this.att.val(), + email: this.email.val(), + direccion: this.direccion.val(), + pais_id: this.pais.children("option:selected").val(), + municipio: this.municipio.val(), + provincia: this.provincia.val(), + cp: this.cp.val(), + telefono: this.telefono.val() + } + } +} + +export default Direccionmodal; \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js index ec9b4079..6a7041b6 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js @@ -1,6 +1,9 @@ import ClassSelect from '../../components/select2.js'; import Ajax from '../../components/ajax.js'; import tarjetaDireccion from '../../components/tarjetaDireccionPresupuesto.js'; +import SelectorTiradaEnvio from './selectorTiradaEnvio.js'; +import DireccionForm from '../../components/modalDireccion.js'; + class Direcciones { @@ -12,11 +15,15 @@ class Direcciones { this.unidadesAdd = this.domItem.find('#unidadesEnvio'); this.btnAdd = this.domItem.find('#insertarDireccion'); + this.btnNew = this.domItem.find('#nuevaDireccion'); this.entregaPieCallero = this.domItem.find('#entregaPieCalle'); - this.direccionesCliente = new ClassSelect($("#direcciones"), '/clientedirecciones/menuitems'); + this.direccionesCliente = new ClassSelect($("#direcciones"), '/misdirecciones/getSelect2'); this.divDirecciones = $(this.domItem.find('#divDirecciones')); + this.divTiradas = this.domItem.find('#containerTiradasEnvios'); + + this.checksTiradasEnvio = $('.tirada-envio'); this.direcciones = []; @@ -31,16 +38,51 @@ class Direcciones { this.direccionesCliente.init(); this.btnAdd.on('click', this.#insertDireccion.bind(this)); + this.btnNew.on('click', this.#nuevaDireccion.bind(this)); } + + initValidation() { const stepper = this.validatorStepper; this.formValidation = FormValidation.formValidation(this.wizardStep, { fields: { + div_error_envios: { + validators: { + callback: { + callback: () => { + const div = $('#divErrorEnvios'); // Selecciona el div + div.find('.fv-plugins-message-container').remove(); + + if ($('.check-tirada-envio:checked').length > 0) { + let unidades = parseInt($($('.check-tirada-envio:checked')[0]).attr('tirada')); + let total_envio = 0; + // se recorre el array this.direcciones + this.direcciones.forEach(direccion => { + total_envio += parseInt(direccion.getUnidades()); + }); + if (total_envio == unidades) { + return true; + } + } + + div.append(` +
+
+ El total de unidades enviadas no se corresponde con las unidades del pedido +
+
+ `); + return false; + }, + } + + } + } }, plugins: { trigger: new FormValidation.plugins.Trigger(), @@ -52,7 +94,7 @@ class Direcciones { // field is the field name // ele is the field element switch (field) { - case ' ': + case 'div_error_envios': return '.col-sm-10'; default: return '.col-sm-3'; @@ -68,24 +110,79 @@ class Direcciones { } - getDirecciones(){ + getDirecciones() { let direcciones = this.divDirecciones.find('.direccion-cliente') - if(direcciones.length > 0){ + if (direcciones.length > 0) { direcciones.forEach(element => { - + }); } } + insertTirada(tirada) { + + const self = this; + + let tarjeta = new SelectorTiradaEnvio(this.divTiradas, 'tiradaEnvios-' + tirada, tirada); + let customOption = tarjeta.card.find('.check-tirada-envio'); + + customOption.on('click', function () { + self.#handleTiradaEnvio(customOption); + }); + } + + + #nuevaDireccion() { + + let dialog = new DireccionForm($("#addressModal"), function () { + try { + let data = dialog.getData(); + data.cliente_id = $("#clienteId").select2('data')[0].id; + + new Ajax( + '/misdirecciones/add', + data, + {}, + () => { dialog.modal.modal('hide') }, + () => { dialog.modal.modal('hide') } + ).post(); + } + catch (e) { + console.error(e); + dialog.modal.modal('hide'); + } + + }); + dialog.init(); + } + + #handleTiradaEnvio(customOption) { + + const el = customOption[0]; + + if (el.checked) { + // If custom option element is radio, remove checked from the siblings (closest `.row`) + if (el.type === 'radio') { + const customRadioOptionList = [].slice.call(el.closest('.row').querySelectorAll('.custom-option')) + customRadioOptionList.map(function (customRadioOptionEL) { + customRadioOptionEL.closest('.custom-option').classList.remove('checked') + }) + } + el.closest('.custom-option').classList.add('checked') + } else { + el.closest('.custom-option').classList.remove('checked') + } + } + #insertDireccion() { self = this; - + try { - let id = this.direccionesCliente.getValue(); + let id = this.direccionesCliente.getVal(); let unidades = this.unidadesAdd.val(); let entregaPalets = this.entregaPieCallero.is(':checked'); let dirId = "dirEnvio-" + id; @@ -111,7 +208,7 @@ class Direcciones { tarjeta.card.find('.direccion-editar').on('click', this.#editUnits.bind(self)); tarjeta.card.find('.direccion-eliminar').on('click', this.#deleteDireccion.bind(self)); this.divDirecciones.append(tarjeta.card); - this.direcciones.push({ "id": id, "unidades": unidades, "enPallets": entregaPalets}); + this.direcciones.push(tarjeta); self.divDirecciones.trigger('change'); $('#loader').hide(); }, @@ -139,7 +236,8 @@ class Direcciones { #editUnits(event) { - let tarjeta = $(event.currentTarget.closest('.direccion-cliente')); + let id = $(event.currentTarget.closest('.direccion-cliente')).id; + let tarjeta = this.direcciones.find(direccion => direccion.id == id).card; let unidades = tarjeta.find('.unidades').text().split(' ')[0]; let modal = $('#modalInput'); @@ -170,7 +268,7 @@ class Direcciones { tarjeta.remove(); this.divDirecciones.trigger('change'); - + this.direcciones = this.direcciones.filter(direccion => direccion.id != id); } } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js index ada4813e..fc41adbc 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js @@ -23,7 +23,7 @@ class DisenioCubierta { this.sinSolapas = this.domItem.find("#solapasCubiertaNo"); this.conSolapas = this.domItem.find("#solapasCubiertaSi"); this.divTamanioSolapas = this.domItem.find("#divTamanioSolapas"); - this.tamanioSolapasCubierta = this.domItem.find("#solapasCubierta"); + this.tamanioSolapasCubierta = $(this.domItem.find("#solapasCubierta")); this.cartulinaEstucada = this.domItem.find("#cartulinaEstucada"); this.estucadoMate = this.domItem.find("#estucadoMate"); @@ -254,10 +254,12 @@ class DisenioCubierta { if (this.solapasCubierta.hasClass("selected").length == 0) return null; else { - if (this.solapasCubierta.hasClass("selected").attr("id") == "solapasCubiertaNo") + if (this.sinSolapas.hasClass("selected")) return false; + else if (this.conSolapas.hasClass("selected")) + return parseInt(this.tamanioSolapasCubierta.val()); else - parseInt(this.tamanioSolapasCubierta.val()); + return null; } } catch (error) { @@ -284,7 +286,7 @@ class DisenioCubierta { try { - if(this.divGramajeCubierta.hasClass("d-none")) + if (this.divGramajeCubierta.hasClass("d-none")) return null; if (this.gramaje.filter(':checked').length > 0) @@ -298,13 +300,26 @@ class DisenioCubierta { } } - getAcabados() { + getAcabados(forResumen = false) { try { let acabados = {}; - acabados.plastificado = this.domItem.find("#plastificado ").children("option:selected").val(); - acabados.barniz = this.domItem.find("#barniz").children("option:selected").val(); - acabados.estampado = this.domItem.find("#estampado").children("option:selected").val(); - acabados.retractilado = this.domItem.find("#retractilado").hasClass('selected') ? true : false; + if (forResumen) { + acabados = 'Plastificado ' + this.domItem.find("#plastificado").children("option:selected").text(); + if (this.domItem.find("#barniz").children("option:selected").val() != 'NONE') + acabados += ", Barniz UVI " + this.domItem.find("#barniz").children("option:selected").text(); + if (this.domItem.find("#estampado").children("option:selected").val() != 'NONE') + acabados += ", Estampado " + this.domItem.find("#estampado").children("option:selected").text(); + if (this.domItem.find("#retractilado").hasClass('selected')) { + acabados += ", Retractilado "; + } + return acabados; + } + else { + acabados.plastificado = this.domItem.find("#plastificado ").children("option:selected").val(); + acabados.barniz = this.domItem.find("#barniz").children("option:selected").val(); + acabados.estampado = this.domItem.find("#estampado").children("option:selected").val(); + acabados.retractilado = this.domItem.find("#retractilado").hasClass('selected') ? true : false; + } return acabados; } catch (e) { return null; @@ -312,20 +327,23 @@ class DisenioCubierta { } - getCabezada() { + getCabezada(forResumen = false) { try { if (this.tapaBlanda.hasClass("selected")) return false; else - return this.domItem.find("#cabezada").children("option:selected").val(); + if (forResumen) + return this.domItem.find("#cabezada").children("option:selected").text(); + else + return this.domItem.find("#cabezada").children("option:selected").val(); } catch (e) { return null; } } - getGuardas() { + getGuardas(forResumen = false) { try { if (this.tapaBlanda.hasClass("selected")) { @@ -333,10 +351,19 @@ class DisenioCubierta { } else { let guardas = {}; - let papelGuardas = this.domItem.find("#papelGuardas").children("option:selected").val(); - guardas.papel = papelGuardas.split('_')[0]; - guardas.gramaje = papelGuardas.split('_')[1]; - guardas.guardasImpresas = this.domItem.find("#guardasImpresas").children("option:selected").val(); + + if (forResumen) { + let papelGuardas = this.domItem.find("#papelGuardas").children("option:selected").text(); + guardas.papel = papelGuardas.split(' ')[0] + ' ' + papelGuardas.split(' ')[1]; + guardas.gramaje = papelGuardas.split(' ')[2]; + guardas.guardasImpresas = this.domItem.find("#guardasImpresas").children("option:selected").text(); + } + else { + let papelGuardas = this.domItem.find("#papelGuardas").children("option:selected").val(); + guardas.papel = papelGuardas.split('_')[0]; + guardas.gramaje = papelGuardas.split('_')[1]; + guardas.guardasImpresas = this.domItem.find("#guardasImpresas").children("option:selected").val(); + } return guardas; } @@ -345,20 +372,30 @@ class DisenioCubierta { } } - getSobrecubierta() { + getSobrecubierta(forResumen = false) { try { if (!this.sobrecubierta.is(":checked")) { return false; } else { - let sobrecubierta = {}; - let papel = this.domItem.find("#papelSobrecubierta").children("option:selected").val(); - sobrecubierta.papel = papel.split('_')[0]; - sobrecubierta.gramaje = papel.split('_')[1]; - sobrecubierta.solapas = this.domItem.find("#solapasSobrecubierta").val(); - sobrecubierta.plastificado = this.domItem.find("#plastificadoSobrecubierta").children("option:selected").val(); - return sobrecubierta; + if (forResumen) { + let sobrecubierta = {}; + const papel = this.domItem.find("#papelSobrecubierta").children("option:selected").text(); + sobrecubierta.papel = papel.split(' ')[0] + ' ' + papel.split(' ')[1]; + sobrecubierta.gramaje = papel.split(' ')[2]; + sobrecubierta.solapas = this.domItem.find("#solapasSobrecubierta").val(); + sobrecubierta.plastificado = 'Plastificado ' + this.domItem.find("#plastificadoSobrecubierta").children("option:selected").text(); + } + else { + let sobrecubierta = {}; + let papel = this.domItem.find("#papelSobrecubierta").children("option:selected").val(); + sobrecubierta.papel = papel.split('_')[0]; + sobrecubierta.gramaje = papel.split('_')[1]; + sobrecubierta.solapas = this.domItem.find("#solapasSobrecubierta").val(); + sobrecubierta.plastificado = this.domItem.find("#plastificadoSobrecubierta").children("option:selected").val(); + return sobrecubierta; + } } } catch (e) { @@ -389,12 +426,12 @@ class DisenioCubierta { } } - #handleCarasCubierta(){ + #handleCarasCubierta() { // Si es a dos caras - if(this.carasCubierta.val() == 4){ + if (this.carasCubierta.val() == 4) { this.cartulinaEstucada.addClass("d-none"); } - else{ + else { this.cartulinaEstucada.removeClass("d-none"); } } @@ -420,7 +457,7 @@ class DisenioCubierta { $(".papel-cubierta").removeClass("selected"); if (this.tapaBlanda.hasClass("selected")) { - if(this.carasCubierta.val() == 2){ + if (this.carasCubierta.val() == 2) { this.cartulinaEstucada.removeClass("d-none"); } this.divGramajeCubierta.addClass("d-none"); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js index 549f272e..866e1f02 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js @@ -318,19 +318,36 @@ class DisenioInterior { } - getPapel() { + getPapel(forResumen = false) { try { if (this.papelInterior.filter('.selected').length > 0) { if (this.papelInterior_color.filter('.selected').length > 0) { - return { - negro: this.papelInterior.filter('.selected').attr('cod'), - color: this.papelInterior_color.filter('.selected').attr('cod') + if(forResumen) + { + return { + negro: $(this.papelInterior.filter('.selected').find('.form-label')).text(), + color: $(this.papelInterior_color.filter('.selected').find('.form-label')).text(), + } + } + else{ + return { + negro: this.papelInterior.filter('.selected').attr('cod'), + color: this.papelInterior_color.filter('.selected').attr('cod') + } + } + + } + if (this.interiorColor.filter('.d-none').length > 0){ + if(forResumen){ + return $(this.papelInterior.filter('.selected').find('.form-label')).text(); + } + else{ + return this.papelInterior.filter('.selected').attr('cod') } } - if (this.interiorColor.filter('.d-none').length > 0) - return this.papelInterior.filter('.selected').attr('cod') + else return null; } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js index 62873e40..8caf20e5 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js @@ -2,6 +2,7 @@ import DatosGenerales from './datosGenerales.js'; import DisenioInterior from './disenioInterior.js'; import DisenioCubierta from './disenioCubierta.js'; import Direcciones from './direcciones.js'; +import Resumen from './resumen.js'; import Ajax from '../../components/ajax.js'; @@ -26,6 +27,7 @@ class PresupuestoCliente { this.disenioInterior = new DisenioInterior($("#interior-libro"), this.clientePresupuestoWizard, this.validationStepper); this.disenioCubierta = new DisenioCubierta($("#cubierta-libro"), this.clientePresupuestoWizard, this.validationStepper); 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"); @@ -34,6 +36,8 @@ class PresupuestoCliente { {}, this.datos, this.#procesarPresupuesto.bind(this), () => { $('#loader').hide(); }); + + this.actualizarTiradasEnvio = false; } @@ -49,7 +53,7 @@ class PresupuestoCliente { document.querySelector('.select2-search__field').focus(); }); - this.validationStepper._element.addEventListener('shown.bs-stepper', this.buttonsHandler.bind(this)); + this.validationStepper._element.addEventListener('shown.bs-stepper', this.stepperHandler.bind(this)); this.datosGenerales.init(); this.disenioInterior.init(); @@ -63,9 +67,27 @@ class PresupuestoCliente { checkForm(event) { + if (event.target.id === 'divDirecciones') { + this.actualizarTiradasEnvio = false; + if(this.direcciones.direcciones.length == 1 && this.direcciones.direcciones[0].getEntregaPalets() == false) { + return; + } + } + else { + this.actualizarTiradasEnvio = true; + this.direcciones.divTiradas.empty(); + } + this.#getDatos(); - if (Object.values(this.datos).every(this.#isValidDataForm)) { + this.divTiradasPrecios.empty(); + + let datos_to_check = this.datos; + if (datos_to_check.direcciones) { + delete datos_to_check.direcciones; + } + + if (Object.values(datos_to_check).every(this.#isValidDataForm)) { try { $('#loader').show(); @@ -97,24 +119,25 @@ class PresupuestoCliente { const newOption2 = new Option("148 x 210", "1", true, true); papelFormatoId.append(newOption2).trigger('change'); + $("#paginasColor").val("6"); $("#paginasColor").trigger('change'); $("#fresado").trigger("click"); - $("#colorEstandar").trigger("click"); + $("#colorPremium").trigger("click"); $("#offsetBlanco").trigger("click"); setTimeout(function () { - $("#gramaje80").trigger("click"); + $("#gramaje90").trigger("click"); }, 0); setTimeout(function () { $("#tapaDura").trigger("click"); }, 0); - /* + setTimeout(function () { $("#btnNext").trigger("click"); }, 0); @@ -127,14 +150,17 @@ class PresupuestoCliente { setTimeout(function () { - $("#unidadesEnvio").val("100"); - }, 0);*/ + $("#unidadesEnvio").val("50"); + }, 0); } - buttonsHandler() { - switch (this.validationStepper._currentIndex + 1) { - case 0: + stepperHandler() { + + const element = $('.fv-plugins-bootstrap5.fv-plugins-framework.active'); + + switch (element.attr('id')) { + case 'datos-generales': this.btnPrev.addClass('d-none'); this.btnNext.removeClass('d-none'); this.btnPrint.addClass('d-none'); @@ -142,13 +168,27 @@ class PresupuestoCliente { this.btnConfirm.addClass('d-none'); break; - case 1: + case 'interior-libro': + case 'cubierta-libro': + case 'direcciones-libro': this.btnPrev.removeClass('d-none'); this.btnNext.removeClass('d-none'); this.btnPrint.addClass('d-none'); this.btnSave.addClass('d-none'); this.btnConfirm.addClass('d-none'); break; + + case 'resumen-libro': + this.btnPrev.removeClass('d-none'); + this.btnNext.addClass('d-none'); + this.btnPrint.removeClass('d-none'); + this.btnSave.removeClass('d-none'); + this.btnConfirm.removeClass('d-none'); + this.resumen.generate(); + break; + + default: + break; } } @@ -166,10 +206,13 @@ class PresupuestoCliente { this.divTiradasPrecios, ('precio-tiradas-' + response.tiradas[i]), response.tiradas[i], - (parseFloat(response.precio_u[i])*parseInt(response.tiradas[i])).toFixed(2), + (parseFloat(response.precio_u[i]) * parseInt(response.tiradas[i])).toFixed(2), response.precio_u[i] ); + if (this.actualizarTiradasEnvio) + this.direcciones.insertTirada(response.tiradas[i]); + } } // DEBUG @@ -204,8 +247,9 @@ class PresupuestoCliente { #prevtStep() { - if (this.validationStepper._currentIndex >= 1 && this.validationStepper._currentIndex <= 4) + if (this.validationStepper._currentIndex >= 1 && this.validationStepper._currentIndex <= 4){ this.validationStepper.previous(); + } } @@ -220,12 +264,12 @@ class PresupuestoCliente { paginas: this.datosGenerales.paginas.val(), paginasColor: this.datosGenerales.paginasColor.val(), paginasCuadernillo: this.datosGenerales.paginasCuadernillo.val(), - papelInteriorDiferente: this.datosGenerales.papelDiferente.is(':checked'); - + papelInteriorDiferente: this.datosGenerales.papelDiferente.is(':checked') ? 1 : 0, + tipo: this.datosGenerales.tiposLibro.filter('.selected').attr('id'), - - isColor: this.datosGenerales.getIsColor(), - isHq: this.disenioInterior.getIsHq(), + + isColor: this.datosGenerales.getIsColor() ? 1 : 0, + isHq: this.disenioInterior.getIsHq() ? 1 : 0, interior: { papelInterior: this.disenioInterior.getPapel(), @@ -245,31 +289,31 @@ class PresupuestoCliente { sobrecubierta: this.disenioCubierta.getSobrecubierta(), faja: this.disenioCubierta.getFaja(), - excluirRotativa: this.datosGenerales.excluirRotativa.is(':checked'), + excluirRotativa: this.datosGenerales.excluirRotativa.is(':checked') ? 1 : 0, ivaReducido: this.datosGenerales.ivaReducido.find('option:selected').val(), servicios: { - 'prototipo' : this.datosGenerales.prototipo.is(':checked'), + 'prototipo': this.datosGenerales.prototipo.is(':checked') ? 1 : 0, }, }; - if(this.datos.tipo == "cosido"){ + if (this.datos.tipo == "cosido") { this.datos.paginasCuadernillo = this.datosGenerales.paginasCuadernillo.val(); } let solapasCubierta = this.disenioCubierta.getSolapasCubierta(); if (solapasCubierta !== null && solapasCubierta !== undefined) { if (solapasCubierta === false) - this.datos.cubierta.solapas = false; + this.datos.cubierta.solapas = 0; else { - this.datos.cubierta.solapas = true; + this.datos.cubierta.solapas = 1; this.datos.cubierta.tamanioSolapas = solapasCubierta; } } - else{ - this.datos.cubierta.solapas = false; + else { + this.datos.cubierta.solapas = 0; } - if(this.direcciones.direcciones.length > 0){ + if (this.direcciones.direcciones.length > 0) { this.datos.direcciones = this.direcciones.direcciones; } } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/resumen.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/resumen.js new file mode 100644 index 00000000..d7f2b5f8 --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/resumen.js @@ -0,0 +1,143 @@ +class Resumen { + constructor(domItem, datosGenerales, disenioInterior, disenioCubierta, direcciones) { + + this.domItem = domItem; + + this.datosGenerales = datosGenerales; + this.disenioInterior = disenioInterior; + this.disenioCubierta = disenioCubierta; + + this.titulo = $(this.domItem.find("#resumenTitulo")); + this.tipoLibro = $(this.domItem.find("#resumenTipoLibro")); + this.formato = $(this.domItem.find("#resumenFormato")); + this.paginas = $(this.domItem.find("#resumenPaginas")); + this.paginasColor = $(this.domItem.find("#resumenPaginasColor")); + this.paginasNegro = $(this.domItem.find("#resumenPaginasNegro")); + this.tirada = $(this.domItem.find("#resumenTirada")); + this.prototipo = $(this.domItem.find("#resumenPrototipo")); + + this.impresionInterior = $(this.domItem.find("#resumenImpresion")); + this.papelInterior = $(this.domItem.find("#resumenPapelInterior")); + this.gramajeInterior = $(this.domItem.find("#resumenGramajeInterior")); + this.papelInteriorColor = $(this.domItem.find("#resumenPapelInteriorColor")); + this.gramajeInteriorColor = $(this.domItem.find("#resumenGramajeInteriorColor")); + this.papelInteriorNegro = $(this.domItem.find("#resumenPapelInteriorNegro")); + this.gramajeInteriorNegro = $(this.domItem.find("#resumenGramajeInteriorNegro")); + + this.cubiertaTipo = $(this.domItem.find("#resumenCubiertaTipo")); + this.itemsCubiertaTapaBlanda = $(this.domItem.find(".cubierta-tapa-blanda")); + this.itemsCubiertaTapaDura = $(this.domItem.find(".cubierta-tapa-dura")); + this.carasCubierta = $(this.domItem.find("#resumenCarasCubierta")); + this.papelCubierta = $(this.domItem.find("#resumenPapelCubierta")); + this.gramajeCubierta = $(this.domItem.find("#resumenGramajeCubierta")); + this.solapasCubierta = $(this.domItem.find("#resumenSolapasCubierta")); + this.papelGuardas = $(this.domItem.find("#resumenPapelGuardas")); + this.guardasImpresas = $(this.domItem.find("#resumenGuardasImpresas")); + this.cabezada = $(this.domItem.find("#resumenCabezada")); + this.cubiertaAcabados = $(this.domItem.find("#resumenCubiertaAcabados")); + + this.divSobrecubierta = $(this.domItem.find("#divResumenSobrecubierta")); + this.papelSobrecubierta = $(this.domItem.find("#resumenPapelSobrecubierta")); + this.gramajeSobrecubierta = $(this.domItem.find("#resumenGramajeSobrecubierta")); + this.solapasSobrecubierta = $(this.domItem.find("#resumenSolapasSobrecubierta")); + this.plastificadoSobrecubierta = $(this.domItem.find("#resumenPlastificadoSobrecubierta")); + + this.precio_unidad = $(this.domItem.find("#resumenPrecioU")); + this.total_base = $(this.domItem.find("#resumenTotalBase")); + this.iva_porcentaje = $(this.domItem.find("#resumenIvaPorcentaje")); + this.iva = $(this.domItem.find("#resumenIva")); + this.total = $(this.domItem.find("#resumenTotal")); + } + + init() { + + } + + generate() { + + this.titulo.text(this.datosGenerales.titulo.val()); + this.tipoLibro.text(this.#capitalizeFirstLetter(this.datosGenerales.tiposLibro.filter('.selected').attr('id'))); + this.formato.text(this.datosGenerales.papelFormatoId.find('option:selected').text()); + this.paginas.text(this.datosGenerales.paginas.val()); + this.paginasColor.text(this.datosGenerales.paginasColor.val()); + this.paginasNegro.text(this.datosGenerales.paginasNegro.val()); + this.tirada.text(parseInt($($('.check-tirada-envio:checked')[0]).attr('tirada'))); + this.prototipo.text(this.datosGenerales.prototipo.is(':checked') ? 'Sí' : 'No'); + + const HQ = this.disenioInterior.getIsHq(); + const color = this.datosGenerales.getIsColor(); + const papelInterior = this.disenioInterior.getPapel(true); + const gramajeInterior = this.disenioInterior.getGramaje(); + if ($(".interior-color").hasClass('d-none')) { + this.domItem.find(".mismoInterior").removeClass('d-none'); + this.domItem.find(".diferenteInterior").addClass('d-none'); + const impInterior = (color ? "Color " : "Blanco y Negro") + (HQ ? "Premium" : "Estándar"); + this.impresionInterior.text(impInterior); + this.papelInterior.text(papelInterior); + this.gramajeInterior.text(gramajeInterior); + } + else { + this.domItem.find(".mismoInterior").addClass('d-none'); + this.domItem.find(".diferenteInterior").removeClass('d-none'); + const impInterior = ("Negro " + (HQ.negro ? "Premium" : "Estándar") + " / Color" + (HQ.color ? "Premium" : "Estándar")); + this.impresionInterior.text(impInterior); + this.papelInteriorNegro.text(papelInterior.negro); + this.papelInteriorColor.text(papelInterior.color); + this.gramajeInteriorNegro.text(gramajeInterior.negro); + this.gramajeInteriorColor.text(gramajeInterior.color); + } + + this.cubiertaTipo.text($($('.tipo-cubierta.selected').find('.form-label')).text()); + this.carasCubierta.text(this.disenioCubierta.carasCubierta.find('option:selected').text()); + if (this.cubiertaTipo.text().toLowerCase().includes('blanda')) { + this.itemsCubiertaTapaBlanda.removeClass('d-none'); + this.itemsCubiertaTapaDura.addClass('d-none'); + const solapasCubierta = this.disenioCubierta.getSolapasCubierta(); + this.solapasCubierta.text( solapasCubierta == false ? 'No' : solapasCubierta); + } + else { + this.itemsCubiertaTapaDura.removeClass('d-none'); + this.itemsCubiertaTapaBlanda.addClass('d-none'); + const guardas = this.disenioCubierta.getGuardas(true); + this.papelGuardas.text(guardas.papel + ' ' + guardas.gramaje); + this.guardasImpresas.text(guardas.guardasImpresas); + this.cabezada.text(this.disenioCubierta.getCabezada(true)); + + } + this.papelCubierta.text($($('.papel-cubierta.selected').find('.form-label')).text()) + this.gramajeCubierta.text(this.disenioCubierta.getGramaje()); + this.cubiertaAcabados.text(this.disenioCubierta.getAcabados(true)); + + if (this.disenioCubierta.getSobrecubierta()) { + this.divSobrecubierta.rempveClass('d-none'); + const sobrecubierta = this.disenioCubierta.getSobrecubierta(true); + this.papelSobrecubierta.text(sobrecubierta.papel); + this.gramajeSobrecubierta.text(sobrecubierta.gramaje); + this.solapasSobrecubierta.text(sobrecubierta.solapas); + this.plastificadoSobrecubierta.text(sobrecubierta.plastificado); + } + else { + this.divSobrecubierta.addClass('d-none'); + } + + const unidades = parseInt($($('.check-tirada-envio:checked')[0]).attr('tirada')); + const tarjetaPrecio = $('.tarjeta-tiradas-precios').filter(function () { + return parseInt($(this).find('.tarjeta-tiradas-precios-tirada').attr('data')) == unidades; + }); + this.precio_unidad.text(tarjetaPrecio.find('.tarjeta-tiradas-precios-precio-unidad').attr('data')); + const base = tarjetaPrecio.find('.tarjeta-tiradas-precios-precio').attr('data'); + const iva_porcentaje = this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? 0.21 : 0.04; + const iva = (parseFloat(base) * iva_porcentaje).toFixed(2); + this.total_base.text(base); + this.iva_porcentaje.text(this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? '21' : '4'); + this.iva.text(iva); + this.total.text((parseFloat(base) + parseFloat(iva)).toFixed(2)); + + } + + #capitalizeFirstLetter(string) { + return string.charAt(0).toUpperCase() + string.slice(1); + } +} + +export default Resumen; \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/selectorTiradaEnvio.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/selectorTiradaEnvio.js index 455a7a95..1ec071c5 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/selectorTiradaEnvio.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/selectorTiradaEnvio.js @@ -1,45 +1,58 @@ class SelectorTiradaEnvio { - constructor(container, id, tirada, precio_u) { + constructor(container, id, tirada) { this.container = container; - this.card = this.#generateHTML(id, tirada, precio_u); + this.tirada = tirada; + this.card = this.#generateHTML(id, tirada); + this.container.append(this.card); } - #generateHTML(id, tirada, precio_u) { + #generateHTML(id, tirada) { - var $div = $('
', { + + var $checkboxContainer = $('
', { + class: 'checkbox-presupuesto-tiradas-envio mb-md-0 mb-3' + }); + + // Crear el segundo div con clase form-check + var $formCheckDiv = $('
', { + class: 'form-check custom-option custom-option-icon tirada-envio' + }); + + // Crear el label + var $label = $('