fix(seed): corregir flows y URLs de endpoints

- ask_finca como dynamic_list con meta_group=finca
- ciclos usan api_report con next_endpoint_key para texto+PDF
- produccion_total encadena texto → PDF
- ausentismos usan date_mode en vez de funcion inexistente
- URLs de endpoints sin {fecha_desde}/{fecha_hasta} (date_mode los agrega)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-29 16:23:00 -05:00
co-authored by Claude Sonnet 4.6
parent 2329df6ac9
commit bd8544fce4
+90 -24
View File
@@ -143,8 +143,28 @@ $configJson = [
// ── Flows globales ──────────────────────────────────────────────────────
'flows' => [
// Producción
'produccion_total' => ['type' => 'function', 'function' => 'produccion_total_bot'],
// Selección de finca (dynamic_list — guarda finca_id en meta)
'ask_finca' => [
'type' => 'dynamic_list',
'source_endpoint_key' => 'fincas_dn',
'value_field' => 'id',
'label_field' => 'label',
'header' => '🌴 Palmas360',
'body' => '¿En qué finca trabajas?',
'section_title' => 'Fincas disponibles',
'meta_group' => 'finca',
'meta_key' => 'finca_id',
'next_node' => 'show_main_menu',
],
// Producción (texto del mes + PDF encadenado)
'produccion_total' => ['type' => 'function', 'function' => 'api_report', 'params' => [
'endpoint_key' => 'produccion_total_bot_dn',
'date_mode' => 'current_month',
'next_endpoint_key' => 'produccion_total_pdf_bot_dn',
'next_caption' => '📊 Producción del mes (PDF)',
'next_filename' => 'produccion_mes.pdf',
]],
'produccion_lotes' => ['type' => 'function', 'function' => 'api_report', 'params' => [
'endpoint_key' => 'produccion_lotes_bot_dn',
'filename' => 'produccion_lotes.xlsx',
@@ -152,33 +172,79 @@ $configJson = [
]],
// Ausentismos
'ausentismos_hoy' => ['type' => 'function', 'function' => 'ausentismos_bot', 'params' => ['periodo' => 'hoy']],
'ausentismos_semana' => ['type' => 'function', 'function' => 'ausentismos_bot', 'params' => ['periodo' => 'semana']],
'ausentismos_hoy' => ['type' => 'function', 'function' => 'api_report', 'params' => [
'endpoint_key' => 'ausentismos_bot_texto_dn',
'date_mode' => 'today',
]],
'ausentismos_semana' => ['type' => 'function', 'function' => 'api_report', 'params' => [
'endpoint_key' => 'ausentismos_bot_texto_dn',
'date_mode' => 'last_7',
]],
'ausentismos_mes' => ['type' => 'function', 'function' => 'api_report', 'params' => [
'endpoint_key' => 'ausentismos_bot_pdf_dn',
'date_mode' => 'current_month',
'filename' => 'ausentismos_mes.pdf',
'caption' => 'Ausentismos del mes',
]],
// Ciclos (menus)
// Menus de sección
'submenu_produccion' => ['type' => 'menu', 'menu' => 'submenu_produccion'],
'submenu_ciclos' => ['type' => 'menu', 'menu' => 'submenu_ciclos'],
'submenu_ausentismos' => ['type' => 'menu', 'menu' => 'submenu_ausentismos'],
// Ciclos individuales
'ciclo_cosecha' => ['type' => 'function', 'function' => 'ciclo_bot', 'params' => ['ciclo' => 'cosecha']],
'ciclo_polinizacion' => ['type' => 'function', 'function' => 'ciclo_bot', 'params' => ['ciclo' => 'polinizacion']],
'ciclo_censo' => ['type' => 'function', 'function' => 'ciclo_bot', 'params' => ['ciclo' => 'censo']],
'ciclo_plagas' => ['type' => 'function', 'function' => 'ciclo_bot', 'params' => ['ciclo' => 'plagas']],
'ciclo_palm' => ['type' => 'function', 'function' => 'ciclo_bot', 'params' => ['ciclo' => 'palm']],
'ciclo_tratamiento' => ['type' => 'function', 'function' => 'ciclo_bot', 'params' => ['ciclo' => 'tratamiento']],
'ciclo_mantenimiento' => ['type' => 'function', 'function' => 'ciclo_bot', 'params' => ['ciclo' => 'mantenimiento']],
// Ciclos (texto top + PDF histórico 30 días encadenado)
'ciclo_cosecha' => ['type' => 'function', 'function' => 'api_report', 'params' => [
'endpoint_key' => 'cosecha_top_texto_bot_dn',
'date_mode' => 'last_30',
'next_endpoint_key' => 'cosecha_historico_bot_dn',
'next_caption' => '📋 Histórico cosecha 30 días',
'next_filename' => 'cosecha_historico.pdf',
]],
'ciclo_polinizacion' => ['type' => 'function', 'function' => 'api_report', 'params' => [
'endpoint_key' => 'polinizacion_top_texto_bot_dn',
'date_mode' => 'last_30',
'next_endpoint_key' => 'polinizacion_historico_bot_dn',
'next_caption' => '📋 Histórico polinización 30 días',
'next_filename' => 'polinizacion_historico.pdf',
]],
'ciclo_censo' => ['type' => 'function', 'function' => 'api_report', 'params' => [
'endpoint_key' => 'censo_top_texto_bot_dn',
'date_mode' => 'last_30',
'next_endpoint_key' => 'censo_historico_bot_dn',
'next_caption' => '📋 Histórico censo 30 días',
'next_filename' => 'censo_historico.pdf',
]],
'ciclo_plagas' => ['type' => 'function', 'function' => 'api_report', 'params' => [
'endpoint_key' => 'plagas_top_texto_bot_dn',
'date_mode' => 'last_30',
'next_endpoint_key' => 'plagas_historico_bot_dn',
'next_caption' => '📋 Histórico plagas 30 días',
'next_filename' => 'plagas_historico.pdf',
]],
'ciclo_palm' => ['type' => 'function', 'function' => 'api_report', 'params' => [
'endpoint_key' => 'palm_top_texto_bot_dn',
'date_mode' => 'last_30',
'next_endpoint_key' => 'palm_historico_bot_dn',
'next_caption' => '📋 Histórico palm 30 días',
'next_filename' => 'palm_historico.pdf',
]],
'ciclo_tratamiento' => ['type' => 'function', 'function' => 'api_report', 'params' => [
'endpoint_key' => 'tratamiento_top_texto_bot_dn',
'date_mode' => 'last_30',
'next_endpoint_key' => 'tratamiento_historico_bot_dn',
'next_caption' => '📋 Histórico tratamiento 30 días',
'next_filename' => 'tratamiento_historico.pdf',
]],
'ciclo_mantenimiento' => ['type' => 'function', 'function' => 'api_report', 'params' => [
'endpoint_key' => 'mantenimiento_top_texto_bot_dn',
'date_mode' => 'last_30',
]],
// Upload
'enviar_informacion' => ['type' => 'menu', 'menu' => 'submenu_subir_ciclos'],
'subir_ciclo_cosecha' => ['type' => 'function', 'function' => 'upload_ciclo', 'params' => ['ciclo' => 'cosecha']],
// Placeholders globales
// Alias globales
'show_main_menu' => ['type' => 'menu', 'menu' => 'show_menu_cat2'],
'descargar_informes' => ['type' => 'menu', 'menu' => 'show_menu_cat2'],
],
@@ -272,11 +338,11 @@ $configJson = [
$BASE = 'https://app.palmas360.com/rosablanca/php/controller/controller_api_externa.php';
$endpoints = [
['key' => 'produccion_total_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=produccion_total_bot&fecha_desde={fecha_desde}&fecha_hasta={fecha_hasta}&finca_id={finca_id}'],
['key' => 'produccion_total_pdf_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=produccion_total_pdf_bot&fecha_desde={fecha_desde}&fecha_hasta={fecha_hasta}&finca_id={finca_id}'],
['key' => 'produccion_total_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=produccion_total_bot&finca_id={finca_id}'],
['key' => 'produccion_total_pdf_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=produccion_total_pdf_bot&finca_id={finca_id}'],
['key' => 'produccion_lotes_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=produccion_lotes_bot&finca_id={finca_id}'],
['key' => 'ausentismos_bot_texto_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=ausentismos_bot_texto&fecha_desde={fecha_desde}&fecha_hasta={fecha_hasta}'],
['key' => 'ausentismos_bot_pdf_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=ausentismos_bot_pdf&fecha_desde={fecha_desde}&fecha_hasta={fecha_hasta}'],
['key' => 'ausentismos_bot_texto_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=ausentismos_bot_texto'],
['key' => 'ausentismos_bot_pdf_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=ausentismos_bot_pdf'],
['key' => 'cosecha_top_texto_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=cosecha_top_texto_bot&finca_id={finca_id}'],
['key' => 'polinizacion_top_texto_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=polinizacion_top_texto_bot&finca_id={finca_id}'],
['key' => 'censo_top_texto_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=censo_top_texto_bot&finca_id={finca_id}'],
@@ -284,12 +350,12 @@ $endpoints = [
['key' => 'palm_top_texto_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=palm_top_texto_bot&finca_id={finca_id}'],
['key' => 'tratamiento_top_texto_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=tratamiento_top_texto_bot&finca_id={finca_id}'],
['key' => 'mantenimiento_top_texto_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=mantenimiento_top_texto_bot&grupo=0&finca_id={finca_id}'],
['key' => 'cosecha_historico_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=cosecha_historico_bot&fecha_hasta={fecha_hasta}&finca_id={finca_id}'],
['key' => 'polinizacion_historico_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=polinizacion_historico_bot&fecha_hasta={fecha_hasta}&finca_id={finca_id}'],
['key' => 'censo_historico_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=censo_historico_bot&fecha_hasta={fecha_hasta}&finca_id={finca_id}'],
['key' => 'plagas_historico_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=plagas_historico_bot&fecha_hasta={fecha_hasta}&finca_id={finca_id}'],
['key' => 'palm_historico_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=palm_historico_bot&fecha_hasta={fecha_hasta}&finca_id={finca_id}'],
['key' => 'tratamiento_historico_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=tratamiento_historico_bot&fecha_hasta={fecha_hasta}&finca_id={finca_id}'],
['key' => 'cosecha_historico_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=cosecha_historico_bot&finca_id={finca_id}'],
['key' => 'polinizacion_historico_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=polinizacion_historico_bot&finca_id={finca_id}'],
['key' => 'censo_historico_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=censo_historico_bot&finca_id={finca_id}'],
['key' => 'plagas_historico_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=plagas_historico_bot&finca_id={finca_id}'],
['key' => 'palm_historico_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=palm_historico_bot&finca_id={finca_id}'],
['key' => 'tratamiento_historico_bot_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=tratamiento_historico_bot&finca_id={finca_id}'],
['key' => 'fincas_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=fincas'],
['key' => 'numeros_dn', 'dir' => 'download', 'url' => $BASE . '?peticion=whatsapp_numeros&estado=1'],
];