![]() 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/domains/soundstudiopro.com/public_html/artist_includes/ |
<?php
// Radio Performance Dashboard for Artists
require_once __DIR__ . '/../includes/translations.php';
// Initialize default values
$radio_data = [
'total_royalties' => 0,
'total_plays' => 0,
'tracks_played' => 0,
'stations_count' => 0,
'paid_royalties' => 0,
'pending_royalties' => 0
];
$top_tracks = [];
$stations = [];
$plays = [];
$monthly_data = [];
$radio_tables_exist = false;
// Check if radio tables exist and fetch data
try {
// Get radio statistics for this artist
$radio_stats = $pdo->prepare("
SELECT
COALESCE(SUM(rr.artist_payout), 0) as total_royalties,
COALESCE(SUM(rr.play_count), 0) as total_plays,
COUNT(DISTINCT rr.track_id) as tracks_played,
COUNT(DISTINCT rr.station_id) as stations_count,
COALESCE(SUM(CASE WHEN rr.payment_status = 'paid' THEN rr.artist_payout ELSE 0 END), 0) as paid_royalties,
COALESCE(SUM(CASE WHEN rr.payment_status = 'pending' THEN rr.artist_payout ELSE 0 END), 0) as pending_royalties
FROM radio_royalties rr
WHERE rr.artist_id = ?
");
$radio_stats->execute([$user_id]);
$radio_data = $radio_stats->fetch() ?: $radio_data;
$radio_tables_exist = true;
// Get top tracks by radio plays
$top_radio_tracks = $pdo->prepare("
SELECT
mt.id,
mt.title,
COUNT(rr.id) as play_count,
SUM(rr.artist_payout) as total_earnings,
MAX(rr.calculated_at) as last_play
FROM music_tracks mt
LEFT JOIN radio_royalties rr ON mt.id = rr.track_id
WHERE mt.user_id = ?
GROUP BY mt.id
HAVING play_count > 0
ORDER BY play_count DESC
LIMIT 10
");
$top_radio_tracks->execute([$user_id]);
$top_tracks = $top_radio_tracks->fetchAll();
// Get top stations playing this artist's music
$top_stations = $pdo->prepare("
SELECT
rs.station_name,
rs.call_sign,
COUNT(rr.id) as play_count,
SUM(rr.artist_payout) as total_earnings
FROM radio_stations rs
JOIN radio_royalties rr ON rs.id = rr.station_id
WHERE rr.artist_id = ?
GROUP BY rs.id
ORDER BY play_count DESC
LIMIT 10
");
$top_stations->execute([$user_id]);
$stations = $top_stations->fetchAll();
// Get recent radio plays
$recent_plays = $pdo->prepare("
SELECT
pl.played_at,
mt.title as track_title,
rs.station_name,
rr.artist_payout,
rr.payment_status
FROM radio_play_logs pl
JOIN music_tracks mt ON pl.track_id = mt.id
JOIN radio_stations rs ON pl.station_id = rs.id
LEFT JOIN radio_royalties rr ON pl.id = rr.play_log_id
WHERE mt.user_id = ?
ORDER BY pl.played_at DESC
LIMIT 20
");
$recent_plays->execute([$user_id]);
$plays = $recent_plays->fetchAll();
// Get monthly radio earnings
$monthly_radio = $pdo->prepare("
SELECT
DATE_FORMAT(rr.calculated_at, '%Y-%m') as month,
COUNT(*) as play_count,
SUM(rr.artist_payout) as earnings
FROM radio_royalties rr
WHERE rr.artist_id = ?
AND rr.calculated_at >= DATE_SUB(NOW(), INTERVAL 12 MONTH)
GROUP BY DATE_FORMAT(rr.calculated_at, '%Y-%m')
ORDER BY month DESC
");
$monthly_radio->execute([$user_id]);
$monthly_data = $monthly_radio->fetchAll();
} catch (Exception $e) {
// Radio tables don't exist yet - feature not enabled
$radio_tables_exist = false;
}
?>
<style>
.radio-performance-dashboard {
background: rgba(255, 255, 255, 0.02);
border-radius: 24px;
padding: 3rem;
border: 1px solid rgba(255, 255, 255, 0.1);
backdrop-filter: blur(20px);
margin-bottom: 2rem;
}
.radio-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 3rem;
padding-bottom: 2rem;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.radio-title {
font-size: 2.8rem;
font-weight: 800;
color: white;
margin: 0;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.radio-subtitle {
font-size: 1.4rem;
color: #a0aec0;
margin: 0.5rem 0 0 0;
font-weight: 400;
}
.radio-stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 2rem;
margin-bottom: 3rem;
}
.radio-stat-card {
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 16px;
padding: 2rem;
text-align: center;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
}
.radio-stat-card::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 3px;
background: linear-gradient(135deg, #667eea, #764ba2);
opacity: 0;
transition: opacity 0.3s ease;
}
.radio-stat-card:hover::before {
opacity: 1;
}
.radio-stat-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 30px rgba(102, 126, 234, 0.2);
border-color: rgba(102, 126, 234, 0.3);
}
.radio-stat-icon {
font-size: 2.5rem;
margin-bottom: 1rem;
}
.radio-stat-amount {
font-size: 2.5rem;
font-weight: 800;
color: white;
margin-bottom: 0.5rem;
}
.radio-stat-label {
font-size: 1.1rem;
color: #a0aec0;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 1px;
}
.radio-section {
background: rgba(255, 255, 255, 0.03);
border-radius: 20px;
padding: 2.5rem;
margin-bottom: 2rem;
border: 1px solid rgba(255, 255, 255, 0.08);
}
.section-title {
font-size: 2rem;
font-weight: 700;
color: white;
margin-bottom: 2rem;
display: flex;
align-items: center;
gap: 1rem;
}
.radio-table {
width: 100%;
border-collapse: collapse;
margin-top: 1.5rem;
}
.radio-table th {
background: rgba(255, 255, 255, 0.05);
color: #cbd5e0;
font-weight: 600;
padding: 1rem;
text-align: left;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.radio-table td {
padding: 1rem;
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
color: white;
}
.radio-table tr:hover {
background: rgba(255, 255, 255, 0.02);
}
.earnings-amount {
font-weight: 600;
color: #48bb78;
}
.payment-status {
padding: 0.25rem 0.75rem;
border-radius: 12px;
font-size: 0.85rem;
font-weight: 600;
display: inline-block;
}
.payment-status.paid {
background: rgba(72, 187, 120, 0.2);
color: #48bb78;
border: 1px solid rgba(72, 187, 120, 0.3);
}
.payment-status.pending {
background: rgba(237, 137, 54, 0.2);
color: #ed8936;
border: 1px solid rgba(237, 137, 54, 0.3);
}
.track-card {
background: rgba(255, 255, 255, 0.05);
border-radius: 12px;
padding: 1.5rem;
margin-bottom: 1rem;
border: 1px solid rgba(255, 255, 255, 0.1);
display: flex;
justify-content: space-between;
align-items: center;
transition: all 0.3s ease;
}
.track-card:hover {
transform: translateX(5px);
border-color: rgba(102, 126, 234, 0.3);
}
.station-card {
background: rgba(255, 255, 255, 0.05);
border-radius: 12px;
padding: 1.5rem;
margin-bottom: 1rem;
border: 1px solid rgba(255, 255, 255, 0.1);
transition: all 0.3s ease;
}
.station-card:hover {
transform: translateX(5px);
border-color: rgba(102, 126, 234, 0.3);
}
.empty-state {
text-align: center;
padding: 3rem;
color: #a0aec0;
}
.empty-state-icon {
font-size: 4rem;
margin-bottom: 1rem;
opacity: 0.3;
}
@media (max-width: 768px) {
.radio-performance-dashboard {
padding: 2rem;
}
.radio-stats-grid {
grid-template-columns: 1fr;
gap: 1.5rem;
}
.radio-table {
font-size: 0.9rem;
}
.track-card,
.station-card {
flex-direction: column;
text-align: center;
gap: 1rem;
}
}
</style>
<div class="radio-performance-dashboard">
<div class="radio-header">
<div>
<h2 class="radio-title">📻 <?= t('radio_performance.title') ?></h2>
<p class="radio-subtitle"><?= t('radio_performance.subtitle') ?></p>
</div>
</div>
<!-- Key Radio Stats -->
<div class="radio-stats-grid">
<div class="radio-stat-card">
<div class="radio-stat-icon">🎵</div>
<div class="radio-stat-amount"><?= number_format($radio_data['total_plays']) ?></div>
<div class="radio-stat-label"><?= t('radio_performance.total_plays') ?></div>
</div>
<div class="radio-stat-card">
<div class="radio-stat-icon">💰</div>
<div class="radio-stat-amount" style="color: #48bb78;">$<?= number_format($radio_data['total_royalties'], 2) ?></div>
<div class="radio-stat-label"><?= t('radio_performance.total_royalties') ?></div>
</div>
<div class="radio-stat-card">
<div class="radio-stat-icon">📊</div>
<div class="radio-stat-amount"><?= number_format($radio_data['tracks_played']) ?></div>
<div class="radio-stat-label"><?= t('radio_performance.tracks_played') ?></div>
</div>
<div class="radio-stat-card">
<div class="radio-stat-icon">📻</div>
<div class="radio-stat-amount"><?= number_format($radio_data['stations_count']) ?></div>
<div class="radio-stat-label"><?= t('radio_performance.stations_count') ?></div>
</div>
<div class="radio-stat-card">
<div class="radio-stat-icon">✅</div>
<div class="radio-stat-amount" style="color: #48bb78;">$<?= number_format($radio_data['paid_royalties'], 2) ?></div>
<div class="radio-stat-label"><?= t('radio_performance.paid_royalties') ?></div>
</div>
<div class="radio-stat-card">
<div class="radio-stat-icon">⏳</div>
<div class="radio-stat-amount" style="color: #ed8936;">$<?= number_format($radio_data['pending_royalties'], 2) ?></div>
<div class="radio-stat-label"><?= t('radio_performance.pending_payout') ?></div>
</div>
</div>
<!-- Top Tracks by Radio Plays -->
<div class="radio-section">
<h3 class="section-title">
<i class="fas fa-trophy" style="color: #667eea;"></i>
<?= t('radio_performance.top_tracks_title') ?>
</h3>
<?php if (empty($top_tracks)): ?>
<div class="empty-state">
<div class="empty-state-icon">📻</div>
<h3><?= t('radio_performance.no_plays_yet') ?></h3>
<p><?= t('radio_performance.no_plays_desc') ?></p>
</div>
<?php else: ?>
<?php foreach ($top_tracks as $track): ?>
<div class="track-card">
<div style="flex: 1;">
<div style="font-size: 1.2rem; font-weight: 600; color: white; margin-bottom: 0.5rem;">
<?= htmlspecialchars($track['title']) ?>
</div>
<div style="display: flex; gap: 2rem; color: #a0aec0; font-size: 0.9rem;">
<span><?= number_format($track['play_count']) ?> <?= t('radio_performance.plays') ?></span>
<span><?= t('radio_performance.last_played') ?>: <?= $track['last_play'] ? date('M j, Y', strtotime($track['last_play'])) : t('radio_performance.never') ?></span>
</div>
</div>
<div style="text-align: right;">
<div style="font-size: 1.5rem; font-weight: 700; color: #48bb78; margin-bottom: 0.25rem;">
$<?= number_format($track['total_earnings'], 2) ?>
</div>
<div style="font-size: 0.8rem; color: #a0aec0;"><?= t('radio_performance.total_earnings') ?></div>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
<!-- Top Stations -->
<div class="radio-section">
<h3 class="section-title">
<i class="fas fa-broadcast-tower" style="color: #667eea;"></i>
<?= t('radio_performance.stations_title') ?>
</h3>
<?php if (empty($stations)): ?>
<div class="empty-state">
<div class="empty-state-icon">📡</div>
<h3><?= t('radio_performance.no_stations') ?></h3>
<p><?= t('radio_performance.no_stations_desc') ?></p>
</div>
<?php else: ?>
<?php foreach ($stations as $station): ?>
<div class="station-card">
<div style="display: flex; justify-content: space-between; align-items: center;">
<div>
<div style="font-size: 1.2rem; font-weight: 600; color: white; margin-bottom: 0.5rem;">
<?= htmlspecialchars($station['station_name']) ?>
<?php if ($station['call_sign']): ?>
<span style="color: #a0aec0; font-weight: 400;">(<?= htmlspecialchars($station['call_sign']) ?>)</span>
<?php endif; ?>
</div>
<div style="color: #a0aec0; font-size: 0.9rem;">
<?= number_format($station['play_count']) ?> <?= t('radio_performance.plays') ?>
</div>
</div>
<div style="text-align: right;">
<div style="font-size: 1.3rem; font-weight: 700; color: #48bb78;">
$<?= number_format($station['total_earnings'], 2) ?>
</div>
<div style="font-size: 0.8rem; color: #a0aec0;"><?= t('radio_performance.earnings') ?></div>
</div>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
<!-- Recent Radio Plays -->
<div class="radio-section">
<h3 class="section-title">
<i class="fas fa-clock" style="color: #667eea;"></i>
<?= t('radio_performance.recent_plays_title') ?>
</h3>
<?php if (empty($plays)): ?>
<div class="empty-state">
<div class="empty-state-icon">🎵</div>
<h3><?= t('radio_performance.no_recent_plays') ?></h3>
<p><?= t('radio_performance.no_recent_plays_desc') ?></p>
</div>
<?php else: ?>
<table class="radio-table">
<thead>
<tr>
<th><?= t('radio_performance.date_time') ?></th>
<th><?= t('radio_performance.track') ?></th>
<th><?= t('radio_performance.station') ?></th>
<th><?= t('radio_performance.earnings') ?></th>
<th><?= t('radio_performance.status') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($plays as $play): ?>
<tr>
<td><?= date('M j, Y g:i A', strtotime($play['played_at'])) ?></td>
<td><?= htmlspecialchars($play['track_title']) ?></td>
<td><?= htmlspecialchars($play['station_name']) ?></td>
<td class="earnings-amount">$<?= number_format($play['artist_payout'] ?? 0, 2) ?></td>
<td>
<span class="payment-status <?= $play['payment_status'] ?? 'pending' ?>">
<?php
$status = $play['payment_status'] ?? 'pending';
echo $status === 'paid' ? t('radio_performance.status_paid') : t('radio_performance.status_pending');
?>
</span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</div>
<!-- Info Box -->
<div style="background: rgba(102, 126, 234, 0.1); border-left: 4px solid #667eea; border-radius: 12px; padding: 1.5rem; margin-top: 2rem;">
<div style="display: flex; align-items: start; gap: 1rem;">
<i class="fas fa-info-circle" style="font-size: 1.5rem; color: #667eea; margin-top: 0.2rem;"></i>
<div>
<h4 style="color: white; margin: 0 0 0.5rem 0; font-size: 1.3rem;"><?= t('radio_performance.how_it_works_title') ?></h4>
<p style="color: #cbd5e0; margin: 0; font-size: 1.1rem; line-height: 1.6;">
<?= t('radio_performance.how_it_works_desc') ?>
</p>
</div>
</div>
</div>
</div>