diff --git a/app/controllers/User.php b/app/controllers/User.php index 435e9e96517119c2fd356bd756d49f93ba487bb0..a9cfa914c1967099759227031f5a3fda19581932 100644 --- a/app/controllers/User.php +++ b/app/controllers/User.php @@ -11,6 +11,7 @@ class User extends Controller { $offset = ($page - 1) * $limit; $offset = intval($offset); $data['book'] = $this->model('BookModel')->getAllBookList($limit, $offset); + // $data['book']['path'] = $this->model('BookModel')->getAllBookFilename($page); $this->view('library/booklist', $data); } else { @@ -71,6 +72,7 @@ class User extends Controller { { if(isset($_SESSION['user_role']) && $_SESSION['user_role'] === 'user'){ $data['book'] = $this->model('BookModel')->getBookDetail($page); + $data['path'] = $this->model('BookModel')->getBookFilename($page); $this->view('library/detailbook', $data); } else{ diff --git a/app/models/BookModel.php b/app/models/BookModel.php index 835e96e4bdaabf7d48ca63eae509a1621c9a408f..63aa5ea0230181ac736095d9747bad138c5780f0 100644 --- a/app/models/BookModel.php +++ b/app/models/BookModel.php @@ -69,12 +69,12 @@ class BookModel return 1; } public function getAllBookmark($limit, $offset){ - $this->database->query("SELECT book.id, title, author.name, category FROM book JOIN author ON book.author_id = author.id JOIN inventory ON book.id = inventory.book_id JOIN user ON user.id = inventory.user_id WHERE user.id = :id LIMIT $limit OFFSET $offset"); + $this->database->query("SELECT book.id, title, author.name, category, audio_path, image_path FROM book JOIN author ON book.author_id = author.id JOIN inventory ON book.id = inventory.book_id JOIN user ON user.id = inventory.user_id WHERE user.id = :id LIMIT $limit OFFSET $offset"); $this->database->bind('id', $_SESSION['id']); return $this->database->resultSet(); } public function getAllBookList($limit, $offset){ - $this->database->query("SELECT book.id, title, author.name, category FROM book JOIN author ON book.author_id = author.id LIMIT $limit OFFSET $offset"); + $this->database->query("SELECT book.id, title, author.name, category, audio_path, image_path FROM book JOIN author ON book.author_id = author.id LIMIT $limit OFFSET $offset"); return $this->database->resultSet(); } public function getBookDetail($id){ @@ -105,7 +105,16 @@ class BookModel $this->database->bind('bookid', $bookid); $this->database->execute(); } - + public function getBookFilename($id){ + $this->database->query("SELECT audio_path, image_path FROM book WHERE id = :id"); + $this->database->bind('id', $id); + return $this->database->single(); + } + public function getAllBookFilename(){ + $this->database->query("SELECT audio_path, image_path FROM book"); + return $this->database->resultSet(); + } + public function searchBookmark($searchInput, $sortSelect, $sortOrder, $filterSelect, $filterQuery, $limit, $offset){ // Construct the SQL query based on the provided parameters $sql = "SELECT book.id, title, author.name, category FROM book JOIN author ON book.author_id = author.id JOIN inventory ON book.id = inventory.book_id JOIN user ON user.id = inventory.user_id WHERE 1=1"; // Initial WHERE condition diff --git a/app/views/bookmark/bookmark.php b/app/views/bookmark/bookmark.php index 6808638c1730b877f287ea1c0b981f20f996bd79..8f6ea672ad554cf9243467982ff1b9449d178303 100644 --- a/app/views/bookmark/bookmark.php +++ b/app/views/bookmark/bookmark.php @@ -28,6 +28,8 @@ $author = $row['name']; $category = $row['category']; $id = $_SESSION['id']; + $imgPath = $row['image_path']; + $audioPath = $row['audio_path']; if ($boxCount % 2 == 0) { if ($boxCount > 0) { @@ -49,7 +51,7 @@ ?> <div class="bookmark-box" data-box-index="<?php echo $boxCount; ?>"> <div class="image-rectangle"> - <img src="<?php echo BASEURL?>/img/image 3.png" alt="Image Alt Text"> + <img src="<?php echo BASEURL?>/img/<?php echo $imgPath ?>" alt="Image Alt Text"> </div> <div class="content-rectangle"> <div class="content-header"> diff --git a/app/views/library/booklist.php b/app/views/library/booklist.php index e0d6cb8159a526cda594625af557e82433a7ad63..b23c3f5346f24c8f10f120fe411c7bd3435dee97 100644 --- a/app/views/library/booklist.php +++ b/app/views/library/booklist.php @@ -27,6 +27,8 @@ $title = $row['title']; $author = $row['name']; $category = $row['category']; + $imgPath = $row['image_path']; + $audioPath = $row['audio_path']; if ($boxCount % 2 == 0) { if ($boxCount > 0) { @@ -48,7 +50,7 @@ ?> <div class="bookmark-box" data-box-index="<?php echo $boxCount; ?>"> <div class="image-rectangle"> - <img src="<?php echo BASEURL?>/img/image 3.png" alt="Image Alt Text"> + <img src="<?php echo BASEURL?>/img/<?php echo $imgPath ?>" alt="Image Alt Text"> </div> <div class="content-rectangle"> <div class="content-header"> diff --git a/app/views/library/detailbook.php b/app/views/library/detailbook.php index 5ddfc57e493c86aa8198d8c6c16b98743033ae39..bcb43cf9cceea7b3c6226876398f3eb83b0d40b8 100644 --- a/app/views/library/detailbook.php +++ b/app/views/library/detailbook.php @@ -22,6 +22,8 @@ $category = $data['book']['category']; $username = $_SESSION['username']; $id = $_SESSION['id']; + $imgPath = $data['path']['image_path']; + $audioPath = $data['path']['audio_path']; // Echo the values from $data into the HTML template @@ -35,11 +37,11 @@ <div class="container"> <div class="content"> <div class="picture"> - <img src="<?php echo BASEURL ?>/img/book1.jpg"> + <img src="<?php echo BASEURL ?>/img/<?php echo $imgPath ?>"> </div> <div class="audio"> <audio controls> - <source src="<?php echo BASEURL ?>/audio/sample.mp3" type="audio/mp3"> + <source src="<?php echo BASEURL ?>/audio/<?php echo $audioPath ?>" type="audio/mp3"> Gagal </audio> </div> diff --git a/public/audio/sample.mp3 b/public/audio/audio1.mp3 similarity index 100% rename from public/audio/sample.mp3 rename to public/audio/audio1.mp3 diff --git a/public/img/book1.jpg b/public/img/image1.jpg similarity index 100% rename from public/img/book1.jpg rename to public/img/image1.jpg diff --git a/public/img/book2.jpg b/public/img/image2.jpg similarity index 100% rename from public/img/book2.jpg rename to public/img/image2.jpg diff --git a/public/img/image 3.png b/public/img/image3.jpg similarity index 100% rename from public/img/image 3.png rename to public/img/image3.jpg diff --git a/public/img/book3.png b/public/img/image4.jpg similarity index 100% rename from public/img/book3.png rename to public/img/image4.jpg diff --git a/public/img/book4.jpg b/public/img/image5.jpg similarity index 100% rename from public/img/book4.jpg rename to public/img/image5.jpg