fix: la fecha final del ausentismo mira hacia adelante
El selector ofrecia Hoy/Ayer/Anteayer tambien para el "hasta", cuando una novedad que se registra hoy termina hoy o mas adelante. Ahora ese campo ofrece Hoy/Manana/Pasado manana, y "Otra fecha" sigue aceptando cualquiera. date_quick gana 'quick' => 'futuro'; sin esa clave se comporta igual que antes, asi que las fechas de labores y ciclos —siempre pasadas— no cambian. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
2ef3091260
commit
6616b63683
+18
-7
@@ -1525,11 +1525,13 @@ class NormalBot
|
||||
}
|
||||
}
|
||||
|
||||
// ── date_quick: Hoy / Ayer / Anteayer / Otra ────────────────────────
|
||||
// ── date_quick: atajos hacia atras o hacia adelante segun 'quick' ───
|
||||
if ($type === 'date_quick') {
|
||||
$hoy = date('Y-m-d');
|
||||
$ayer = date('Y-m-d', strtotime('-1 day'));
|
||||
$ant = date('Y-m-d', strtotime('-2 days'));
|
||||
$man = date('Y-m-d', strtotime('+1 day'));
|
||||
$pas = date('Y-m-d', strtotime('+2 days'));
|
||||
return self::enqueueInteractive($to, [
|
||||
'type' => 'list',
|
||||
'header' => ['type' => 'text', 'text' => mb_substr($cap['header'], 0, 60)],
|
||||
@@ -1537,12 +1539,21 @@ class NormalBot
|
||||
'footer' => ['text' => ''],
|
||||
'action' => ['button' => 'Ver fechas', 'sections' => [[
|
||||
'title' => 'Fecha',
|
||||
'rows' => [
|
||||
['id' => $hoy, 'title' => '📅 Hoy', 'description' => $hoy],
|
||||
['id' => $ayer, 'title' => '📅 Ayer', 'description' => $ayer],
|
||||
['id' => $ant, 'title' => '📅 Anteayer', 'description' => $ant],
|
||||
['id' => '__cap_other', 'title' => '✏️ Otra fecha', 'description' => 'Escribe la fecha'],
|
||||
],
|
||||
// Una fecha de cierre cae hoy o mas adelante: ofrecer ayer y
|
||||
// anteayer ahi no tenia sentido. 'futuro' invierte los atajos.
|
||||
'rows' => (($field['quick'] ?? 'pasado') === 'futuro')
|
||||
? [
|
||||
['id' => $hoy, 'title' => '📅 Hoy', 'description' => $hoy],
|
||||
['id' => $man, 'title' => '📅 Mañana', 'description' => $man],
|
||||
['id' => $pas, 'title' => '📅 Pasado mañana', 'description' => $pas],
|
||||
['id' => '__cap_other', 'title' => '✏️ Otra fecha', 'description' => 'Escribe la fecha'],
|
||||
]
|
||||
: [
|
||||
['id' => $hoy, 'title' => '📅 Hoy', 'description' => $hoy],
|
||||
['id' => $ayer, 'title' => '📅 Ayer', 'description' => $ayer],
|
||||
['id' => $ant, 'title' => '📅 Anteayer', 'description' => $ant],
|
||||
['id' => '__cap_other', 'title' => '✏️ Otra fecha', 'description' => 'Escribe la fecha'],
|
||||
],
|
||||
]]],
|
||||
], $company);
|
||||
}
|
||||
|
||||
@@ -478,6 +478,8 @@ $configJson = [
|
||||
'key' => 'fecha_final',
|
||||
'label' => 'Hasta',
|
||||
'type' => 'date_quick',
|
||||
// Una novedad termina hoy o mas adelante, nunca anteayer
|
||||
'quick' => 'futuro',
|
||||
'prompt' => '📅 ¿Hasta qué fecha? (si es un solo día, elige la misma)',
|
||||
'other_validate' => 'date',
|
||||
'other_prompt' => 'Escribe la fecha final (YYYY-MM-DD):',
|
||||
|
||||
@@ -62,11 +62,21 @@ check('y el nombre completo va en la descripción',
|
||||
|
||||
$r = NormalBot::processInteractive($co, $ctx, '46');
|
||||
check('sigue la fecha inicial', str_contains(textoDe($r), 'Desde qué fecha'));
|
||||
check('la fecha inicial sí mira hacia atrás',
|
||||
isset(filasDe($r)[date('Y-m-d', strtotime('-1 day'))]));
|
||||
|
||||
$hoy = date('Y-m-d'); $ayer = date('Y-m-d', strtotime('-1 day'));
|
||||
$manana = date('Y-m-d', strtotime('+1 day'));
|
||||
$r = NormalBot::processInteractive($co, $ctx, $hoy);
|
||||
check('sigue la fecha final', str_contains(textoDe($r), 'Hasta qué fecha'));
|
||||
|
||||
// Una novedad termina hoy o despues: los atajos van hacia adelante
|
||||
$atajos = filasDe($r);
|
||||
check('ofrece hoy, mañana y pasado — no ayer',
|
||||
array_map('strval', array_keys($atajos)),
|
||||
[$hoy, $manana, date('Y-m-d', strtotime('+2 days')), '__cap_other']);
|
||||
check('sin atajos hacia atrás', !isset($atajos[$ayer]));
|
||||
|
||||
WhatsAppSender::$enviados = [];
|
||||
$r = NormalBot::processInteractive($co, $ctx, $ayer);
|
||||
check('rechaza el rango invertido',
|
||||
|
||||
Reference in New Issue
Block a user