0) { $stmt = db()->prepare("SELECT * FROM startups WHERE id = ? AND founder_id = ?"); $stmt->execute([$startup_id, $_SESSION['user_id']]); $existingStartup = $stmt->fetch(); } 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'] ?? ''); // 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 $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); // File Uploads $upload_dir = 'assets/docs/financials/'; if (!is_dir($upload_dir)) { mkdir($upload_dir, 0775, true); } $doc_fields = [ 'doc_income_statements', 'doc_balance_sheets', 'doc_cash_flow_statements', 'doc_revenue_breakdown', 'doc_gross_margin', 'doc_opex_breakdown' ]; $uploaded_paths = []; foreach ($doc_fields as $field) { 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; } } elseif ($existingStartup && !empty($existingStartup[$field])) { $uploaded_paths[$field] = $existingStartup[$field]; } else { $error = "The financial document for $field is mandatory."; break; } } if (!$error) { if (empty($name) || empty($legal_name) || empty($country) || empty($industry) || empty($business_model) || empty($product_service) || empty($operational_stage)) { $error = "Please fill in all mandatory company information fields."; } } if (!$error) { db()->beginTransaction(); try { // Compute AI Recommended Return Rate $recommended_return_rate = $existingStartup['recommended_return_rate'] ?? 0.0; // AI Prompt $prompt = "As a financial analyst, calculate a recommended annual dividend yield (interest percentage) based on this startup profile: Name: {$name} Industry: {$industry}/{$sub_industry} Business Model: {$business_model} Product: {$product_service} Stage: {$operational_stage} Cash Balance: £{$current_cash_balance} Burn Rate: £{$burn_rate} Respond ONLY with a JSON object: {\"recommended_rate\": X.X}"; $aiResponse = LocalAIApi::createResponse([ 'input' => [ ['role' => 'system', 'content' => 'You are a financial analyst. Return JSON only.'], ['role' => 'user', 'content' => $prompt], ], ]); if (!empty($aiResponse['success'])) { $decoded = LocalAIApi::decodeJsonFromResponse($aiResponse); $recommended_return_rate = (float)($decoded['recommended_rate'] ?? 5.0); } if ($existingStartup) { $stmt = db()->prepare("UPDATE startups SET 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 = ?, recommended_return_rate = ? WHERE id = ? AND founder_id = ?"); $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'], $recommended_return_rate, $existingStartup['id'], $_SESSION['user_id'] ]); $final_id = $existingStartup['id']; } else { $stmt = db()->prepare("INSERT INTO startups ( 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, founder_id, recommended_return_rate, status ) 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'], $_SESSION['user_id'], $recommended_return_rate ]); $final_id = db()->lastInsertId(); } 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); } catch (Exception $e) { db()->rollBack(); $error = "Error: " . $e->getMessage(); } } } $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby'; ?> <?= $existingStartup ? 'Edit Profile' : 'Step 1: Setup Startup Profile' ?> — <?= htmlspecialchars($platformName) ?>

1. Basic Company Information

2. Co-founder Matching & Partnership

3. Mandatory Financials

Historical Financial Documentation (PDF/Images)

'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', 'doc_opex_breakdown' => 'OpEx Breakdown' ]; foreach ($doc_labels as $f_name => $label): ?>
accept=".pdf,image/*"> Already uploaded
Cancel