Autosave: 20260708-233731
This commit is contained in:
parent
31e763bfe7
commit
36dde6307a
@ -146,7 +146,7 @@ $orders = [];
|
|||||||
$visibleOrders = [];
|
$visibleOrders = [];
|
||||||
$modalsHtml = [];
|
$modalsHtml = [];
|
||||||
$totalRows = 0;
|
$totalRows = 0;
|
||||||
$loadLimit = 20;
|
$loadLimit = $storeKey === 'otra_tienda' ? 0 : 100;
|
||||||
$startRow = (int) ($storeConfig['startRow'] ?? 5552);
|
$startRow = (int) ($storeConfig['startRow'] ?? 5552);
|
||||||
$catalogoProductos = [];
|
$catalogoProductos = [];
|
||||||
$stats = [
|
$stats = [
|
||||||
|
|||||||
@ -39,11 +39,23 @@ function getStatusStyle($status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getPendientesStyle($pendientes) {
|
function getPendientesStyle($pendientes) {
|
||||||
if ($pendientes === 'PENDIENTE') return 'background-color: #ffc107; color: black;'; // Warning yellow
|
$v = strtoupper(trim((string)$pendientes));
|
||||||
if ($pendientes === 'GESTIONADO') return 'background-color: #198754; color: white;'; // Success green
|
if ($v === 'PENDIENTE') return 'background-color: #ffc107; color: black;'; // Warning yellow
|
||||||
|
if ($v === 'GESTIONADO') return 'background-color: #198754; color: white;'; // Success green
|
||||||
return 'background-color: #6c757d; color: white;'; // Secondary grey
|
return 'background-color: #6c757d; color: white;'; // Secondary grey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatPendientesLabel($pendientes) {
|
||||||
|
$raw = (string)$pendientes;
|
||||||
|
$v = strtoupper(trim($raw));
|
||||||
|
|
||||||
|
if ($v === 'PENDIENTE') return 'PENDIENTE A GESTIONAR';
|
||||||
|
if ($v === 'GESTIONADO') return 'GESTIONADO';
|
||||||
|
if ($v === '') return 'Seleccionar';
|
||||||
|
|
||||||
|
return $raw;
|
||||||
|
}
|
||||||
|
|
||||||
$pdo = db();
|
$pdo = db();
|
||||||
|
|
||||||
$user_id = $_SESSION['user_id'];
|
$user_id = $_SESSION['user_id'];
|
||||||
@ -203,7 +215,7 @@ include 'layout_header.php';
|
|||||||
</td>
|
</td>
|
||||||
<td class="editable-pendientes" data-id="<?php echo $pedido['id']; ?>" data-value="<?php echo htmlspecialchars($pedido['pendientes'] ?? ''); ?>" style="cursor: pointer;">
|
<td class="editable-pendientes" data-id="<?php echo $pedido['id']; ?>" data-value="<?php echo htmlspecialchars($pedido['pendientes'] ?? ''); ?>" style="cursor: pointer;">
|
||||||
<span class="badge" style="<?php echo getPendientesStyle($pedido['pendientes'] ?? ''); ?>">
|
<span class="badge" style="<?php echo getPendientesStyle($pedido['pendientes'] ?? ''); ?>">
|
||||||
<?php echo htmlspecialchars(!empty($pedido['pendientes']) ? $pedido['pendientes'] : 'Seleccionar'); ?>
|
<?php echo htmlspecialchars(formatPendientesLabel($pedido['pendientes'] ?? '')); ?>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td><span class="badge" style="<?php echo getStatusStyle($pedido['estado']); ?>"><?php echo htmlspecialchars($pedido['estado']); ?></span></td>
|
<td><span class="badge" style="<?php echo getStatusStyle($pedido['estado']); ?>"><?php echo htmlspecialchars($pedido['estado']); ?></span></td>
|
||||||
@ -251,11 +263,19 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function getPendientesStyleJS(pendientes) {
|
function getPendientesStyleJS(pendientes) {
|
||||||
if (pendientes === 'PENDIENTE') return 'background-color: #ffc107; color: black;';
|
const v = (pendientes || '').toString().toUpperCase().trim();
|
||||||
if (pendientes === 'GESTIONADO') return 'background-color: #198754; color: white;';
|
if (v === 'PENDIENTE') return 'background-color: #ffc107; color: black;';
|
||||||
|
if (v === 'GESTIONADO') return 'background-color: #198754; color: white;';
|
||||||
return 'background-color: #6c757d; color: white;';
|
return 'background-color: #6c757d; color: white;';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatPendientesLabelJS(value) {
|
||||||
|
const v = (value || '').toString().toUpperCase().trim();
|
||||||
|
if (!v) return 'Seleccionar';
|
||||||
|
if (v === 'PENDIENTE') return 'PENDIENTE A GESTIONAR';
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
const table = document.querySelector('.table');
|
const table = document.querySelector('.table');
|
||||||
|
|
||||||
@ -274,7 +294,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
|
|
||||||
const options = [
|
const options = [
|
||||||
{val: '', text: 'Seleccionar'},
|
{val: '', text: 'Seleccionar'},
|
||||||
{val: 'PENDIENTE', text: 'PENDIENTE'},
|
{val: 'PENDIENTE', text: 'PENDIENTE A GESTIONAR'},
|
||||||
{val: 'GESTIONADO', text: 'GESTIONADO'}
|
{val: 'GESTIONADO', text: 'GESTIONADO'}
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -298,7 +318,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
|
|
||||||
// Optimistic update
|
// Optimistic update
|
||||||
cell.dataset.value = newVal;
|
cell.dataset.value = newVal;
|
||||||
cell.innerHTML = `<span class="badge" style="${getPendientesStyleJS(newVal)}">${newVal || 'Seleccionar'}</span>`;
|
cell.innerHTML = `<span class="badge" style="${getPendientesStyleJS(newVal)}">${formatPendientesLabelJS(newVal)}</span>`;
|
||||||
|
|
||||||
if (newVal === currentVal) return; // No change
|
if (newVal === currentVal) return; // No change
|
||||||
|
|
||||||
|
|||||||
@ -35,11 +35,23 @@ function getStatusStyle($status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getPendientesStyle($pendientes) {
|
function getPendientesStyle($pendientes) {
|
||||||
if ($pendientes === 'PENDIENTE') return 'background-color: #ffc107; color: black;'; // Warning yellow
|
$v = strtoupper(trim((string)$pendientes));
|
||||||
if ($pendientes === 'GESTIONADO') return 'background-color: #198754; color: white;'; // Success green
|
if ($v === 'PENDIENTE') return 'background-color: #ffc107; color: black;'; // Warning yellow
|
||||||
|
if ($v === 'GESTIONADO') return 'background-color: #198754; color: white;'; // Success green
|
||||||
return 'background-color: #6c757d; color: white;'; // Secondary grey
|
return 'background-color: #6c757d; color: white;'; // Secondary grey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatPendientesLabel($pendientes) {
|
||||||
|
$raw = (string)$pendientes;
|
||||||
|
$v = strtoupper(trim($raw));
|
||||||
|
|
||||||
|
if ($v === 'PENDIENTE') return 'PENDIENTE A GESTIONAR';
|
||||||
|
if ($v === 'GESTIONADO') return 'GESTIONADO';
|
||||||
|
if ($v === '') return 'Seleccionar';
|
||||||
|
|
||||||
|
return $raw;
|
||||||
|
}
|
||||||
|
|
||||||
$pdo = db();
|
$pdo = db();
|
||||||
|
|
||||||
$user_id = $_SESSION['user_id'];
|
$user_id = $_SESSION['user_id'];
|
||||||
@ -199,7 +211,7 @@ include 'layout_header.php';
|
|||||||
</td>
|
</td>
|
||||||
<td class="editable-pendientes" data-id="<?php echo $pedido['id']; ?>" data-value="<?php echo htmlspecialchars($pedido['pendientes'] ?? ''); ?>" style="cursor: pointer;">
|
<td class="editable-pendientes" data-id="<?php echo $pedido['id']; ?>" data-value="<?php echo htmlspecialchars($pedido['pendientes'] ?? ''); ?>" style="cursor: pointer;">
|
||||||
<span class="badge" style="<?php echo getPendientesStyle($pedido['pendientes'] ?? ''); ?>">
|
<span class="badge" style="<?php echo getPendientesStyle($pedido['pendientes'] ?? ''); ?>">
|
||||||
<?php echo htmlspecialchars(!empty($pedido['pendientes']) ? $pedido['pendientes'] : 'Seleccionar'); ?>
|
<?php echo htmlspecialchars(formatPendientesLabel($pedido['pendientes'] ?? '')); ?>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td><span class="badge" style="<?php echo getStatusStyle($pedido['estado']); ?>"><?php echo ($pedido['estado'] == 'Gestion') ? 'GESTIONES ⚙️' : htmlspecialchars($pedido['estado']); ?></span></td>
|
<td><span class="badge" style="<?php echo getStatusStyle($pedido['estado']); ?>"><?php echo ($pedido['estado'] == 'Gestion') ? 'GESTIONES ⚙️' : htmlspecialchars($pedido['estado']); ?></span></td>
|
||||||
@ -247,11 +259,19 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function getPendientesStyleJS(pendientes) {
|
function getPendientesStyleJS(pendientes) {
|
||||||
if (pendientes === 'PENDIENTE') return 'background-color: #ffc107; color: black;';
|
const v = (pendientes || '').toString().toUpperCase().trim();
|
||||||
if (pendientes === 'GESTIONADO') return 'background-color: #198754; color: white;';
|
if (v === 'PENDIENTE') return 'background-color: #ffc107; color: black;';
|
||||||
|
if (v === 'GESTIONADO') return 'background-color: #198754; color: white;';
|
||||||
return 'background-color: #6c757d; color: white;';
|
return 'background-color: #6c757d; color: white;';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatPendientesLabelJS(value) {
|
||||||
|
const v = (value || '').toString().toUpperCase().trim();
|
||||||
|
if (!v) return 'Seleccionar';
|
||||||
|
if (v === 'PENDIENTE') return 'PENDIENTE A GESTIONAR';
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
const table = document.querySelector('.table');
|
const table = document.querySelector('.table');
|
||||||
|
|
||||||
@ -270,7 +290,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
|
|
||||||
const options = [
|
const options = [
|
||||||
{val: '', text: 'Seleccionar'},
|
{val: '', text: 'Seleccionar'},
|
||||||
{val: 'PENDIENTE', text: 'PENDIENTE'},
|
{val: 'PENDIENTE', text: 'PENDIENTE A GESTIONAR'},
|
||||||
{val: 'GESTIONADO', text: 'GESTIONADO'}
|
{val: 'GESTIONADO', text: 'GESTIONADO'}
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -294,7 +314,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
|
|
||||||
// Optimistic update
|
// Optimistic update
|
||||||
cell.dataset.value = newVal;
|
cell.dataset.value = newVal;
|
||||||
cell.innerHTML = `<span class="badge" style="${getPendientesStyleJS(newVal)}">${newVal || 'Seleccionar'}</span>`;
|
cell.innerHTML = `<span class="badge" style="${getPendientesStyleJS(newVal)}">${formatPendientesLabelJS(newVal)}</span>`;
|
||||||
|
|
||||||
if (newVal === currentVal) return; // No change
|
if (newVal === currentVal) return; // No change
|
||||||
|
|
||||||
|
|||||||
@ -146,7 +146,7 @@ $orders = [];
|
|||||||
$visibleOrders = [];
|
$visibleOrders = [];
|
||||||
$modalsHtml = [];
|
$modalsHtml = [];
|
||||||
$totalRows = 0;
|
$totalRows = 0;
|
||||||
$loadLimit = 20;
|
$loadLimit = $storeKey === 'otra_tienda' ? 0 : 100;
|
||||||
|
|
||||||
$cupoObjetivoPorAsesora = 10;
|
$cupoObjetivoPorAsesora = 10;
|
||||||
$advisorOpenCounts = [];
|
$advisorOpenCounts = [];
|
||||||
|
|||||||
@ -25,7 +25,7 @@ function drive_test_available_stores(): array
|
|||||||
'label' => 'TUANI',
|
'label' => 'TUANI',
|
||||||
'spreadsheet_id' => '1QYKeBJIIqYm6yW6Ka-5gKdxhUHwXOAc0No7RjnimxTw',
|
'spreadsheet_id' => '1QYKeBJIIqYm6yW6Ka-5gKdxhUHwXOAc0No7RjnimxTw',
|
||||||
'sheet_gid' => 1523126328,
|
'sheet_gid' => 1523126328,
|
||||||
'startRow' => 5552,
|
'startRow' => 6710,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
33
pedidos.php
33
pedidos.php
@ -10,6 +10,7 @@ require_once 'db/config.php';
|
|||||||
function getStatusStyle($status) {
|
function getStatusStyle($status) {
|
||||||
$style = 'color: white;'; // Default text color
|
$style = 'color: white;'; // Default text color
|
||||||
$bgColor = '#0dcaf0'; // Default info blue
|
$bgColor = '#0dcaf0'; // Default info blue
|
||||||
|
$shadow = ''; // Default no shadow
|
||||||
|
|
||||||
switch (strtoupper(trim($status))) {
|
switch (strtoupper(trim($status))) {
|
||||||
case 'ROTULADO':
|
case 'ROTULADO':
|
||||||
@ -30,6 +31,11 @@ function getStatusStyle($status) {
|
|||||||
case 'COMPLETADO ✅':
|
case 'COMPLETADO ✅':
|
||||||
$bgColor = '#198754'; // dark green
|
$bgColor = '#198754'; // dark green
|
||||||
break;
|
break;
|
||||||
|
case 'PENDIENTE':
|
||||||
|
$bgColor = '#dc3545'; // red
|
||||||
|
$style = 'color: white;';
|
||||||
|
$shadow = 'box-shadow: 0 0.6rem 1.2rem rgba(220, 53, 69, 0.35) !important;';
|
||||||
|
break;
|
||||||
case 'GESTION':
|
case 'GESTION':
|
||||||
$bgColor = '#6c757d'; // secondary grey
|
$bgColor = '#6c757d'; // secondary grey
|
||||||
break;
|
break;
|
||||||
@ -53,11 +59,34 @@ function getStatusStyle($status) {
|
|||||||
$bgColor = '#6f42c1'; // indigo/purple
|
$bgColor = '#6f42c1'; // indigo/purple
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return "background-color: {$bgColor} !important; {$style}";
|
return "background-color: {$bgColor} !important; {$style} {$shadow}";
|
||||||
}
|
}
|
||||||
|
|
||||||
$pdo = db();
|
$pdo = db();
|
||||||
|
|
||||||
|
// Auto-promoción: los pedidos rotulados que ya superaron 1 día pasan a estado PENDIENTE
|
||||||
|
// (para que se vean más resaltantes en la operación).
|
||||||
|
$auto_promoted_count = 0;
|
||||||
|
try {
|
||||||
|
$auto_stmt = $pdo->prepare("
|
||||||
|
UPDATE pedidos
|
||||||
|
SET estado = 'PENDIENTE'
|
||||||
|
WHERE estado = 'ROTULADO 📦'
|
||||||
|
AND created_at <= NOW() - INTERVAL 1 DAY
|
||||||
|
");
|
||||||
|
$auto_stmt->execute();
|
||||||
|
$auto_promoted_count = (int)$auto_stmt->rowCount();
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
error_log('Auto-promote ROTULADO 📦 -> PENDIENTE failed: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($auto_promoted_count > 0 && empty($_SESSION['flash_message'])) {
|
||||||
|
$_SESSION['flash_message'] = [
|
||||||
|
'type' => 'warning',
|
||||||
|
'message' => 'Se marcaron automáticamente ' . $auto_promoted_count . ' pedido(s) como "PENDIENTE" (pasaron 1 día desde su creación) y siguen visibles en Pedidos Rotulados.'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
$user_id = $_SESSION['user_id'];
|
$user_id = $_SESSION['user_id'];
|
||||||
$user_role = $_SESSION['user_role'] ?? 'Asesor';
|
$user_role = $_SESSION['user_role'] ?? 'Asesor';
|
||||||
|
|
||||||
@ -78,7 +107,7 @@ $selected_month = $_GET['mes'] ?? '';
|
|||||||
$selected_year = $_GET['año'] ?? '';
|
$selected_year = $_GET['año'] ?? '';
|
||||||
$search_query = $_GET['q'] ?? '';
|
$search_query = $_GET['q'] ?? '';
|
||||||
|
|
||||||
$sql = "SELECT p.*, u.nombre_asesor as asesor_nombre FROM pedidos p LEFT JOIN users u ON p.asesor_id = u.id WHERE p.estado = 'ROTULADO 📦'";
|
$sql = "SELECT p.*, u.nombre_asesor as asesor_nombre FROM pedidos p LEFT JOIN users u ON p.asesor_id = u.id WHERE (p.estado = 'ROTULADO 📦' OR (p.estado = 'PENDIENTE' AND p.created_at <= NOW() - INTERVAL 1 DAY))";
|
||||||
$params = [];
|
$params = [];
|
||||||
|
|
||||||
if ($user_role === 'Asesor') {
|
if ($user_role === 'Asesor') {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user