Edit create_startup.php via Editor

This commit is contained in:
Flatlogic Bot 2026-02-28 19:54:19 +00:00
parent a7855afce8
commit 017ad41531
3 changed files with 251 additions and 338 deletions

View File

@ -1,28 +1,19 @@
<?php
session_start();
require_once 'db/config.php';
require_once 'ai/LocalAIApi.php';
session_start();
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'founder') {
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'founder') {
header('Location: login.php');
exit;
}
$error = '';
$success = '';
$startup_id = $_GET['id'] ?? null;
$existingStartup = null;
$error = '';
if ($startup_id) {
$stmt = db()->prepare("SELECT * FROM startups WHERE id = ? AND founder_id = ?");
$stmt->execute([$startup_id, $_SESSION['user_id']]);
$existingStartup = $stmt->fetch();
if (!$existingStartup) {
header('Location: dashboard.php');
exit;
}
}
$stmt = db()->prepare("SELECT * FROM startups WHERE founder_id = ?");
$stmt->execute([$_SESSION['user_id']]);
$existingStartup = $stmt->fetch();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = $_POST['name'] ?? '';
@ -34,24 +25,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$product_service = $_POST['product_service'] ?? '';
$operational_stage = $_POST['operational_stage'] ?? '';
// Co-founder matching fields
$cofounder_equity_pct = $_POST['cofounder_equity_pct'] ?? '';
$cofounder_equity_pct = $_POST['cofounder_equity_pct'] ?? 0.0;
$cofounder_equity_type = $_POST['cofounder_equity_type'] ?? '';
$cofounder_responsibilities = $_POST['cofounder_responsibilities'] ?? '';
$desired_cofounder_experience = $_POST['desired_cofounder_experience'] ?? '';
$cofounder_commitment = $_POST['cofounder_commitment'] ?? '';
$other_partnership_details = $_POST['other_partnership_details'] ?? '';
// Financial stats
$current_cash_balance = (float)($_POST['current_cash_balance'] ?? 0);
$burn_rate = (float)($_POST['burn_rate'] ?? 0);
$current_cash_balance = $_POST['current_cash_balance'] ?? 0.0;
$outstanding_debt = $_POST['outstanding_debt'] ?? '';
$accounts_receivable_payable = $_POST['accounts_receivable_payable'] ?? '';
$upload_dir = 'assets/docs/financials/';
if (!is_dir($upload_dir)) {
mkdir($upload_dir, 0775, true);
}
$burn_rate = $_POST['burn_rate'] ?? 0.0;
$doc_fields = [
'doc_income_statements',
@ -63,21 +47,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$uploaded_paths = [];
foreach ($doc_fields as $field) {
$uploaded_paths[$field] = $existingStartup[$field] ?? null;
if (isset($_FILES[$field]) && $_FILES[$field]['error'] === UPLOAD_ERR_OK) {
$file_ext = pathinfo($_FILES[$field]['name'], PATHINFO_EXTENSION);
$file_name = uniqid($field . '_', true) . '.' . $file_ext;
$dest_path = $upload_dir . $file_name;
if (move_uploaded_file($_FILES[$field]['tmp_name'], $dest_path)) {
$uploaded_paths[$field] = $dest_path;
} else {
$error = "Failed to upload $field.";
break;
$ext = pathinfo($_FILES[$field]['name'], PATHINFO_EXTENSION);
$new_name = $field . '_' . time() . '.' . $ext;
$upload_dir = 'assets/docs/financials/';
if (!is_dir($upload_dir)) mkdir($upload_dir, 0775, true);
$upload_path = $upload_dir . $new_name;
if (move_uploaded_file($_FILES[$field]['tmp_name'], $upload_path)) {
$uploaded_paths[$field] = $upload_path;
}
} elseif ($existingStartup && !empty($existingStartup[$field])) {
$uploaded_paths[$field] = $existingStartup[$field];
} else {
$error = "The financial document for $field is mandatory.";
break;
}
}
@ -92,7 +71,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
try {
// Compute AI Recommended Return Rate
$recommended_return_rate = $existingStartup['recommended_return_rate'] ?? 0.0;
$recommended_return_reasoning = $existingStartup['recommended_return_reasoning'] ?? '';
$doc_list = [];
foreach ($uploaded_paths as $key => $path) {
if ($path) {
$label = str_replace(['doc_', '_'], ['', ' '], $key);
$doc_list[] = ucwords($label);
}
}
$docs_str = !empty($doc_list) ? implode(", ", $doc_list) : "None";
// AI Prompt
$prompt = "As a financial analyst, calculate a recommended annual dividend yield (interest percentage) based on this startup profile:
Name: {$name}
@ -102,8 +91,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
Stage: {$operational_stage}
Cash Balance: £{$current_cash_balance}
Burn Rate: £{$burn_rate}
Documents provided: {$docs_str}
Respond ONLY with a JSON object: {\"recommended_rate\": X.X}";
Based on the financial documents provided and the company's stage/industry, please provide:
1. A recommended return rate (percentage).
2. A brief reasoning (2-3 sentences) on how you arrived at this figure, explicitly mentioning how the provided documents influenced your decision.
Respond ONLY with a JSON object: {\"recommended_rate\": X.X, \"reasoning\": \"...\"}";
$aiResponse = LocalAIApi::createResponse([
'input' => [
@ -115,6 +109,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!empty($aiResponse['success'])) {
$decoded = LocalAIApi::decodeJsonFromResponse($aiResponse);
$recommended_return_rate = (float)($decoded['recommended_rate'] ?? 5.0);
$recommended_return_reasoning = (string)($decoded['reasoning'] ?? 'Based on industry standards and provided financials.');
}
if ($existingStartup) {
@ -123,7 +118,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
cofounder_equity_pct = ?, cofounder_equity_type = ?, cofounder_responsibilities = ?, desired_cofounder_experience = ?, cofounder_commitment = ?, other_partnership_details = ?,
current_cash_balance = ?, outstanding_debt = ?, accounts_receivable_payable = ?, burn_rate = ?,
doc_income_statements = ?, doc_balance_sheets = ?, doc_cash_flow_statements = ?, doc_revenue_breakdown = ?, doc_gross_margin = ?,
recommended_return_rate = ?
recommended_return_rate = ?, recommended_return_reasoning = ?
WHERE id = ? AND founder_id = ?");
$stmt->execute([
@ -132,7 +127,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$current_cash_balance, $outstanding_debt, $accounts_receivable_payable, $burn_rate,
$uploaded_paths['doc_income_statements'], $uploaded_paths['doc_balance_sheets'], $uploaded_paths['doc_cash_flow_statements'],
$uploaded_paths['doc_revenue_breakdown'], $uploaded_paths['doc_gross_margin'],
$recommended_return_rate, $existingStartup['id'], $_SESSION['user_id']
$recommended_return_rate, $recommended_return_reasoning, $existingStartup['id'], $_SESSION['user_id']
]);
$final_id = $existingStartup['id'];
} else {
@ -141,8 +136,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
cofounder_equity_pct, cofounder_equity_type, cofounder_responsibilities, desired_cofounder_experience, cofounder_commitment, other_partnership_details,
current_cash_balance, outstanding_debt, accounts_receivable_payable, burn_rate,
doc_income_statements, doc_balance_sheets, doc_cash_flow_statements, doc_revenue_breakdown, doc_gross_margin,
founder_id, recommended_return_rate, status
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'private')");
founder_id, recommended_return_rate, recommended_return_reasoning, status
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'private')");
$stmt->execute([
$name, $legal_name, $country, $industry, $sub_industry, $business_model, $product_service, $operational_stage,
@ -150,13 +145,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$current_cash_balance, $outstanding_debt, $accounts_receivable_payable, $burn_rate,
$uploaded_paths['doc_income_statements'], $uploaded_paths['doc_balance_sheets'], $uploaded_paths['doc_cash_flow_statements'],
$uploaded_paths['doc_revenue_breakdown'], $uploaded_paths['doc_gross_margin'],
$_SESSION['user_id'], $recommended_return_rate
$_SESSION['user_id'], $recommended_return_rate, $recommended_return_reasoning
]);
$final_id = db()->lastInsertId();
}
db()->commit();
$success = "Startup profile saved successfully! Recommended return rate: " . number_format($recommended_return_rate, 2) . "%";
$success = "Startup profile saved successfully! Recommended return rate: " . number_format($recommended_return_rate, 2) . "%" ;
// Refresh local data
$stmt = db()->prepare("SELECT * FROM startups WHERE id = ?");
@ -191,167 +186,112 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<?php endif; ?>
<?php if ($success): ?>
<div style="background: rgba(76, 217, 100, 0.1); color: #4cd964; padding: 15px; border-radius: 12px; border: 1px solid #4cd964; margin-bottom: 25px;">
<div style="background: rgba(48, 209, 88, 0.1); color: #30d158; padding: 15px; border-radius: 12px; border: 1px solid #30d158; margin-bottom: 25px;">
<i class="fas fa-check-circle"></i> <?= $success ?>
<div style="margin-top: 10px;">
<a href="startup_details.php?id=<?= $final_id ?>" class="btn btn-secondary" style="padding: 8px 15px; font-size: 13px;">View Live Profile</a>
</div>
</div>
<?php endif; ?>
<?php if (!$success || $existingStartup): ?>
<form method="POST" enctype="multipart/form-data" class="card" style="padding: 30px; border-radius: 24px;">
<h3 style="margin-top: 0; margin-bottom: 20px; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; font-size: 18px;"><i class="fas fa-info-circle"></i> 1. Basic Company Information</h3>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px;">
<form method="POST" enctype="multipart/form-data">
<!-- Basic Info -->
<section style="background: var(--card-bg); padding: 30px; border-radius: 20px; border: 1px solid var(--border-color); margin-bottom: 30px;">
<h2 style="font-size: 20px; margin-bottom: 20px;"><i class="fas fa-info-circle" style="color: var(--accent-color);"></i> Company Information</h2>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px;">
<div>
<label>Public Name (Marketing) *</label>
<input type="text" name="name" required value="<?= htmlspecialchars($existingStartup['name'] ?? '') ?>">
<label style="display: block; margin-bottom: 8px; color: #aaa;">Startup Name *</label>
<input type="text" name="name" value="<?= htmlspecialchars($existingStartup['name'] ?? '') ?>" required style="width: 100%; padding: 12px; border-radius: 8px; background: #222; border: 1px solid #333; color: #fff;">
</div>
<div>
<label>Legal Entity Name *</label>
<input type="text" name="legal_name" required value="<?= htmlspecialchars($existingStartup['legal_name'] ?? '') ?>">
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px;">
<div>
<label>Country of Incorporation *</label>
<input type="text" name="country" required value="<?= htmlspecialchars($existingStartup['country'] ?? '') ?>">
<label style="display: block; margin-bottom: 8px; color: #aaa;">Legal Entity Name *</label>
<input type="text" name="legal_name" value="<?= htmlspecialchars($existingStartup['legal_name'] ?? '') ?>" required style="width: 100%; padding: 12px; border-radius: 8px; background: #222; border: 1px solid #333; color: #fff;">
</div>
<div>
<label>Primary Industry *</label>
<select name="industry" required>
<option value="">Select...</option>
<label style="display: block; margin-bottom: 8px; color: #aaa;">Country of Incorporation *</label>
<input type="text" name="country" value="<?= htmlspecialchars($existingStartup['country'] ?? '') ?>" required style="width: 100%; padding: 12px; border-radius: 8px; background: #222; border: 1px solid #333; color: #fff;">
</div>
<div>
<label style="display: block; margin-bottom: 8px; color: #aaa;">Industry *</label>
<select name="industry" required style="width: 100%; padding: 12px; border-radius: 8px; background: #222; border: 1px solid #333; color: #fff;">
<option value="FinTech" <?= ($existingStartup['industry'] ?? '') === 'FinTech' ? 'selected' : '' ?>>FinTech</option>
<option value="HealthTech" <?= ($existingStartup['industry'] ?? '') === 'HealthTech' ? 'selected' : '' ?>>HealthTech</option>
<option value="SaaS" <?= ($existingStartup['industry'] ?? '') === 'SaaS' ? 'selected' : '' ?>>SaaS</option>
<option value="HealthTech" <?= ($existingStartup['industry'] ?? '') === 'HealthTech' ? 'selected' : '' ?>>HealthTech</option>
<option value="E-commerce" <?= ($existingStartup['industry'] ?? '') === 'E-commerce' ? 'selected' : '' ?>>E-commerce</option>
<option value="CleanTech" <?= ($existingStartup['industry'] ?? '') === 'CleanTech' ? 'selected' : '' ?>>CleanTech</option>
<option value="EdTech" <?= ($existingStartup['industry'] ?? '') === 'EdTech' ? 'selected' : '' ?>>EdTech</option>
<option value="AI/ML" <?= ($existingStartup['industry'] ?? '') === 'AI/ML' ? 'selected' : '' ?>>AI/ML</option>
<option value="Other" <?= ($existingStartup['industry'] ?? '') === 'Other' ? 'selected' : '' ?>>Other</option>
</select>
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px;">
<div>
<label>Sub-Industry / Niche</label>
<input type="text" name="sub_industry" value="<?= htmlspecialchars($existingStartup['sub_industry'] ?? '') ?>" placeholder="e.g. AI-driven logistics">
</div>
<div>
<label>Business Model *</label>
<select name="business_model" required>
<option value="">Select...</option>
<option value="B2B" <?= ($existingStartup['business_model'] ?? '') === 'B2B' ? 'selected' : '' ?>>B2B</option>
<option value="B2C" <?= ($existingStartup['business_model'] ?? '') === 'B2C' ? 'selected' : '' ?>>B2C</option>
<option value="Marketplace" <?= ($existingStartup['business_model'] ?? '') === 'Marketplace' ? 'selected' : '' ?>>Marketplace</option>
<option value="SaaS" <?= ($existingStartup['business_model'] ?? '') === 'SaaS' ? 'selected' : '' ?>>SaaS Subscription</option>
</select>
</div>
<div style="margin-top: 20px;">
<label style="display: block; margin-bottom: 8px; color: #aaa;">Business Model *</label>
<textarea name="business_model" required style="width: 100%; padding: 12px; border-radius: 8px; background: #222; border: 1px solid #333; color: #fff; height: 100px;"><?= htmlspecialchars($existingStartup['business_model'] ?? '') ?></textarea>
</div>
<div style="margin-bottom: 20px;">
<label>Operational Stage *</label>
<select name="operational_stage" required>
<option value="">Select...</option>
<option value="Pre-revenue" <?= ($existingStartup['operational_stage'] ?? '') === 'Pre-revenue' ? 'selected' : '' ?>>Pre-revenue / Prototype</option>
<option value="Early-traction" <?= ($existingStartup['operational_stage'] ?? '') === 'Early-traction' ? 'selected' : '' ?>>Early Traction (Paying customers)</option>
<option value="Growth" <?= ($existingStartup['operational_stage'] ?? '') === 'Growth' ? 'selected' : '' ?>>Growth (Consistent MRR)</option>
<option value="Scale" <?= ($existingStartup['operational_stage'] ?? '') === 'Scale' ? 'selected' : '' ?>>Scaling (National/International)</option>
<div style="margin-top: 20px;">
<label style="display: block; margin-bottom: 8px; color: #aaa;">Product/Service Overview *</label>
<textarea name="product_service" required style="width: 100%; padding: 12px; border-radius: 8px; background: #222; border: 1px solid #333; color: #fff; height: 100px;"><?= htmlspecialchars($existingStartup['product_service'] ?? '') ?></textarea>
</div>
<div style="margin-top: 20px;">
<label style="display: block; margin-bottom: 8px; color: #aaa;">Operational Stage *</label>
<select name="operational_stage" required style="width: 100%; padding: 12px; border-radius: 8px; background: #222; border: 1px solid #333; color: #fff;">
<option value="Idea/Prototype" <?= ($existingStartup['operational_stage'] ?? '') === 'Idea/Prototype' ? 'selected' : '' ?>>Idea/Prototype</option>
<option value="MVP/Early Traction" <?= ($existingStartup['operational_stage'] ?? '') === 'MVP/Early Traction' ? 'selected' : '' ?>>MVP/Early Traction</option>
<option value="Growth/Scaling" <?= ($existingStartup['operational_stage'] ?? '') === 'Growth/Scaling' ? 'selected' : '' ?>>Growth/Scaling</option>
<option value="Mature" <?= ($existingStartup['operational_stage'] ?? '') === 'Mature' ? 'selected' : '' ?>>Mature</option>
</select>
</div>
<div style="margin-bottom: 30px;">
<label>Briefly describe your Product/Service *</label>
<textarea name="product_service" required style="height: 80px;"><?= htmlspecialchars($existingStartup['product_service'] ?? '') ?></textarea>
</div>
</section>
<h3 style="margin-bottom: 20px; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; font-size: 18px;"><i class="fas fa-handshake"></i> 2. Co-founder Matching & Partnership</h3>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px;">
<div>
<label>Equity Offered (%)</label>
<input type="text" name="cofounder_equity_pct" value="<?= htmlspecialchars($existingStartup['cofounder_equity_pct'] ?? '') ?>" placeholder="e.g. 10-15%">
</div>
<div>
<label>Commitment Level</label>
<input type="text" name="cofounder_commitment" value="<?= htmlspecialchars($existingStartup['cofounder_commitment'] ?? '') ?>" placeholder="e.g. Full-time">
</div>
</div>
<div style="margin-bottom: 20px;">
<label>Equity Type</label>
<input type="text" name="cofounder_equity_type" value="<?= htmlspecialchars($existingStartup['cofounder_equity_type'] ?? '') ?>" placeholder="e.g. Common Shares, Options">
</div>
<div style="margin-bottom: 20px;">
<label>Core Responsibilities for Co-founder</label>
<textarea name="cofounder_responsibilities" style="height: 60px;"><?= htmlspecialchars($existingStartup['cofounder_responsibilities'] ?? '') ?></textarea>
</div>
<div style="margin-bottom: 20px;">
<label>Desired Experience/Background</label>
<textarea name="desired_cofounder_experience" style="height: 60px;"><?= htmlspecialchars($existingStartup['desired_cofounder_experience'] ?? '') ?></textarea>
</div>
<div style="margin-bottom: 30px;">
<label>Other Partnership Details</label>
<textarea name="other_partnership_details" style="height: 60px;"><?= htmlspecialchars($existingStartup['other_partnership_details'] ?? '') ?></textarea>
</div>
<h3 style="margin-bottom: 20px; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; font-size: 18px;"><i class="fas fa-file-invoice-dollar"></i> 3. Mandatory Financials</h3>
<!-- Financials -->
<section style="background: var(--card-bg); padding: 30px; border-radius: 20px; border: 1px solid var(--border-color); margin-bottom: 30px;">
<h2 style="font-size: 20px; margin-bottom: 20px;"><i class="fas fa-chart-line" style="color: var(--accent-color);"></i> Financial Overview</h2>
<div style="background: rgba(255,255,255,0.03); padding: 20px; border-radius: 12px; margin-bottom: 25px;">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px;">
<div>
<label>Current Cash Balance (£)</label>
<input type="number" step="0.01" name="current_cash_balance" value="<?= (float)($existingStartup['current_cash_balance'] ?? 0) ?>">
</div>
<div>
<label>Monthly Burn Rate (£)</label>
<input type="number" step="0.01" name="burn_rate" value="<?= (float)($existingStartup['burn_rate'] ?? 0) ?>">
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px;">
<div>
<label style="display: block; margin-bottom: 8px; color: #aaa;">Current Cash Balance (£)</label>
<input type="number" step="0.01" name="current_cash_balance" value="<?= htmlspecialchars($existingStartup['current_cash_balance'] ?? 0) ?>" style="width: 100%; padding: 12px; border-radius: 8px; background: #222; border: 1px solid #333; color: #fff;">
</div>
<div style="margin-bottom: 20px;">
<label>Outstanding Debt</label>
<input type="text" name="outstanding_debt" value="<?= htmlspecialchars($existingStartup['outstanding_debt'] ?? '') ?>">
</div>
<div style="margin-bottom: 20px;">
<label>Accounts Receivable / Payable</label>
<input type="text" name="accounts_receivable_payable" value="<?= htmlspecialchars($existingStartup['accounts_receivable_payable'] ?? '') ?>">
<div>
<label style="display: block; margin-bottom: 8px; color: #aaa;">Monthly Burn Rate (£)</label>
<input type="number" step="0.01" name="burn_rate" value="<?= htmlspecialchars($existingStartup['burn_rate'] ?? 0) ?>" style="width: 100%; padding: 12px; border-radius: 8px; background: #222; border: 1px solid #333; color: #fff;">
</div>
</div>
<p style="font-size: 14px; font-weight: 700; color: var(--accent-blue); margin-bottom: 15px;">Historical Financial Documentation (PDF/Images)</p>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 30px;">
<?php
$doc_labels = [
'doc_income_statements' => 'Income Statements',
'doc_balance_sheets' => 'Balance Sheets',
'doc_cash_flow_statements' => 'Cash Flow Statements',
'doc_revenue_breakdown' => 'Revenue Breakdown',
'doc_gross_margin' => 'Gross Margin Data'
];
foreach ($doc_labels as $f_name => $label):
?>
<div class="file-input-group">
<label><?= $label ?> <?= $existingStartup ? '' : '*' ?></label>
<input type="file" name="<?= $f_name ?>" <?= $existingStartup ? '' : 'required' ?> accept=".pdf,image/*">
<?php if ($existingStartup && !empty($existingStartup[$f_name])):
<div style="margin-top: 30px;">
<h3 style="font-size: 16px; margin-bottom: 15px; color: #fff;">Upload Financial Documents (PDF/Images)</h3>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px;">
<?php
$doc_labels = [
'doc_income_statements' => 'Income Statements',
'doc_balance_sheets' => 'Balance Sheets',
'doc_cash_flow_statements' => 'Cash Flow Statements',
'doc_revenue_breakdown' => 'Revenue Breakdown',
'doc_gross_margin' => 'Gross Margin Analysis'
];
foreach ($doc_labels as $field => $label):
?>
<span style="font-size: 10px; color: #4cd964;"><i class="fas fa-check"></i> Already uploaded</span>
<?php endif; ?>
<div style="background: #222; padding: 15px; border-radius: 12px; border: 1px solid #333;">
<label style="display: block; margin-bottom: 8px; font-size: 14px; color: #aaa;"><?= $label ?></label>
<input type="file" name="<?= $field ?>" style="width: 100%; color: #888; font-size: 12px;">
<?php if (!empty($existingStartup[$field])):
?>
<div style="margin-top: 8px; font-size: 12px; color: var(--accent-color);">
<i class="fas fa-file-alt"></i> Already uploaded
</div>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
</div>
</section>
<button type="submit" class="btn btn-primary" style="width: 100%; padding: 18px; font-weight: 800; font-size: 18px; border-radius: 16px;">
<?= $existingStartup ? 'Update Profile' : 'Create Startup Profile' ?> <i class="fas fa-save" style="margin-left: 10px;"></i>
</button>
<a href="<?= $existingStartup ? 'startup_details.php?id=' . $startup_id : 'dashboard.php' ?>" style="display: block; text-align: center; margin-top: 15px; color: var(--text-secondary); text-decoration: none;">Cancel</a>
</form>
<?php endif; ?>
<button type="submit" style="width: 100%; padding: 16px; border-radius: 12px; background: var(--accent-color); color: #000; font-weight: 700; border: none; font-size: 18px; cursor: pointer;">
Save & Compute AI Recommendation
</button>
</form>
</div>
</div>
<style>
label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--text-secondary); }
input, select, textarea { width: 100%; padding: 12px 16px; background: var(--surface-color); border: 1px solid var(--border-color); border-radius: 12px; color: #fff; font-size: 14px; margin-bottom: 10px; }
textarea { resize: vertical; }
.file-input-group { background: rgba(255,255,255,0.02); padding: 15px; border-radius: 12px; border: 1px dashed var(--border-color); }
.file-input-group input { border: none; padding: 0; margin: 0; background: transparent; }
</style>
</body>
</html>
</html>

View File

@ -0,0 +1,3 @@
-- Migration: Add recommended return reasoning to startups
ALTER TABLE startups
ADD COLUMN recommended_return_reasoning TEXT AFTER recommended_return_rate;

View File

@ -1,153 +1,166 @@
<?php
require_once 'db/config.php';
session_start();
require_once 'db/config.php';
$startup_id = $_GET['id'] ?? null;
if (!$startup_id) {
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit;
}
$startupId = $_GET['id'] ?? null;
if (!$startupId) {
header('Location: startups.php');
exit;
}
// Fetch startup details
$stmt = db()->prepare("SELECT s.*, u.full_name as founder_name
FROM startups s
JOIN users u ON s.founder_id = u.id
WHERE s.id = ?");
$stmt->execute([$startup_id]);
$stmt = db()->prepare("SELECT * FROM startups WHERE id = ?");
$stmt->execute([$startupId]);
$startup = $stmt->fetch();
if (!$startup) {
header('Location: startups.php');
exit;
die("Startup not found.");
}
// Fetch funding history
$stmt = db()->prepare("SELECT i.*, u.full_name as investor_name
FROM investments i
JOIN users u ON i.investor_id = u.id
WHERE i.startup_id = ?
ORDER BY i.created_at DESC");
$stmt->execute([$startup_id]);
$fundingHistory = $stmt->fetchAll();
// Check if user is the founder or an investor
$isFounder = ($_SESSION['user_id'] == $startup['founder_id']);
$isInvestor = ($_SESSION['user_role'] == 'investor');
// Check if user is the founder
$isFounder = isset($_SESSION['user_id']) && $_SESSION['user_id'] == $startup['founder_id'];
$isInvestor = isset($_SESSION['user_id']) && $_SESSION['role'] === 'investor';
// For investors, check if they can see history (maybe only after some interaction?)
// For now, let everyone see.
$canSeeHistory = true;
// Handle following
$isFollowing = false;
if (isset($_SESSION['user_id'])) {
$stmt = db()->prepare("SELECT 1 FROM startup_followers WHERE startup_id = ? AND user_id = ?");
$stmt->execute([$startup_id, $_SESSION['user_id']]);
$isFollowing = (bool)$stmt->fetch();
// Basic permissions check
if (!$isFounder && $startup['status'] === 'private' && !$isInvestor) {
die("You do not have permission to view this profile.");
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit;
}
if ($_POST['action'] === 'follow') {
if ($isFollowing) {
$stmt = db()->prepare("DELETE FROM startup_followers WHERE startup_id = ? AND user_id = ?");
$stmt->execute([$startup_id, $_SESSION['user_id']]);
$stmt = db()->prepare("UPDATE startups SET followers_count = followers_count - 1 WHERE id = ?");
$stmt->execute([$startup_id]);
} else {
$stmt = db()->prepare("INSERT INTO startup_followers (startup_id, user_id) VALUES (?, ?)");
$stmt->execute([$startup_id, $_SESSION['user_id']]);
$stmt = db()->prepare("UPDATE startups SET followers_count = followers_count + 1 WHERE id = ?");
$stmt->execute([$startup_id]);
}
header("Location: startup_details.php?id=$startup_id");
exit;
}
// Fetch funding history if investor
$canSeeHistory = $isFounder || $isInvestor;
$fundingHistory = [];
if ($canSeeHistory) {
$stmt = db()->prepare("SELECT i.*, u.name as investor_name FROM investments i JOIN users u ON i.investor_id = u.id WHERE i.startup_id = ? ORDER BY i.created_at DESC");
$stmt->execute([$startupId]);
$fundingHistory = $stmt->fetchAll();
}
// Fetch founders
$stmt = db()->prepare("SELECT name FROM users WHERE id = ?");
$stmt->execute([$startup['founder_id']]);
$founder = $stmt->fetch();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><?= htmlspecialchars($startup['name']) ?> | Venture Capitalist</title>
<title><?= htmlspecialchars($startup['name']) ?> | Startup Details</title>
<link rel="stylesheet" href="assets/css/custom.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/dist/css/all.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<style>
.doc-link {
:root {
--accent-blue: #00f2ff;
--surface-color: #1a1a1a;
--text-secondary: #999;
--border-color: rgba(255,255,255,0.1);
}
.card {
background: var(--surface-color);
border: 1px solid var(--border-color);
border-radius: 24px;
padding: 35px;
position: relative;
overflow: hidden;
}
.section-title {
font-size: 20px;
font-weight: 800;
margin-bottom: 25px;
display: flex;
align-items: center;
gap: 10px;
gap: 12px;
}
.data-label {
font-size: 12px;
text-transform: uppercase;
letter-spacing: 1px;
color: var(--text-secondary);
margin-bottom: 8px;
}
.doc-link {
background: rgba(255,255,255,0.05);
padding: 12px 20px;
background: rgba(255, 255, 255, 0.05);
border: 1px solid var(--border-color);
border-radius: 12px;
text-decoration: none;
color: #fff;
display: flex;
align-items: center;
gap: 10px;
font-size: 14px;
transition: all 0.2s;
border: 1px solid var(--border-color);
}
.doc-link:hover {
background: rgba(255, 255, 255, 0.1);
border-color: var(--accent-blue);
background: rgba(255,255,255,0.1);
transform: translateY(-2px);
}
.data-label { color: var(--text-secondary); font-size: 12px; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
.invest-btn {
background: var(--accent-blue);
color: #000;
padding: 16px 32px;
border-radius: 14px;
text-decoration: none;
font-weight: 800;
display: inline-flex;
align-items: center;
gap: 10px;
transition: all 0.3s;
box-shadow: 0 8px 24px rgba(0, 242, 255, 0.3);
}
.invest-btn:hover {
transform: scale(1.05);
box-shadow: 0 12px 32px rgba(0, 242, 255, 0.4);
}
</style>
</head>
<body style="background: var(--bg-color); color: #fff;">
<body style="background: #000; color: #fff;">
<div style="background: linear-gradient(to right, #001f3f, #000); padding: 60px 0; border-bottom: 1px solid var(--border-color);">
<div class="container">
<div style="display: flex; justify-content: space-between; align-items: flex-end;">
<div class="container" style="padding: 60px 20px;">
<div style="max-width: 900px; margin: 0 auto;">
<!-- Header Section -->
<div style="display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 50px;">
<div>
<a href="startups.php" style="color: var(--accent-blue); text-decoration: none; font-size: 14px; margin-bottom: 20px; display: inline-block;">
<i class="fas fa-arrow-left"></i> Back to Discover
</a>
<div style="display: flex; align-items: center; gap: 20px;">
<div style="width: 80px; height: 80px; background: var(--surface-color); border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 900; color: var(--accent-blue); border: 2px solid var(--border-color);">
<?= substr($startup['name'], 0, 1) ?>
</div>
<div>
<h1 style="margin: 0; font-size: 42px; font-weight: 900;"><?= htmlspecialchars($startup['name']) ?></h1>
<div style="display: flex; gap: 15px; margin-top: 10px; color: var(--text-secondary);">
<span><i class="fas fa-industry"></i> <?= htmlspecialchars($startup['industry']) ?></span>
<span><i class="fas fa-map-marker-alt"></i> <?= htmlspecialchars($startup['country']) ?></span>
<span><i class="fas fa-users"></i> <?= $startup['followers_count'] ?> Followers</span>
</div>
</div>
<div style="display: flex; align-items: center; gap: 15px; margin-bottom: 15px;">
<span style="background: rgba(0, 242, 255, 0.1); color: var(--accent-blue); padding: 6px 14px; border-radius: 100px; font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;">
<?= htmlspecialchars($startup['industry']) ?>
</span>
<span style="color: var(--text-secondary); font-size: 13px;">
<i class="fas fa-map-marker-alt"></i> <?= htmlspecialchars($startup['country']) ?>
</span>
</div>
<h1 style="font-size: 48px; font-weight: 900; margin: 0; line-height: 1.1; letter-spacing: -1px;">
<?= htmlspecialchars($startup['name']) ?>
</h1>
<p style="color: var(--text-secondary); margin-top: 10px; font-size: 16px;">
Founded by <span style="color: #fff; font-weight: 700;"><?= htmlspecialchars($founder['name']) ?></span>
</p>
</div>
<div style="display: flex; gap: 10px;">
<form method="POST">
<input type="hidden" name="action" value="follow">
<button type="submit" class="btn <?= $isFollowing ? 'btn-secondary' : 'btn-primary' ?>" style="padding: 12px 25px; border-radius: 12px;">
<i class="fas <?= $isFollowing ? 'fa-check' : 'fa-plus' ?>"></i> <?= $isFollowing ? 'Following' : 'Follow' ?>
</button>
</form>
<?php if ($isInvestor): ?>
<a href="messages.php?start_chat=<?= $startup['founder_id'] ?>&startup_id=<?= $startup['id'] ?>" class="btn btn-secondary" style="padding: 12px 25px; border-radius: 12px; text-decoration: none; display: inline-flex; align-items: center; gap: 8px;">
<i class="fas fa-envelope"></i> Contact Founder
</a>
<?php endif; ?>
<?php if ($isFounder): ?>
<a href="create_startup.php?id=<?= $startup['id'] ?>" class="btn btn-secondary" style="padding: 12px 25px; border-radius: 12px; text-decoration: none;">
<i class="fas fa-edit"></i> Edit Profile
</a>
<?php endif; ?>
<?php if ($isInvestor): ?>
<div style="display: flex; gap: 15px;">
<a href="messages.php?startup_id=<?= $startup['id'] ?>" style="background: rgba(255,255,255,0.05); border: 1px solid var(--border-color); color: #fff; padding: 16px 24px; border-radius: 14px; text-decoration: none; font-weight: 700; display: inline-flex; align-items: center; gap: 10px;">
<i class="far fa-comment-dots"></i> Message Founder
</a>
<a href="invest.php?id=<?= $startup['id'] ?>" class="invest-btn">
<i class="fas fa-rocket"></i> Invest Now
</a>
</div>
<?php elseif ($isFounder): ?>
<a href="create_startup.php" style="background: rgba(255,255,255,0.05); border: 1px solid var(--border-color); color: #fff; padding: 16px 24px; border-radius: 14px; text-decoration: none; font-weight: 700; display: inline-flex; align-items: center; gap: 10px;">
<i class="fas fa-edit"></i> Edit Profile
</a>
<?php endif; ?>
</div>
</div>
</div>
<div class="container" style="padding: 40px 0; display: grid; grid-template-columns: 2fr 1fr; gap: 40px;">
<div>
<!-- Product & Vision -->
<section class="card" style="margin-bottom: 40px;">
<h2 class="section-title"><i class="fas fa-info-circle" style="color: var(--accent-blue);"></i> Executive Summary</h2>
<h2 class="section-title"><i class="fas fa-eye" style="color: var(--accent-blue);"></i> Product & Vision</h2>
<p style="font-size: 18px; line-height: 1.6; color: rgba(255,255,255,0.9);">
<?= nl2br(htmlspecialchars($startup['product_service'])) ?>
</p>
@ -230,6 +243,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
<div style="font-size: 11px; color: var(--text-secondary); margin-top: 5px;">Target annual dividend yield set by founder</div>
</div>
</div>
<?php if (!empty($startup['recommended_return_reasoning'])): ?>
<div style="margin-top: 20px; padding: 15px; background: rgba(255,255,255,0.03); border-radius: 12px; border: 1px solid rgba(0, 242, 255, 0.1); font-size: 13px; line-height: 1.5; color: rgba(255,255,255,0.8);">
<div style="font-weight: 700; margin-bottom: 5px; color: var(--accent-blue); text-transform: uppercase; font-size: 10px; letter-spacing: 0.5px;">Calculation Reasoning</div>
<?= htmlspecialchars($startup['recommended_return_reasoning']) ?>
</div>
<?php endif; ?>
</section>
<!-- Funding History Section -->
@ -249,12 +268,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
<span style="font-weight: 800; color: var(--accent-blue);"><?= substr($inv['investor_name'], 0, 1) ?></span>
</div>
<div>
<div style="font-weight: 700; font-size: 16px;"><?= htmlspecialchars($inv['investor_name']) ?></div>
<div style="font-weight: 700;"><?= htmlspecialchars($inv['investor_name']) ?></div>
<div style="font-size: 12px; color: var(--text-secondary);"><?= date('M d, Y', strtotime($inv['created_at'])) ?></div>
</div>
</div>
<div style="text-align: right;">
<div style="font-weight: 800; font-size: 18px; color: var(--accent-blue);">£<?= number_format($inv['amount']) ?></div>
<div style="font-weight: 900; color: #fff; font-size: 18px;">£<?= number_format($inv['amount']) ?></div>
<div style="font-size: 12px; color: var(--accent-blue); font-weight: 700;"><?= $inv['equity_pct'] ?>% Equity</div>
</div>
</div>
<?php endforeach; ?>
@ -263,61 +283,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
</section>
<?php endif; ?>
</div>
<div>
<!-- Sidebar with Financial Stats -->
<section class="card" style="margin-bottom: 30px; border-left: 4px solid var(--accent-blue);">
<h4 style="margin-top: 0; color: var(--text-secondary); text-transform: uppercase; font-size: 12px; letter-spacing: 1px;">Venture Financials</h4>
<div style="margin: 20px 0;">
<div style="font-size: 32px; font-weight: 900; color: var(--text-primary);">£<?= number_format($startup['funding_raised']) ?></div>
<div style="font-size: 13px; color: var(--text-secondary);">Total Raised All-Time</div>
</div>
<div style="height: 1px; background: var(--border-color); margin: 20px 0;"></div>
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;">
<div>
<div style="font-weight: 700;"><?= count($fundingHistory) ?></div>
<div style="font-size: 11px; color: var(--text-secondary);">Investors</div>
</div>
<div style="text-align: right;">
<div style="font-weight: 700;">£<?= number_format($startup['funding_goal']) ?></div>
<div style="font-size: 11px; color: var(--text-secondary);">Current Goal</div>
</div>
</div>
<div style="margin-top: 25px;">
<div style="height: 8px; background: rgba(255,255,255,0.05); border-radius: 10px; overflow: hidden;">
<div style="width: <?= min(100, ($startup['funding_raised'] / ($startup['funding_goal'] ?: 1)) * 100) ?>%; height: 100%; background: var(--accent-blue);"></div>
</div>
<div style="display: flex; justify-content: space-between; font-size: 11px; margin-top: 8px; color: var(--text-secondary);">
<span><?= number_format(($startup['funding_raised'] / ($startup['funding_goal'] ?: 1)) * 100, 1) ?>% Funded</span>
<span>£<?= number_format(max(0, $startup['funding_goal'] - $startup['funding_raised'])) ?> Left</span>
</div>
</div>
<?php if ($isInvestor): ?>
<a href="portfolio.php?invest_id=<?= $startup_id ?>" class="btn btn-primary" style="width: 100%; margin-top: 25px; padding: 15px; border-radius: 12px; text-decoration: none; display: block; text-align: center; font-weight: 800;">
Invest Now
</a>
<?php endif; ?>
</section>
<section class="card">
<h4 style="margin-top: 0; color: var(--text-secondary); text-transform: uppercase; font-size: 12px; letter-spacing: 1px;">The Founder</h4>
<div style="display: flex; align-items: center; gap: 15px; margin: 20px 0;">
<div style="width: 50px; height: 50px; border-radius: 15px; background: var(--surface-color); display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-color);">
<i class="fas fa-user-tie" style="color: var(--accent-blue);"></i>
</div>
<div>
<div style="font-weight: 700; font-size: 16px;"><?= htmlspecialchars($startup['founder_name']) ?></div>
<div style="font-size: 12px; color: var(--text-secondary);">Founder & CEO</div>
</div>
</div>
<div style="font-size: 14px; line-height: 1.5; color: var(--text-secondary);">
Managed and verified by Venture Capitalist Platform.
</div>
</section>
</div>
</div>
<footer style="padding: 60px 0; border-top: 1px solid var(--border-color); margin-top: 100px; text-align: center;">
<p style="color: var(--text-secondary); font-size: 14px;">&copy; <?= date('Y') ?> Venture Capitalist Platform. All rights reserved.</p>
</footer>
</body>
</html>
</html>