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 e69de29b..e22083d0 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 @@ -0,0 +1,55 @@ +
+ +
+
+
+ +
+

Direcciones de envío

+
+ +
+ +
+
+ +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ +
+ +
+
+
+ + +
+
+
+ +
+ +
+
+ +
\ No newline at end of file diff --git a/httpdocs/assets/js/safekat/components/select2.js b/httpdocs/assets/js/safekat/components/select2.js index 8a9ed414..5ae55954 100644 --- a/httpdocs/assets/js/safekat/components/select2.js +++ b/httpdocs/assets/js/safekat/components/select2.js @@ -1,12 +1,13 @@ class ClassSelect2 { - constructor(domItem, url, placeholder = "", delay = 60, text_field = 'nombre', id_field = 'id') { + constructor(domItem, url, placeholder = "", delay = 60, text_field = 'nombre', id_field = 'id', params={}) { this.domItem = domItem; this.url = url; this.placeholder = placeholder; this.delay = delay; this.text_field = text_field; this.id_field = id_field; + this.params = params; } init() { @@ -20,11 +21,17 @@ class ClassSelect2 { dataType: 'json', data: (params) => { - return { + let d = { id: this.id_field, text: this.text_field, searchTerm: params.term, }; + + for (let key in this.params) { + d[key] = this.params[key]; + } + + return d; }, delay: this.delay, processResults: function (response) { @@ -38,6 +45,10 @@ class ClassSelect2 { }); } + setParams(params) { + this.params = params; + } + // Método para obtener el valor seleccionado getValue() { return this.domItem.val(); @@ -48,6 +59,10 @@ class ClassSelect2 { this.domItem.val(value).trigger('change'); } + clear() { + this.domItem.val(null).trigger('change'); + } + // Método para oculatar el select2 hide() { this.domItem.select2('close'); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js new file mode 100644 index 00000000..7ffb7b50 --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/direcciones.js @@ -0,0 +1,68 @@ +import ClassSelect from '../../components/select2.js'; + +class Direcciones { + + constructor(domItem, wizardForm, validatorStepper) { + + this.domItem = domItem; + this.wizardStep = wizardForm.querySelector('#direcciones-libro'); + this.validatorStepper = validatorStepper; + + this.direcciones = new ClassSelect($("#direcciones"), '/clientedirecciones/menuitems'); + + this.initValidation(); + + } + + + init() { + + $("#clienteId").on('change', this.#handleChangeCliente.bind(this)); + + this.direcciones.init(); + } + + + initValidation() { + + const stepper = this.validatorStepper; + + this.formValidation = FormValidation.formValidation(this.wizardStep, { + fields: { + + }, + plugins: { + trigger: new FormValidation.plugins.Trigger(), + bootstrap5: new FormValidation.plugins.Bootstrap5({ + // Use this for enabling/changing valid/invalid class + // eleInvalidClass: '', + eleValidClass: '', + rowSelector: function (field, ele) { + // field is the field name + // ele is the field element + switch (field) { + case ' ': + return '.col-sm-10'; + default: + return '.col-sm-3'; + } + } + }), + autoFocus: new FormValidation.plugins.AutoFocus(), + submitButton: new FormValidation.plugins.SubmitButton() + } + }).on('core.form.valid', () => { + stepper.next(); + }); + } + + + #handleChangeCliente() { + this.direcciones.setParams({ 'cliente_id': $("#clienteId").select2('data')[0].id }) + this.direcciones.clear(); + // falta quitar las direcciones que haya!!!! + } +} + + +export default Direcciones; \ 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 07c8c969..f87320f7 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js @@ -1,6 +1,7 @@ import DatosGenerales from './datosGenerales.js'; import DisenioInterior from './disenioInterior.js'; import DisenioCubierta from './disenioCubierta.js'; +import Direcciones from './direcciones.js'; import Ajax from '../../components/ajax.js'; class PresupuestoCliente { @@ -21,6 +22,7 @@ class PresupuestoCliente { this.datosGenerales = new DatosGenerales($("#datos-generales"), this.clientePresupuestoWizard, this.validationStepper); 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); } @@ -39,6 +41,7 @@ class PresupuestoCliente { this.datosGenerales.init(); this.disenioInterior.init(); this.disenioCubierta.init(); + this.direcciones.init(); this.RELLENAR_PRESUPUESTO(); @@ -51,14 +54,14 @@ class PresupuestoCliente { $("#titulo").trigger('change'); const clienteId = $("#clienteId"); - const newOption = new Option("Cliente Potencial", "1", true, true); + const newOption = new Option("Cliente Potencial", "1817", true, true); clienteId.append(newOption).trigger('change'); const papelFormatoId = $("#papelFormatoId"); const newOption2 = new Option("Formato 1", "1", true, true); papelFormatoId.append(newOption2).trigger('change'); - $("#paginasColor").val("5"); + $("#paginasColor").val("6"); $("#paginasColor").trigger('change'); $("#fresado").trigger("click"); @@ -70,6 +73,10 @@ class PresupuestoCliente { setTimeout(function() { $("#gramaje80").trigger("click"); }, 0); + + setTimeout(function() { + $("#tapaDura").trigger("click"); + }, 0); }