fix
This commit is contained in:
192
user/catalog.php
Normal file
192
user/catalog.php
Normal file
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
/**
|
||||
* Catalogo Lezioni
|
||||
*
|
||||
* Mostra tutte le lezioni disponibili per l'acquisto
|
||||
*/
|
||||
|
||||
require_once '../includes/config.php';
|
||||
require_once '../includes/functions.php';
|
||||
|
||||
session_start();
|
||||
check_session_timeout();
|
||||
require_login();
|
||||
|
||||
$user_id = $_SESSION['user_id'];
|
||||
|
||||
// Ottieni tutte le lezioni attive
|
||||
$all_lessons = get_all_lessons('all');
|
||||
|
||||
// Ottieni le lezioni già acquistate dall'utente
|
||||
$pdo = get_db_connection();
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT lesson_id FROM purchases
|
||||
WHERE user_id = ? AND status = 'completed'
|
||||
");
|
||||
$stmt->execute([$user_id]);
|
||||
$owned_lesson_ids = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Catalogo Lezioni - Pilates Platform</title>
|
||||
<link rel="stylesheet" href="../assets/css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<header class="header">
|
||||
<div class="container">
|
||||
<div class="header-content">
|
||||
<h1 class="logo">Pilates Studio</h1>
|
||||
<nav class="nav">
|
||||
<a href="../index.php" class="btn btn-outline">Home</a>
|
||||
<a href="dashboard.php" class="btn btn-secondary">Le Mie Lezioni</a>
|
||||
<a href="../includes/logout.php" class="btn btn-outline">Logout</a>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="container">
|
||||
<div class="dashboard">
|
||||
<!-- Sidebar con filtri -->
|
||||
<aside class="sidebar">
|
||||
<h3 style="margin-bottom: 1rem;">Filtri</h3>
|
||||
|
||||
<div style="margin-bottom: 1.5rem;">
|
||||
<label style="font-weight: 500; display: block; margin-bottom: 0.5rem;">Tipo</label>
|
||||
<label style="display: block; margin-bottom: 0.25rem;">
|
||||
<input type="checkbox" class="filter-type" value="video" checked> Videolezioni
|
||||
</label>
|
||||
<label style="display: block;">
|
||||
<input type="checkbox" class="filter-type" value="live" checked> Lezioni Live
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 1.5rem;">
|
||||
<label style="font-weight: 500; display: block; margin-bottom: 0.5rem;">Livello</label>
|
||||
<label style="display: block; margin-bottom: 0.25rem;">
|
||||
<input type="checkbox" class="filter-level" value="principiante" checked> Principiante
|
||||
</label>
|
||||
<label style="display: block; margin-bottom: 0.25rem;">
|
||||
<input type="checkbox" class="filter-level" value="intermedio" checked> Intermedio
|
||||
</label>
|
||||
<label style="display: block;">
|
||||
<input type="checkbox" class="filter-level" value="avanzato" checked> Avanzato
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button onclick="applyFilters()" class="btn btn-primary" style="width: 100%;">
|
||||
Applica Filtri
|
||||
</button>
|
||||
</aside>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="main-content">
|
||||
<h2 class="section-title" style="text-align: left;">Catalogo Lezioni</h2>
|
||||
|
||||
<?php echo display_flash_message(); ?>
|
||||
|
||||
<div class="lessons-grid" id="lessons-container">
|
||||
<?php foreach ($all_lessons as $lesson): ?>
|
||||
<?php
|
||||
$is_owned = in_array($lesson['id'], $owned_lesson_ids);
|
||||
$is_demo = $lesson['is_demo'];
|
||||
?>
|
||||
<div class="lesson-card"
|
||||
data-type="<?php echo $lesson['type']; ?>"
|
||||
data-level="<?php echo $lesson['level']; ?>">
|
||||
|
||||
<?php if ($lesson['thumbnail']): ?>
|
||||
<img src="<?php echo htmlspecialchars($lesson['thumbnail']); ?>"
|
||||
alt="<?php echo htmlspecialchars($lesson['title']); ?>"
|
||||
class="lesson-thumbnail">
|
||||
<?php else: ?>
|
||||
<div class="lesson-thumbnail-placeholder">
|
||||
<span><?php echo $lesson['type'] === 'video' ? '📹' : '📡'; ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="lesson-content">
|
||||
<h3 class="lesson-title"><?php echo htmlspecialchars($lesson['title']); ?></h3>
|
||||
<p class="lesson-description">
|
||||
<?php echo htmlspecialchars(substr($lesson['description'], 0, 100)) . '...'; ?>
|
||||
</p>
|
||||
|
||||
<div class="lesson-meta">
|
||||
<?php if ($lesson['duration']): ?>
|
||||
<span>⏱️ <?php echo $lesson['duration']; ?> min</span>
|
||||
<?php endif; ?>
|
||||
<span>📊 <?php echo ucfirst($lesson['level']); ?></span>
|
||||
</div>
|
||||
|
||||
<?php if ($lesson['type'] === 'live' && $lesson['live_date']): ?>
|
||||
<p class="text-muted" style="font-size: 0.875rem; margin: 0.5rem 0;">
|
||||
📅 <?php echo format_datetime($lesson['live_date']); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($is_demo): ?>
|
||||
<div class="lesson-price text-success">GRATIS</div>
|
||||
<a href="../lesson.php?id=<?php echo $lesson['id']; ?>" class="btn btn-success btn-small">
|
||||
Guarda Gratis
|
||||
</a>
|
||||
<?php elseif ($is_owned): ?>
|
||||
<div class="text-success" style="margin-bottom: 0.5rem;">✓ Già acquistata</div>
|
||||
<a href="../lesson.php?id=<?php echo $lesson['id']; ?>" class="btn btn-primary btn-small">
|
||||
Vai alla Lezione
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<div class="lesson-price"><?php echo format_price($lesson['price']); ?></div>
|
||||
<a href="../lesson.php?id=<?php echo $lesson['id']; ?>" class="btn btn-primary btn-small">
|
||||
Vedi Dettagli
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?php if (empty($all_lessons)): ?>
|
||||
<div class="card text-center">
|
||||
<p class="text-muted">Nessuna lezione disponibile al momento.</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Funzione per applicare i filtri
|
||||
function applyFilters() {
|
||||
// Ottieni i tipi selezionati
|
||||
const selectedTypes = Array.from(document.querySelectorAll('.filter-type:checked'))
|
||||
.map(cb => cb.value);
|
||||
|
||||
// Ottieni i livelli selezionati
|
||||
const selectedLevels = Array.from(document.querySelectorAll('.filter-level:checked'))
|
||||
.map(cb => cb.value);
|
||||
|
||||
// Filtra le lezioni
|
||||
const lessonCards = document.querySelectorAll('.lesson-card');
|
||||
|
||||
lessonCards.forEach(card => {
|
||||
const cardType = card.dataset.type;
|
||||
const cardLevel = card.dataset.level;
|
||||
|
||||
const typeMatch = selectedTypes.length === 0 || selectedTypes.includes(cardType);
|
||||
const levelMatch = selectedLevels.length === 0 || selectedLevels.includes(cardLevel);
|
||||
|
||||
if (typeMatch && levelMatch) {
|
||||
card.style.display = 'block';
|
||||
} else {
|
||||
card.style.display = 'none';
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<script src="../assets/js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user