-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
206 lines (180 loc) · 9.64 KB
/
Copy pathindex.php
File metadata and controls
206 lines (180 loc) · 9.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<?php
session_start();
// Si el usuario no ha iniciado sesión, redirigir a la página de login
if (!isset($_SESSION['user_id'])) {
header("Location: Login/login-bootstrap.php");
exit;
}
// Obtener datos del usuario de la sesión
$user_name = $_SESSION['user_name'] ?? 'Usuario';
$user_lastname = $_SESSION['user_lastname'] ?? 'Invitado';
$user_role = $_SESSION['user_role'] ?? 'N/A';
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard - SoftCall</title>
<link rel="stylesheet" href="styles.css">
<style>
/* Estilos para las pestañas dinámicas (sin cambios) */
.dynamic-tabs-bar { display: none; background-color: #f1f3f4; padding: 5px 5px 0 5px; border-bottom: 1px solid #dcdcdc; }
.dynamic-tab { padding: 8px 12px; cursor: pointer; border: 1px solid #dcdcdc; border-bottom: none; margin-right: 5px; background-color: #e8eaed; border-radius: 5px 5px 0 0; display: flex; align-items: center; font-size: 14px; }
.dynamic-tab.active { background-color: #fff; border-bottom: 1px solid #fff; margin-bottom: -1px; }
.dynamic-tab-content { display: none; height: calc(100vh - 130px); }
.dynamic-tab-content .tab-pane { display: none; height: 100%; }
.dynamic-tab-content .tab-pane.active { display: block; background-color: #fff; }
.tab-pane.has-iframe { padding: 0; }
.tab-pane iframe { border: none; width: 100%; height: 100%; }
.close-tab-btn { margin-left: 10px; cursor: pointer; border: none; background: none; font-weight: bold; font-size: 16px; color: #5f6368; }
.close-tab-btn:hover { color: #000; }
</style>
</head>
<body>
<nav class="google-tabs-nav">
<div class="user-profile-container">
<div class="user-avatar" id="user-avatar">
<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="18" cy="18" r="18" fill="#e3eafc" /><path d="M18 18c2.761 0 5-2.239 5-5s-2.239-5-5-5-5 2.239-5 5 2.239 5 5 5zm0 2c-3.33 0-10 1.667-10 5v2h20v-2c0-3.333-6.67-5-10-5z" fill="#1a73e8" /></svg>
</div>
<div class="user-name-role">
<span id="user-name"><?php echo htmlspecialchars($user_name . ' ' . $user_lastname); ?></span>
<span id="user-role" class="user-role"><?php echo htmlspecialchars($user_role); ?></span>
</div>
</div>
<div class="google-tabs">
<?php if ($user_role === 'Agente'): ?>
<div class="google-tab-dropdown">
<a href="#" class="google-tab active google-submenu-item" data-url="agente/dashboard.html">Mi Dashboard</a>
</div>
<?php endif; ?>
<?php if ($user_role === 'Supervisor' || $user_role === 'Administrador'): ?>
<div class="google-tab-dropdown">
<a href="#" class="google-tab active">Principal</a>
<div class="google-submenu">
<a href="#" class="google-submenu-item" data-url="supervisor/dashboard.html">Dashboard Supervisor</a>
<a href="#" class="google-submenu-item">Estadísticas</a>
</div>
</div>
<?php endif; ?>
<?php if ($user_role === 'Administrador'): ?>
<div class="google-tab-dropdown">
<a href="#" class="google-tab">Usuarios</a>
<div class="google-submenu">
<a href="#" class="google-submenu-item" data-url="usuarios/lista.html">Lista de usuarios</a>
<a href="#" class="google-submenu-item" data-url="usuarios/register.html">Agregar usuario</a>
<a href="#" class="google-submenu-item" data-url="usuarios/bulk_register.html">Carga Masiva de Usuarios</a>
<a href="#" class="google-submenu-item" data-url="usuarios/privilegios.html">Gestionar Privilegios</a>
</div>
</div>
<?php endif; ?>
<?php if ($user_role === 'Supervisor' || $user_role === 'Administrador'): ?>
<div class="google-tab-dropdown">
<a href="#" class="google-tab">Calidad</a>
<div class="google-submenu">
<a href="#" class="google-submenu-item" data-url="matriz/matriz.html">Auditar Llamada</a>
<a href="#" class="google-submenu-item" data-url="matriz/auditorias_rea.html">Auditorías Realizadas</a>
</div>
</div>
<?php endif; ?>
<div class="google-tab-dropdown">
<a href="#" class="google-tab">Mensajes</a>
<div class="google-submenu">
<a href="#" class="google-submenu-item">Bandeja de entrada</a>
<a href="#" class="google-submenu-item">Nuevo mensaje</a>
</div>
</div>
</div>
<button class="logout-btn" title="Cerrar sesión" onclick="window.location.href='logout.php'">
<img src="logout-icon.png.png" alt="Cerrar Sesión" style="height: 40px; width: 40px;">
</button>
</nav>
<div class="login-datetime-container">
<span id="login-datetime"></span>
</div>
<div id="dynamic-tabs-bar" class="dynamic-tabs-bar"></div>
<div id="dynamic-tab-content" class="dynamic-tab-content"></div>
<div class="dashboard-container">
<h1 class="dashboard-title">Bienvenido a SoftCall</h1>
<p>Selecciona una opción del menú para comenzar a trabajar.</p>
</div>
<script>
// Mostrar fecha y hora de inicio de sesión
function pad(n) { return n < 10 ? '0' + n : n; }
const now = new Date();
const fecha = pad(now.getDate()) + '/' + pad(now.getMonth() + 1) + '/' + now.getFullYear();
const hora = pad(now.getHours()) + ':' + pad(now.getMinutes()) + ':' + pad(now.getSeconds());
document.getElementById('login-datetime').textContent = `Sesión iniciada: ${fecha} ${hora}`;
document.addEventListener('DOMContentLoaded', () => {
const submenuItems = document.querySelectorAll('.google-submenu-item');
const tabsBar = document.getElementById('dynamic-tabs-bar');
const tabContentContainer = document.getElementById('dynamic-tab-content');
const mainDashboard = document.querySelector('.dashboard-container');
const openTabs = new Map();
document.querySelector('.logout-btn').addEventListener('click', () => {
if (confirm('¿Estás seguro de que quieres cerrar la sesión?')) {
window.location.href = 'logout.php';
}
});
submenuItems.forEach(item => {
item.addEventListener('click', (e) => {
e.preventDefault();
const url = item.dataset.url;
if (!url) return;
const tabName = item.textContent.trim();
const tabId = 'tab-' + tabName.replace(/\s+/g, '-').toLowerCase();
if (!openTabs.has(tabId)) {
const tabButton = document.createElement('div');
tabButton.className = 'dynamic-tab';
tabButton.dataset.tabId = tabId;
tabButton.innerHTML = `<span>${tabName}</span><button class="close-tab-btn" data-tab-id="${tabId}">×</button>`;
tabsBar.appendChild(tabButton);
const tabPane = document.createElement('div');
tabPane.id = tabId;
tabPane.className = 'tab-pane has-iframe';
tabPane.innerHTML = `<iframe src="${url}"></iframe>`;
tabContentContainer.appendChild(tabPane);
openTabs.set(tabId, { button: tabButton, pane: tabPane });
tabButton.querySelector('.close-tab-btn').addEventListener('click', (ev) => {
ev.stopPropagation();
closeTab(tabId);
});
tabButton.addEventListener('click', () => activateTab(tabId));
}
activateTab(tabId);
});
});
function closeTab(tabId) {
const tab = openTabs.get(tabId);
if (!tab) return;
const wasActive = tab.button.classList.contains('active');
tab.button.remove();
tab.pane.remove();
openTabs.delete(tabId);
if (wasActive && openTabs.size > 0) {
const lastTabId = Array.from(openTabs.keys()).pop();
activateTab(lastTabId);
} else if (openTabs.size === 0) {
mainDashboard.style.display = 'block';
tabsBar.style.display = 'none';
tabContentContainer.style.display = 'none';
}
}
function activateTab(tabId) {
openTabs.forEach(tab => {
tab.button.classList.remove('active');
tab.pane.classList.remove('active');
});
mainDashboard.style.display = 'none';
tabsBar.style.display = 'flex';
tabContentContainer.style.display = 'block';
const tabToActivate = openTabs.get(tabId);
if (tabToActivate) {
tabToActivate.button.classList.add('active');
tabToActivate.pane.classList.add('active');
}
}
});
</script>
</body>
</html>