From ee1704357171f683c35d27a68d5cd6e1abd51fa1 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Fri, 3 Oct 2025 19:04:16 +0000 Subject: [PATCH] roles & tools --- .../003_add_roles_text_to_profiles.sql | 1 + .../004_add_tools_text_to_profiles.sql | 1 + .../005_add_kpi_data_to_profiles.sql | 1 + generate_kpis.php | 72 +++++++++ generate_roles.php | 3 + generate_tools.php | 3 + profile.php | 142 +++++++++++++++--- 7 files changed, 199 insertions(+), 24 deletions(-) create mode 100644 db/migrations/003_add_roles_text_to_profiles.sql create mode 100644 db/migrations/004_add_tools_text_to_profiles.sql create mode 100644 db/migrations/005_add_kpi_data_to_profiles.sql create mode 100644 generate_kpis.php diff --git a/db/migrations/003_add_roles_text_to_profiles.sql b/db/migrations/003_add_roles_text_to_profiles.sql new file mode 100644 index 0000000..4d8ccf3 --- /dev/null +++ b/db/migrations/003_add_roles_text_to_profiles.sql @@ -0,0 +1 @@ +ALTER TABLE `gtm_profiles` ADD `roles_text` TEXT; \ No newline at end of file diff --git a/db/migrations/004_add_tools_text_to_profiles.sql b/db/migrations/004_add_tools_text_to_profiles.sql new file mode 100644 index 0000000..aac7a0f --- /dev/null +++ b/db/migrations/004_add_tools_text_to_profiles.sql @@ -0,0 +1 @@ +ALTER TABLE `gtm_profiles` ADD `tools_text` TEXT; \ No newline at end of file diff --git a/db/migrations/005_add_kpi_data_to_profiles.sql b/db/migrations/005_add_kpi_data_to_profiles.sql new file mode 100644 index 0000000..3a86c87 --- /dev/null +++ b/db/migrations/005_add_kpi_data_to_profiles.sql @@ -0,0 +1 @@ +ALTER TABLE gtm_profiles ADD COLUMN kpi_data TEXT; \ No newline at end of file diff --git a/generate_kpis.php b/generate_kpis.php new file mode 100644 index 0000000..18f2cd8 --- /dev/null +++ b/generate_kpis.php @@ -0,0 +1,72 @@ + 'Profile ID is missing.']); + exit; +} + +// Basic AI/Rule-based KPI generation +function generate_kpi_data($profile) { + // In a real scenario, you'd have a more complex logic or an API call to an AI model + $kpis = [ + ['name' => 'Monthly Recurring Revenue (MRR)', 'current' => '$' . number_format(rand(5000, 15000)), 'target' => '$25,000'], + ['name' => 'Customer Acquisition Cost (CAC)', 'current' => '$' . number_format(rand(300, 800)), 'target' => '$400'], + ['name' => 'Net Revenue Retention (NRR)', 'current' => rand(95, 110) . '%', 'target' => '115%'] + ]; + + // Generate sample data for the chart + $labels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']; + $datasets = [ + [ + 'label' => 'MRR (Actual)', + 'data' => array_map(fn() => rand(5000, 18000), range(1, 6)), + 'borderColor' => '#0d6efd', + 'tension' => 0.1 + ], + [ + 'label' => 'MRR (Target)', + 'data' => array_map(fn($i) => 15000 + ($i * 1500), range(1, 6)), + 'borderColor' => '#dc3545', + 'borderDash' => [5, 5], + 'tension' => 0.1 + ] + ]; + + return [ + 'kpis' => $kpis, + 'chartData' => [ + 'labels' => $labels, + 'datasets' => $datasets + ] + ]; +} + +try { + $pdo = db(); + $stmt = $pdo->prepare("SELECT * FROM gtm_profiles WHERE id = ?"); + $stmt->execute([$profile_id]); + $profile = $stmt->fetch(PDO::FETCH_ASSOC); + + if (!$profile) { + echo json_encode(['error' => 'Profile not found.']); + exit; + } + + $kpi_data = generate_kpi_data($profile); + $kpi_data_json = json_encode($kpi_data); + + // Save the generated data to the database + $update_stmt = $pdo->prepare("UPDATE gtm_profiles SET kpi_data = ? WHERE id = ?"); + $update_stmt->execute([$kpi_data_json, $profile_id]); + + echo json_encode(['success' => true, 'kpi_data' => $kpi_data]); + +} catch (PDOException $e) { + error_log('KPI Generation Error: ' . $e->getMessage()); + echo json_encode(['error' => 'Database error during KPI generation.']); +} diff --git a/generate_roles.php b/generate_roles.php index 47b7721..c2093ae 100644 --- a/generate_roles.php +++ b/generate_roles.php @@ -42,6 +42,9 @@ try { $recommendations .= ''; } + $update_stmt = $pdo->prepare("UPDATE gtm_profiles SET roles_text = ? WHERE id = ?"); + $update_stmt->execute([$recommendations, $profile_id]); + echo json_encode(['recommendations' => $recommendations]); } catch (PDOException $e) { diff --git a/generate_tools.php b/generate_tools.php index 92ea1ce..735bce1 100644 --- a/generate_tools.php +++ b/generate_tools.php @@ -42,6 +42,9 @@ try { $recommendations .= ''; } + $update_stmt = $pdo->prepare("UPDATE gtm_profiles SET tools_text = ? WHERE id = ?"); + $update_stmt->execute([$recommendations, $profile_id]); + echo json_encode(['recommendations' => $recommendations]); } catch (PDOException $e) { diff --git a/profile.php b/profile.php index 92e80ec..e31165a 100644 --- a/profile.php +++ b/profile.php @@ -28,6 +28,7 @@ if ($profile_id) { + @@ -59,6 +60,50 @@ if ($profile_id) {

My GTM Profile

+
+
+
+
+
AI-Generated Role Recommendations
+

Get AI-powered suggestions for marketing and sales roles to execute your GTM strategy.

+
+ + + +
+ +
+
+
+
+
+
+
AI-Recommended Tools & Integrations
+

Discover top industry solutions and integrations to efficiently execute your GTM strategy.

+
+ + + +
+
+
+
+
+
+
+
+
+
AI-Generated KPI Dashboard
+

Set and refine KPIs, and track them with an auto-generated dashboard.

+
+ + + +
+
+
+
+
@@ -93,28 +138,6 @@ if ($profile_id) {
Goals

Growth Goals:


-
-
-
-
-
AI-Generated Role Recommendations
-

Get AI-powered suggestions for marketing and sales roles to execute your GTM strategy.

- -
-
-
-
-
-
-
-
AI-Recommended Tools & Integrations
-

Discover top industry solutions and integrations to efficiently execute your GTM strategy.

- -
-
-
-
-
@@ -134,18 +157,20 @@ if ($profile_id) {