revert(sidebar): eliminar sub-acordeón — restaurar sidebar y module.php a estado estable
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
f724e2e94c
commit
d6e1d083f4
+47
-50
@@ -1,18 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* Descriptor del módulo Turnero — Oleada 1
|
||||
* Links filtrados por rol con sub-acordeones para recepción y muestras.
|
||||
* Los links visibles se filtran según el rol del usuario.
|
||||
*/
|
||||
|
||||
$_trRole = $_SESSION['admin_user']['role'] ?? 'admin';
|
||||
$_trIsRecep = $_trRole === 'recepcionista';
|
||||
$_trIsBacte = $_trRole === 'bacteriologo';
|
||||
$_trRole = $_SESSION['admin_user']['role'] ?? 'admin';
|
||||
$_trAdminRoles = ['superadmin', 'admin', 'supervisor'];
|
||||
$_trIsAdmin = in_array($_trRole, $_trAdminRoles, true);
|
||||
$_trIsRecep = $_trRole === 'recepcionista';
|
||||
$_trIsBacte = $_trRole === 'bacteriologo';
|
||||
|
||||
try {
|
||||
$_trPdo = Database::getInstance()->getConnection();
|
||||
|
||||
$_trDesks = $_trPdo->query(
|
||||
"SELECT id, nombre FROM turnero_lugares WHERE activo=1 AND tipo='recepcion' ORDER BY sort_order"
|
||||
)->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$_trMuestras = $_trPdo->query(
|
||||
"SELECT id, nombre FROM turnero_lugares WHERE activo=1 AND tipo='muestras' ORDER BY sort_order"
|
||||
)->fetchAll(PDO::FETCH_ASSOC);
|
||||
@@ -21,67 +25,60 @@ try {
|
||||
$_trMuestras = [];
|
||||
}
|
||||
|
||||
// Sub-links de recepción
|
||||
$_trRecepChildren = [];
|
||||
foreach ($_trDesks as $_d) {
|
||||
$_trRecepChildren[] = [
|
||||
'name' => $_d['nombre'],
|
||||
'icon' => 'fas fa-chair',
|
||||
'route' => '/erp.php?m=turnero&v=recepcion&desk_id=' . (int)$_d['id'],
|
||||
];
|
||||
}
|
||||
if (empty($_trRecepChildren)) {
|
||||
$_trRecepChildren[] = ['name' => 'Recepción', 'icon' => 'fas fa-chair', 'route' => '/erp.php?m=turnero&v=recepcion'];
|
||||
}
|
||||
|
||||
// Sub-links de muestras
|
||||
$_trMuestrasChildren = [];
|
||||
foreach ($_trMuestras as $_m) {
|
||||
$_trMuestrasChildren[] = [
|
||||
'name' => $_m['nombre'],
|
||||
'icon' => 'fas fa-flask',
|
||||
'route' => '/erp.php?m=turnero&v=lugar&lugar_id=' . (int)$_m['id'],
|
||||
];
|
||||
}
|
||||
|
||||
$_trLinks = [];
|
||||
|
||||
// ── Recepcionista ─────────────────────────────────────────────
|
||||
// ── Recepcionista: solo sus escritorios + pantalla TV ─────────
|
||||
if ($_trIsRecep) {
|
||||
$_trLinks[] = ['name' => 'Pantalla TV', 'icon' => 'fas fa-tv', 'route' => '/erp.php?m=turnero&v=display_global'];
|
||||
if (count($_trRecepChildren) > 1) {
|
||||
$_trLinks[] = ['name' => 'Recepción', 'icon' => 'fas fa-concierge-bell', 'route' => null, 'children' => $_trRecepChildren];
|
||||
if (!empty($_trDesks)) {
|
||||
foreach ($_trDesks as $_d) {
|
||||
$_trLinks[] = [
|
||||
'name' => $_d['nombre'],
|
||||
'icon' => 'fas fa-concierge-bell',
|
||||
'route' => '/erp.php?m=turnero&v=recepcion&desk_id=' . (int)$_d['id'],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$_trLinks[] = array_merge($_trRecepChildren[0], ['icon' => 'fas fa-concierge-bell']);
|
||||
$_trLinks[] = ['name' => 'Recepción', 'icon' => 'fas fa-concierge-bell', 'route' => '/erp.php?m=turnero&v=recepcion'];
|
||||
}
|
||||
|
||||
// ── Bacteriólogo ──────────────────────────────────────────────
|
||||
// ── Bacteriólogo: dashboard, historial, TV + sus estaciones ──
|
||||
} elseif ($_trIsBacte) {
|
||||
$_trLinks[] = ['name' => 'Dashboard', 'icon' => 'fas fa-tachometer-alt', 'route' => '/erp.php?m=turnero&v=dashboard'];
|
||||
$_trLinks[] = ['name' => 'Historial', 'icon' => 'fas fa-history', 'route' => '/erp.php?m=turnero&v=historial'];
|
||||
$_trLinks[] = ['name' => 'Pantalla TV', 'icon' => 'fas fa-tv', 'route' => '/erp.php?m=turnero&v=display_global'];
|
||||
if (count($_trMuestrasChildren) > 1) {
|
||||
$_trLinks[] = ['name' => 'Estaciones', 'icon' => 'fas fa-flask', 'route' => null, 'children' => $_trMuestrasChildren];
|
||||
} elseif (!empty($_trMuestrasChildren)) {
|
||||
$_trLinks[] = $_trMuestrasChildren[0];
|
||||
foreach ($_trMuestras as $_m) {
|
||||
$_trLinks[] = [
|
||||
'name' => $_m['nombre'],
|
||||
'icon' => 'fas fa-flask',
|
||||
'route' => '/erp.php?m=turnero&v=lugar&lugar_id=' . (int)$_m['id'],
|
||||
];
|
||||
}
|
||||
|
||||
// ── Admin / Supervisor / otros ────────────────────────────────
|
||||
// ── Admin / Supervisor / otros: acceso completo ───────────────
|
||||
} else {
|
||||
$_trLinks[] = ['name' => 'Dashboard', 'icon' => 'fas fa-tachometer-alt', 'route' => '/erp.php?m=turnero&v=dashboard'];
|
||||
$_trLinks[] = ['name' => 'Historial', 'icon' => 'fas fa-history', 'route' => '/erp.php?m=turnero&v=historial'];
|
||||
$_trLinks[] = ['name' => 'Configuración', 'icon' => 'fas fa-sliders-h', 'route' => '/erp.php?m=turnero&v=configuracion'];
|
||||
$_trLinks[] = ['name' => 'Kiosko', 'icon' => 'fas fa-desktop', 'route' => '/erp.php?m=turnero&v=kiosko'];
|
||||
$_trLinks[] = ['name' => 'Pantalla TV', 'icon' => 'fas fa-tv', 'route' => '/erp.php?m=turnero&v=display_global'];
|
||||
if (count($_trRecepChildren) > 1) {
|
||||
$_trLinks[] = ['name' => 'Recepción', 'icon' => 'fas fa-concierge-bell', 'route' => null, 'children' => $_trRecepChildren];
|
||||
} elseif (!empty($_trRecepChildren)) {
|
||||
$_trLinks[] = array_merge($_trRecepChildren[0], ['icon' => 'fas fa-concierge-bell']);
|
||||
$_trLinks[] = ['name' => 'Dashboard', 'icon' => 'fas fa-tachometer-alt', 'route' => '/erp.php?m=turnero&v=dashboard'];
|
||||
$_trLinks[] = ['name' => 'Historial', 'icon' => 'fas fa-history', 'route' => '/erp.php?m=turnero&v=historial'];
|
||||
$_trLinks[] = ['name' => 'Configuración', 'icon' => 'fas fa-sliders-h', 'route' => '/erp.php?m=turnero&v=configuracion'];
|
||||
$_trLinks[] = ['name' => 'Kiosko', 'icon' => 'fas fa-desktop', 'route' => '/erp.php?m=turnero&v=kiosko'];
|
||||
$_trLinks[] = ['name' => 'Pantalla TV Global', 'icon' => 'fas fa-th-large', 'route' => '/erp.php?m=turnero&v=display_global'];
|
||||
if (!empty($_trDesks)) {
|
||||
foreach ($_trDesks as $_d) {
|
||||
$_trLinks[] = [
|
||||
'name' => $_d['nombre'],
|
||||
'icon' => 'fas fa-concierge-bell',
|
||||
'route' => '/erp.php?m=turnero&v=recepcion&desk_id=' . (int)$_d['id'],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$_trLinks[] = ['name' => 'Recepción', 'icon' => 'fas fa-concierge-bell', 'route' => '/erp.php?m=turnero&v=recepcion'];
|
||||
}
|
||||
if (count($_trMuestrasChildren) > 1) {
|
||||
$_trLinks[] = ['name' => 'Estaciones', 'icon' => 'fas fa-flask', 'route' => null, 'children' => $_trMuestrasChildren];
|
||||
} elseif (!empty($_trMuestrasChildren)) {
|
||||
$_trLinks[] = $_trMuestrasChildren[0];
|
||||
foreach ($_trMuestras as $_m) {
|
||||
$_trLinks[] = [
|
||||
'name' => $_m['nombre'],
|
||||
'icon' => 'fas fa-flask',
|
||||
'route' => '/erp.php?m=turnero&v=lugar&lugar_id=' . (int)$_m['id'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -171,43 +171,15 @@ if (class_exists('ModuleRegistry', false)) {
|
||||
<?php foreach ($catData['modules'] as $slug => $mod):
|
||||
$links = $mod['links'] ?? [];
|
||||
if (!empty($links)):
|
||||
foreach ($links as $lnkIdx => $lnk):
|
||||
$children = $lnk['children'] ?? [];
|
||||
if (!empty($children)):
|
||||
// Sub-acordeón para links con hijos
|
||||
$subId = $catId . '-sub-' . $slug . '-' . $lnkIdx;
|
||||
$hasActive = false;
|
||||
foreach ($children as $ch) { if ($_isActive($ch['route']) !== '') { $hasActive = true; break; } }
|
||||
?>
|
||||
<li class="sb-sub-header<?= $hasActive ? ' has-active' : '' ?>"
|
||||
onclick="sbToggleSub('<?= $subId ?>',this,event)">
|
||||
<i class="<?= htmlspecialchars($lnk['icon'], ENT_QUOTES, 'UTF-8') ?>"></i>
|
||||
<span><?= htmlspecialchars($lnk['name'], ENT_QUOTES, 'UTF-8') ?></span>
|
||||
<i class="fas fa-chevron-down sb-sub-chev"></i>
|
||||
</li>
|
||||
<li class="sb-sub-group<?= $hasActive ? '' : ' collapsed' ?>" id="<?= $subId ?>">
|
||||
<ul>
|
||||
<?php foreach ($children as $ch):
|
||||
$href = $_base . $ch['route'];
|
||||
$active = $_isActive($ch['route']);
|
||||
?>
|
||||
<li><a href="<?= htmlspecialchars($href, ENT_QUOTES, 'UTF-8') ?>"
|
||||
class="nav-link nav-link-sub<?= $active ?>">
|
||||
<i class="<?= htmlspecialchars($ch['icon'], ENT_QUOTES, 'UTF-8') ?>"></i>
|
||||
<?= htmlspecialchars($ch['name'], ENT_QUOTES, 'UTF-8') ?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php else:
|
||||
$href = $_base . ($lnk['route'] ?? '');
|
||||
$active = isset($lnk['route']) ? $_isActive($lnk['route']) : '';
|
||||
foreach ($links as $lnk):
|
||||
$href = $_base . $lnk['route'];
|
||||
$active = $_isActive($lnk['route']);
|
||||
?>
|
||||
<li><a href="<?= htmlspecialchars($href, ENT_QUOTES, 'UTF-8') ?>"
|
||||
class="nav-link<?= $active ?>">
|
||||
<i class="<?= htmlspecialchars($lnk['icon'], ENT_QUOTES, 'UTF-8') ?>"></i>
|
||||
<?= htmlspecialchars($lnk['name'], ENT_QUOTES, 'UTF-8') ?></a></li>
|
||||
<?php endif;
|
||||
endforeach;
|
||||
<?php endforeach;
|
||||
else:
|
||||
$route = $mod['route'] ?? '';
|
||||
$href = $route ? $_base . $route : '#';
|
||||
@@ -382,25 +354,6 @@ if (class_exists('ModuleRegistry', false)) {
|
||||
.sb-group { overflow: hidden; transition: max-height .28s ease, opacity .2s ease; }
|
||||
.sb-group > ul { list-style: none; padding: 0 0 4px; margin: 0; }
|
||||
.sb-group.collapsed { max-height: 0 !important; opacity: 0; pointer-events: none; }
|
||||
|
||||
/* Sub-acordeón dentro de un módulo */
|
||||
.sb-sub-header {
|
||||
display: flex; align-items: center; gap: 8px;
|
||||
padding: 7px 16px 7px 20px;
|
||||
cursor: pointer; user-select: none;
|
||||
color: rgba(255,255,255,.75);
|
||||
font-size: .84rem;
|
||||
border-radius: 6px; margin: 1px 6px;
|
||||
transition: background .15s, color .15s;
|
||||
}
|
||||
.sb-sub-header:hover, .sb-sub-header.has-active { color: #fff; background: rgba(255,255,255,.1); }
|
||||
.sb-sub-header span { flex: 1; }
|
||||
.sb-sub-chev { font-size: .6rem; opacity: .7; transition: transform .22s ease; flex-shrink: 0; }
|
||||
.sb-sub-header.collapsed .sb-sub-chev { transform: rotate(-90deg); }
|
||||
.sb-sub-group { overflow: hidden; transition: max-height .25s ease, opacity .2s ease; }
|
||||
.sb-sub-group > ul { list-style: none; padding: 0; margin: 0; }
|
||||
.sb-sub-group.collapsed { max-height: 0 !important; opacity: 0; pointer-events: none; }
|
||||
.nav-link-sub { padding-left: 36px !important; font-size: .82rem !important; }
|
||||
</style>
|
||||
|
||||
<script>
|
||||
@@ -427,28 +380,6 @@ if (class_exists('ModuleRegistry', false)) {
|
||||
}
|
||||
}
|
||||
|
||||
window.sbToggleSub = function(subId, headerEl, ev) {
|
||||
if (ev) { ev.preventDefault(); ev.stopPropagation(); }
|
||||
var group = document.getElementById(subId);
|
||||
if (!group) return;
|
||||
var collapsed = group.classList.contains('collapsed');
|
||||
if (collapsed) {
|
||||
group.classList.remove('collapsed');
|
||||
group.style.maxHeight = group.scrollHeight + 'px';
|
||||
group.style.opacity = '1';
|
||||
headerEl.classList.remove('collapsed');
|
||||
} else {
|
||||
group.style.maxHeight = group.scrollHeight + 'px';
|
||||
group.style.opacity = '1';
|
||||
requestAnimationFrame(function(){
|
||||
group.classList.add('collapsed');
|
||||
headerEl.classList.add('collapsed');
|
||||
group.style.maxHeight = '0';
|
||||
group.style.opacity = '0';
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
window.sbToggleCat = function(catId, sectionEl, ev) {
|
||||
if (ev) { ev.preventDefault(); ev.stopPropagation(); }
|
||||
var nav = document.getElementById('erp-sidebar');
|
||||
@@ -535,14 +466,6 @@ if (class_exists('ModuleRegistry', false)) {
|
||||
style.textContent = '.sb-group { transition: none !important; }';
|
||||
document.head.appendChild(style);
|
||||
|
||||
// Inicializar sub-grupos
|
||||
document.querySelectorAll('.sb-sub-group').forEach(function(sg) {
|
||||
if (!sg.classList.contains('collapsed')) {
|
||||
sg.style.maxHeight = sg.scrollHeight + 'px';
|
||||
sg.style.opacity = '1';
|
||||
}
|
||||
});
|
||||
|
||||
document.querySelectorAll('.sb-group').forEach(function(group) {
|
||||
var catId = group.id;
|
||||
var section = document.querySelector('[data-cat="' + catId + '"]');
|
||||
|
||||
Reference in New Issue
Block a user