From 2f2d20604bd5fddc3238186d98c9952d3fafc1e6 Mon Sep 17 00:00:00 2001 From: Soporte ZH Consultores Date: Thu, 4 Jun 2026 20:17:10 -0500 Subject: [PATCH] =?UTF-8?q?feat(tramites):=20involucrados=20pueden=20edita?= =?UTF-8?q?r=20y=20eliminar=20horas=20tambi=C3=A9n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Antes solo el autor original de la entrada (o un Socio/Admin) podía editar/eliminar registros de horas. Ahora cualquiera con acceso al trámite (creador, abogado solicitante, involucrado, socio, admin) puede editar/eliminar horas de cualquier entrada — útil cuando un involucrado nota un error en una hora registrada por otro. * tramites/api.php: removido el check (autor_email == me OR isSocio) de update_hours y delete_hours. canView() sigue siendo el único gate, lo cual es consistente con add_hours. * tramites.html: los botones ✎ y ✕ ahora siempre se muestran en cada entrada de horas. El backend protege la operación. --- public/tramites/api.php | 9 +++------ views/tramites.html | 13 ++++++------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/public/tramites/api.php b/public/tramites/api.php index aa7be47..ee95b1b 100644 --- a/public/tramites/api.php +++ b/public/tramites/api.php @@ -369,9 +369,8 @@ try { $tramiteId = (int)$row['tramite_id']; if (!canView($pdo, $tramiteId)) err('No tienes acceso al trámite', 403); - if (!Auth::isSocio() && $row['autor_email'] !== $user['email']) { - err('Solo quien registró las horas (o un Socio/Admin) puede editarlas', 403); - } + // Cualquiera que pueda ver el trámite (creador, abogado solicitante, + // involucrado, o socio/admin) puede editar las horas registradas. $abog = trim((string)($b['abogado'] ?? $row['abogado'])); $hrs = (float) ($b['hrs'] ?? $row['hrs']); @@ -400,9 +399,7 @@ try { $tramiteId = (int)$row['tramite_id']; if (!canView($pdo, $tramiteId)) err('No tienes acceso al trámite', 403); - if (!Auth::isSocio() && $row['autor_email'] !== $user['email']) { - err('Solo quien registró las horas (o un Socio/Admin) puede eliminarlas', 403); - } + // Misma regla que update_hours: cualquiera con acceso al trámite puede eliminar. $pdo->prepare('DELETE FROM tramites_hours WHERE id = :id')->execute([':id' => $hourId]); $pdo->prepare('UPDATE tramites_legales SET actualizado_por = :u WHERE id = :id') diff --git a/views/tramites.html b/views/tramites.html index e974449..c271306 100644 --- a/views/tramites.html +++ b/views/tramites.html @@ -538,14 +538,13 @@ function buildDetail(dept,r){ const obs=(r.obs||[]).map(o=>`
  • ${esc(o.texto)}
    ${esc(o.abogado)} · ${esc(o.fecha)}${o.autor_email?` · ${esc(o.autor_email.split('@')[0])}`:''}
  • `).join(''); const lastUpd=r.obs&&r.obs.length?`
    Última actualización: ${esc(r.obs[r.obs.length-1].fecha)}
    `:''; + // Cualquiera que pueda ver este trámite puede editar/eliminar horas + // (la API valida lo mismo: canView del trámite). const hrs=(r.hours||[]).map(h => { - const canEditHr = IS_SOCIO || h.autor_email === MY_EMAIL; - const actions = canEditHr - ? ` - - - ` - : ''; + const actions = ` + + + `; return `
  • ${esc(h.abogado)} ${fmtHours(h.hrs)} · ${esc(h.fecha)}${actions}