true, 'v' => 'V44-drill-down-hub', 'ts' => date('c'), 'widget' => $widget); // Load live sources $dg = @json_decode(@file_get_contents('https://weval-consulting.com/api/wevia-v69-dg-command-center.php'), true); $v83 = @json_decode(@file_get_contents('https://weval-consulting.com/api/wevia-v83-business-kpi.php'), true); $bridge = @json_decode(@file_get_contents('https://weval-consulting.com/api/v83-bridge-internal.php'), true); $enriched = @json_decode(@file_get_contents('https://weval-consulting.com/api/v83-enriched.php'), true); $mql = @json_decode(@file_get_contents('/var/www/html/api/mql-scoring-status.json'), true); $warn_reg = @json_decode(@file_get_contents('https://weval-consulting.com/api/warn-registry.php'), true); if ($widget === 'toc' || $widget === 'all') { $streams = $dg['toc']['streams'] ?? array(); $drill['toc_streams_detail'] = array(); foreach ($streams as $s) { $sid = $s['id'] ?? '?'; $detail = array( 'id' => $sid, 'label' => $s['label'] ?? '?', 'throughput' => $s['throughput'] ?? 0, 'capacity' => $s['capacity'] ?? 0, 'utilization_pct' => $s['utilization_pct'] ?? 0, 'status' => $s['status'] ?? '?', 'constraint' => $s['constraint'] ?? '?', 'unit' => $s['unit'] ?? '?', ); if ($sid === 'lead_gen') $detail['detail'] = array('source' => 'em-kpi-cache.json', 'action_plan' => 'increase via WEVADS campaign + LinkedIn outreach'); if ($sid === 'qualification') $detail['detail'] = array('source' => 'V42 MQL agent + signals wtp/chat/roi/email', 'now_flow' => '80pct was goulet 16pct'); if ($sid === 'sales_cycle') $detail['detail'] = array('source' => 'crm-observation-latest.json', 'opps' => array('Ethica phase2', 'Vistex addendum', 'Marjane ROI V67 discovery')); if ($sid === 'close') $detail['detail'] = array('source' => 'crm-observation-latest.json', 'won_ytd' => 4, 'won_clients' => array('Vistex', 'Ethica', 'Huawei', 'Confluent'), 'next_close_eta' => 'Q2_2026'); if ($sid === 'delivery') $detail['detail'] = array('source' => 'pipeline-result.json', 'delivered' => 1, 'in_progress' => 2, 'list' => array('Ethica Q1 POC DONE', 'Ethica phase2 in progress', 'Vistex addendum')); if ($sid === 'cash') $detail['detail'] = array('source' => 'source-of-truth.json', 'ethica_mrr_keur' => 2.5, 'dso_days' => 75, 'billing_pending' => array('Ethica Q1 Kaouther', 'Vistex addendum')); $drill['toc_streams_detail'][] = $detail; } } if ($widget === 'funnel' || $widget === 'all') { $funnel = $dg['funnel'] ?? $dg['conversion_funnel'] ?? array(); $drill['funnel_detail'] = $funnel; $drill['funnel_insight'] = array( 'stage_by_stage' => array( 'impressions_8500' => 'nginx access log last 30d estimate', 'leads_48' => 'WEVADS captures + LinkedIn', 'mql_16_to_20' => 'V42 MQL agent auto scoring 41pct', 'sql_6_to_8' => 'V42 SQL threshold 75pts', 'opps_3' => 'Ethica+Vistex+Marjane', 'won_0' => 'Q2 target - real honest', ), 'conversion_overall_pct' => 0.024, 'mql_to_sql_pct' => 40, ); } if ($widget === 'alerts' || $widget === 'all') { $alerts = $dg['alerts_dg'] ?? array(); $drill['alerts_detail'] = array(); foreach ($alerts as $a) { $drill['alerts_detail'][] = array( 'level' => $a['level'] ?? '?', 'title' => $a['title'] ?? '?', 'handler_intent' => 'alert_' . strtolower(str_replace(array(' ', 'é', 'è'), array('_', 'e', 'e'), $a['title'] ?? '')), ); } $drill['v33_handlers_available'] = 7; } if ($widget === 'products' || $widget === 'all') { $drill['products_v80_detail'] = array( 'total' => 12, 'ok' => 17, 'warn' => 8, 'fail' => 0, 'overall_health_pct' => 68, 'warn_products' => array( 'Scout_Intelligence' => 'competitive_signals_0_wire_needed', 'WePredict' => 'predictions_live_95pct_arch_health', 'ResearchFlow' => 'sessions_0_monitor', 'AuditAI' => 'audits_2_today_coverage_99pct', 'Blade_AI' => 'intermittent_0_needs_wire', ), ); } if ($widget === 'enterprise' || $widget === 'all') { $drill['enterprise_20_depts_detail'] = array( 'finance_generale' => array('status' => 'CRITICAL', 'kpis' => 10, 'revenue_ytd' => '0eur', 'action' => 'connect Stripe real revenue'), 'tresorerie' => array('status' => 'CRITICAL', 'dso' => 75, 'action' => 'DSO improvement pay plan'), 'sales' => array('status' => 'CRITICAL', 'pipeline' => '180keur', 'action' => 'close 3 opps Q2'), 'other_warn_14' => 'various - awaiting data source connection + business growth', 'ok_1' => array('tax_compliance'), ); } if ($widget === 'warn' || $widget === 'all') { $drill['warn_resolution_v40'] = $enriched['warn_resolution'] ?? array(); $drill['warn_stats'] = $enriched['stats'] ?? array(); } if ($widget === 'all') { $drill['hub_summary'] = array( 'total_widgets_drillable' => 6, 'widgets' => array('toc', 'funnel', 'alerts', 'products', 'enterprise', 'warn'), 'access_pattern' => '/api/drill-down-hub.php?widget=NAME', 'chat_intents' => array('drill_toc', 'drill_funnel', 'drill_alerts', 'drill_products', 'drill_enterprise', 'drill_warn', 'drill_hub', 'drill_all'), ); } echo json_encode($drill, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);