prepare("SELECT * FROM users WHERE id = ?"); $stmt->execute([$user_id]); $user = $stmt->fetch(); $startupId = $_GET['id'] ?? null; if (!$startupId) { header('Location: startups.php'); exit; } $stmt = db()->prepare(" SELECT s.*, fr.id as round_id, fr.funding_goal as active_goal, fr.funding_raised as active_raised, fr.status as round_status FROM startups s LEFT JOIN funding_rounds fr ON s.id = fr.startup_id AND fr.status = 'Active' WHERE s.id = ? "); $stmt->execute([$startupId]); $startup = $stmt->fetch(); if (!$startup) { die("Startup not found."); } // Check if user is the founder or an investor $isFounder = ($_SESSION['user_id'] == $startup['founder_id']); $isInvestor = ($user['role'] == 'investor'); // Basic permissions check if (!$isFounder && $startup['status'] === 'private' && !$isInvestor) { die("You do not have permission to view this profile."); } // Fetch funding history $canSeeHistory = $isFounder || $isInvestor; $fundingHistory = []; if ($canSeeHistory) { $stmt = db()->prepare(" SELECT i.*, u.full_name as investor_name, u.id as investor_user_id FROM investments i LEFT 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([$startupId]); $fundingHistory = $stmt->fetchAll(); } // Fetch approved investments for dividends calculation (Founder only) $approvedInvestments = []; if ($isFounder) { $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 = ? AND i.status = 'approved' "); $stmt->execute([$startupId]); $approvedInvestments = $stmt->fetchAll(); } // Fetch founders $stmt = db()->prepare("SELECT id, full_name FROM users WHERE id = ?"); $stmt->execute([$startup['founder_id']]); $founder = $stmt->fetch(); $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby'; // Calculate progress $goal = $startup['active_goal'] ?: 0; $raised = $startup['active_raised'] ?: 0; $progress = ($goal > 0) ? round(($raised / $goal) * 100) : 0; /** * Helper to calculate time left for next dividend */ function getNextDividendInfo($createdAt) { $created = new DateTime($createdAt); $day = $created->format('d'); $now = new DateTime(); $thisMonth = new DateTime($now->format('Y-m-') . $day); // If today is past the day, next is next month if ($thisMonth <= $now) { $next = clone $thisMonth; $next->modify('+1 month'); } else { $next = $thisMonth; } $interval = $now->diff($next); $days = $interval->days; return [ 'date' => $next->format('M d, Y'), 'days_left' => $days ]; } ?>
Founded by = htmlspecialchars($founder['full_name']) ?>
This pot holds all investments received. You can withdraw funds for business operations or add funds to cover investor dividends.
Track upcoming monthly payments to your investors based on your = number_format($startup['founder_return_rate'] ?? 0, 1) ?>% offered return.
= nl2br(htmlspecialchars($startup['product_service'])) ?>
= htmlspecialchars($startup['business_model']) ?>
= htmlspecialchars($startup['operational_stage']) ?>
No investment history available yet.