From af9986f354211068198e8eee42304c7c170b322d Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Tue, 18 Feb 2025 12:00:44 +0100 Subject: [PATCH] corregidos permisos borrar en presupuestos --- ci4/app/Config/RBAC/permissionMatrix.php | 27 ++++++++++++++----- .../admin/viewPresupuestoAdminList.php | 6 +++-- .../buscador/viewBuscadorList.php | 12 +++++---- .../cliente/viewPresupuestoList.php | 14 ++++++---- .../main/menus/presupuesto_cliente_menu.php | 11 +++----- 5 files changed, 45 insertions(+), 25 deletions(-) diff --git a/ci4/app/Config/RBAC/permissionMatrix.php b/ci4/app/Config/RBAC/permissionMatrix.php index c13aa388..ce466841 100644 --- a/ci4/app/Config/RBAC/permissionMatrix.php +++ b/ci4/app/Config/RBAC/permissionMatrix.php @@ -45,10 +45,6 @@ const SK_PERMISSION_MATRIX = [ "tarifa-encuadernacion.edit", "tarifa-encuadernacion.delete", "tarifa-encuadernacion.menu", - "tarifa-extra.create", - "tarifa-extra.edit", - "tarifa-extra.delete", - "tarifa-extra.menu", "tarifa-envio.create", "tarifa-envio.edit", "tarifa-envio.delete", @@ -122,8 +118,27 @@ const SK_PERMISSION_MATRIX = [ "pedidos-todos.menu", ], "comercial" => [ - "token.token", - "token.menu", + "clientes.create", + "clientes.edit", + "clientes.menu", + "direcciones.create", + "direcciones.edit", + "direcciones.menu", + "presupuesto.create", + "presupuesto.edit", + "presupuesto.delete", + "presupuesto.menu", + "presupuesto-cliente.create", + "presupuesto-cliente.edit", + "presupuesto-cliente.menu", + "pedidos-activos.view", + "pedidos-activos.menu", + "pedidos-finalizados.view", + "pedidos-finalizados.menu", + "pedidos-cancelados.view", + "pedidos-cancelados.menu", + "pedidos-todos.view", + "pedidos-todos.menu", ], "produccion" => [ "clientes.create", diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoAdminList.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoAdminList.php index 40f409b5..37de7959 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoAdminList.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoAdminList.php @@ -64,7 +64,9 @@ const actionBtns = function(data) {
- + user()->can('presupuesto.delete')): ?> + +
`; } @@ -240,7 +242,7 @@ $(document).on('click', '.btn-remove', function(e) { const row = $(this).closest('tr'); if ($.isNumeric(dataId)) { $.ajax({ - url: `/presupuestoadmin/delete/${dataId}`, + url: `/presupuestos/presupuestocliente/delete/${dataId}`, method: 'GET', }).done((data, textStatus, jqXHR) => { $('#confirm2delete').modal('toggle'); diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/buscador/viewBuscadorList.php b/ci4/app/Views/themes/vuexy/form/presupuestos/buscador/viewBuscadorList.php index 51e70074..56b9a9ef 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/buscador/viewBuscadorList.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/buscador/viewBuscadorList.php @@ -55,7 +55,9 @@ const actionBtns = function(data) {
- + user()->can('presupuesto.delete')): ?> + +
`; }; @@ -287,13 +289,13 @@ $(document).on('click', '.btn-edit', function(e) { window.location.href = `/presupuestoadmin/edit/${$(this).attr('data-id')}/`; }); -theTable.on('click', 'tr', function () { - var data = theTable.row(this).data(); - console.log(data); +theTable.on('click', 'tbody td:not(:last-child)', function () { + var data = theTable.row($(this).closest('tr')).data(); var url = '/presupuestoadmin/edit/' + data['id']; window.location.href = url; }); + $(document).on('click', '.btn-delete', function(e) { $(".btn-remove").attr('data-id', $(this).attr('data-id')); }); @@ -304,7 +306,7 @@ $(document).on('click', '.btn-remove', function(e) { const row = $(this).closest('tr'); if ($.isNumeric(dataId)) { $.ajax({ - url: `/presupuestoadmin/delete/${dataId}`, + url: `/presupuestos/presupuestocliente/delete/${dataId}`, method: 'GET', }).done((data, textStatus, jqXHR) => { $('#confirm2delete').modal('toggle'); diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoList.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoList.php index 21629292..907bd706 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoList.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/viewPresupuestoList.php @@ -50,21 +50,25 @@ const lastColNr = $('#tableOfPresupuestos').find("tr:first th").length - 1; const actionBtns = function(data) { - if(data.estado == 'borrador') + if(data.estado == 'borrador'){ return `
- + user()->can('presupuesto-cliente.delete')): ?> + +
`; - else + } + else{ return `
`; + } }; // Setup - add a text input to each footer cell @@ -292,8 +296,8 @@ theTable = $('#tableOfPresupuestos').DataTable({ ] }); -theTable.on('click', 'tr', function () { - var data = theTable.row(this).data(); +theTable.on('click', 'tbody td:not(:last-child)', function () { + var data = theTable.row($(this).closest('tr')).data(); var url = '/presupuestos/presupuestocliente/edit/' + data['id']; window.location.href = url; }); diff --git a/ci4/app/Views/themes/vuexy/main/menus/presupuesto_cliente_menu.php b/ci4/app/Views/themes/vuexy/main/menus/presupuesto_cliente_menu.php index 4b367bfc..d5bb0e8d 100644 --- a/ci4/app/Views/themes/vuexy/main/menus/presupuesto_cliente_menu.php +++ b/ci4/app/Views/themes/vuexy/main/menus/presupuesto_cliente_menu.php @@ -2,19 +2,16 @@ /** * MENU PRESUPUESTOS VISTA CLIENTES */ -if (auth()->user()->inGroup('cliente-admin') - || auth()->user()->inGroup('cliente-editor') - || auth()->user()->inGroup('admin') -) { - if (auth()->user()->can('presupuesto-cliente.menu') || auth()->user()->inGroup('admin')) { + if(auth()->user()->can('presupuesto-cliente.menu')){ + ?>