Commit de louay : modifs

This commit is contained in:
stiti 2024-06-10 20:41:30 +02:00
parent a3bcef8683
commit 73f0cb1377
2 changed files with 15 additions and 11 deletions

View File

@ -87,9 +87,11 @@ class Model_music extends CI_Model {
); );
$album = $query->row(); $album = $query->row();
$tracks = []; // Initialiser le tableau des pistes
if ($album) { if ($album) {
$query = $this->db->query( $query = $this->db->query(
"SELECT track.id, track.diskNumber, track.number, track.duration, song.name as songName "SELECT track.id, track.diskNumber, track.number, track.duration, song.id as song_id, song.name as songName
FROM track FROM track
JOIN song ON track.songid = song.id JOIN song ON track.songid = song.id
WHERE track.albumid = ? WHERE track.albumid = ?
@ -98,8 +100,8 @@ class Model_music extends CI_Model {
$tracks = $query->result(); $tracks = $query->result();
} }
return [$album,$tracks]; return [$album, $tracks];
} }
public function getMusiques($limit, $offset, $order_by = 'name', $order_direction = 'ASC', $genre_id = null, $artist_id = null) { public function getMusiques($limit, $offset, $order_by = 'name', $order_direction = 'ASC', $genre_id = null, $artist_id = null) {
// Préparer la colonne de tri en fonction du paramètre $order_by // Préparer la colonne de tri en fonction du paramètre $order_by

View File

@ -23,14 +23,16 @@
<?php if (!empty($tracks)): ?> <?php if (!empty($tracks)): ?>
<h2>Musiques</h2> <h2>Musiques</h2>
<ul> <ul>
<?php foreach ($tracks as $track): ?> <?php foreach ($tracks as $track): ?>
<li> <li>
<strong><?php echo $track->diskNumber . '.' . $track->number; ?>:</strong> <?php echo $track->songName; ?> (<?php echo gmdate("i:s", $track->duration); ?>) <strong><?php echo $track->diskNumber . '.' . $track->number; ?>:</strong>
<?php if ($this->session->userdata('user_id')): ?> <a href="<?php echo site_url('musiques/view/' . $track->song_id); ?>"><?php echo $track->songName; ?></a>
<button onclick="addSongToPlaylist(<?php echo $track->id; ?>, <?php echo $album->id; ?>)" class="btn-add-music-to-playlist">Ajouter la musique à la playlist</button> (<?php echo gmdate("i:s", $track->duration); ?>)
<?php endif; ?> <?php if ($this->session->userdata('user_id')): ?>
</li> <button onclick="addSongToPlaylist(<?php echo $track->id; ?>, <?php echo $album->id; ?>)" class="btn-add-music-to-playlist">Ajouter la musique à la playlist</button>
<?php endforeach; ?> <?php endif; ?>
</li>
<?php endforeach; ?>
</ul> </ul>
<?php else: ?> <?php else: ?>
<p>Aucune musique n'est disponible dans cet album...</p> <p>Aucune musique n'est disponible dans cet album...</p>