diff --git a/create_startup.php b/create_startup.php index ff2ff65..42863e5 100644 --- a/create_startup.php +++ b/create_startup.php @@ -1,50 +1,53 @@ 0) { +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; + } } if ($_SERVER['REQUEST_METHOD'] === 'POST') { - // Basic Info - $name = trim($_POST['name'] ?? ''); - $legal_name = trim($_POST['legal_name'] ?? ''); - $country = trim($_POST['country'] ?? ''); - $industry = trim($_POST['industry'] ?? ''); - $sub_industry = trim($_POST['sub_industry'] ?? ''); - $business_model = trim($_POST['business_model'] ?? ''); - $product_service = trim($_POST['product_service'] ?? ''); - $operational_stage = trim($_POST['operational_stage'] ?? ''); + $name = $_POST['name'] ?? ''; + $legal_name = $_POST['legal_name'] ?? ''; + $country = $_POST['country'] ?? ''; + $industry = $_POST['industry'] ?? ''; + $sub_industry = $_POST['sub_industry'] ?? ''; + $business_model = $_POST['business_model'] ?? ''; + $product_service = $_POST['product_service'] ?? ''; + $operational_stage = $_POST['operational_stage'] ?? ''; + + // Co-founder matching fields + $cofounder_equity_pct = $_POST['cofounder_equity_pct'] ?? ''; + $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'] ?? ''; - // Co-founder Matching - $cofounder_equity_pct = trim($_POST['cofounder_equity_pct'] ?? ''); - $cofounder_equity_type = trim($_POST['cofounder_equity_type'] ?? ''); - $cofounder_responsibilities = trim($_POST['cofounder_responsibilities'] ?? ''); - $desired_cofounder_experience = trim($_POST['desired_cofounder_experience'] ?? ''); - $cofounder_commitment = trim($_POST['cofounder_commitment'] ?? ''); - $other_partnership_details = trim($_POST['other_partnership_details'] ?? ''); - - // Current Financials + // Financial stats $current_cash_balance = (float)($_POST['current_cash_balance'] ?? 0); - $outstanding_debt = trim($_POST['outstanding_debt'] ?? ''); - $accounts_receivable_payable = trim($_POST['accounts_receivable_payable'] ?? ''); $burn_rate = (float)($_POST['burn_rate'] ?? 0); + $outstanding_debt = $_POST['outstanding_debt'] ?? ''; + $accounts_receivable_payable = $_POST['accounts_receivable_payable'] ?? ''; - // File Uploads $upload_dir = 'assets/docs/financials/'; if (!is_dir($upload_dir)) { mkdir($upload_dir, 0775, true); @@ -55,8 +58,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { 'doc_balance_sheets', 'doc_cash_flow_statements', 'doc_revenue_breakdown', - 'doc_gross_margin', - 'doc_opex_breakdown' + 'doc_gross_margin' ]; $uploaded_paths = []; @@ -120,7 +122,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { name = ?, legal_name = ?, country = ?, industry = ?, sub_industry = ?, business_model = ?, product_service = ?, operational_stage = ?, 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 = ?, doc_opex_breakdown = ?, + doc_income_statements = ?, doc_balance_sheets = ?, doc_cash_flow_statements = ?, doc_revenue_breakdown = ?, doc_gross_margin = ?, recommended_return_rate = ? WHERE id = ? AND founder_id = ?"); @@ -129,7 +131,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, $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'], $uploaded_paths['doc_opex_breakdown'], + $uploaded_paths['doc_revenue_breakdown'], $uploaded_paths['doc_gross_margin'], $recommended_return_rate, $existingStartup['id'], $_SESSION['user_id'] ]); $final_id = $existingStartup['id']; @@ -138,16 +140,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { name, legal_name, country, industry, sub_industry, business_model, product_service, operational_stage, 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, doc_opex_breakdown, + doc_income_statements, doc_balance_sheets, doc_cash_flow_statements, doc_revenue_breakdown, doc_gross_margin, founder_id, recommended_return_rate, status - ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'private')"); + ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'private')"); $stmt->execute([ $name, $legal_name, $country, $industry, $sub_industry, $business_model, $product_service, $operational_stage, $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, $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'], $uploaded_paths['doc_opex_breakdown'], + $uploaded_paths['doc_revenue_breakdown'], $uploaded_paths['doc_gross_margin'], $_SESSION['user_id'], $recommended_return_rate ]); $final_id = db()->lastInsertId(); @@ -155,99 +157,108 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { db()->commit(); $success = "Startup profile saved successfully! Recommended return rate: " . number_format($recommended_return_rate, 2) . "%"; - header("refresh:2;url=startup_details.php?id=" . $final_id); + + // Refresh local data + $stmt = db()->prepare("SELECT * FROM startups WHERE id = ?"); + $stmt->execute([$final_id]); + $existingStartup = $stmt->fetch(); + } catch (Exception $e) { db()->rollBack(); - $error = "Error: " . $e->getMessage(); + $error = "Database error: " . $e->getMessage(); } } } - -$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby'; ?> - + - - - <?= $existingStartup ? 'Edit Profile' : 'Step 1: Setup Startup Profile' ?> — <?= htmlspecialchars($platformName) ?> - - - + + <?= $existingStartup ? 'Edit' : 'Create' ?> Startup Profile | Venture Capitalist + + - + -
-
-

-

- -

+
+
+

Startup Profile

-
- +
+
-
- + - -
- -

1. Basic Company Information

+ + + + +

1. Basic Company Information

- +
- +
+
+
- +
+
+
- - + +
- - + + + + +
- - + +
- +
@@ -310,8 +321,7 @@ $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby'; 'doc_balance_sheets' => 'Balance Sheets', 'doc_cash_flow_statements' => 'Cash Flow Statements', 'doc_revenue_breakdown' => 'Revenue Breakdown', - 'doc_gross_margin' => 'Gross Margin Data', - 'doc_opex_breakdown' => 'OpEx Breakdown' + 'doc_gross_margin' => 'Gross Margin Data' ]; foreach ($doc_labels as $f_name => $label): ?> diff --git a/startup_details.php b/startup_details.php index a049449..6361e2c 100644 --- a/startup_details.php +++ b/startup_details.php @@ -2,493 +2,322 @@ require_once 'db/config.php'; session_start(); -$user_id = $_SESSION['user_id'] ?? null; -if (!$user_id) { header('Location: login.php'); exit; } +$startup_id = $_GET['id'] ?? null; +if (!$startup_id) { + header('Location: startups.php'); + exit; +} -$stmt = db()->prepare("SELECT * FROM users WHERE id = ?"); -$stmt->execute([$user_id]); -$user = $stmt->fetch(); -if (!$user) { header('Location: login.php'); exit; } - -$startup_id = (int)($_GET['id'] ?? 0); -$stmt = db()->prepare("SELECT * FROM startups WHERE id = ?"); +// 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]); $startup = $stmt->fetch(); -if (!$startup) { header('Location: startups.php'); exit; } +if (!$startup) { + header('Location: startups.php'); + exit; +} -$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby'; -$error = ''; -$success = ''; +// 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 following -$stmt = db()->prepare("SELECT id FROM startup_followers WHERE user_id = ? AND startup_id = ?"); -$stmt->execute([$user_id, $startup_id]); -$isFollowing = $stmt->fetch(); +// 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(); +} -// Actions: follow/unfollow, invest, post_update, finish_round, cancel_round if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) { + if (!isset($_SESSION['user_id'])) { + header('Location: login.php'); + exit; + } + if ($_POST['action'] === 'follow') { - $stmt = db()->prepare("INSERT IGNORE INTO startup_followers (user_id, startup_id) VALUES (?, ?)"); - $stmt->execute([$user_id, $startup_id]); - if ($stmt->rowCount() > 0) { + 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]); } - $success = "You are now following " . $startup['name'] . "!"; - } elseif ($_POST['action'] === 'unfollow') { - $stmt = db()->prepare("DELETE FROM startup_followers WHERE user_id = ? AND startup_id = ?"); - $stmt->execute([$user_id, $startup_id]); - if ($stmt->rowCount() > 0) { - $stmt = db()->prepare("UPDATE startups SET followers_count = GREATEST(0, followers_count - 1) WHERE id = ?"); - $stmt->execute([$startup_id]); - } - $success = "You have unfollowed " . $startup['name'] . "."; - } elseif ($_POST['action'] === 'invest' && $user['role'] === 'investor') { - $amount = (float)($_POST['amount'] ?? 0); - if ($amount > 0) { - $stmt = db()->prepare("SELECT * FROM funding_rounds WHERE startup_id = ? AND status = 'Active'"); - $stmt->execute([$startup_id]); - $round = $stmt->fetch(); - if ($round) { - $stmt = db()->prepare("INSERT INTO investments (investor_id, startup_id, funding_round_id, amount, status) VALUES (?, ?, ?, ?, 'approved')"); - $stmt->execute([$user_id, $startup_id, $round['id'], $amount]); - - $stmt = db()->prepare("UPDATE funding_rounds SET funding_raised = funding_raised + ? WHERE id = ?"); - $stmt->execute([$amount, $round['id']]); - - $stmt = db()->prepare("UPDATE startups SET funding_raised = funding_raised + ? WHERE id = ?"); - $stmt->execute([$amount, $startup_id]); - - // Create notification for founder - $notif = db()->prepare("INSERT INTO notifications (user_id, content) VALUES (?, ?)"); - $notif->execute([$startup['founder_id'], $user['full_name'] . " just invested £" . number_format($amount) . " in " . $startup['name'] . "!"]); - - $success = "Investment of £" . number_format($amount) . " successfully processed!"; - // Refresh data - $stmt = db()->prepare("SELECT * FROM startups WHERE id = ?"); - $stmt->execute([$startup_id]); - $startup = $stmt->fetch(); - } - } - } elseif ($_POST['action'] === 'post_update' && $user['role'] === 'founder' && $startup['founder_id'] == $user_id) { - $title = $_POST['update_title'] ?? ''; - $content = $_POST['update_content'] ?? ''; - if ($title && $content) { - $stmt = db()->prepare("INSERT INTO startup_updates (startup_id, founder_id, title, content) VALUES (?, ?, ?, ?)"); - $stmt->execute([$startup_id, $user_id, $title, $content]); - - // Notify followers - $stmt = db()->prepare("SELECT user_id FROM startup_followers WHERE startup_id = ?"); - $stmt->execute([$startup_id]); - $followers = $stmt->fetchAll(PDO::FETCH_COLUMN); - - if (!empty($followers)) { - $notif = db()->prepare("INSERT INTO notifications (user_id, content) VALUES (?, ?)"); - foreach ($followers as $f_id) { - $notif->execute([$f_id, "New update from " . $startup['name'] . ": " . $title]); - } - } - $success = "Update posted successfully!"; - } - } elseif ($_POST['action'] === 'finish_round' && $user['role'] === 'founder' && $startup['founder_id'] == $user_id) { - $stmt = db()->prepare("UPDATE funding_rounds SET status = 'Closed' WHERE startup_id = ? AND status = 'Active'"); - $stmt->execute([$startup_id]); - $success = "Funding round successfully closed!"; - } elseif ($_POST['action'] === 'cancel_round' && $user['role'] === 'founder' && $startup['founder_id'] == $user_id) { - db()->beginTransaction(); - try { - $stmt = db()->prepare("SELECT id FROM funding_rounds WHERE startup_id = ? AND status = 'Active'"); - $stmt->execute([$startup_id]); - $round = $stmt->fetch(); - - if ($round) { - $stmt = db()->prepare("UPDATE funding_rounds SET status = 'Cancelled' WHERE id = ?"); - $stmt->execute([$round['id']]); - - $stmt = db()->prepare("UPDATE investments SET status = 'Refunded' WHERE funding_round_id = ?"); - $stmt->execute([$round['id']]); - - $stmt = db()->prepare("SELECT SUM(amount) as total FROM investments WHERE funding_round_id = ? AND status = 'Refunded'"); - $stmt->execute([$round['id']]); - $totalRefunded = $stmt->fetch()['total'] ?? 0; - - $stmt = db()->prepare("UPDATE startups SET funding_raised = GREATEST(0, funding_raised - ?) WHERE id = ?"); - $stmt->execute([$totalRefunded, $startup_id]); - - db()->commit(); - $success = "Funding round cancelled and all investments marked for refund."; - - $stmt = db()->prepare("SELECT * FROM startups WHERE id = ?"); - $stmt->execute([$startup_id]); - $startup = $stmt->fetch(); - } else { - db()->rollBack(); - $error = "No active round found to cancel."; - } - } catch (Exception $e) { - db()->rollBack(); - $error = "Error: " . $e->getMessage(); - } + header("Location: startup_details.php?id=$startup_id"); + exit; } } -$stmt = db()->prepare("SELECT * FROM funding_rounds WHERE startup_id = ? AND status = 'Active'"); -$stmt->execute([$startup_id]); -$activeRound = $stmt->fetch(); - -$canSeeHistory = ($user['role'] === 'investor' || ($user['role'] === 'founder' && $startup['founder_id'] == $user_id)); - -$fundingHistory = []; -if ($canSeeHistory) { - $stmt = db()->prepare(" - SELECT i.*, u.full_name as investor_name, u.profile_photo as investor_photo - FROM investments i - JOIN users u ON i.investor_id = u.id - WHERE i.startup_id = ? AND i.status != 'rejected' - ORDER BY i.created_at DESC - "); - $stmt->execute([$startup_id]); - $fundingHistory = $stmt->fetchAll(); -} - ?> - + - - - <?= htmlspecialchars($startup['name']) ?> — <?= htmlspecialchars($platformName) ?> - - - - - + + <?= htmlspecialchars($startup['name']) ?> | Venture Capitalist + + - + -
- -
- -
- -
- - -
- - -
-
-
-
- -
-
-

-
- - - () - +
+
+
+
+ + Back to Discover + +
+
+ +
+
+

+
+ + + Followers +
- - - - - - - - - - +
+ +
+
+
-
-

About the Venture

-
-

Business Model

-

+
+
+
+

Executive Summary

+

+ +

+ +
+
+

Business Model

+

-

Product/Service

-

+

Operational Stage

+

-
+
+
-
-

Co-founder Matching & Partnership

-
-
-
Equity Offered
-
-
-
-
Commitment
-
-
-
-
Equity Type
-
-
-
-
-
-
Core Responsibilities
-
-
-
-
Desired Background
-
-
-
-
-
Other Partnership Details
-
-
-
- -
-

Financial Position & Docs

-
-
-
Current Cash Balance
-
£
-
-
-
Monthly Burn Rate
-
£
-
-
-
-
-
-
Outstanding Debt
-
-
-
-
Accounts Receivable/Payable
-
-
-
-
- -

Historical Documentation

-
- $startup['doc_income_statements'], - 'Balance Sheets' => $startup['doc_balance_sheets'], - 'Cash Flow' => $startup['doc_cash_flow_statements'], - 'Revenue Breakdown' => $startup['doc_revenue_breakdown'], - 'Gross Margin' => $startup['doc_gross_margin'], - 'OpEx Breakdown' => $startup['doc_opex_breakdown'] - ]; - foreach ($docs as $label => $path): if ($path): - ?> - - - - -
-
- - -
-

- Expected Investor Returns -

+
+

Financial Health

+ +
-
-
Platform Recommendation
-
%
-
AI analysis based on uploaded financials
+
+
Cash on Hand
+
£
-
-
Founder's Proposal
-
- -
-
Target annual dividend yield set by founder
+
+
Monthly Burn
+
£
-
+
+
+
+
+
Outstanding Debt
+
+
+
+
Accounts Receivable/Payable
+
+
+
+
+ +

Historical Documentation

+
+ $startup['doc_income_statements'], + 'Balance Sheets' => $startup['doc_balance_sheets'], + 'Cash Flow' => $startup['doc_cash_flow_statements'], + 'Revenue Breakdown' => $startup['doc_revenue_breakdown'], + 'Gross Margin' => $startup['doc_gross_margin'] + ]; + foreach ($docs as $label => $path): if ($path): + ?> + + + + +
+ - - -
-

Funding History

- -
-

No investment history available yet.

-
- -
- -
-
-
- -
-
-
-
-
+ +
+

+ Expected Investor Returns +

+
+
+
Platform Recommendation
+
%
+
AI analysis based on uploaded financials
+
+
+
Founder's Proposal
+
+ +
+
Target annual dividend yield set by founder
+
+
+
+ + + +
+

Funding History

+ +
+

No investment history available yet.

+
+ +
+ +
+
+
+
-
-
£
+
+
+
- -
- -
- -
- -
- -
-

Venture Financials

-
-
£
-
Total Raised All-Time
-
-
-
-
-
-
Investments
-
-
-
-
Followers
-
-
-
-
Stage
-
-
-
- - -
-

Active Round

-
- 0) ? min(100, ($activeRound['funding_raised'] / $activeRound['funding_goal']) * 100) : 0; ?> -
-
-
-
- £ - £ target -
-
- - -
- -
- - +
+
£
+
- -
- -
-
- - -
-
- - -
-
- -
- - -
- -

No Active Round

-

Ready to raise capital?

- Start New Round -
- - - -
-

Founder

- prepare("SELECT * FROM users WHERE id = ?"); - $stmt->execute([$startup['founder_id']]); - $founder = $stmt->fetch(); - ?> -
-
- +
-
-
-
-
-
- Send Message - - Edit Profile
-
+
-
-
-
-

© . All rights reserved.

+
+ +
+

Venture Financials

+
+
£
+
Total Raised All-Time
+
+
+
+
+
+
Investors
+
+
+
£
+
Current Goal
+
+
+ +
+
+
+
+
+ % Funded + £ Left +
+
+ + + + Invest Now + + +
+ +
+

The Founder

+
+
+ +
+
+
+
Founder & CEO
+
+
+
+ Managed and verified by Venture Capitalist Platform. +
+
-
+
- - + \ No newline at end of file