v46
This commit is contained in:
parent
48562f356c
commit
98fedc4d56
@ -40,7 +40,7 @@ if (!$isFounder && $startup['status'] === 'private' && !$isInvestor) {
|
||||
die("You do not have permission to view this profile.");
|
||||
}
|
||||
|
||||
// Fetch funding history if investor
|
||||
// Fetch funding history
|
||||
$canSeeHistory = $isFounder || $isInvestor;
|
||||
$fundingHistory = [];
|
||||
if ($canSeeHistory) {
|
||||
@ -55,6 +55,19 @@ if ($canSeeHistory) {
|
||||
$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 as name FROM users WHERE id = ?");
|
||||
$stmt->execute([$startup['founder_id']]);
|
||||
@ -66,6 +79,33 @@ $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
|
||||
$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
|
||||
];
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
@ -155,6 +195,44 @@ $progress = ($goal > 0) ? round(($raised / $goal) * 100) : 0;
|
||||
box-shadow: 0 0 15px rgba(0, 242, 255, 0.3);
|
||||
border-radius: 100px;
|
||||
}
|
||||
.dividend-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 15px;
|
||||
background: rgba(255,255,255,0.02);
|
||||
border-radius: 16px;
|
||||
border: 1px solid var(--border-color);
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.btn-status-small {
|
||||
padding: 10px 15px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
border-radius: 10px;
|
||||
border: 1px solid transparent;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
background: transparent;
|
||||
text-decoration: none;
|
||||
}
|
||||
.btn-cancel-small {
|
||||
border-color: rgba(255, 59, 48, 0.3);
|
||||
color: #ff3b30;
|
||||
}
|
||||
.btn-cancel-small:hover {
|
||||
background: rgba(255, 59, 48, 0.1);
|
||||
}
|
||||
.btn-finish-small {
|
||||
border-color: rgba(48, 209, 88, 0.3);
|
||||
color: #30d158;
|
||||
}
|
||||
.btn-finish-small:hover {
|
||||
background: rgba(48, 209, 88, 0.1);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body style="background: #000; color: #fff;">
|
||||
@ -191,6 +269,12 @@ $progress = ($goal > 0) ? round(($raised / $goal) * 100) : 0;
|
||||
<div class="container" style="padding: 60px 20px;">
|
||||
<div style="max-width: 900px; margin: 0 auto;">
|
||||
|
||||
<?php if (isset($_GET['success'])): ?>
|
||||
<div style="background: rgba(48, 209, 88, 0.1); border: 1px solid rgba(48, 209, 88, 0.3); color: #30d158; padding: 15px; border-radius: 12px; margin-bottom: 25px; font-size: 14px; text-align: center;">
|
||||
Round status updated successfully!
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Header Section -->
|
||||
<div style="display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 50px;">
|
||||
<div>
|
||||
@ -246,6 +330,53 @@ $progress = ($goal > 0) ? round(($raised / $goal) * 100) : 0;
|
||||
<div style="font-size: 20px;">£<?= number_format($goal) ?></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($isFounder): ?>
|
||||
<div style="display: flex; gap: 15px; margin-top: 30px; border-top: 1px solid var(--border-color); padding-top: 25px;">
|
||||
<form action="update_round_status.php" method="POST" style="margin: 0;" onsubmit="return confirm('Finish this round early?');">
|
||||
<input type="hidden" name="round_id" value="<?= $startup['round_id'] ?>">
|
||||
<input type="hidden" name="status" value="Closed">
|
||||
<button type="submit" class="btn-status-small btn-finish-small">
|
||||
<i class="fas fa-check-circle"></i> Finish Round Early
|
||||
</button>
|
||||
</form>
|
||||
<form action="update_round_status.php" method="POST" style="margin: 0;" onsubmit="return confirm('Cancel this funding round?');">
|
||||
<input type="hidden" name="round_id" value="<?= $startup['round_id'] ?>">
|
||||
<input type="hidden" name="status" value="Cancelled">
|
||||
<button type="submit" class="btn-status-small btn-cancel-small">
|
||||
<i class="fas fa-times-circle"></i> Cancel Round
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($isFounder && !empty($approvedInvestments)): ?>
|
||||
<!-- Dividend Management (Founder Only) -->
|
||||
<section class="card" style="margin-bottom: 40px; border-color: rgba(48, 209, 88, 0.3);">
|
||||
<h2 class="section-title"><i class="fas fa-hand-holding-usd" style="color: #30d158;"></i> Monthly Dividends Due</h2>
|
||||
<div style="margin-bottom: 20px;">
|
||||
<p style="color: var(--text-secondary); font-size: 14px;">Track upcoming monthly payments to your investors based on your <strong><?= number_format($startup['founder_return_rate'] ?? 0, 1) ?>%</strong> offered return.</p>
|
||||
</div>
|
||||
|
||||
<?php foreach ($approvedInvestments as $inv):
|
||||
$monthlyYield = ($inv['amount'] * ($startup['founder_return_rate'] ?? 0) / 100) / 12;
|
||||
$nextPay = getNextDividendInfo($inv['created_at']);
|
||||
?>
|
||||
<div class="dividend-item">
|
||||
<div>
|
||||
<div style="font-weight: 700; font-size: 15px;"><?= htmlspecialchars($inv['investor_name']) ?></div>
|
||||
<div style="font-size: 12px; color: var(--text-secondary);">Invested £<?= number_format($inv['amount']) ?></div>
|
||||
</div>
|
||||
<div style="text-align: right;">
|
||||
<div style="font-size: 18px; font-weight: 900; color: #fff;">£<?= number_format($monthlyYield, 2) ?></div>
|
||||
<div style="font-size: 11px; color: <?= $nextPay['days_left'] < 7 ? '#ff3b30' : '#30d158' ?>; font-weight: 700;">
|
||||
<i class="far fa-clock"></i> <?= $nextPay['days_left'] ?> days left
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
59
startups.php
59
startups.php
@ -28,7 +28,7 @@ $stmt->execute();
|
||||
$trendingIds = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
$stmt = db()->prepare("
|
||||
SELECT s.*, fr.funding_goal as active_goal, fr.funding_raised as active_raised, fr.status as round_status
|
||||
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.founder_id = ?
|
||||
@ -72,6 +72,36 @@ $myStartups = $stmt->fetchAll();
|
||||
50% { transform: scale(1.05); }
|
||||
100% { transform: scale(1); }
|
||||
}
|
||||
.btn-status {
|
||||
padding: 8px 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
border-radius: 8px;
|
||||
border: 1px solid transparent;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 5px;
|
||||
background: transparent;
|
||||
}
|
||||
.btn-cancel {
|
||||
border-color: rgba(255, 59, 48, 0.3);
|
||||
color: #ff3b30;
|
||||
}
|
||||
.btn-cancel:hover {
|
||||
background: rgba(255, 59, 48, 0.1);
|
||||
}
|
||||
.btn-finish {
|
||||
border-color: rgba(48, 209, 88, 0.3);
|
||||
color: #30d158;
|
||||
}
|
||||
.btn-finish:hover {
|
||||
background: rgba(48, 209, 88, 0.1);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@ -115,6 +145,12 @@ $myStartups = $stmt->fetchAll();
|
||||
<a href="create_startup.php" class="btn btn-primary">List New Startup</a>
|
||||
</div>
|
||||
|
||||
<?php if (isset($_GET['success'])): ?>
|
||||
<div style="background: rgba(48, 209, 88, 0.1); border: 1px solid rgba(48, 209, 88, 0.3); color: #30d158; padding: 15px; border-radius: 12px; margin-bottom: 25px; font-size: 14px; text-align: center;">
|
||||
Round status updated successfully!
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 25px;">
|
||||
<?php if (empty($myStartups)): ?>
|
||||
<div class="card" style="grid-column: 1 / -1; text-align: center; padding: 60px 20px;">
|
||||
@ -153,9 +189,28 @@ $myStartups = $stmt->fetchAll();
|
||||
<span>£<?= number_format($raised) ?> Raised</span>
|
||||
<span style="color: var(--text-secondary);"><?= $progress ?>%</span>
|
||||
</div>
|
||||
<div style="width: 100%; height: 6px; background: var(--border-color); border-radius: 3px; overflow: hidden; margin-bottom: 25px;">
|
||||
<div style="width: 100%; height: 6px; background: var(--border-color); border-radius: 3px; overflow: hidden; margin-bottom: 15px;">
|
||||
<div style="width: <?= min(100, $progress) ?>%; height: 100%; background: var(--gradient-primary);"></div>
|
||||
</div>
|
||||
|
||||
<!-- Management Buttons -->
|
||||
<div style="display: flex; gap: 10px; margin-bottom: 25px;">
|
||||
<form action="update_round_status.php" method="POST" style="flex: 1;" onsubmit="return confirm('Are you sure you want to finish this round early?');">
|
||||
<input type="hidden" name="round_id" value="<?= $startup['round_id'] ?>">
|
||||
<input type="hidden" name="status" value="Closed">
|
||||
<button type="submit" class="btn-status btn-finish">
|
||||
<i class="fas fa-check-circle"></i> Finish
|
||||
</button>
|
||||
</form>
|
||||
<form action="update_round_status.php" method="POST" style="flex: 1;" onsubmit="return confirm('Are you sure you want to cancel this round?');">
|
||||
<input type="hidden" name="round_id" value="<?= $startup['round_id'] ?>">
|
||||
<input type="hidden" name="status" value="Cancelled">
|
||||
<button type="submit" class="btn-status btn-cancel">
|
||||
<i class="fas fa-times-circle"></i> Cancel
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php else: ?>
|
||||
<div style="margin-bottom: 25px; padding: 15px; background: rgba(255,255,255,0.02); border-radius: 12px; border: 1px dashed var(--border-color); text-align: center;">
|
||||
<a href="start_funding_round.php?id=<?= $startup['id'] ?>" style="color: var(--accent-blue); text-decoration: none; font-size: 13px; font-weight: 700;">
|
||||
|
||||
42
update_round_status.php
Normal file
42
update_round_status.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$user_id = $_SESSION['user_id'];
|
||||
$round_id = $_POST['round_id'] ?? null;
|
||||
$status = $_POST['status'] ?? null;
|
||||
|
||||
if (!$round_id || !in_array($status, ['Closed', 'Cancelled'])) {
|
||||
header('Location: startups.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Verify that the user owns the startup associated with this round
|
||||
$stmt = db()->prepare("
|
||||
SELECT fr.*, s.founder_id
|
||||
FROM funding_rounds fr
|
||||
JOIN startups s ON fr.startup_id = s.id
|
||||
WHERE fr.id = ?
|
||||
");
|
||||
$stmt->execute([$round_id]);
|
||||
$round = $stmt->fetch();
|
||||
|
||||
if (!$round || $round['founder_id'] != $user_id) {
|
||||
die("Unauthorized action.");
|
||||
}
|
||||
|
||||
// Update the round status
|
||||
$stmt = db()->prepare("UPDATE funding_rounds SET status = ? WHERE id = ?");
|
||||
$stmt->execute([$status, $round_id]);
|
||||
|
||||
// If closed/cancelled, we should also ensure the startup status is updated if needed,
|
||||
// though the app uses funding_rounds status for 'Active' logic.
|
||||
// In startups.php, it checks: LEFT JOIN funding_rounds fr ON s.id = fr.startup_id AND fr.status = 'Active'
|
||||
|
||||
header('Location: startups.php?success=status_updated');
|
||||
exit;
|
||||
Loading…
x
Reference in New Issue
Block a user