Autosave: 20260723-070830
This commit is contained in:
parent
3dfe356038
commit
2caec74b43
@ -433,7 +433,7 @@ try {
|
||||
$order['promo_final_evidencia_cargada'] = trim((string) ($order['promo_final_evidencia_path'] ?? '')) !== '';
|
||||
$order['es_promo_final'] = $order['promo_final_habilitado'] && $order['promo_final_evidencia_cargada'];
|
||||
$order['promo_final_pendiente'] = $order['promo_final_habilitado'] && !$order['promo_final_evidencia_cargada'];
|
||||
$order['pendiente_logistica_destino'] = $storeKey === 'otra_tienda'
|
||||
$order['pendiente_logistica_destino'] = cc_test_is_tuani_store_key($storeKey)
|
||||
? cc_test_pending_logistica_destination($order)
|
||||
: null;
|
||||
$order['pendiente_logistica'] = $order['pendiente_logistica_destino'] !== null;
|
||||
@ -603,7 +603,7 @@ try {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ($storeKey === 'otra_tienda') {
|
||||
if (cc_test_is_tuani_store_key($storeKey)) {
|
||||
$aSourceRow = (int) ($a['source_row'] ?? 0);
|
||||
$bSourceRow = (int) ($b['source_row'] ?? 0);
|
||||
if ($aSourceRow > 0 && $bSourceRow > 0 && $aSourceRow !== $bSourceRow) {
|
||||
@ -804,13 +804,14 @@ require_once 'layout_header.php';
|
||||
<?php endif; ?>
|
||||
<a href="<?php echo htmlspecialchars(cc_test_build_url('call_center_pro.php', $callCenterParams)); ?>" class="btn btn-sm btn-primary">Pedidos Asignados</a>
|
||||
</div>
|
||||
<ul class="nav nav-pills mt-3" role="tablist" aria-label="Selector de tienda">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php echo $storeKey === 'flower' ? 'active' : ''; ?>" href="<?php echo htmlspecialchars(cc_test_build_url('call_center_pro.php', array_merge($callCenterParams, ['store' => 'flower']))); ?>">Flower</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php echo $storeKey === 'otra_tienda' ? 'active' : ''; ?>" href="<?php echo htmlspecialchars(cc_test_build_url('call_center_pro.php', array_merge($callCenterParams, ['store' => 'otra_tienda']))); ?>">TUANI</a>
|
||||
</li>
|
||||
<ul class="nav nav-pills mt-3 flex-wrap gap-2" role="tablist" aria-label="Selector de tienda">
|
||||
<?php foreach ($availableStores as $key => $config): ?>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php echo $storeKey === $key ? 'active' : ''; ?>" href="<?php echo htmlspecialchars(cc_test_build_url('call_center_pro.php', array_merge($callCenterParams, ['store' => $key]))); ?>">
|
||||
<?php echo htmlspecialchars((string) ($config['label'] ?? strtoupper((string) $key))); ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="d-flex flex-wrap gap-2">
|
||||
@ -1022,7 +1023,7 @@ require_once 'layout_header.php';
|
||||
$subirLogisticaButtonLabel = 'Subir pedido';
|
||||
$subirLogisticaNoteClass = 'small mt-2 text-muted';
|
||||
$subirLogisticaNoteHtml = 'Selecciona <strong>CONFIRMADO CONTRAENTREGA</strong> o <strong>CONFIRMADO ENVIO</strong> para enviarlo a logística.';
|
||||
if ($storeKey === 'otra_tienda') {
|
||||
if (cc_test_is_tuani_store_key($storeKey)) {
|
||||
if ($order['estado'] === 'CONFIRMADO CONTRAENTREGA') {
|
||||
if (!empty($order['ruta_contraentrega_pedido_id'])) {
|
||||
$subirLogisticaButtonLabel = 'Actualizar en ruta';
|
||||
@ -1217,7 +1218,7 @@ require_once 'layout_header.php';
|
||||
</div>
|
||||
<div class="d-flex flex-wrap align-items-center justify-content-between gap-2">
|
||||
<h3 class="modal-title h5 mb-0"><?php echo htmlspecialchars(cc_test_display_value($order['nombre'], 'Cliente sin nombre')); ?></h3>
|
||||
<?php if ($storeKey === 'otra_tienda'): ?>
|
||||
<?php if (cc_test_is_tuani_store_key($storeKey)): ?>
|
||||
<button type="button" class="btn btn-primary btn-sm px-3" id="subir-logistica-<?php echo htmlspecialchars($order['source_key']); ?>" data-route-pedido-id="<?php echo (int) ($order['ruta_contraentrega_pedido_id'] ?? 0); ?>" data-rotulado-pedido-id="<?php echo (int) ($order['pedido_rotulado_pedido_id'] ?? 0); ?>" onclick="guardarGestion('<?php echo htmlspecialchars($order['source_key']); ?>', this, { subirLogistica: true })"><?php echo htmlspecialchars($subirLogisticaButtonLabel); ?></button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@ -1252,7 +1253,7 @@ require_once 'layout_header.php';
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($storeKey === 'otra_tienda'): ?>
|
||||
<?php if (cc_test_is_tuani_store_key($storeKey)): ?>
|
||||
<div class="<?php echo htmlspecialchars($subirLogisticaNoteClass); ?>" id="subir-logistica-note-<?php echo htmlspecialchars($order['source_key']); ?>"><?php echo $subirLogisticaNoteHtml; ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@ -1595,7 +1596,7 @@ require_once 'layout_header.php';
|
||||
|
||||
<div class="modal-footer d-flex justify-content-between flex-wrap gap-2">
|
||||
<div class="small text-muted">
|
||||
<?php if ($storeKey === 'otra_tienda'): ?>
|
||||
<?php if (cc_test_is_tuani_store_key($storeKey)): ?>
|
||||
<strong>Guardar gestión</strong> solo guarda el historial. Para enviarlo a logística, usa el <strong>botón del encabezado</strong> junto al nombre del cliente.
|
||||
<?php else: ?>
|
||||
Los cambios se guardan en la base local del módulo de prueba.
|
||||
|
||||
@ -523,7 +523,7 @@ try {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ($storeKey === 'otra_tienda') {
|
||||
if (cc_test_is_tuani_store_key($storeKey)) {
|
||||
$aSourceRow = (int) ($a['source_row'] ?? 0);
|
||||
$bSourceRow = (int) ($b['source_row'] ?? 0);
|
||||
if ($aSourceRow > 0 && $bSourceRow > 0 && $aSourceRow !== $bSourceRow) {
|
||||
@ -633,7 +633,7 @@ try {
|
||||
$order['promo_final_evidencia_cargada'] = trim((string) ($order['promo_final_evidencia_path'] ?? '')) !== '';
|
||||
$order['es_promo_final'] = $order['promo_final_habilitado'] && $order['promo_final_evidencia_cargada'];
|
||||
$order['promo_final_pendiente'] = $order['promo_final_habilitado'] && !$order['promo_final_evidencia_cargada'];
|
||||
$order['pendiente_logistica_destino'] = $storeKey === 'otra_tienda'
|
||||
$order['pendiente_logistica_destino'] = cc_test_is_tuani_store_key($storeKey)
|
||||
? cc_test_pending_logistica_destination($order)
|
||||
: null;
|
||||
$order['pendiente_logistica'] = $order['pendiente_logistica_destino'] !== null;
|
||||
@ -840,7 +840,7 @@ try {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ($storeKey === 'otra_tienda') {
|
||||
if (cc_test_is_tuani_store_key($storeKey)) {
|
||||
$aSourceRow = (int) ($a['source_row'] ?? 0);
|
||||
$bSourceRow = (int) ($b['source_row'] ?? 0);
|
||||
if ($aSourceRow > 0 && $bSourceRow > 0 && $aSourceRow !== $bSourceRow) {
|
||||
@ -1096,13 +1096,14 @@ require_once 'layout_header.php';
|
||||
<a href="?view=pendientes_hoy&store=<?php echo htmlspecialchars($storeKey); ?>" class="btn btn-sm <?php echo $view !== 'todos' ? 'btn-primary' : 'btn-outline-primary'; ?>">Bandeja principal</a>
|
||||
<a href="call_center_pro.php?view=<?php echo urlencode($view); ?>&store=<?php echo htmlspecialchars($storeKey); ?>" class="btn btn-sm btn-outline-dark">Pedidos Asignados</a>
|
||||
</div>
|
||||
<ul class="nav nav-pills mt-3" role="tablist" aria-label="Selector de tienda">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php echo $storeKey === 'flower' ? 'active' : ''; ?>" href="?view=<?php echo htmlspecialchars($view); ?>&store=flower">Flower</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php echo $storeKey === 'otra_tienda' ? 'active' : ''; ?>" href="?view=<?php echo htmlspecialchars($view); ?>&store=otra_tienda">TUANI</a>
|
||||
</li>
|
||||
<ul class="nav nav-pills mt-3 flex-wrap gap-2" role="tablist" aria-label="Selector de tienda">
|
||||
<?php foreach ($availableStores as $key => $config): ?>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php echo $storeKey === $key ? 'active' : ''; ?>" href="?view=<?php echo htmlspecialchars($view); ?>&store=<?php echo htmlspecialchars((string) $key); ?>">
|
||||
<?php echo htmlspecialchars((string) ($config['label'] ?? strtoupper((string) $key))); ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="d-flex flex-wrap gap-2">
|
||||
@ -1138,7 +1139,7 @@ require_once 'layout_header.php';
|
||||
<i class="bi bi-upload text-primary"></i> Agregar pedidos por Excel
|
||||
</h2>
|
||||
<div class="text-muted small">
|
||||
Para: <strong><?php echo $storeKey === 'otra_tienda' ? 'TUANI' : 'Flower'; ?></strong>.
|
||||
Para: <strong><?php echo htmlspecialchars($storeLabel); ?></strong>.
|
||||
Los pedidos cargados se muestran como <strong>AGREGADOS</strong> y no afectan la secuencia de Drive.
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
@ -1379,7 +1380,7 @@ require_once 'layout_header.php';
|
||||
$subirLogisticaButtonLabel = 'Subir pedido';
|
||||
$subirLogisticaNoteClass = 'small mt-2 text-muted';
|
||||
$subirLogisticaNoteHtml = 'Selecciona <strong>CONFIRMADO CONTRAENTREGA</strong> o <strong>CONFIRMADO ENVIO</strong> para enviarlo a logística.';
|
||||
if ($storeKey === 'otra_tienda') {
|
||||
if (cc_test_is_tuani_store_key($storeKey)) {
|
||||
if ($order['estado'] === 'CONFIRMADO CONTRAENTREGA') {
|
||||
if (!empty($order['ruta_contraentrega_pedido_id'])) {
|
||||
$subirLogisticaButtonLabel = 'Actualizar en ruta';
|
||||
@ -1605,7 +1606,7 @@ require_once 'layout_header.php';
|
||||
</div>
|
||||
<div class="d-flex flex-wrap align-items-center justify-content-between gap-2">
|
||||
<h3 class="modal-title h5 mb-0"><?php echo htmlspecialchars(cc_test_display_value($order['nombre'], 'Cliente sin nombre')); ?></h3>
|
||||
<?php if ($storeKey === 'otra_tienda'): ?>
|
||||
<?php if (cc_test_is_tuani_store_key($storeKey)): ?>
|
||||
<button type="button" class="btn btn-primary btn-sm px-3" id="subir-logistica-<?php echo htmlspecialchars($order['source_key']); ?>" data-route-pedido-id="<?php echo (int) ($order['ruta_contraentrega_pedido_id'] ?? 0); ?>" data-rotulado-pedido-id="<?php echo (int) ($order['pedido_rotulado_pedido_id'] ?? 0); ?>" onclick="guardarGestion('<?php echo htmlspecialchars($order['source_key']); ?>', this, { subirLogistica: true })"><?php echo htmlspecialchars($subirLogisticaButtonLabel); ?></button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@ -1640,7 +1641,7 @@ require_once 'layout_header.php';
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($storeKey === 'otra_tienda'): ?>
|
||||
<?php if (cc_test_is_tuani_store_key($storeKey)): ?>
|
||||
<div class="<?php echo htmlspecialchars($subirLogisticaNoteClass); ?>" id="subir-logistica-note-<?php echo htmlspecialchars($order['source_key']); ?>"><?php echo $subirLogisticaNoteHtml; ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@ -1983,7 +1984,7 @@ require_once 'layout_header.php';
|
||||
|
||||
<div class="modal-footer d-flex justify-content-between flex-wrap gap-2">
|
||||
<div class="small text-muted">
|
||||
<?php if ($storeKey === 'otra_tienda'): ?>
|
||||
<?php if (cc_test_is_tuani_store_key($storeKey)): ?>
|
||||
<strong>Guardar gestión</strong> solo guarda el historial. Para enviarlo a logística, usa el <strong>botón del encabezado</strong> junto al nombre del cliente.
|
||||
<?php else: ?>
|
||||
Los cambios se guardan en la base local del módulo de prueba.
|
||||
|
||||
@ -238,6 +238,12 @@ function cc_test_default_assessor_keys(): array
|
||||
return ['KARINA', 'ESTEFANYA', 'CARMEN'];
|
||||
}
|
||||
|
||||
function cc_test_is_tuani_store_key(string $storeKey): bool
|
||||
{
|
||||
$storeKey = trim(mb_strtolower($storeKey));
|
||||
return in_array($storeKey, ['otra_tienda', 'tuani_recuperables'], true);
|
||||
}
|
||||
|
||||
function cc_test_fetch_assessors(PDO $pdo, array $allowedNames = []): array
|
||||
{
|
||||
if (empty($allowedNames)) {
|
||||
|
||||
@ -23,15 +23,26 @@ function drive_test_available_stores(): array
|
||||
'enforce_db_start_row' => true,
|
||||
'incremental_sync' => true,
|
||||
],
|
||||
// Segunda tienda (nuevo link que pasaste).
|
||||
// Segunda tienda (pedido principal de TUANI).
|
||||
'otra_tienda' => [
|
||||
'label' => 'TUANI',
|
||||
'sheet_title' => 'TUANI PEDIDOS',
|
||||
'spreadsheet_id' => '1QYKeBJIIqYm6yW6Ka-5gKdxhUHwXOAc0No7RjnimxTw',
|
||||
'sheet_gid' => 1523126328,
|
||||
'startRow' => 6804,
|
||||
'enforce_db_start_row' => true,
|
||||
'incremental_sync' => true,
|
||||
],
|
||||
// Prueba de carritos abandonados: misma estructura, pero desde la fila 2000.
|
||||
'tuani_recuperables' => [
|
||||
'label' => 'Carritos recuperables',
|
||||
'sheet_title' => 'easysell_abandoneds',
|
||||
'spreadsheet_id' => '1QYKeBJIIqYm6yW6Ka-5gKdxhUHwXOAc0No7RjnimxTw',
|
||||
'sheet_gid' => 965530888,
|
||||
'startRow' => 2000,
|
||||
'enforce_db_start_row' => true,
|
||||
'incremental_sync' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -27,6 +27,8 @@ if (!isset($availableStores[$storeKey])) {
|
||||
$storeKey = 'flower';
|
||||
}
|
||||
$storeConfig = $availableStores[$storeKey];
|
||||
$storeLabel = (string) ($storeConfig['label'] ?? strtoupper($storeKey));
|
||||
$sheetTitle = trim((string) ($storeConfig['sheet_title'] ?? ''));
|
||||
|
||||
$spreadsheetId = (string) ($storeConfig['spreadsheet_id'] ?? '');
|
||||
$rangeA1 = 'A:Z';
|
||||
@ -67,6 +69,27 @@ try {
|
||||
?>
|
||||
|
||||
<div class="container py-4">
|
||||
<div class="card shadow-sm border-0 mb-4">
|
||||
<div class="card-body py-3">
|
||||
<div class="d-flex flex-column flex-lg-row align-items-lg-center gap-3">
|
||||
<div class="d-flex flex-wrap gap-2">
|
||||
<?php foreach ($availableStores as $key => $config): ?>
|
||||
<a class="btn btn-sm <?php echo $storeKey === $key ? 'btn-primary' : 'btn-outline-primary'; ?>" href="?store=<?php echo htmlspecialchars((string) $key); ?>">
|
||||
<?php echo htmlspecialchars((string) ($config['label'] ?? strtoupper((string) $key))); ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="ms-lg-auto d-flex flex-wrap gap-2">
|
||||
<span class="badge bg-light text-dark border px-3 py-2">Tienda: <?php echo htmlspecialchars($storeLabel); ?></span>
|
||||
<?php if ($sheetTitle !== ''): ?>
|
||||
<span class="badge bg-light text-dark border px-3 py-2">Hoja: <?php echo htmlspecialchars($sheetTitle); ?></span>
|
||||
<?php endif; ?>
|
||||
<span class="badge bg-light text-dark border px-3 py-2">Desde fila: <?php echo (int) ($storeConfig['startRow'] ?? 0); ?></span>
|
||||
<span class="badge bg-primary-subtle text-primary-emphasis px-3 py-2"><?php echo (int) count($previewRows); ?> visibles</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row g-4 align-items-stretch">
|
||||
<div class="col-12 col-xl-8">
|
||||
<div class="card shadow-sm border-0 h-100">
|
||||
|
||||
@ -158,7 +158,7 @@ function cc_test_build_contraentrega_notes(array $parts): string
|
||||
|
||||
function cc_test_prepare_route_order_payload(array $sourceOrder, array $formData, int $fallbackUserId): array
|
||||
{
|
||||
if (($sourceOrder['store_key'] ?? '') !== 'otra_tienda') {
|
||||
if (!cc_test_is_tuani_store_key((string) ($sourceOrder['store_key'] ?? ''))) {
|
||||
throw new RuntimeException('En este primer paso la subida automática a ruta está activa solo para TUANI.');
|
||||
}
|
||||
|
||||
@ -490,7 +490,7 @@ function cc_test_sync_route_order(PDO $pdo, ?int $existingPedidoId, array $paylo
|
||||
|
||||
function cc_test_prepare_rotulado_order_payload(array $sourceOrder, array $formData, int $fallbackUserId): array
|
||||
{
|
||||
if (($sourceOrder['store_key'] ?? '') !== 'otra_tienda') {
|
||||
if (!cc_test_is_tuani_store_key((string) ($sourceOrder['store_key'] ?? ''))) {
|
||||
throw new RuntimeException('En este primer paso la subida automática a Pedidos Rotulados está activa solo para TUANI.');
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user