corregidos permisos borrar en presupuestos

This commit is contained in:
2025-02-18 12:00:44 +01:00
parent 2402ea2835
commit af9986f354
5 changed files with 45 additions and 25 deletions

View File

@ -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",

View File

@ -64,7 +64,9 @@ const actionBtns = function(data) {
<td class="text-right py-0 align-middle">
<div class="btn-group btn-group-sm">
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
<?php if(auth()->user()->can('presupuesto.delete')): ?>
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
<?php endif; ?>
</div>
</td>`;
}
@ -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');

View File

@ -55,7 +55,9 @@ const actionBtns = function(data) {
<td class="text-right py-0 align-middle">
<div class="btn-group btn-group-sm">
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
<?php if(auth()->user()->can('presupuesto.delete')): ?>
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
<?php endif; ?>
</div>
</td>`;
};
@ -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');

View File

@ -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 `
<td class="text-right py-0 align-middle">
<div class="btn-group btn-group-sm">
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
<?php if(auth()->user()->can('presupuesto-cliente.delete')): ?>
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
<?php endif; ?>
</div>
</td>`;
else
}
else{
return `
<td class="text-right py-0 align-middle">
<div class="btn-group btn-group-sm">
<a href="javascript:void(0);"><i class="ti ti-eye ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
</div>
</td>`;
}
};
// 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;
});

View File

@ -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')){
?>
<li class="menu-item">
<a href="javascript:void(0);" class="menu-link menu-toggle">
<i class="menu-icon tf-icons ti ti-currency-dollar"></i>
<?php
echo(
auth()->user()->inGroup('admin') ?
auth()->user()->can('presupuesto.menu') ?
lang("App.menu_presupuestos_clientes") :
lang("App.menu_presupuestos")
);
@ -38,6 +35,6 @@ if (auth()->user()->inGroup('cliente-admin')
</ul>
</li>
<?php
}
} ?>