Autosave: 20260804-180124

This commit is contained in:
Flatlogic Bot 2026-08-04 17:59:42 +00:00
parent 9a2a8b59ef
commit dea09b02d8
5 changed files with 564 additions and 9 deletions

View File

@ -1084,6 +1084,10 @@ $callCenterBaseParams = [
if ($kpiPeriodCustomDateInput !== '') {
$callCenterBaseParams['kpi_date'] = $kpiPeriodCustomDateInput;
}
$callCenterDatabaseParams = $callCenterBaseParams;
if ($isAdmin) {
$callCenterDatabaseParams['view'] = 'todos';
}
$callCenterParams = $callCenterBaseParams;
if ($selectedAssessorFilter !== '') {
$callCenterParams['assessor'] = $selectedAssessorFilter;
@ -1132,6 +1136,11 @@ require_once 'layout_header.php';
line-height: 1.15;
}
.cc-callcenter-row-timer {
font-size: .78rem;
line-height: 1;
}
.cc-callcenter-table {
min-width: 1600px;
}
@ -1298,6 +1307,21 @@ require_once 'layout_header.php';
font-size: .78rem;
white-space: nowrap;
}
.cc-callcenter-modal-timer {
min-width: 6.5rem;
white-space: nowrap;
font-variant-numeric: tabular-nums;
letter-spacing: .02em;
justify-content: center;
}
.cc-callcenter-modal-timer.is-running {
background: rgba(var(--bs-primary-rgb), 0.10) !important;
border-color: rgba(var(--bs-primary-rgb), 0.22) !important;
color: var(--bs-primary-text-emphasis) !important;
}
</style>
<main class="container-fluid py-4" data-cc-panel-root="1">
@ -1307,7 +1331,7 @@ require_once 'layout_header.php';
<h1 class="h2 fw-bold mb-1"><i class="bi bi-headset text-primary"></i> <?php echo htmlspecialchars($callCenterSectionLabel); ?></h1>
<div class="d-flex flex-wrap gap-2 mt-3">
<?php if ($isAdmin): ?>
<a href="<?php echo htmlspecialchars(cc_test_build_url('gestiones_callcenter.php', $callCenterBaseParams)); ?>" class="btn btn-sm btn-outline-primary">Base de Datos Pedidos</a>
<a href="<?php echo htmlspecialchars(cc_test_build_url('gestiones_callcenter.php', $callCenterDatabaseParams)); ?>" class="btn btn-sm btn-outline-primary">Base de Datos Pedidos</a>
<?php endif; ?>
<a href="<?php echo htmlspecialchars(cc_test_build_url('call_center_pro.php', $callCenterParams)); ?>" class="btn btn-sm btn-primary"><?php echo htmlspecialchars($callCenterSectionLabel); ?></a>
</div>
@ -1575,6 +1599,9 @@ require_once 'layout_header.php';
<tr class="cc-callcenter-row" data-source-key="<?php echo htmlspecialchars($order['source_key']); ?>" style="<?php echo htmlspecialchars($rowBackgroundStyle); ?>">
<td>
<div class="badge bg-light text-dark border mb-2 text-nowrap" title="ID del pedido"><?php echo htmlspecialchars(cc_test_order_label($order)); ?></div>
<div class="badge rounded-pill bg-info-subtle text-info-emphasis border mb-2 text-nowrap d-inline-flex align-items-center gap-1 cc-callcenter-row-timer js-cc-callcenter-modal-timer d-none" data-source-key="<?php echo htmlspecialchars($order['source_key']); ?>" aria-live="polite" title="Tiempo acumulado del pedido">
<span class="me-1" aria-hidden="true" style="font-size: 0.95em; line-height: 1;"></span><span class="js-cc-callcenter-modal-timer-value">00:00</span>
</div>
<?php if ($followupDayInfo !== null): ?>
<div class="cc-followup-day-badge <?php echo htmlspecialchars($followupDayInfo['badge_class']); ?>" title="<?php echo htmlspecialchars($followupDayInfo['description']); ?>" aria-label="<?php echo htmlspecialchars($followupDayInfo['display_label']); ?>">
<span class="cc-followup-day-badge-label">DÍA</span>
@ -1743,7 +1770,7 @@ require_once 'layout_header.php';
<?php $rowHtml = ob_get_clean(); echo $rowHtml; ?>
<?php ob_start(); ?>
<div class="modal fade" id="<?php echo htmlspecialchars($modalId); ?>" tabindex="-1" aria-hidden="true" data-bs-backdrop="static" data-bs-keyboard="false">
<div class="modal fade" id="<?php echo htmlspecialchars($modalId); ?>" tabindex="-1" aria-hidden="true" data-bs-backdrop="static" data-bs-keyboard="false" data-source-key="<?php echo htmlspecialchars($order['source_key']); ?>">
<div class="modal-dialog modal-xl modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header align-items-start gap-2">
@ -1809,7 +1836,14 @@ require_once 'layout_header.php';
<div class="<?php echo htmlspecialchars($subirLogisticaNoteClass); ?>" id="subir-logistica-note-<?php echo htmlspecialchars($order['source_key']); ?>" role="alert"><?php echo $subirLogisticaNoteHtml; ?></div>
<?php endif; ?>
</div>
<button type="button" class="btn-close mt-1" data-bs-dismiss="modal" aria-label="Cerrar"></button>
<div class="d-flex flex-column align-items-end gap-2 flex-shrink-0">
<span class="badge rounded-pill bg-light text-body-emphasis border shadow-sm d-inline-flex align-items-center cc-callcenter-modal-timer js-cc-callcenter-modal-timer" data-source-key="<?php echo htmlspecialchars($order['source_key']); ?>" aria-live="polite">
<span class="me-1" aria-hidden="true" style="font-size: 0.95em; line-height: 1;"></span><span class="js-cc-callcenter-modal-timer-value">00:00</span>
</span>
<button type="button" class="btn-close mt-1" data-bs-dismiss="modal" aria-label="Cerrar"></button>
</div>
</div>
<div class="modal-body">
<div class="border border-primary-subtle rounded-4 bg-primary-subtle p-2 mb-3 sticky-top shadow-sm" id="airDroidModalCard-<?php echo htmlspecialchars($order['source_key']); ?>">
@ -2305,6 +2339,245 @@ const ccCallCenterPanelRefreshMs = 300000;
let ccCallCenterPanelRefreshInFlight = false;
let ccCallCenterPanelLastSignature = ccCallCenterPanelInitialSignature;
const ccCallCenterTimerStorageKey = 'cc-callcenter-modal-timers:v1';
const ccCallCenterTimerModalPrefix = 'modalDriveTest';
let ccCallCenterTimerTotals = ccCallCenterTimerReadTotals();
let ccCallCenterTimerRunningSince = {};
let ccCallCenterTimerTickHandle = null;
function ccCallCenterTimerReadTotals() {
try {
const raw = window.localStorage.getItem(ccCallCenterTimerStorageKey);
if (!raw) {
return {};
}
const parsed = JSON.parse(raw);
if (!parsed || typeof parsed !== 'object') {
return {};
}
const cleaned = {};
Object.keys(parsed).forEach(function (sourceKey) {
const numericTotal = Number(parsed[sourceKey]);
if (sourceKey && Number.isFinite(numericTotal) && numericTotal >= 0) {
cleaned[sourceKey] = Math.floor(numericTotal);
}
});
return cleaned;
} catch (error) {
return {};
}
}
function ccCallCenterTimerWriteTotals() {
try {
window.localStorage.setItem(ccCallCenterTimerStorageKey, JSON.stringify(ccCallCenterTimerTotals));
} catch (error) {
// Si el navegador bloquea localStorage, el contador sigue funcionando en esta sesión.
}
}
function ccCallCenterTimerGetTotal(sourceKey) {
const numericTotal = Number(ccCallCenterTimerTotals[sourceKey] || 0);
return Number.isFinite(numericTotal) && numericTotal > 0 ? Math.floor(numericTotal) : 0;
}
function ccCallCenterTimerSetTotal(sourceKey, totalMs) {
if (!sourceKey) {
return;
}
ccCallCenterTimerTotals[sourceKey] = Math.max(0, Math.floor(Number(totalMs) || 0));
ccCallCenterTimerWriteTotals();
}
function ccCallCenterTimerFormat(totalMs) {
const totalSeconds = Math.max(0, Math.floor(Number(totalMs) / 1000));
const hours = Math.floor(totalSeconds / 3600);
const minutes = Math.floor((totalSeconds % 3600) / 60);
const seconds = totalSeconds % 60;
const paddedMinutes = String(minutes).padStart(2, '0');
const paddedSeconds = String(seconds).padStart(2, '0');
if (hours > 0) {
return String(hours) + ':' + paddedMinutes + ':' + paddedSeconds;
}
return paddedMinutes + ':' + paddedSeconds;
}
function ccCallCenterTimerResolveSourceKey(modalElement) {
if (!modalElement) {
return '';
}
const explicitSourceKey = String(modalElement.dataset?.sourceKey || '').trim();
if (explicitSourceKey !== '') {
return explicitSourceKey;
}
const modalId = String(modalElement.id || '').trim();
if (modalId.startsWith(ccCallCenterTimerModalPrefix)) {
return modalId.slice(ccCallCenterTimerModalPrefix.length);
}
return '';
}
function ccCallCenterTimerStopTicker() {
if (ccCallCenterTimerTickHandle !== null) {
window.clearInterval(ccCallCenterTimerTickHandle);
ccCallCenterTimerTickHandle = null;
}
}
function ccCallCenterTimerRenderSource(sourceKey) {
if (!sourceKey) {
return;
}
const nodes = document.querySelectorAll('.js-cc-callcenter-modal-timer[data-source-key="' + sourceKey + '"]');
if (!nodes.length) {
return;
}
const runningSince = ccCallCenterTimerRunningSince[sourceKey] || null;
const totalMs = ccCallCenterTimerGetTotal(sourceKey) + (runningSince ? (Date.now() - runningSince) : 0);
const label = ccCallCenterTimerFormat(totalMs);
const ariaLabel = (runningSince ? 'Tiempo abierto' : 'Tiempo acumulado') + ': ' + label;
nodes.forEach(function (node) {
const valueNode = node.querySelector('.js-cc-callcenter-modal-timer-value');
if (valueNode) {
valueNode.textContent = label;
} else {
node.textContent = label;
}
node.classList.toggle('is-running', !!runningSince);
node.classList.toggle('d-none', node.classList.contains('cc-callcenter-row-timer') && !runningSince && totalMs <= 0);
node.setAttribute('aria-label', ariaLabel);
node.setAttribute('title', ariaLabel);
});
}
function ccCallCenterTimerRenderAll() {
const sourceKeys = new Set();
document.querySelectorAll('.js-cc-callcenter-modal-timer').forEach(function (node) {
const sourceKey = String(node.dataset.sourceKey || '').trim();
if (sourceKey !== '') {
sourceKeys.add(sourceKey);
}
});
Object.keys(ccCallCenterTimerRunningSince).forEach(function (sourceKey) {
if (sourceKey) {
sourceKeys.add(sourceKey);
}
});
sourceKeys.forEach(function (sourceKey) {
ccCallCenterTimerRenderSource(sourceKey);
});
}
function ccCallCenterTimerEnsureTicker() {
if (ccCallCenterTimerTickHandle !== null) {
return;
}
ccCallCenterTimerTickHandle = window.setInterval(function () {
const runningKeys = Object.keys(ccCallCenterTimerRunningSince);
if (!runningKeys.length) {
ccCallCenterTimerStopTicker();
return;
}
runningKeys.forEach(function (sourceKey) {
if (ccCallCenterTimerRunningSince[sourceKey]) {
ccCallCenterTimerRenderSource(sourceKey);
}
});
}, 1000);
}
function ccCallCenterTimerStart(sourceKey) {
if (!sourceKey) {
return;
}
if (!ccCallCenterTimerRunningSince[sourceKey]) {
ccCallCenterTimerRunningSince[sourceKey] = Date.now();
}
ccCallCenterTimerRenderSource(sourceKey);
ccCallCenterTimerEnsureTicker();
}
function ccCallCenterTimerStop(sourceKey) {
if (!sourceKey) {
return;
}
const startedAt = ccCallCenterTimerRunningSince[sourceKey];
if (startedAt) {
const elapsed = Date.now() - startedAt;
ccCallCenterTimerSetTotal(sourceKey, ccCallCenterTimerGetTotal(sourceKey) + elapsed);
delete ccCallCenterTimerRunningSince[sourceKey];
}
ccCallCenterTimerRenderSource(sourceKey);
if (!Object.keys(ccCallCenterTimerRunningSince).length) {
ccCallCenterTimerStopTicker();
}
}
function ccCallCenterTimerFlushRunningTimers() {
Object.keys(ccCallCenterTimerRunningSince).forEach(function (sourceKey) {
const startedAt = ccCallCenterTimerRunningSince[sourceKey];
if (startedAt) {
const elapsed = Date.now() - startedAt;
ccCallCenterTimerSetTotal(sourceKey, ccCallCenterTimerGetTotal(sourceKey) + elapsed);
}
delete ccCallCenterTimerRunningSince[sourceKey];
});
ccCallCenterTimerStopTicker();
ccCallCenterTimerRenderAll();
}
function ccCallCenterTimerBindEvents() {
document.addEventListener('shown.bs.modal', function (event) {
const sourceKey = ccCallCenterTimerResolveSourceKey(event.target);
if (sourceKey) {
ccCallCenterTimerStart(sourceKey);
}
});
document.addEventListener('hidden.bs.modal', function (event) {
const sourceKey = ccCallCenterTimerResolveSourceKey(event.target);
if (sourceKey) {
ccCallCenterTimerStop(sourceKey);
}
});
window.addEventListener('beforeunload', ccCallCenterTimerFlushRunningTimers);
window.addEventListener('pagehide', ccCallCenterTimerFlushRunningTimers);
window.addEventListener('pageshow', ccCallCenterTimerRenderAll);
window.addEventListener('storage', function (event) {
if (event.key === ccCallCenterTimerStorageKey) {
ccCallCenterTimerTotals = ccCallCenterTimerReadTotals();
ccCallCenterTimerRenderAll();
}
});
}
ccCallCenterTimerBindEvents();
ccCallCenterTimerRenderAll();
function getLocationControls(sourceKey) {
return {
department: document.getElementById('sede-' + sourceKey),

View File

@ -213,7 +213,8 @@ function cc_test_followup_semaforo(array $order): ?array
return cc_test_account_followup_semaforo($order['numero_cuenta_enviado_at'] ?? null);
}
$view = $_GET['view'] ?? 'pendientes_hoy';
$defaultView = 'todos';
$view = trim((string) ($_GET['view'] ?? $defaultView));
$storeKey = trim((string) ($_GET['store'] ?? 'flower'));
$storeKey = mb_strtolower($storeKey);
@ -335,8 +336,11 @@ $allowedViews = [];
foreach ($viewCards as $viewKey => $cardConfig) {
$allowedViews[$viewKey] = $cardConfig['heading'];
}
if ($view === '') {
$view = $defaultView;
}
if (!isset($allowedViews[$view])) {
$view = array_key_first($allowedViews) ?: 'pendientes_hoy';
$view = isset($allowedViews[$defaultView]) ? $defaultView : (array_key_first($allowedViews) ?: $defaultView);
}
$_SESSION[cc_test_callcenter_store_session_key()] = cc_test_normalize_context_key($storeKey);
@ -1273,6 +1277,11 @@ require_once 'layout_header.php';
line-height: 1.15;
}
.cc-callcenter-row-timer {
font-size: .78rem;
line-height: 1;
}
.cc-callcenter-row.is-selected td:first-child {
box-shadow: inset 4px 0 0 #0d6efd;
}
@ -1554,6 +1563,21 @@ require_once 'layout_header.php';
padding-bottom: .42rem;
}
}
.cc-callcenter-modal-timer {
min-width: 6.5rem;
white-space: nowrap;
font-variant-numeric: tabular-nums;
letter-spacing: .02em;
justify-content: center;
}
.cc-callcenter-modal-timer.is-running {
background: rgba(var(--bs-primary-rgb), 0.10) !important;
border-color: rgba(var(--bs-primary-rgb), 0.22) !important;
color: var(--bs-primary-text-emphasis) !important;
}
</style>
<main class="container-fluid py-4">
@ -1984,6 +2008,9 @@ require_once 'layout_header.php';
<tr class="cc-callcenter-row" data-source-key="<?php echo htmlspecialchars($order['source_key']); ?>" style="<?php echo htmlspecialchars(cc_test_row_background_style((string) ($order['estado'] ?? 'POR LLAMAR')) . (!empty($order['pedido_repetido_en_tienda']) ? '--cc-row-bg:#CCCCCC;' : '')); ?>">
<td class="text-center">
<div class="badge bg-light text-dark border mb-2 text-nowrap" title="ID del pedido"><?php echo htmlspecialchars(cc_test_order_label($order)); ?></div>
<div class="badge rounded-pill bg-info-subtle text-info-emphasis border mb-2 text-nowrap d-inline-flex align-items-center gap-1 cc-callcenter-row-timer js-cc-callcenter-modal-timer d-none" data-source-key="<?php echo htmlspecialchars($order['source_key']); ?>" aria-live="polite" title="Tiempo acumulado del pedido">
<span class="me-1" aria-hidden="true" style="font-size: 0.95em; line-height: 1;"></span><span class="js-cc-callcenter-modal-timer-value">00:00</span>
</div>
<div class="d-flex justify-content-center">
<button
@ -2201,7 +2228,7 @@ require_once 'layout_header.php';
<?php $rowHtml = ob_get_clean(); echo $rowHtml; ?>
<?php ob_start(); ?>
<div class="modal fade" id="<?php echo htmlspecialchars($modalId); ?>" tabindex="-1" aria-hidden="true" data-bs-backdrop="static" data-bs-keyboard="false">
<div class="modal fade" id="<?php echo htmlspecialchars($modalId); ?>" tabindex="-1" aria-hidden="true" data-bs-backdrop="static" data-bs-keyboard="false" data-source-key="<?php echo htmlspecialchars($order['source_key']); ?>">
<div class="modal-dialog modal-xl modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header align-items-start gap-2">
@ -2267,7 +2294,14 @@ require_once 'layout_header.php';
<div class="<?php echo htmlspecialchars($subirLogisticaNoteClass); ?>" id="subir-logistica-note-<?php echo htmlspecialchars($order['source_key']); ?>" role="alert"><?php echo $subirLogisticaNoteHtml; ?></div>
<?php endif; ?>
</div>
<button type="button" class="btn-close mt-1" data-bs-dismiss="modal" aria-label="Cerrar"></button>
<div class="d-flex flex-column align-items-end gap-2 flex-shrink-0">
<span class="badge rounded-pill bg-light text-body-emphasis border shadow-sm d-inline-flex align-items-center cc-callcenter-modal-timer js-cc-callcenter-modal-timer" data-source-key="<?php echo htmlspecialchars($order['source_key']); ?>" aria-live="polite">
<span class="me-1" aria-hidden="true" style="font-size: 0.95em; line-height: 1;"></span><span class="js-cc-callcenter-modal-timer-value">00:00</span>
</span>
<button type="button" class="btn-close mt-1" data-bs-dismiss="modal" aria-label="Cerrar"></button>
</div>
</div>
<div class="modal-body">
<div class="border border-primary-subtle rounded-4 bg-primary-subtle p-2 mb-3 sticky-top shadow-sm" id="airDroidModalCard-<?php echo htmlspecialchars($order['source_key']); ?>">
@ -2803,6 +2837,245 @@ const provinciasPorDepartamento = <?php echo json_encode($provinciasPorDepartame
const distritosPorProvincia = <?php echo json_encode($distritosPorProvinciaContraentrega, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>;
const ccAssessorCatalog = <?php echo json_encode($assessorUiCatalog, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>;
const ccCallCenterTimerStorageKey = 'cc-callcenter-modal-timers:v1';
const ccCallCenterTimerModalPrefix = 'modalDriveTest';
let ccCallCenterTimerTotals = ccCallCenterTimerReadTotals();
let ccCallCenterTimerRunningSince = {};
let ccCallCenterTimerTickHandle = null;
function ccCallCenterTimerReadTotals() {
try {
const raw = window.localStorage.getItem(ccCallCenterTimerStorageKey);
if (!raw) {
return {};
}
const parsed = JSON.parse(raw);
if (!parsed || typeof parsed !== 'object') {
return {};
}
const cleaned = {};
Object.keys(parsed).forEach(function (sourceKey) {
const numericTotal = Number(parsed[sourceKey]);
if (sourceKey && Number.isFinite(numericTotal) && numericTotal >= 0) {
cleaned[sourceKey] = Math.floor(numericTotal);
}
});
return cleaned;
} catch (error) {
return {};
}
}
function ccCallCenterTimerWriteTotals() {
try {
window.localStorage.setItem(ccCallCenterTimerStorageKey, JSON.stringify(ccCallCenterTimerTotals));
} catch (error) {
// Si el navegador bloquea localStorage, el contador sigue funcionando en esta sesión.
}
}
function ccCallCenterTimerGetTotal(sourceKey) {
const numericTotal = Number(ccCallCenterTimerTotals[sourceKey] || 0);
return Number.isFinite(numericTotal) && numericTotal > 0 ? Math.floor(numericTotal) : 0;
}
function ccCallCenterTimerSetTotal(sourceKey, totalMs) {
if (!sourceKey) {
return;
}
ccCallCenterTimerTotals[sourceKey] = Math.max(0, Math.floor(Number(totalMs) || 0));
ccCallCenterTimerWriteTotals();
}
function ccCallCenterTimerFormat(totalMs) {
const totalSeconds = Math.max(0, Math.floor(Number(totalMs) / 1000));
const hours = Math.floor(totalSeconds / 3600);
const minutes = Math.floor((totalSeconds % 3600) / 60);
const seconds = totalSeconds % 60;
const paddedMinutes = String(minutes).padStart(2, '0');
const paddedSeconds = String(seconds).padStart(2, '0');
if (hours > 0) {
return String(hours) + ':' + paddedMinutes + ':' + paddedSeconds;
}
return paddedMinutes + ':' + paddedSeconds;
}
function ccCallCenterTimerResolveSourceKey(modalElement) {
if (!modalElement) {
return '';
}
const explicitSourceKey = String(modalElement.dataset?.sourceKey || '').trim();
if (explicitSourceKey !== '') {
return explicitSourceKey;
}
const modalId = String(modalElement.id || '').trim();
if (modalId.startsWith(ccCallCenterTimerModalPrefix)) {
return modalId.slice(ccCallCenterTimerModalPrefix.length);
}
return '';
}
function ccCallCenterTimerStopTicker() {
if (ccCallCenterTimerTickHandle !== null) {
window.clearInterval(ccCallCenterTimerTickHandle);
ccCallCenterTimerTickHandle = null;
}
}
function ccCallCenterTimerRenderSource(sourceKey) {
if (!sourceKey) {
return;
}
const nodes = document.querySelectorAll('.js-cc-callcenter-modal-timer[data-source-key="' + sourceKey + '"]');
if (!nodes.length) {
return;
}
const runningSince = ccCallCenterTimerRunningSince[sourceKey] || null;
const totalMs = ccCallCenterTimerGetTotal(sourceKey) + (runningSince ? (Date.now() - runningSince) : 0);
const label = ccCallCenterTimerFormat(totalMs);
const ariaLabel = (runningSince ? 'Tiempo abierto' : 'Tiempo acumulado') + ': ' + label;
nodes.forEach(function (node) {
const valueNode = node.querySelector('.js-cc-callcenter-modal-timer-value');
if (valueNode) {
valueNode.textContent = label;
} else {
node.textContent = label;
}
node.classList.toggle('is-running', !!runningSince);
node.classList.toggle('d-none', node.classList.contains('cc-callcenter-row-timer') && !runningSince && totalMs <= 0);
node.setAttribute('aria-label', ariaLabel);
node.setAttribute('title', ariaLabel);
});
}
function ccCallCenterTimerRenderAll() {
const sourceKeys = new Set();
document.querySelectorAll('.js-cc-callcenter-modal-timer').forEach(function (node) {
const sourceKey = String(node.dataset.sourceKey || '').trim();
if (sourceKey !== '') {
sourceKeys.add(sourceKey);
}
});
Object.keys(ccCallCenterTimerRunningSince).forEach(function (sourceKey) {
if (sourceKey) {
sourceKeys.add(sourceKey);
}
});
sourceKeys.forEach(function (sourceKey) {
ccCallCenterTimerRenderSource(sourceKey);
});
}
function ccCallCenterTimerEnsureTicker() {
if (ccCallCenterTimerTickHandle !== null) {
return;
}
ccCallCenterTimerTickHandle = window.setInterval(function () {
const runningKeys = Object.keys(ccCallCenterTimerRunningSince);
if (!runningKeys.length) {
ccCallCenterTimerStopTicker();
return;
}
runningKeys.forEach(function (sourceKey) {
if (ccCallCenterTimerRunningSince[sourceKey]) {
ccCallCenterTimerRenderSource(sourceKey);
}
});
}, 1000);
}
function ccCallCenterTimerStart(sourceKey) {
if (!sourceKey) {
return;
}
if (!ccCallCenterTimerRunningSince[sourceKey]) {
ccCallCenterTimerRunningSince[sourceKey] = Date.now();
}
ccCallCenterTimerRenderSource(sourceKey);
ccCallCenterTimerEnsureTicker();
}
function ccCallCenterTimerStop(sourceKey) {
if (!sourceKey) {
return;
}
const startedAt = ccCallCenterTimerRunningSince[sourceKey];
if (startedAt) {
const elapsed = Date.now() - startedAt;
ccCallCenterTimerSetTotal(sourceKey, ccCallCenterTimerGetTotal(sourceKey) + elapsed);
delete ccCallCenterTimerRunningSince[sourceKey];
}
ccCallCenterTimerRenderSource(sourceKey);
if (!Object.keys(ccCallCenterTimerRunningSince).length) {
ccCallCenterTimerStopTicker();
}
}
function ccCallCenterTimerFlushRunningTimers() {
Object.keys(ccCallCenterTimerRunningSince).forEach(function (sourceKey) {
const startedAt = ccCallCenterTimerRunningSince[sourceKey];
if (startedAt) {
const elapsed = Date.now() - startedAt;
ccCallCenterTimerSetTotal(sourceKey, ccCallCenterTimerGetTotal(sourceKey) + elapsed);
}
delete ccCallCenterTimerRunningSince[sourceKey];
});
ccCallCenterTimerStopTicker();
ccCallCenterTimerRenderAll();
}
function ccCallCenterTimerBindEvents() {
document.addEventListener('shown.bs.modal', function (event) {
const sourceKey = ccCallCenterTimerResolveSourceKey(event.target);
if (sourceKey) {
ccCallCenterTimerStart(sourceKey);
}
});
document.addEventListener('hidden.bs.modal', function (event) {
const sourceKey = ccCallCenterTimerResolveSourceKey(event.target);
if (sourceKey) {
ccCallCenterTimerStop(sourceKey);
}
});
window.addEventListener('beforeunload', ccCallCenterTimerFlushRunningTimers);
window.addEventListener('pagehide', ccCallCenterTimerFlushRunningTimers);
window.addEventListener('pageshow', ccCallCenterTimerRenderAll);
window.addEventListener('storage', function (event) {
if (event.key === ccCallCenterTimerStorageKey) {
ccCallCenterTimerTotals = ccCallCenterTimerReadTotals();
ccCallCenterTimerRenderAll();
}
});
}
ccCallCenterTimerBindEvents();
ccCallCenterTimerRenderAll();
function getLocationControls(sourceKey) {
return {
department: document.getElementById('sede-' + sourceKey),

View File

@ -24,6 +24,9 @@ foreach ([
$callCenterParams[$paramKey] = (string) $_SESSION[$sessionKey];
}
}
if (in_array($userRole, ['Administrador', 'admin'], true)) {
$callCenterParams['view'] = 'todos';
}
$callCenterUrl = 'gestiones_callcenter.php';
if (!empty($callCenterParams)) {
$callCenterUrl .= '?' . http_build_query($callCenterParams);

View File

@ -14,6 +14,7 @@ require_once __DIR__ . '/db/config.php';
require_once __DIR__ . '/includes/callcenter_test_helpers.php';
$userRole = $_SESSION['user_role'] ?? '';
$isAdmin = in_array($userRole, ['Administrador', 'admin'], true);
$currentPage = basename($_SERVER['PHP_SELF']);
$isMarketingUser = strcasecmp(trim((string) $userRole), 'Marketing') === 0;
if ($isMarketingUser && $currentPage !== 'marketing_produccion.php') {
@ -57,7 +58,7 @@ if ($currentCallCenterView !== '') {
$callCenterPersistentParams['view'] = $currentCallCenterView;
}
$callCenterProDefaultView = ($currentCallCenterStore !== '' && cc_test_is_tuani_main_store_key($currentCallCenterStore)) ? 'ultimos_3_dias' : '';
$appendCallCenterParams = static function (string $url) use ($callCenterPersistentParams, $callCenterProDefaultView): string {
$appendCallCenterParams = static function (string $url) use ($callCenterPersistentParams, $callCenterProDefaultView, $isAdmin): string {
if (empty($callCenterPersistentParams)) {
return $url;
}
@ -67,7 +68,9 @@ $appendCallCenterParams = static function (string $url) use ($callCenterPersiste
}
$params = $callCenterPersistentParams;
if ($url === 'call_center_pro.php' && $callCenterProDefaultView !== '') {
if ($url === 'gestiones_callcenter.php' && $isAdmin) {
$params['view'] = 'todos';
} elseif ($url === 'call_center_pro.php' && $callCenterProDefaultView !== '') {
$params['view'] = $callCenterProDefaultView;
}

View File

@ -50,6 +50,9 @@ foreach ([
$callCenterParams[$paramKey] = (string) $_SESSION[$sessionKey];
}
}
if (in_array((string) ($_SESSION['user_role'] ?? ''), ['Administrador', 'admin'], true)) {
$callCenterParams['view'] = 'todos';
}
$callCenterUrl = 'gestiones_callcenter.php';
if (!empty($callCenterParams)) {
$callCenterUrl .= '?' . http_build_query($callCenterParams);