2024-05-30 13:49:35 +02:00
|
|
|
|
2024-05-20 18:18:00 +02:00
|
|
|
<h1 class="title">Listes des albums</h1>
|
2024-05-22 20:59:59 +02:00
|
|
|
|
|
|
|
<div class="filters">
|
|
|
|
<form method="GET" action="<?php echo base_url('index.php/albums/index'); ?>">
|
|
|
|
<label for="genre">Genre:</label>
|
|
|
|
<select name="genre_id" id="genre">
|
|
|
|
<option value="">Tous les genres</option>
|
|
|
|
<?php foreach($genres as $genre): ?>
|
|
|
|
<option value="<?php echo $genre->id; ?>" <?php echo ($genre->id == $genre_id) ? 'selected' : ''; ?>><?php echo $genre->name; ?></option>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<label for="artist">Artiste:</label>
|
|
|
|
<select name="artist_id" id="artist">
|
|
|
|
<option value="">Tous les artistes</option>
|
|
|
|
<?php foreach($artists as $artist): ?>
|
|
|
|
<option value="<?php echo $artist->id; ?>" <?php echo ($artist->id == $artist_id) ? 'selected' : ''; ?>><?php echo $artist->name; ?></option>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<label for="order_by">Trier par:</label>
|
|
|
|
<select name="order_by" id="order_by">
|
|
|
|
<option value="year" <?php echo ($order_by == 'year') ? 'selected' : ''; ?>>Année</option>
|
|
|
|
<option value="name" <?php echo ($order_by == 'name') ? 'selected' : ''; ?>>Nom</option>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<button type="submit">Filtrer</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
|
2024-05-20 18:18:00 +02:00
|
|
|
<section class="list">
|
|
|
|
<?php foreach($albums as $album): ?>
|
|
|
|
<div>
|
|
|
|
<article>
|
|
|
|
<header class="short-text">
|
|
|
|
<?php echo anchor("albums/view/{$album->id}", $album->name); ?>
|
|
|
|
</header>
|
|
|
|
<img src="data:image/jpeg;base64,<?php echo base64_encode($album->jpeg); ?>" alt="<?php echo $album->name; ?>">
|
2024-06-01 18:08:30 +02:00
|
|
|
<footer class="short-text"><?php echo $album->year; ?> - <?php echo $album->artistName; ?>
|
2024-05-31 11:35:07 +02:00
|
|
|
<?php if ($this->session->userdata('user_id')): ?>
|
2024-06-01 18:08:30 +02:00
|
|
|
<?php if (!empty($user_playlists)): ?>
|
|
|
|
<br><br><select id="playlist_<?php echo $album->id; ?>" class="select-playlist">
|
2024-05-31 11:35:07 +02:00
|
|
|
<?php foreach ($user_playlists as $playlist) : ?>
|
|
|
|
<option value="<?php echo $playlist->id; ?>"><?php echo $playlist->name; ?></option>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</select>
|
|
|
|
<button onclick="addToPlaylist(<?php echo $album->id; ?>)" class="btn-add-to-playlist">Ajouter l'album à la playlist</button>
|
|
|
|
<?php endif; ?>
|
2024-06-01 18:08:30 +02:00
|
|
|
<?php endif; ?>
|
2024-05-31 12:07:09 +02:00
|
|
|
</footer>
|
2024-05-20 18:18:00 +02:00
|
|
|
</article>
|
|
|
|
</div>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</section>
|
2024-05-19 15:27:13 +02:00
|
|
|
|
2024-05-20 18:18:00 +02:00
|
|
|
<div class="pagination">
|
2024-05-22 20:59:59 +02:00
|
|
|
<?php if ($current_page > 1): ?>
|
|
|
|
<a class="fleche" href="<?php echo base_url('index.php/albums/index/'.($current_page-1).'?order_by='.$order_by.'&genre_id='.$genre_id.'&artist_id='.$artist_id); ?>"><</a>
|
|
|
|
<?php endif; ?>
|
2024-05-20 18:18:00 +02:00
|
|
|
|
2024-05-22 20:59:59 +02:00
|
|
|
<?php for ($i = max(1, $current_page - 2); $i <= min($total_pages, $current_page + 2); $i++): ?>
|
|
|
|
<a href="<?php echo base_url('index.php/albums/index/'.$i.'?order_by='.$order_by.'&genre_id='.$genre_id.'&artist_id='.$artist_id); ?>" <?php echo ($i == $current_page) ? 'class="active"' : ''; ?>><?php echo $i; ?></a>
|
|
|
|
<?php endfor; ?>
|
2024-05-20 20:26:00 +02:00
|
|
|
|
2024-05-22 20:59:59 +02:00
|
|
|
<?php if ($current_page < $total_pages): ?>
|
|
|
|
<a class="fleche" href="<?php echo base_url('index.php/albums/index/'.($current_page+1).'?order_by='.$order_by.'&genre_id='.$genre_id.'&artist_id='.$artist_id); ?>">></a>
|
|
|
|
<?php endif; ?>
|
|
|
|
</div>
|
2024-05-20 18:18:00 +02:00
|
|
|
</body>
|
2024-05-31 11:35:07 +02:00
|
|
|
<script>
|
|
|
|
function addToPlaylist(albumId) {
|
|
|
|
// Récupérer l'ID de la playlist sélectionnée
|
|
|
|
var playlistId = document.getElementById('playlist_' + albumId).value;
|
|
|
|
|
|
|
|
// Redirection vers la méthode du contrôleur Playlists pour ajouter la chanson à la playlist spécifiée
|
|
|
|
window.location.href = "<?php echo base_url('index.php/playlists/add_album_to_playlist/'); ?>" + albumId + "/" + playlistId;
|
|
|
|
}
|
2024-06-01 17:49:36 +02:00
|
|
|
</script>
|