From 0862128f604d921de09bed85ae58be79f5ac5c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Sun, 17 Nov 2024 21:05:37 +0100 Subject: [PATCH] =?UTF-8?q?a=C3=B1adido=20el=20fichero=20de=20nullable=20p?= =?UTF-8?q?ara=20la=20tabla=20clientes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...-194547_ModifyNullableComercialSoporte.php | 37 +++++++++++ .../js/safekat/pages/cliente/cliente.js | 66 +++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 ci4/app/Database/Migrations/2024-11-17-194547_ModifyNullableComercialSoporte.php create mode 100644 httpdocs/assets/js/safekat/pages/cliente/cliente.js diff --git a/ci4/app/Database/Migrations/2024-11-17-194547_ModifyNullableComercialSoporte.php b/ci4/app/Database/Migrations/2024-11-17-194547_ModifyNullableComercialSoporte.php new file mode 100644 index 00000000..0805fcf0 --- /dev/null +++ b/ci4/app/Database/Migrations/2024-11-17-194547_ModifyNullableComercialSoporte.php @@ -0,0 +1,37 @@ +forge->modifyColumn('clientes', [ + 'comercial_id' => [ + 'type' => 'int(10) unsigned', + 'null' => true, // Permitir valores NULL + ], + 'soporte_id' => [ + 'type' => 'int(10) unsigned', + 'null' => true, // Permitir valores NULL + ], + ]); + + } + + public function down() + { + $this->forge->modifyColumn('clientes', [ + 'comercial_id' => [ + 'type' => 'int(10) unsigned', + 'null' => false, + ], + 'soporte_id' => [ + 'type' => 'int(10) unsigned', + 'null' => false, + ], + ]); + } +} diff --git a/httpdocs/assets/js/safekat/pages/cliente/cliente.js b/httpdocs/assets/js/safekat/pages/cliente/cliente.js new file mode 100644 index 00000000..fabbe83f --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/cliente/cliente.js @@ -0,0 +1,66 @@ +import ClassSelect from '../../components/select2.js'; + +class Cliente { + + constructor() { + + this.csrf_token = this.getToken(); + this.csrf_hash = $('#clienteForm').find('input[name="' + this.csrf_token + '"]').val(); + + this.pais = new ClassSelect($("#paisId"), '/paises/menuitems2', "Seleccione un país", {[this.csrf_token]: this.csrf_hash}); + this.soporte = new ClassSelect($("#soporteId"), '/users/getMenuComerciales', "Seleccione un usuario", {[this.csrf_token]: this.csrf_hash}); + this.comercial = new ClassSelect($("#comercialId"), '/users/getMenuComerciales', "Seleccione un usuario", {[this.csrf_token]: this.csrf_hash}); + this.formaPago = new ClassSelect($("#formaPagoId"), '/formas-pago/menuitems', "Seleccione una forma de pago", {[this.csrf_token]: this.csrf_hash}); + this.provincia = new ClassSelect($("#provinciaId"), '/provincias/menuitems2', "Seleccione una provincia", {[this.csrf_token]: this.csrf_hash}); + this.comunidadAutonoma = new ClassSelect($("#comunidadAutonomaId"), '/comunidades-autonomas/menuitems2', "Seleccione una comunidad autónoma", {[this.csrf_token]: this.csrf_hash}); + + this.init(); + } + + init() { + + // Fuerza el foco en el campo de búsqueda de select2 + $(document).on('select2:open', () => { + document.querySelector('.select2-search__field').focus(); + }); + + this.pais.init(); + this.soporte.init(); + this.comercial.init(); + this.formaPago.init(); + this.provincia.init(); + this.comunidadAutonoma.init(); + + $(document).keypress(function (e) { + var key = e.which; + if (key == 13) // the enter key code + { + e.preventDefault() + if ($('#addressForm').hasClass('show')) { + $("#saveAdd").click(); + } + else if ($('#convert2Template').hasClass('show')) { + $("#saveTemplate").click(); + } + else { + $('#saveForm').click(); + } + } + }); + + } + + getToken(){ + + const scriptUrl = new URL(import.meta.url); + const params = new URLSearchParams(scriptUrl.search); + + const paramsObject = Object.fromEntries(params.entries()); + return paramsObject.token; + } +} + + +document.addEventListener('DOMContentLoaded', function () { + new Cliente().init(); +}); \ No newline at end of file