ajout temps

This commit is contained in:
James BOUTARIC 2024-06-11 15:08:29 +02:00
parent ffd3f5dd39
commit 906c5abf52
4 changed files with 16 additions and 6 deletions

View File

@ -40,9 +40,10 @@ class Albums extends CI_Controller {
} }
$playlists = $this->model_music->getPlaylist(); $playlists = $this->model_music->getPlaylist();
$this->load->view('layout/header'); $this->load->view('layout/header');
$this->load->view('song_album_list', ['songs' => $songs, 'playlists' => $playlists]); $this->load->view('song_album_list', ['songs' => $songs, 'playlists' => $playlists]);
$this->load->view('layout/footer'); $this->load->view('layout/footer');
}
}
public function addAllSongsToPlaylist(){ public function addAllSongsToPlaylist(){
$album_id = $this->input->post('album_id'); $album_id = $this->input->post('album_id');

View File

@ -10,9 +10,10 @@ class Song extends CI_Controller {
public function view($album_id){ public function view($album_id){
$songs = $this->model_music->getSongOfAlbum($album_id); $songs = $this->model_music->getSongOfAlbum($album_id);
$duration = $this->model_music->getDurationSong($songs);
$playlists = $this->model_music->getPlaylist(); $playlists = $this->model_music->getPlaylist();
$this->load->view('layout/header'); $this->load->view('layout/header');
$this->load->view('song_album_list', ['songs' => $songs, 'playlists' => $playlists]); $this->load->view('song_album_list', ['songs' => $songs, 'playlists' => $playlists, 'duration' => $duration]);
$this->load->view('layout/footer'); $this->load->view('layout/footer');
} }
} }

View File

@ -92,9 +92,11 @@ class Model_music extends CI_Model {
public function getSongOfAlbum($album_id){ public function getSongOfAlbum($album_id){
$query = $this->db->query( $query = $this->db->query(
"SELECT song.id, song.name "SELECT song.id, song.name, track.duration
FROM song FROM song
INNER JOIN track ON song.id = track.songId INNER JOIN track ON song.id = track.songId
WHERE track.albumId = ?", WHERE track.albumId = ?",
array($album_id) array($album_id)
); );
@ -237,4 +239,5 @@ class Model_music extends CI_Model {
WHERE id = ?", WHERE id = ?",
array($new_playlist_id, $playlist_id)); array($new_playlist_id, $playlist_id));
} }
} }

View File

@ -1,10 +1,15 @@
<section class="list"> <section class="list">
<?php <?php
$i = 0;
echo '<img src="data:image/jpeg;base64,' . base64_encode($album->jpeg) . '" alt="' . $album->name . '" />';
echo "<footer class='short-text'>{$album->year} - {$album->artistName}</footer>";
foreach($songs as $song){ foreach($songs as $song){
echo "<div><article>"; echo "<div><article>";
echo "<header class='short-text'>"; echo "<header class='short-text'>";
echo "{$song->name} "; $i = $i+1;
$minutes = floor($song->duration/60);
$secondes = $song->duration %60;
echo "{$i} - {$song->name} : {$minutes} min {$secondes} sec";
if ($this->session->userdata('logged')): if ($this->session->userdata('logged')):
echo "<form action='" . base_url("index.php/playlist/addSongToPlaylist") . "' method='post'>"; echo "<form action='" . base_url("index.php/playlist/addSongToPlaylist") . "' method='post'>";
echo "<select name='playlist'>"; echo "<select name='playlist'>";