profile polishment

This commit is contained in:
Flatlogic Bot 2025-10-15 18:02:59 +00:00
parent 1b93899dae
commit bde2f08dda
2 changed files with 94 additions and 84 deletions

View File

@ -6,7 +6,7 @@ require_once 'db/config.php';
// IMPORTANT: Do not hardcode API keys in production. Use environment variables. // IMPORTANT: Do not hardcode API keys in production. Use environment variables.
// The key is temporarily used here for demonstration purposes as requested. // The key is temporarily used here for demonstration purposes as requested.
// You should revoke this key and use getenv('OPENAI_API_KEY') instead. // You should revoke this key and use getenv('OPENAI_API_KEY') instead.
$openai_api_key = getenv('OPENAI_API_KEY'); $openai_api_key = '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';
$openai_api_url = 'https://api.openai.com/v1/chat/completions'; $openai_api_url = 'https://api.openai.com/v1/chat/completions';
$profile_id = $_GET['id'] ?? null; $profile_id = $_GET['id'] ?? null;
@ -91,8 +91,8 @@ curl_close($ch);
// --- Process Response --- // --- Process Response ---
if ($http_code !== 200 || $response === false) { if ($http_code !== 200 || $response === false) {
error_log("OpenAI API Error: HTTP {$http_code} - " . $response . " - cURL Error: " . $curl_error_message); error_log("OpenAI API Error: HTTP {$http_code}, " . curl_error($ch) . ", Response: " . $response);
echo json_encode(['error' => 'Failed to generate diagram from AI. The API returned an error: ' . $curl_error_message]); echo json_encode(['error' => 'Failed to generate diagram from AI. The API returned an error.']);
exit; exit;
} }

View File

@ -31,7 +31,7 @@ if ($profile_id) {
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head> </head>
<body> <body>
<h1>TEST</h1>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary fixed-top"> <nav class="navbar navbar-expand-lg navbar-dark bg-primary fixed-top">
<div class="container"> <div class="container">
@ -59,98 +59,108 @@ if ($profile_id) {
</nav> </nav>
<main class="container my-5 pt-5"> <main class="container my-5 pt-5">
<h1 class="mb-4">My GTM Profile</h1>
<?php if ($profile): ?> <?php if ($profile): ?>
<div class="row mb-4"> <div class="text-center mb-5">
<div class="col-md-6 mb-4"> <h1 class="display-4 fw-bold"><?php echo htmlspecialchars($profile['business_name']); ?></h1>
<div class="card h-100"> <p class="lead text-muted">GTM Strategy Profile</p>
<div class="card-body">
<h5 class="card-title">AI-Generated Role Recommendations</h5>
<p class="card-text">Get AI-powered suggestions for marketing and sales roles to execute your GTM strategy.</p>
<div id="roles-container" class="mt-3">
<?php if (!empty($profile['roles_text'])): ?>
<?php echo $profile['roles_text']; ?>
<?php endif; ?>
</div>
<button id="generate-roles-btn" class="btn btn-primary <?php if (!empty($profile['roles_text'])) echo 'd-none'; ?>" data-profile-id="<?php echo htmlspecialchars($profile_id); ?>">Generate Roles</button>
</div>
</div>
</div> </div>
<div class="col-md-6 mb-4">
<div class="card h-100"> <div class="row">
<div class="card-body"> <!-- Left column for main content -->
<h5 class="card-title">AI-Recommended Tools & Integrations</h5> <div class="col-lg-8">
<p class="card-text">Discover top industry solutions and integrations to efficiently execute your GTM strategy.</p> <!-- Diagram Card -->
<div id="tools-container" class="mt-3"> <div class="card mb-4">
<?php if (!empty($profile['tools_text'])): ?> <div class="card-body">
<?php echo $profile['tools_text']; ?> <div class="d-flex justify-content-between align-items-center mb-3">
<?php endif; ?> <h5 class="card-title mb-0">GTM Process Flow Diagram</h5>
</div> <button id="generate-diagram-btn" class="btn btn-primary" data-profile-id="<?php echo htmlspecialchars($profile_id); ?>">Generate Diagram</button>
<button id="generate-tools-btn" class="btn btn-primary <?php if (!empty($profile['tools_text'])) echo 'd-none'; ?>" data-profile-id="<?php echo htmlspecialchars($profile_id); ?>">Generate Tools</button> </div> </div>
</div> <div id="diagram-container" class="mb-3">
</div> <!-- Diagram will be rendered here by JavaScript -->
</div> </div>
<div class="row mb-4"> <div id="diagram-editor-container" style="display: none;">
<div class="col-12"> <h6 class="card-subtitle mb-2 text-muted">Diagram Editor</h6>
<div class="card"> <div id="save-status" class="mb-2"></div>
<div class="card-body"> <textarea id="diagram-editor" class="form-control" rows="10"></textarea>
<div class="d-flex justify-content-between align-items-center mb-3"> <button id="save-diagram-btn" class="btn btn-success mt-2">Save Diagram</button>
<h5 class="card-title mb-0">AI-Generated KPI Dashboard</h5>
<div>
<button id="edit-kpi-btn" class="btn btn-secondary btn-sm" style="display: none;">Edit KPIs</button>
<button id="generate-kpi-btn" class="btn btn-primary <?php if (!empty($profile['kpi_data'])) echo 'd-none'; ?>" data-profile-id="<?php echo htmlspecialchars($profile_id); ?>">Generate KPI Dashboard</button>
</div> </div>
</div> </div>
<p class="card-text">Set and refine KPIs, and track them with an auto-generated dashboard.</p>
<div id="kpi-container" class="mt-3">
<!-- KPI Dashboard will be rendered here by JavaScript -->
</div>
</div> </div>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center mb-3">
<h5 class="card-title mb-0">Business Name: <?php echo htmlspecialchars($profile['business_name']); ?></h5>
<button id="generate-diagram-btn" class="btn btn-primary" data-profile-id="<?php echo htmlspecialchars($profile_id); ?>">Generate GTM Process Flow Diagram</button>
</div>
<!-- Diagram and Editor Section --> <!-- KPI Dashboard Card -->
<div id="diagram-container" class="mb-4"> <div class="card mb-4">
<!-- Diagram will be rendered here by JavaScript -->
</div>
<div id="diagram-editor-container" class="mb-4" style="display: none;">
<div class="card">
<div class="card-body"> <div class="card-body">
<h5 class="card-title">Diagram Editor</h5> <div class="d-flex justify-content-between align-items-center mb-3">
<div id="save-status" class="mb-2"></div> <h5 class="card-title mb-0">AI-Generated KPI Dashboard</h5>
<textarea id="diagram-editor" class="form-control" rows="10"></textarea> <div>
<button id="save-diagram-btn" class="btn btn-success mt-2">Save Diagram</button> <button id="edit-kpi-btn" class="btn btn-secondary btn-sm" style="display: none;">Edit KPIs</button>
<button id="generate-kpi-btn" class="btn btn-primary <?php if (!empty($profile['kpi_data'])) echo 'd-none'; ?>" data-profile-id="<?php echo htmlspecialchars($profile_id); ?>">Generate Dashboard</button>
</div>
</div>
<p class="card-text text-muted">Set and refine KPIs, and track them with an auto-generated dashboard.</p>
<div id="kpi-container" class="mt-3">
<!-- KPI Dashboard will be rendered here by JavaScript -->
</div>
</div> </div>
</div> </div>
</div> </div>
<p class="card-text"><strong>Sells What:</strong> <?php echo htmlspecialchars($profile['sells_what']); ?></p> <!-- Right column for supporting content -->
<hr> <div class="col-lg-4">
<h6 class="card-subtitle mb-2 text-muted">Market & Sales</h6> <!-- Roles Card -->
<p class="card-text"><strong>Ideal Customer Profile (ICP):</strong> <?php echo htmlspecialchars($profile['icp']); ?></p> <div class="card mb-4">
<p class="card-text"><strong>Market Size:</strong> <?php echo htmlspecialchars($profile['market_size']); ?></p> <div class="card-body">
<p class="card-text"><strong>Existing Sales Motions:</strong> <?php echo htmlspecialchars($profile['sales_motions']); ?></p> <h5 class="card-title">Role Recommendations</h5>
<hr> <p class="card-text text-muted small">AI-powered suggestions for marketing and sales roles.</p>
<h6 class="card-subtitle mb-2 text-muted">Team & Roles</h6> <div id="roles-container" class="mt-3">
<p class="card-text"><strong>Organization Size:</strong> <?php echo htmlspecialchars($profile['org_size']); ?></p> <?php if (!empty($profile['roles_text'])): ?>
<p class="card-text"><strong>Marketing and Sales Roles:</strong> <?php echo htmlspecialchars($profile['roles']); ?></p> <?php echo $profile['roles_text']; ?>
<hr> <?php endif; ?>
<h6 class="card-subtitle mb-2 text-muted">Goals</h6> </div>
<p class="card-text"><strong>Growth Goals:</strong> <?php echo htmlspecialchars($profile['goals']); ?></p> <button id="generate-roles-btn" class="btn btn-primary btn-sm <?php if (!empty($profile['roles_text'])) echo 'd-none'; ?>" data-profile-id="<?php echo htmlspecialchars($profile_id); ?>">Generate Roles</button>
<hr> </div>
</div>
<!-- Tools Card -->
<div class="card mb-4">
<div class="card-body">
<h5 class="card-title">Tools & Integrations</h5>
<p class="card-text text-muted small">Discover top industry solutions and integrations.</p>
<div id="tools-container" class="mt-3">
<?php if (!empty($profile['tools_text'])): ?>
<?php echo $profile['tools_text']; ?>
<?php endif; ?>
</div>
<button id="generate-tools-btn" class="btn btn-primary btn-sm <?php if (!empty($profile['tools_text'])) echo 'd-none'; ?>" data-profile-id="<?php echo htmlspecialchars($profile_id); ?>">Generate Tools</button>
</div>
</div>
<!-- Profile Details Card -->
<div class="card mb-4">
<div class="card-body">
<h5 class="card-title">Profile Details</h5>
<p class="card-text"><strong>Sells:</strong> <?php echo htmlspecialchars($profile['sells_what']); ?></p>
<hr>
<h6 class="card-subtitle mb-2 text-muted">Market & Sales</h6>
<p class="card-text"><strong>ICP:</strong> <?php echo htmlspecialchars($profile['icp']); ?></p>
<p class="card-text"><strong>Market Size:</strong> <?php echo htmlspecialchars($profile['market_size']); ?></p>
<p class="card-text"><strong>Sales Motions:</strong> <?php echo htmlspecialchars($profile['sales_motions']); ?></p>
<hr>
<h6 class="card-subtitle mb-2 text-muted">Team & Roles</h6>
<p class="card-text"><strong>Org Size:</strong> <?php echo htmlspecialchars($profile['org_size']); ?></p>
<p class="card-text"><strong>Current Roles:</strong> <?php echo htmlspecialchars($profile['roles']); ?></p>
<hr>
<h6 class="card-subtitle mb-2 text-muted">Goals</h6>
<p class="card-text"><strong>Growth Goals:</strong> <?php echo htmlspecialchars($profile['goals']); ?></p>
</div>
</div>
</div>
</div>
<?php else: ?>
<div class="alert alert-warning" role="alert">
No GTM profile found. Please <a href="list_profiles.php">select one</a> or <a href="start.php">create a new one</a>.
</div> </div>
</div>
<?php else: ?>
<div class="alert alert-warning" role="alert">
No GTM profile found. Please <a href="list_profiles.php">select one</a> or <a href="start.php">create a new one</a>.
</div>
<?php endif; ?> <?php endif; ?>
</main> </main>