$peticion, 'query' => $_GET, 'body' => $body, ], JSON_UNESCAPED_UNICODE) . "\n", FILE_APPEND); // Mismo shape que BotEntradaProcesador para que el bot repita el detalle echo json_encode([ 'status' => 'ok', 'mensaje' => 'capturado:' . $peticion, ], JSON_UNESCAPED_UNICODE); exit; } // ── GET: catálogos fijos ────────────────────────────────────────────────────── $fincas = [ ['id' => '0', 'label' => '🌐 Todas las fincas'], ['id' => '4', 'label' => 'REPOSO'], ['id' => '7', 'label' => 'ROSA BLANCA'], ]; // El ERP acota por número: este wa solo tiene una finca asignada if (($_GET['wa'] ?? '') === '57300RESTRINGIDO') { $fincas = [['id' => '4', 'label' => 'REPOSO']]; } $novedades17 = []; foreach (range(1, 17) as $i) $novedades17[] = ['id' => (string)(100 + $i), 'nombre' => "NOVEDAD {$i}"]; $lotes12 = []; foreach (range(1, 12) as $i) $lotes12[] = ['id' => (string)$i, 'label' => "REPOSO {$i}A (" . (50 - $i) . "d)"]; // Como el ERP real: sin finca_id valida, el catalogo mezcla fincas if (intval($_GET['finca_id'] ?? 0) !== 4) { array_unshift($lotes12, ['id' => '99', 'label' => 'ROSA BLANCA 9Z (60d)']); } $fixtures = [ 'fincas' => $fincas, 'empleados' => [ ['id' => '412', 'nombre' => 'JULIO PEREZ GOMEZ'], ['id' => '415', 'nombre' => 'JULIO CESAR RAMIREZ'], ['id' => '418', 'nombre' => 'MARIA GOMEZ RUIZ'], ], 'novedades_ausentismo_dn' => $novedades17, 'novedades_labor_dn' => !empty($_GET['grupo']) ? [['id' => '77', 'nombre' => 'PLATEO MANUAL']] : [ ['id' => '42', 'nombre' => 'TRACTORISTA'], ['id' => '43', 'nombre' => 'HORAS EXTRA'], ], 'lotes_apertura_dn' => $lotes12, 'lotes_abiertos_dn' => array_slice($lotes12, 0, 3), 'lotes_x_finca' => intval($_GET['finca_id'] ?? 0) === 4 ? [['id' => '4', 'label' => 'REPOSO 1A'], ['id' => '9', 'label' => 'REPOSO 2A']] : [['id' => '99', 'label' => 'ROSA BLANCA 9Z']], 'grupos_mantenimiento' => [ ['id' => '5', 'label' => 'PLATEO'], ['id' => '6', 'label' => 'CORONA'], ], 'lotes_mantenimiento_dn' => [ ['id' => '4', 'label' => 'REPOSO 1A (falta 12)', 'faltante' => 12], ], 'productos_fertilizacion_dn' => [ ['id' => '30', 'nombre' => 'UREA (falta 120)', 'dosis' => 120], ], ]; // Los informes de texto responden {status, message} if (str_contains($peticion, '_texto_bot')) { file_put_contents($capture, json_encode(['peticion' => $peticion, 'query' => $_GET]) . "\n", FILE_APPEND); echo json_encode(['status' => '1', 'message' => 'informe-de-prueba']); exit; } if (isset($fixtures[$peticion])) { // La paginación del ERP: los catálogos cortos devuelven 10 salvo &todos=1 $datos = $fixtures[$peticion]; if (in_array($peticion, ['lotes_apertura_dn', 'lotes_abiertos_dn'], true) && empty($_GET['todos'])) { $datos = array_slice($datos, 0, 10); } echo json_encode(['status' => '1', 'datos' => $datos], JSON_UNESCAPED_UNICODE); exit; } http_response_code(404); echo json_encode(['status' => 'error', 'mensaje' => "sin fixture: {$peticion}"]);