![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/.cursor-server/data/User/History/7b132b3c/ |
<?php
// Get detailed earnings breakdown
$earnings_details = $pdo->prepare("
SELECT
s.*,
mt.title as track_title,
u.name as buyer_name,
DATE(s.created_at) as sale_date
FROM sales s
JOIN music_tracks mt ON s.track_id = mt.id
LEFT JOIN users u ON s.buyer_id = u.id
WHERE s.artist_id = ?
ORDER BY s.created_at DESC
LIMIT 50
");
$earnings_details->execute([$user_id]);
$recent_sales = $earnings_details->fetchAll();
// Get monthly earnings for chart
$monthly_earnings = $pdo->prepare("
SELECT
DATE_FORMAT(created_at, '%Y-%m') as month,
COUNT(*) as sales_count,
SUM(amount) as gross_revenue,
SUM(amount * ?) as artist_revenue
FROM sales
WHERE artist_id = ?
AND created_at >= DATE_SUB(NOW(), INTERVAL 12 MONTH)
GROUP BY DATE_FORMAT(created_at, '%Y-%m')
ORDER BY month DESC
");
$monthly_earnings->execute([1 - $commission_rate, $user_id]);
$monthly_data = $monthly_earnings->fetchAll();
// Calculate totals
$total_lifetime_earnings = $earnings['total_sales'];
$total_artist_earnings = $total_lifetime_earnings * (1 - $commission_rate);
$total_platform_commission = $total_lifetime_earnings * $commission_rate;
$pending_payout = $total_artist_earnings; // Simplified - could track actual payouts
// Get top-performing tracks
$top_tracks = $pdo->prepare("
SELECT
mt.title,
mt.price,
COUNT(s.id) as sales_count,
SUM(s.amount) as gross_revenue,
SUM(s.amount * ?) as artist_revenue
FROM music_tracks mt
LEFT JOIN sales s ON mt.id = s.track_id
WHERE mt.user_id = ?
GROUP BY mt.id
HAVING sales_count > 0
ORDER BY gross_revenue DESC
LIMIT 10
");
$top_tracks->execute([1 - $commission_rate, $user_id]);
$top_performing = $top_tracks->fetchAll();
?>
<div class="content-section">
<h2><i class="fas fa-dollar-sign"></i> Sales & Earnings Overview</h2>
<!-- Earnings Summary -->
<div class="earnings-breakdown">
<div class="earnings-item">
<div class="earnings-amount">$<?= number_format($total_lifetime_earnings, 2) ?></div>
<div>Total Gross Sales</div>
</div>
<div class="earnings-item">
<div class="earnings-amount">$<?= number_format($total_artist_earnings, 2) ?></div>
<div>Your Total Earnings (85%)</div>
</div>
<div class="earnings-item">
<div class="earnings-amount commission-amount">$<?= number_format($total_platform_commission, 2) ?></div>
<div>Platform Commission (15%)</div>
</div>
<div class="earnings-item">
<div class="earnings-amount" style="color: #4299e1;">$<?= number_format($pending_payout, 2) ?></div>
<div>Pending Payout</div>
</div>
</div>
<!-- Commission Breakdown Info -->
<div style="background: rgba(255, 255, 255, 0.05); border-radius: 12px; padding: 1.5rem; margin: 2rem 0;">
<h3 style="margin-bottom: 1rem;"><i class="fas fa-info-circle"></i> How Earnings Work</h3>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem;">
<div>
<strong style="color: #48bb78;">You Keep 85%</strong>
<p style="color: #a0aec0; margin-top: 0.5rem;">For every sale, you receive 85% of the track price directly to your account.</p>
</div>
<div>
<strong style="color: #ed8936;">Platform Fee 15%</strong>
<p style="color: #a0aec0; margin-top: 0.5rem;">Covers hosting, payment processing, promotion, and platform maintenance.</p>
</div>
<div>
<strong style="color: #4299e1;">Monthly Payouts</strong>
<p style="color: #a0aec0; margin-top: 0.5rem;">Earnings are paid out monthly via PayPal or bank transfer (minimum $25).</p>
</div>
</div>
</div>
</div>
<!-- Monthly Performance -->
<?php if (!empty($monthly_data)): ?>
<div class="content-section">
<h2><i class="fas fa-chart-line"></i> Monthly Performance</h2>
<div style="overflow-x: auto;">
<table style="width: 100%; border-collapse: collapse;">
<thead>
<tr style="border-bottom: 1px solid rgba(255, 255, 255, 0.1);">
<th style="padding: 1rem; text-align: left; color: #cbd5e0;">Month</th>
<th style="padding: 1rem; text-align: right; color: #cbd5e0;">Sales</th>
<th style="padding: 1rem; text-align: right; color: #cbd5e0;">Gross Revenue</th>
<th style="padding: 1rem; text-align: right; color: #cbd5e0;">Your Earnings</th>
</tr>
</thead>
<tbody>
<?php foreach ($monthly_data as $month): ?>
<tr style="border-bottom: 1px solid rgba(255, 255, 255, 0.05);">
<td style="padding: 1rem;"><?= date('F Y', strtotime($month['month'] . '-01')) ?></td>
<td style="padding: 1rem; text-align: right;"><?= number_format($month['sales_count']) ?></td>
<td style="padding: 1rem; text-align: right;">$<?= number_format($month['gross_revenue'], 2) ?></td>
<td style="padding: 1rem; text-align: right; color: #48bb78; font-weight: bold;">$<?= number_format($month['artist_revenue'], 2) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php endif; ?>
<!-- Top Performing Tracks -->
<?php if (!empty($top_performing)): ?>
<div class="content-section">
<h2><i class="fas fa-trophy"></i> Top Performing Tracks</h2>
<div style="display: grid; gap: 1rem;">
<?php foreach ($top_performing as $index => $track): ?>
<div style="display: flex; align-items: center; background: rgba(255, 255, 255, 0.05); border-radius: 12px; padding: 1rem;">
<div style="background: linear-gradient(135deg, #667eea, #764ba2); color: white; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; margin-right: 1rem;">
#<?= $index + 1 ?>
</div>
<div style="flex: 1;">
<div style="font-weight: 600; margin-bottom: 0.25rem;"><?= htmlspecialchars($track['title']) ?></div>
<div style="color: #a0aec0; font-size: 0.9rem;">
$<?= number_format($track['price'], 2) ?> • <?= number_format($track['sales_count']) ?> sales
</div>
</div>
<div style="text-align: right;">
<div style="font-size: 1.2rem; font-weight: bold; color: #48bb78;">
$<?= number_format($track['artist_revenue'], 2) ?>
</div>
<div style="font-size: 0.9rem; color: #a0aec0;">
Your earnings
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<!-- Recent Sales -->
<?php if (!empty($recent_sales)): ?>
<div class="content-section">
<h2><i class="fas fa-receipt"></i> Recent Sales</h2>
<div style="overflow-x: auto;">
<table style="width: 100%; border-collapse: collapse;">
<thead>
<tr style="border-bottom: 1px solid rgba(255, 255, 255, 0.1);">
<th style="padding: 1rem; text-align: left; color: #cbd5e0;">Date</th>
<th style="padding: 1rem; text-align: left; color: #cbd5e0;">Track</th>
<th style="padding: 1rem; text-align: left; color: #cbd5e0;">Buyer</th>
<th style="padding: 1rem; text-align: right; color: #cbd5e0;">Price</th>
<th style="padding: 1rem; text-align: right; color: #cbd5e0;">Your Earnings</th>
</tr>
</thead>
<tbody>
<?php foreach ($recent_sales as $sale): ?>
<tr style="border-bottom: 1px solid rgba(255, 255, 255, 0.05);">
<td style="padding: 1rem;"><?= date('M j, Y', strtotime($sale['created_at'])) ?></td>
<td style="padding: 1rem;"><?= htmlspecialchars($sale['track_title']) ?></td>
<td style="padding: 1rem;"><?= htmlspecialchars($sale['buyer_name'] ?: 'Anonymous') ?></td>
<td style="padding: 1rem; text-align: right;">$<?= number_format($sale['amount'], 2) ?></td>
<td style="padding: 1rem; text-align: right; color: #48bb78; font-weight: bold;">
$<?= number_format($sale['amount'] * (1 - $commission_rate), 2) ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php else: ?>
<div class="content-section">
<div style="text-align: center; padding: 3rem; color: #a0aec0;">
<i class="fas fa-receipt" style="font-size: 4rem; margin-bottom: 1rem; opacity: 0.3;"></i>
<h3>No sales yet</h3>
<p>Start promoting your tracks to get your first sale!</p>
<div style="margin-top: 2rem;">
<a href="?tab=tracks" class="btn btn-primary">
<i class="fas fa-music"></i> Manage My Tracks
</a>
<a href="community_fixed.php" class="btn btn-success" style="margin-left: 1rem;">
<i class="fas fa-share"></i> Share on Community
</a>
</div>
</div>
</div>
<?php endif; ?>
<!-- Payout Information -->
<div class="content-section">
<h2><i class="fas fa-credit-card"></i> Payout Information</h2>
<div style="background: rgba(255, 255, 255, 0.05); border-radius: 12px; padding: 1.5rem;">
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 2rem;">
<div>
<h4 style="color: #48bb78; margin-bottom: 1rem;">Next Payout</h4>
<div style="font-size: 2rem; font-weight: bold; margin-bottom: 0.5rem;">
$<?= number_format($pending_payout, 2) ?>
</div>
<div style="color: #a0aec0;">
<?php if ($pending_payout >= 25): ?>
Eligible for payout on <?= date('M j, Y', strtotime('first day of next month')) ?>
<?php else: ?>
Minimum $25.00 required for payout
<?php endif; ?>
</div>
</div>
<div>
<h4 style="color: #4299e1; margin-bottom: 1rem;">Payment Method</h4>
<div style="margin-bottom: 1rem;">
<i class="fab fa-paypal" style="font-size: 1.5rem; margin-right: 0.5rem;"></i>
PayPal (coming soon)
</div>
<div>
<i class="fas fa-university" style="font-size: 1.5rem; margin-right: 0.5rem;"></i>
Bank Transfer (coming soon)
</div>
</div>
<div>
<h4 style="color: #ed8936; margin-bottom: 1rem;">Tax Information</h4>
<p style="color: #a0aec0; line-height: 1.6;">
You're responsible for reporting earnings to your tax authority.
We'll provide annual earnings statements for tax purposes.
</p>
</div>
</div>
<div style="margin-top: 2rem; padding-top: 2rem; border-top: 1px solid rgba(255, 255, 255, 0.1);">
<div style="display: flex; gap: 1rem; justify-content: center;">
<button class="btn btn-primary" disabled>
<i class="fas fa-cog"></i> Setup Payment Method
</button>
<button class="btn btn-success" disabled>
<i class="fas fa-download"></i> Download Tax Statement
</button>
</div>
<div style="text-align: center; margin-top: 1rem; color: #a0aec0;">
<small>Payment features coming soon!</small>
</div>
</div>
</div>
</div>