From ad9fc69858de1bb68864ea859efb6c33202cc468 Mon Sep 17 00:00:00 2001 From: Gulilil <juan.csantoso@gmail.com> Date: Tue, 14 Nov 2023 18:07:46 +0700 Subject: [PATCH] fix: admin page --- Dockerfile | 16 +- app/api/anime/add.php | 2 +- app/api/anime/delete.php | 6 +- app/api/anime/edit.php | 7 +- app/api/client/add.php | 8 +- app/api/client/delete.php | 6 +- app/api/client/edit.php | 3 +- app/api/studio/add.php | 2 +- app/api/studio/delete.php | 6 +- app/api/studio/edit.php | 3 +- app/controller/AdminController.php | 27 +- app/models/anime.php | 6 +- app/models/client.php | 5 + app/public/handler/admin.js | 15 +- app/views/Admin/anime.php | 281 ++++++++++++++++ app/views/Admin/client.php | 206 ++++++++++++ app/views/Admin/index.php | 517 ----------------------------- app/views/Admin/studio.php | 178 ++++++++++ app/views/Client/detail.php | 7 +- app/views/includes/header.php | 2 +- 20 files changed, 744 insertions(+), 559 deletions(-) create mode 100644 app/views/Admin/anime.php create mode 100644 app/views/Admin/client.php delete mode 100644 app/views/Admin/index.php create mode 100644 app/views/Admin/studio.php diff --git a/Dockerfile b/Dockerfile index 4a99758..9f1409b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,17 +8,17 @@ COPY ./app /var/www/html RUN echo "ServerName localhost:80" >> /etc/apache2/apache2.conf CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"] -RUN sudo chown www-data:www-data /var/www/html/public/img/anime/ -RUN sudo chmod 755 /var/www/html/public/img/anime/ +# RUN sudo chown www-data:www-data /var/www/html/public/img/anime/ +# RUN sudo chmod 755 /var/www/html/public/img/anime/ -RUN sudo chown www-data:www-data /var/www/html/public/img/client/ -RUN sudo chmod 755 /var/www/html/public/img/client/ +# RUN sudo chown www-data:www-data /var/www/html/public/img/client/ +# RUN sudo chmod 755 /var/www/html/public/img/client/ -RUN sudo chown www-data:www-data /var/www/html/public/img/studio/ -RUN sudo chmod 755 /var/www/html/public/img/studio/ +# RUN sudo chown www-data:www-data /var/www/html/public/img/studio/ +# RUN sudo chmod 755 /var/www/html/public/img/studio/ -RUN sudo chown www-data:www-data /var/www/html/public/vid/ -RUN sudo chmod 755 /var/www/html/public/vid/ +# RUN sudo chown www-data:www-data /var/www/html/public/vid/ +# RUN sudo chmod 755 /var/www/html/public/vid/ RUN service apache2 restart \ No newline at end of file diff --git a/app/api/anime/add.php b/app/api/anime/add.php index 482aacf..735ba0e 100644 --- a/app/api/anime/add.php +++ b/app/api/anime/add.php @@ -115,7 +115,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { $result = $a->insertAnime($data); if ($result) { - header("Location: /?admin"); + header("Location: /?admin/anime/page=1"); exit(); } else { echo "Failed to add anime. Please try again."; diff --git a/app/api/anime/delete.php b/app/api/anime/delete.php index b4ad269..88c88c0 100644 --- a/app/api/anime/delete.php +++ b/app/api/anime/delete.php @@ -5,12 +5,14 @@ require_once(BASE_DIR.'/models/Anime.php'); if (isset($_GET['id'])) { $id = $_GET['id']; + $page = floor($id/20)+1; + $a = new Anime(); if ($a->deleteAnime($id)) { - header('Location: /?admin?message=Deleted successfully'); + header('Location: /?admin/anime/page='.$page.'?message=Deleted successfully'); } else { - header('Location: /?admin?error=Failed to delete'); + header('Location: /?admin/anime/page='.$page.'?error=Failed to delete'); } } ?> diff --git a/app/api/anime/edit.php b/app/api/anime/edit.php index a913f70..a3793c9 100644 --- a/app/api/anime/edit.php +++ b/app/api/anime/edit.php @@ -17,8 +17,8 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { 'status' => $_POST['status'], 'rating' => $_POST['rating'], 'studio_id' => $_POST['studio_id'], - 'score' => null - ]; + 'score' => $_POST['score'], + ]; // Check if release_date is set and not empty if (isset($_POST['release_date']) && !empty($_POST['release_date'])) { @@ -137,9 +137,10 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { // Call the updateclient method $result = $a->updateAnime($data); + $page = floor($animeId/20)+1; if ($result) { - header("Location: /?admin"); + header("Location: /?admin/anime/page=".$page); exit(); } else { echo "Failed to edit anime. Please try again."; diff --git a/app/api/client/add.php b/app/api/client/add.php index 91428e5..8d0c0bb 100644 --- a/app/api/client/add.php +++ b/app/api/client/add.php @@ -75,21 +75,21 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($c->getClientByUsername($data['username'])) { $_SESSION['error_message'] = "Username already exists!"; - header("Location: /?admin"); + header("Location: /?admin/client/page=1"); exit(); } elseif ($c->getClientByEmail($data['email'])) { $_SESSION['error_message'] = "Email already exists!"; - header("Location: /?admin"); + header("Location: /?admin/client/page=1"); exit(); } else { $result = $c->insertClient($data); if ($result) { - header("Location: /?admin"); + header("Location: /?admin/client/page=1"); exit(); } else { $_SESSION['error_message'] = "Failed to add client"; - header("Location: /?admin"); + header("Location: /?admin/client/page=1"); exit(); } } diff --git a/app/api/client/delete.php b/app/api/client/delete.php index 9bb902d..c238907 100644 --- a/app/api/client/delete.php +++ b/app/api/client/delete.php @@ -5,12 +5,14 @@ require_once(BASE_DIR.'/models/Client.php'); if (isset($_GET['id'])) { $id = $_GET['id']; + $page = floor($id/20)+1; + $c = new Client(); if ($c->deleteClient($id)) { - header('Location: /?admin?message=Deleted successfully'); + header('Location: /?admin/client/page='.$page.'?message=Deleted successfully'); } else { - header('Location: /?admin?error=Failed to delete'); + header('Location: /?admin/client/page='.$page.'?error=Failed to delete'); } } ?> diff --git a/app/api/client/edit.php b/app/api/client/edit.php index dabc82a..da24c6d 100644 --- a/app/api/client/edit.php +++ b/app/api/client/edit.php @@ -89,12 +89,13 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { // Call the updateclient method $result = $c->updateClient($data); + $page = floor($clientId/20)+1; if ($result) { if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER']) { header("Location: " . $_SERVER['HTTP_REFERER']); } else { - header("Location: /?admin"); // Fallback if there's no referrer + header("Location: /?admin/client/page=".$page); // Fallback if there's no referrer } exit(); } else { diff --git a/app/api/studio/add.php b/app/api/studio/add.php index c658cf5..49ac568 100644 --- a/app/api/studio/add.php +++ b/app/api/studio/add.php @@ -71,7 +71,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { $result = $s->insertStudio($data); if ($result) { - header("Location: /?admin"); + header("Location: /?admin/studio/page=1"); exit(); } else { echo "Failed to add studio. Please try again."; diff --git a/app/api/studio/delete.php b/app/api/studio/delete.php index 1d70e53..275663c 100644 --- a/app/api/studio/delete.php +++ b/app/api/studio/delete.php @@ -5,12 +5,14 @@ require_once(BASE_DIR.'/models/Studio.php'); if (isset($_GET['id'])) { $id = $_GET['id']; + $page = floor($id/20)+1; + $s = new Studio(); if ($s->deleteStudio($id)) { - header('Location: /?admin?message=Deleted successfully'); + header('Location: /?admin/studio/page='.$page.'?message=Deleted successfully'); } else { - header('Location: /?admin?error=Failed to delete'); + header('Location: /?admin/studio/page='.$page.'?error=Failed to delete'); } } ?> diff --git a/app/api/studio/edit.php b/app/api/studio/edit.php index 8dbb940..21e7b3c 100644 --- a/app/api/studio/edit.php +++ b/app/api/studio/edit.php @@ -84,9 +84,10 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { // Call the updateStudio method $result = $s->updateStudio($data); + $page = floor($studioId/20)+1; if ($result) { - header("Location: /?admin"); + header("Location: /?admin/studio/page=".$page); exit(); } else { echo "Failed to edit studio. Please try again."; diff --git a/app/controller/AdminController.php b/app/controller/AdminController.php index 9e4bf4a..a443417 100644 --- a/app/controller/AdminController.php +++ b/app/controller/AdminController.php @@ -4,10 +4,33 @@ require_once(dirname(__DIR__,1).'/define.php'); require_once(BASE_DIR.'/models/Controller.php'); class AdminController extends Controller { - public function index(){ + public function client($path = "page=1"){ if (isset($_SESSION['admin_status'])){ if ($_SESSION['admin_status']){ - $this->view('Admin/index'); + $this->view('Admin/client'); + } else { + $this->view('Error/index'); + } + } else { + $this->view('Error/index'); + } + } + public function anime($path = "page=1"){ + if (isset($_SESSION['admin_status'])){ + if ($_SESSION['admin_status']){ + $this->view('Admin/anime'); + } else { + $this->view('Error/index'); + } + } else { + $this->view('Error/index'); + } + } + + public function studio($path = "page=1"){ + if (isset($_SESSION['admin_status'])){ + if ($_SESSION['admin_status']){ + $this->view('Admin/studio'); } else { $this->view('Error/index'); } diff --git a/app/models/anime.php b/app/models/anime.php index 957ecc3..a4d8912 100644 --- a/app/models/anime.php +++ b/app/models/anime.php @@ -188,8 +188,10 @@ class Anime { $this->db->query($fullQuery); return $this->db->fetchAllData(); - } - + public function getAllAnimeLimitOffset($limit, $offset){ + $this->db->query('SELECT * FROM ' . $this->table . ' ORDER BY anime_id LIMIT '.$limit." OFFSET ".$offset); + return $this->db->fetchAllData(); + } } \ No newline at end of file diff --git a/app/models/client.php b/app/models/client.php index 703b2f8..efecc9d 100644 --- a/app/models/client.php +++ b/app/models/client.php @@ -63,4 +63,9 @@ class Client { // if countRow == 0, query fails } + public function getAllClientLimitOffset($limit, $offset){ + $this->db->query('SELECT * FROM ' . $this->table . ' ORDER BY client_id LIMIT '.$limit." OFFSET ".$offset); + return $this->db->fetchAllData(); + } + } \ No newline at end of file diff --git a/app/public/handler/admin.js b/app/public/handler/admin.js index cf3089c..d5002ce 100644 --- a/app/public/handler/admin.js +++ b/app/public/handler/admin.js @@ -61,14 +61,9 @@ document.addEventListener('DOMContentLoaded', function() { }); }); -let activeMenuItem = 'client'; -// Function to set the active menu item -function setActiveMenuItem(menuItem) { - activeMenuItem = menuItem; -} -function openAddModal() { +function openAddModal(activeMenuItem) { if (activeMenuItem === 'client') { document.getElementById('addClientModal').style.display = 'block'; } else if (activeMenuItem === 'anime') { @@ -78,7 +73,7 @@ function openAddModal() { } } -function closeAddModal() { +function closeAddModal(activeMenuItem) { if (activeMenuItem === 'client') { document.getElementById('addClientModal').style.display = 'none'; } else if (activeMenuItem === 'anime') { @@ -88,7 +83,7 @@ function closeAddModal() { } } -function openUpdateModal() { +function openUpdateModal(activeMenuItem) { if (activeMenuItem === 'client') { document.getElementById('updateClientModal').style.display = 'block'; } else if (activeMenuItem === 'anime') { @@ -98,7 +93,7 @@ function openUpdateModal() { } } -function closeUpdateModal() { +function closeUpdateModal(activeMenuItem) { if (activeMenuItem === 'client') { document.getElementById('updateClientModal').style.display = 'none'; } else if (activeMenuItem === 'anime') { @@ -200,6 +195,7 @@ function openEditAnimeModal(button) { const release_date = button.getAttribute('data-release_date'); const episodes = button.getAttribute('data-episodes'); const rating = button.getAttribute('data-rating'); + const score = button.getAttribute('data-score'); const imagePath = button.getAttribute('data-image'); const trailerPath = button.getAttribute('data-trailer'); const synopsis = button.getAttribute('data-synopsis'); @@ -210,6 +206,7 @@ function openEditAnimeModal(button) { document.getElementById('editTitle').value = title; document.getElementById('editType').value = type; document.getElementById('editStatus').value = status; + document.getElementById('editScore').value = score; document.getElementById('editRelease_date').value = release_date; document.getElementById('editEpisodes').value = episodes; document.getElementById('editRating').value = rating; diff --git a/app/views/Admin/anime.php b/app/views/Admin/anime.php new file mode 100644 index 0000000..bcb3a47 --- /dev/null +++ b/app/views/Admin/anime.php @@ -0,0 +1,281 @@ +<?php + +require_once(dirname(__DIR__,2).'/define.php'); +require_once(BASE_DIR.'/views/includes/header.php'); +require_once(BASE_DIR.'/models/Client.php'); +require_once(BASE_DIR.'/models/Anime.php'); +require_once(BASE_DIR.'/models/Studio.php'); + +$c = new Client(); +$a = new Anime(); +$s = new Studio(); + +?> + +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Admin Page: Anime</title> + <link rel="stylesheet" href="../../public/style/global.css"> + <link rel="stylesheet" href="../../public/style/admin.css"> + <script src='/public/handler/navbar.js'></script> + <script src='/public/handler/admin.js'></script> +</head> + +<body> + + <div class="manage-header"> + <div class="menu"> + <a href="/?admin/client/page=1"> + <button class="menu-item" + onclick="showTable('client'); setActiveMenuItem('client')">Client</button> + </a> + <a href="/?admin/anime/page=1"> + <button class="menu-item active" + onclick="showTable('anime'); setActiveMenuItem('anime')">Anime</button> + </a> + <a href="/?admin/studio/page=1"> + <button class="menu-item" + onclick="showTable('studio'); setActiveMenuItem('studio')">Studio</button> + </a> + </div> + + <button class="add-btn" onclick="openAddModal('anime')">Add</button> + + <div id="addAnimeModal" class="modal"> + <div class="modal-content"> + <span class="close-btn" onclick="closeAddModal('anime')">×</span> + <h2>Add New Anime</h2> + + <form class="form-vertical" action="/api/anime/add.php" method="post" enctype="multipart/form-data"> + <label for="title">Title:</label> + <input type="text" id="title" name="title" placeholder="Title" required> + + <label for="type">Type:</label> + <select id="type" name="type" placeholder="Type" required> + <option value="TV">TV</option> + <option value="MOVIE">Movie</option> + <option value="OVA">OVA</option> + </select> + + <label for="status">Status:</label> + <select id="status" name="status" placeholder="Status" required> + <option value="ON-GOING">On Going</option> + <option value="COMPLETED">Completed</option> + <option value="HIATUS">Hiatus</option> + <option value="UPCOMING">Upcoming</option> + </select> + + <label for="release_date">Release Date:</label> + <input type="date" id="release_date" name="release_date" placeholder="Release Date"> + + <label for="episodes">Episodes:</label> + <input type="number" id="episodes" name="episodes" min="0"> + + <label for="rating">Rating:</label> + <select id="rating" name="rating" placeholder="Rating" required> + <option value="G">G</option> + <option value="PG-13">PG-13</option> + <option value="R(17+)">R(17+)</option> + <option value="Rx">Rx</option> + </select> + + <label for="image">Cover Picture:</label> + <input type="file" id="image" name="image"> + + <label for="trailer">Trailer:</label> + <input type="file" id="trailer" name="trailer"> + + <label for="synopsis">Synopsis:</label> + <textarea id="synopsis" name="synopsis" placeholder="Synopsis"></textarea> + + <label for="studio_id">Studio:</label> + <select id="studio_id" name="studio_id" placeholder="Studio" required> + <?php + $studios = $s->getAllStudio(); + foreach($studios as $studio){ + echo " <option value=$studio[studio_id]>$studio[name]</option>"; + } + ?> + </select> + <input type="submit" value="Add Anime"> + </form> + + </div> + </div> + </div> + + <div class="container"> + <div class="content"> + <div class="manage-section"> + + <div id="anime" class="table active-table"> + <!-- Anime table goes here --> + <table> + <thead> + <tr> + <th>id</th> + <th>title</th> + <th>type</th> + <th>status</th> + <th>release</th> + <th>eps</th> + <th>rating</th> + <th>score</th> + <th>image</th> + <th>trailer</th> + <th>synopsis</th> + <th>studio</th> + <th>actions</th> + </tr> + </thead> + <tbody> + <?php + $animes = $a->getAllAnime(); + foreach($animes as $anime){ + $date = $anime['release_date'] ?? '-'; + $episodes = $anime['episodes'] ?? ''; + $score = $anime['score'] ?? '-'; + $image = is_null($anime['image']) ? '-' : str_replace('/', '/<wbr>', $anime['image']); + $trailer = is_null($anime['trailer']) ? '-' : str_replace('/', '/<wbr>', $anime['trailer']); + $synopsis = $anime['synopsis'] === '' ? '-' : $anime['synopsis']; + echo " + <tr> + <td>$anime[anime_id]</td> + <td>$anime[title]</td> + <td>$anime[type]</td> + <td>$anime[status]</td> + <td>$date</td> + <td>$episodes</td> + <td>$anime[rating]</td> + <td>$score</td> + <td>$image</td> + <td>$trailer</td> + <td>$synopsis</td> + <td>$anime[studio_id]</td> + <td> + <div class='btn-container'> + <button class='edit-btn' + data-anime-id=$anime[anime_id] + data-title='$anime[title]' + data-type='$anime[type]' + data-status='$anime[status]' + data-release-date='$anime[release_date]' ?? '' + data-episodes=$anime[episodes] + data-rating='$anime[rating]' + data-score='$anime[score]' + data-image='$anime[image]' + data-trailer='$anime[trailer]' + data-synopsis='$anime[synopsis]' + data-studio-id=$anime[studio_id] + onclick='openEditAnimeModal(this)'> + Edit + </button> + <button class='delete-btn-anime' anime-id=$anime[anime_id]>Delete</button> + </div> + </td> + </tr> + "; + } + ?> + </tbody> + </table> + </div> + + <div id="editAnimeModal" class="modal"> + <div class="modal-content"> + <span class="close-btn" onclick="closeEditAnimeModal('anime')">×</span> + <h2>Edit Anime</h2> + + <form class="form-vertical" action="/api/anime/edit.php" method="post" enctype="multipart/form-data"> + <!-- Hidden input for anime_id --> + <input type="hidden" id="editAnimeId" name="anime_id"> + + <label for="editTitle">Title:</label> + <input type="text" id="editTitle" name="title" placeholder="Title" required> + + <label for="editType">Type:</label> + <select id="editType" name="type" placeholder="Type" required> + <option value="TV">TV</option> + <option value="MOVIE">Movie</option> + <option value="OVA">OVA</option> + </select> + + <label for="editStatus">Status:</label> + <select id="editStatus" name="status" placeholder="Status" required> + <option value="ON-GOING">On Going</option> + <option value="COMPLETED">Completed</option> + <option value="HIATUS">Hiatus</option> + <option value="UPCOMING">Upcoming</option> + </select> + + <label for="editRelease_date">Release Date:</label> + <input type="date" id="editRelease_date" name="release_date" placeholder="Release Date"> + + <label for="editEpisodes">Episodes:</label> + <input type="number" id="editEpisodes" name="episodes" min="0"> + + <label for="editRating">Rating:</label> + <select id="editRating" name="rating" placeholder="Rating" required> + <option value="G">G</option> + <option value="PG-13">PG-13</option> + <option value="R(17+)">R(17+)</option> + <option value="Rx">Rx</option> + </select> + + <label for="editScore"> Score: </label> + <input type='number' id='editScore' name='score' required/> + + <label for="currentAnimeImage">Current Image:</label> + <img src="" alt="No image available." id="currentAnimeImage" style="display: none;"> + + <label for="newImage">Update Image:</label> + <input type="file" id="newImage" name="newImage"> + + <label for="currentTrailer">Current Trailer:</label> + <video width="320" height="240" controls id="currentTrailer" style="display: none;"> + <source src="" type="video/mp4" id="currentTrailer"> + Your browser does not support the video tag. + </video> + + <label for="newTrailer">Update Trailer:</label> + <input type="file" id="newTrailer" name="newTrailer"> + + <label for="editSynopsis">Synopsis:</label> + <textarea id="editSynopsis" name="synopsis" placeholder="Synopsis"></textarea> + + <label for="editStudio_id">Studio:</label> + <select id="editStudio_id" name="studio_id" placeholder="Studio" required> + <?php + $studios = $s->getAllStudio(); + foreach($studios as $studio){ + echo " <option value=$studio[studio_id]>$studio[name]</option>"; + } + ?> + </select> + <input type="submit" value="Update Anime"> + </form> + + </div> + </div> + </div> + </div> + </div> + +</body> +</html> + +<script> + <?php if (isset($_SESSION['error_message'])): ?> + window.onload = function() { + alert('<?php echo $_SESSION['error_message']; ?>'); + }; + <?php unset($_SESSION['error_message']); // Clear the message so it doesn't persist ?> + <?php endif; ?> +</script> + +<?php +require_once(BASE_DIR.'/views/includes/footer.php'); +?> \ No newline at end of file diff --git a/app/views/Admin/client.php b/app/views/Admin/client.php new file mode 100644 index 0000000..fcecebd --- /dev/null +++ b/app/views/Admin/client.php @@ -0,0 +1,206 @@ +<?php + +require_once(dirname(__DIR__,2).'/define.php'); +require_once(BASE_DIR.'/views/includes/header.php'); +require_once(BASE_DIR.'/models/Client.php'); +require_once(BASE_DIR.'/models/Anime.php'); +require_once(BASE_DIR.'/models/Studio.php'); + +$c = new Client(); +$a = new Anime(); +$s = new Studio(); + +?> + +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Admin Page: Client</title> + <link rel="stylesheet" href="../../public/style/global.css"> + <link rel="stylesheet" href="../../public/style/admin.css"> + <script src='/public/handler/navbar.js'></script> + <script src='/public/handler/admin.js'></script> +</head> + +<body> + + <div class="manage-header"> + <div class="menu"> + <a href="/?admin/client/page=1"> + <button class="menu-item active" + onclick="showTable('client'); setActiveMenuItem('client')">Client</button> + </a> + <a href="/?admin/anime/page=1"> + <button class="menu-item" + onclick="showTable('anime'); setActiveMenuItem('anime')">Anime</button> + </a> + <a href="/?admin/studio/page=1"> + <button class="menu-item" + onclick="showTable('studio'); setActiveMenuItem('studio')">Studio</button> + </a> + </div> + + <button class="add-btn" onclick="openAddModal('client')">Add</button> + + <div id="addClientModal" class="modal"> + <div class="modal-content"> + <span class="close-btn" onclick="closeAddModal('client')">×</span> + <h2>Add New Client</h2> + + <form class="form-vertical" action="/api/client/add.php" method="post" enctype="multipart/form-data"> + <label for="username">Username:</label> + <input type="text" id="username" name="username" placeholder="Username" required> + + <label for="email">Email:</label> + <input type="email" id="email" name="email" placeholder="Email" required> + + <label for="password">Password:</label> + <input type="text" id="password" name="password" placeholder="Password" required> + + <label for="admin_status">Status:</label> + <select id="admin_status" name="admin_status"> + <option value="false">Client</option> + <option value="true">Admin</option> + </select> + + <label for="birthdate">Birthdate:</label> + <input type="date" id="birthdate" name="birthdate"> + + <label for="bio">Biography:</label> + <textarea name="bio" id="bio" placeholder="Biography"></textarea> + + <label for="image">Picture:</label> + <input type="file" id="image" name="image"> + + <input type="submit" value="Add Client"> + </form> + + </div> + </div> + + </div> + + <div class="container"> + <div class="content"> + + <div class="manage-section"> + <div id="client" class="table active-table"> + <!-- Client table goes here --> + <table> + <thead> + <tr> + <th>id</th> + <th>username</th> + <th>email</th> + <th>password</th> + <th>admin</th> + <th>birthdate</th> + <th>biography</th> + <th>image</th> + <th>actions</th> + </tr> + </thead> + <tbody> + <?php + $clients = $c->getAllClient(); + foreach($clients as $client){ + $date = $client['birthdate'] ?? '-'; + $bio = $client['bio'] === '' ? '-' : $client['bio']; + $image = is_null($client['image']) ? '-' : str_replace('/', '/<wbr>', $client['image']); + $admin_status = ($client['admin_status']) ? 'true' : 'false'; + echo " + <tr> + <td>$client[client_id]</td> + <td>$client[username]</td> + <td>$client[email]</td> + <td>$client[password]</td> + <td>$admin_status</td> + <td>$date</td> + <td>$bio</td> + <td>$image</td> + <td> + <div class='btn-container'> + <button class='edit-btn' + data-client-id=$client[client_id] + data-username='$client[username]' + data-email='$client[email]' + data-password='$client[password]' + data-admin-status='$admin_status' + data-birthdate='$client[birthdate]' ?? '' + data-bio='$client[bio]' + data-image='$client[image]' + onclick='openEditClientModal(this)'> + Edit + </button> + <button class='delete-btn-client' client-id=$client[client_id]>Delete</button> + </div> + </td> + </tr> + "; + } + ?> + </tbody> + </table> + </div> + + <div id="editClientModal" class="modal"> + <div class="modal-content"> + <span class="close-btn" onclick="closeEditClientModal('client')">×</span> + <h2>Edit Client</h2> + + <form class="form-vertical" action="/api/client/edit.php" method="post" enctype="multipart/form-data"> + <!-- Hidden input for client_id --> + <input type="hidden" id="editClientId" name="client_id"> + + <label for="editUsername" hidden>Username:</label> + <input type="text" id="editUsername" name="username" hidden> + + <label for="editEmail">Email:</label> + <input type="email" id="editEmail" name="email" required> + + <label for="editBirthdate">Established Date:</label> + <input type="date" id="editBirthdate" name="birthdate"> + + <!-- Note: Consider if you really want to show and edit passwords this way --> + <label for="editPassword">Password:</label> + <input type="text" id="editPassword" name="password" required> + + <label for="editAdminStatus">Status:</label> + <select id="editAdminStatus" name="admin_status"> + <option value="false">Client</option> + <option value="true">Admin</option> + </select> + + <label for="editBio">Bio:</label> + <textarea id="editBio" name="bio"></textarea> + + <label for="currentImage">Current Image:</label> + <img src="" alt="No image available." id="currentImage" style="display: none;"> + + <label for="newImage">Update Image:</label> + <input type="file" id="newImage" name="newImage"> + + <input type="submit" value="Update Client"> + </form> + </div> + </div> + </div> + </div> + </div> +</body> +</html> + +<script> + <?php if (isset($_SESSION['error_message'])): ?> + window.onload = function() { + alert('<?php echo $_SESSION['error_message']; ?>'); + }; + <?php unset($_SESSION['error_message']); // Clear the message so it doesn't persist ?> + <?php endif; ?> +</script> + +<?php +require_once(BASE_DIR.'/views/includes/footer.php'); +?> \ No newline at end of file diff --git a/app/views/Admin/index.php b/app/views/Admin/index.php deleted file mode 100644 index 6382623..0000000 --- a/app/views/Admin/index.php +++ /dev/null @@ -1,517 +0,0 @@ -<?php - -require_once(dirname(__DIR__,2).'/define.php'); -require_once(BASE_DIR.'/views/includes/header.php'); -require_once(BASE_DIR.'/models/Client.php'); -require_once(BASE_DIR.'/models/Anime.php'); -require_once(BASE_DIR.'/models/Studio.php'); - -$c = new Client(); -$a = new Anime(); -$s = new Studio(); - -?> - -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <title>Admin Page</title> - <link rel="stylesheet" href="../../public/style/global.css"> - <link rel="stylesheet" href="../../public/style/admin.css"> - <script src='/public/handler/navbar.js'></script> - <script src='/public/handler/admin.js'></script> -</head> - -<body> - - <div class="manage-header"> - <div class="menu"> - <button class="menu-item active" - onclick="showTable('client'); setActiveMenuItem('client')">Client</button> - <button class="menu-item" - onclick="showTable('anime'); setActiveMenuItem('anime')">Anime</button> - <button class="menu-item" - onclick="showTable('studio'); setActiveMenuItem('studio')">Studio</button> - </div> - - <button class="add-btn" onclick="openAddModal()">Add</button> - - <div id="addClientModal" class="modal"> - <div class="modal-content"> - <span class="close-btn" onclick="closeAddModal()">×</span> - <h2>Add New Client</h2> - - <form class="form-vertical" action="/api/client/add.php" method="post" enctype="multipart/form-data"> - <label for="username">Username:</label> - <input type="text" id="username" name="username" placeholder="Username" required> - - <label for="email">Email:</label> - <input type="email" id="email" name="email" placeholder="Email" required> - - <label for="password">Password:</label> - <input type="text" id="password" name="password" placeholder="Password" required> - - <label for="admin_status">Status:</label> - <select id="admin_status" name="admin_status"> - <option value="false">Client</option> - <option value="true">Admin</option> - </select> - - <label for="birthdate">Birthdate:</label> - <input type="date" id="birthdate" name="birthdate"> - - <label for="bio">Biography:</label> - <textarea name="bio" id="bio" placeholder="Biography"></textarea> - - <label for="image">Picture:</label> - <input type="file" id="image" name="image"> - - <input type="submit" value="Add Client"> - </form> - - </div> - </div> - - <div id="addAnimeModal" class="modal"> - <div class="modal-content"> - <span class="close-btn" onclick="closeAddModal()">×</span> - <h2>Add New Anime</h2> - - <form class="form-vertical" action="/api/anime/add.php" method="post" enctype="multipart/form-data"> - <label for="title">Title:</label> - <input type="text" id="title" name="title" placeholder="Title" required> - - <label for="type">Type:</label> - <select id="type" name="type" placeholder="Type" required> - <option value="TV">TV</option> - <option value="MOVIE">Movie</option> - <option value="OVA">OVA</option> - </select> - - <label for="status">Status:</label> - <select id="status" name="status" placeholder="Status" required> - <option value="ON-GOING">On Going</option> - <option value="COMPLETED">Completed</option> - <option value="HIATUS">Hiatus</option> - <option value="UPCOMING">Upcoming</option> - </select> - - <label for="release_date">Release Date:</label> - <input type="date" id="release_date" name="release_date" placeholder="Release Date"> - - <label for="episodes">Episodes:</label> - <input type="number" id="episodes" name="episodes" min="0"> - - <label for="rating">Rating:</label> - <select id="rating" name="rating" placeholder="Rating" required> - <option value="G">G</option> - <option value="PG-13">PG-13</option> - <option value="R(17+)">R(17+)</option> - <option value="Rx">Rx</option> - </select> - - <label for="image">Cover Picture:</label> - <input type="file" id="image" name="image"> - - <label for="trailer">Trailer:</label> - <input type="file" id="trailer" name="trailer"> - - <label for="synopsis">Synopsis:</label> - <textarea id="synopsis" name="synopsis" placeholder="Synopsis"></textarea> - - <label for="studio_id">Studio:</label> - <select id="studio_id" name="studio_id" placeholder="Studio" required> - <?php - $studios = $s->getAllStudio(); - foreach($studios as $studio){ - echo " <option value=$studio[studio_id]>$studio[name]</option>"; - } - ?> - </select> - <input type="submit" value="Add Anime"> - </form> - - </div> - </div> - - <div id="addStudioModal" class="modal"> - <div class="modal-content"> - <span class="close-btn" onclick="closeAddModal()">×</span> - <h2>Add New Studio</h2> - - <form class="form-vertical" action="/api/studio/add.php" method="post" enctype="multipart/form-data"> - <label for="name">Name:</label> - <input type="text" id="name" name="name" placeholder="Name" required> - - <label for="description">Description:</label> - <textarea name="description" id="description" placeholder="Description"></textarea> - - <label for="established_date">Established Date:</label> - <input type="date" id="established_date" name="established_date"> - - <label for="image">Picture:</label> - <input type="file" id="image" name="image"> - - <input type="submit" value="Add Studio"> - </form> - - </div> - </div> - - </div> - - <div class="container"> - <div class="content"> - - <div class="manage-section"> - <div id="client" class="table active-table"> - <!-- Client table goes here --> - <table> - <thead> - <tr> - <th>id</th> - <th>username</th> - <th>email</th> - <th>password</th> - <th>admin</th> - <th>birthdate</th> - <th>biography</th> - <th>image</th> - <th>actions</th> - </tr> - </thead> - <tbody> - <?php - $clients = $c->getAllClient(); - foreach($clients as $client){ - $date = $client['birthdate'] ?? '-'; - $bio = $client['bio'] === '' ? '-' : $client['bio']; - $image = is_null($client['image']) ? '-' : str_replace('/', '/<wbr>', $client['image']); - $admin_status = ($client['admin_status']) ? 'true' : 'false'; - echo " - <tr> - <td>$client[client_id]</td> - <td>$client[username]</td> - <td>$client[email]</td> - <td>$client[password]</td> - <td>$admin_status</td> - <td>$date</td> - <td>$bio</td> - <td>$image</td> - <td> - <div class='btn-container'> - <button class='edit-btn' - data-client-id=$client[client_id] - data-username='$client[username]' - data-email='$client[email]' - data-password='$client[password]' - data-admin-status='$admin_status' - data-birthdate='$client[birthdate]' ?? '' - data-bio='$client[bio]' - data-image='$client[image]' - onclick='openEditClientModal(this)'> - Edit - </button> - <button class='delete-btn-client' client-id=$client[client_id]>Delete</button> - </div> - </td> - </tr> - "; - } - ?> - </tbody> - </table> - </div> - - <div id="editClientModal" class="modal"> - <div class="modal-content"> - <span class="close-btn" onclick="closeEditClientModal()">×</span> - <h2>Edit Client</h2> - - <form class="form-vertical" action="/api/client/edit.php" method="post" enctype="multipart/form-data"> - <!-- Hidden input for client_id --> - <input type="hidden" id="editClientId" name="client_id"> - - <label for="editUsername">Username:</label> - <input type="text" id="editUsername" name="username" disabled value=""> - - <label for="editEmail">Email:</label> - <input type="email" id="editEmail" name="email" required> - - <label for="editBirthdate">Established Date:</label> - <input type="date" id="editBirthdate" name="birthdate"> - - <!-- Note: Consider if you really want to show and edit passwords this way --> - <label for="editPassword">Password:</label> - <input type="text" id="editPassword" name="password" required> - - <label for="editAdminStatus">Status:</label> - <select id="editAdminStatus" name="admin_status"> - <option value="false">Client</option> - <option value="true">Admin</option> - </select> - - <label for="editBio">Bio:</label> - <textarea id="editBio" name="bio"></textarea> - - <label for="currentImage">Current Image:</label> - <img src="" alt="No image available." id="currentImage" style="display: none;"> - - <label for="newImage">Update Image:</label> - <input type="file" id="newImage" name="newImage"> - - <input type="submit" value="Update Client"> - </form> - </div> - </div> - - - <div id="anime" class="table"> - <!-- Anime table goes here --> - <table> - <thead> - <tr> - <th>id</th> - <th>title</th> - <th>type</th> - <th>status</th> - <th>release</th> - <th>eps</th> - <th>rating</th> - <th>score</th> - <th>image</th> - <th>trailer</th> - <th>synopsis</th> - <th>studio</th> - <th>actions</th> - </tr> - </thead> - <tbody> - <?php - $animes = $a->getAllAnime(); - foreach($animes as $anime){ - $date = $anime['release_date'] ?? '-'; - $episodes = $anime['episodes'] ?? ''; - $score = $anime['score'] ?? '-'; - $image = is_null($anime['image']) ? '-' : str_replace('/', '/<wbr>', $anime['image']); - $trailer = is_null($anime['trailer']) ? '-' : str_replace('/', '/<wbr>', $anime['trailer']); - $synopsis = $anime['synopsis'] === '' ? '-' : $anime['synopsis']; - echo " - <tr> - <td>$anime[anime_id]</td> - <td>$anime[title]</td> - <td>$anime[type]</td> - <td>$anime[status]</td> - <td>$date</td> - <td>$episodes</td> - <td>$anime[rating]</td> - <td>$score</td> - <td>$image</td> - <td>$trailer</td> - <td>$synopsis</td> - <td>$anime[studio_id]</td> - <td> - <div class='btn-container'> - <button class='edit-btn' - data-anime-id=$anime[anime_id] - data-title='$anime[title]' - data-type='$anime[type]' - data-status='$anime[status]' - data-release-date='$anime[release_date]' ?? '' - data-episodes=$anime[episodes] - data-rating='$anime[rating]' - data-image='$anime[image]' - data-trailer='$anime[trailer]' - data-synopsis='$anime[synopsis]' - data-studio-id=$anime[studio_id] - onclick='openEditAnimeModal(this)'> - Edit - </button> - <button class='delete-btn-anime' anime-id=$anime[anime_id]>Delete</button> - </div> - </td> - </tr> - "; - } - ?> - </tbody> - </table> - </div> - - <div id="editAnimeModal" class="modal"> - <div class="modal-content"> - <span class="close-btn" onclick="closeEditAnimeModal()">×</span> - <h2>Edit Anime</h2> - - <form class="form-vertical" action="/api/anime/edit.php" method="post" enctype="multipart/form-data"> - <!-- Hidden input for anime_id --> - <input type="hidden" id="editAnimeId" name="anime_id"> - - <label for="editTitle">Title:</label> - <input type="text" id="editTitle" name="title" placeholder="Title" required> - - <label for="editType">Type:</label> - <select id="editType" name="type" placeholder="Type" required> - <option value="TV">TV</option> - <option value="MOVIE">Movie</option> - <option value="OVA">OVA</option> - </select> - - <label for="editStatus">Status:</label> - <select id="editStatus" name="status" placeholder="Status" required> - <option value="ON-GOING">On Going</option> - <option value="COMPLETED">Completed</option> - <option value="HIATUS">Hiatus</option> - <option value="UPCOMING">Upcoming</option> - </select> - - <label for="editRelease_date">Release Date:</label> - <input type="date" id="editRelease_date" name="release_date" placeholder="Release Date"> - - <label for="editEpisodes">Episodes:</label> - <input type="number" id="editEpisodes" name="episodes" min="0"> - - <label for="editRating">Rating:</label> - <select id="editRating" name="rating" placeholder="Rating" required> - <option value="G">G</option> - <option value="PG-13">PG-13</option> - <option value="R(17+)">R(17+)</option> - <option value="Rx">Rx</option> - </select> - - <label for="currentAnimeImage">Current Image:</label> - <img src="" alt="No image available." id="currentAnimeImage" style="display: none;"> - - <label for="newImage">Update Image:</label> - <input type="file" id="newImage" name="newImage"> - - <label for="currentTrailer">Current Trailer:</label> - <video width="320" height="240" controls id="currentTrailer" style="display: none;"> - <source src="" type="video/mp4" id="currentTrailer"> - Your browser does not support the video tag. - </video> - - <label for="newTrailer">Update Trailer:</label> - <input type="file" id="newTrailer" name="newTrailer"> - - <label for="editSynopsis">Synopsis:</label> - <textarea id="editSynopsis" name="synopsis" placeholder="Synopsis"></textarea> - - <label for="editStudio_id">Studio:</label> - <select id="editStudio_id" name="studio_id" placeholder="Studio" required> - <?php - $studios = $s->getAllStudio(); - foreach($studios as $studio){ - echo " <option value=$studio[studio_id]>$studio[name]</option>"; - } - ?> - </select> - <input type="submit" value="Update Anime"> - </form> - - </div> - </div> - - - <div id="studio" class="table"> - <!-- Studio table goes here --> - <table> - <thead> - <tr> - <th>studio_id</th> - <th>name</th> - <th>description</th> - <th>established_date</th> - <th>image</th> - <th>actions</th> - </tr> - </thead> - <tbody> - <?php - $studios = $s->getAllStudio(); - foreach($studios as $studio){ - $desc = $studio['description'] === '' ? '-' : $studio['description']; - $date = $studio['established_date'] ?? '-'; - $image = is_null($studio['image']) ? '-' : str_replace('/', '/<wbr>', $studio['image']); - echo " - <tr> - <td>$studio[studio_id]</td> - <td>$studio[name]</td> - <td>$desc</td> - <td>$date</td> - <td>$image</td> - <td> - <div class='btn-container'> - <button class='edit-btn' - data-studio-id=$studio[studio_id] - data-name='$studio[name]' - data-description='$studio[description]' - data-established-date='$studio[established_date]' ?? '' - data-image='$studio[image]' - onclick='openEditStudioModal(this)'> - Edit - </button> - <button class='delete-btn-studio' studio-id=$studio[studio_id]>Delete</button> - </div> - </td> - </tr>"; - } - ?> - </tbody> - </table> - - <div id="editStudioModal" class="modal"> - <div class="modal-content"> - <span class="close-btn" onclick="closeEditStudioModal()">×</span> - <h2>Edit Studio</h2> - - <form class="form-vertical" action="/api/studio/edit.php" method="post" enctype="multipart/form-data"> - <input type="hidden" id="editStudioId" name="studio_id"> - - <label for="editName">Name:</label> - <input type="text" id="editName" name="name" placeholder="Name" required> - - <label for="editDescription">Description:</label> - <textarea name="description" id="editDescription" placeholder="Description"></textarea> - - <label for="editEstablishedDate">Established Date:</label> - <input type="date" id="editEstablishedDate" name="established_date"> - - <label for="currentStudioImage">Current Image:</label> - <img src="" alt="No image available." id="currentStudioImage" style="display: none;"> - - <label for="newImage">Update Image:</label> - <input type="file" id="newImage" name="newImage"> - - <input type="submit" value="Edit Studio"> - </form> - </div> - </div> - - </div> - - </div> - - - </div> - </div> - - - -</body> -</html> - -<script> - <?php if (isset($_SESSION['error_message'])): ?> - window.onload = function() { - alert('<?php echo $_SESSION['error_message']; ?>'); - }; - <?php unset($_SESSION['error_message']); // Clear the message so it doesn't persist ?> - <?php endif; ?> -</script> - -<?php -require_once(BASE_DIR.'/views/includes/footer.php'); -?> \ No newline at end of file diff --git a/app/views/Admin/studio.php b/app/views/Admin/studio.php new file mode 100644 index 0000000..6ca0859 --- /dev/null +++ b/app/views/Admin/studio.php @@ -0,0 +1,178 @@ +<?php + +require_once(dirname(__DIR__,2).'/define.php'); +require_once(BASE_DIR.'/views/includes/header.php'); +require_once(BASE_DIR.'/models/Client.php'); +require_once(BASE_DIR.'/models/Anime.php'); +require_once(BASE_DIR.'/models/Studio.php'); + +$c = new Client(); +$a = new Anime(); +$s = new Studio(); + +?> + +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Admin Page: Studio</title> + <link rel="stylesheet" href="../../public/style/global.css"> + <link rel="stylesheet" href="../../public/style/admin.css"> + <script src='/public/handler/navbar.js'></script> + <script src='/public/handler/admin.js'></script> +</head> + +<body> + + <div class="manage-header"> + <div class="menu"> + <a href="/?admin/client/page=1"> + <button class="menu-item " + onclick="showTable('client'); setActiveMenuItem('client')">Client</button> + </a> + <a href="/?admin/anime/page=1"> + <button class="menu-item" + onclick="showTable('anime'); setActiveMenuItem('anime')">Anime</button> + </a> + <a href="/?admin/studio/page=1"> + <button class="menu-item active" + onclick="showTable('studio'); setActiveMenuItem('studio')">Studio</button> + </a> + </div> + + <button class="add-btn" onclick="openAddModal('studio')">Add</button> + + <div id="addStudioModal" class="modal"> + <div class="modal-content"> + <span class="close-btn" onclick="closeAddModal('studio')">×</span> + <h2>Add New Studio</h2> + + <form class="form-vertical" action="/api/studio/add.php" method="post" enctype="multipart/form-data"> + <label for="name">Name:</label> + <input type="text" id="name" name="name" placeholder="Name" required> + + <label for="description">Description:</label> + <textarea name="description" id="description" placeholder="Description"></textarea> + + <label for="established_date">Established Date:</label> + <input type="date" id="established_date" name="established_date"> + + <label for="image">Picture:</label> + <input type="file" id="image" name="image"> + + <input type="submit" value="Add Studio"> + </form> + + </div> + </div> + + </div> + + <div class="container"> + <div class="content"> + + <div class="manage-section"> + + + <div id="studio" class="table active-table"> + <!-- Studio table goes here --> + <table> + <thead> + <tr> + <th>studio_id</th> + <th>name</th> + <th>description</th> + <th>established_date</th> + <th>image</th> + <th>actions</th> + </tr> + </thead> + <tbody> + <?php + $studios = $s->getAllStudio(); + foreach($studios as $studio){ + $desc = $studio['description'] === '' ? '-' : $studio['description']; + $date = $studio['established_date'] ?? '-'; + $image = is_null($studio['image']) ? '-' : str_replace('/', '/<wbr>', $studio['image']); + echo " + <tr> + <td>$studio[studio_id]</td> + <td>$studio[name]</td> + <td>$desc</td> + <td>$date</td> + <td>$image</td> + <td> + <div class='btn-container'> + <button class='edit-btn' + data-studio-id=$studio[studio_id] + data-name='$studio[name]' + data-description='$studio[description]' + data-established-date='$studio[established_date]' ?? '' + data-image='$studio[image]' + onclick='openEditStudioModal(this)'> + Edit + </button> + <button class='delete-btn-studio' studio-id=$studio[studio_id]>Delete</button> + </div> + </td> + </tr>"; + } + ?> + </tbody> + </table> + + <div id="editStudioModal" class="modal"> + <div class="modal-content"> + <span class="close-btn" onclick="closeEditStudioModal('studio')">×</span> + <h2>Edit Studio</h2> + + <form class="form-vertical" action="/api/studio/edit.php" method="post" enctype="multipart/form-data"> + <input type="hidden" id="editStudioId" name="studio_id"> + + <label for="editName">Name:</label> + <input type="text" id="editName" name="name" placeholder="Name" required> + + <label for="editDescription">Description:</label> + <textarea name="description" id="editDescription" placeholder="Description"></textarea> + + <label for="editEstablishedDate">Established Date:</label> + <input type="date" id="editEstablishedDate" name="established_date"> + + <label for="currentStudioImage">Current Image:</label> + <img src="" alt="No image available." id="currentStudioImage" style="display: none;"> + + <label for="newImage">Update Image:</label> + <input type="file" id="newImage" name="newImage"> + + <input type="submit" value="Edit Studio"> + </form> + </div> + </div> + + </div> + + </div> + + + </div> + </div> + + + +</body> +</html> + +<script> + <?php if (isset($_SESSION['error_message'])): ?> + window.onload = function() { + alert('<?php echo $_SESSION['error_message']; ?>'); + }; + <?php unset($_SESSION['error_message']); // Clear the message so it doesn't persist ?> + <?php endif; ?> +</script> + +<?php +require_once(BASE_DIR.'/views/includes/footer.php'); +?> \ No newline at end of file diff --git a/app/views/Client/detail.php b/app/views/Client/detail.php index c0721c4..f0a66a1 100644 --- a/app/views/Client/detail.php +++ b/app/views/Client/detail.php @@ -37,8 +37,8 @@ $isUser = $c->getClientByUsername($_SESSION['username'])['client_id'] == $id; <!-- Hidden input for client_id --> <input type="hidden" id="editClientId" name="client_id"> - <label for="editUsername">Username:</label> - <input type="text" id="editUsername" name="username" disabled> + <label for="editUsername" hidden>Username:</label> + <input type="text" id="editUsername" name="username" hidden> <label for="editEmail">Email:</label> <input type="email" id="editEmail" name="email" required> @@ -148,11 +148,12 @@ $isUser = $c->getClientByUsername($_SESSION['username'])['client_id'] == $id; if ($alc){ foreach($alc as $anime){ $user_score = $anime['user_score'] ? $anime['user_score'].' ★' : 'None'; + $image = $anime['image'] ?? '../../public/img/placeholder.jpg'; echo " <a href='/?client/list/$anime[list_id]'> <div class='client-anime-list-card'> <div class='client-anime-image-box'> - <img class='client-anime-image' src='$anime[image]' alt='Anime image'/> + <img class='client-anime-image' src='$image' alt='Anime image'/> </div> <div style='text-align:center'> $anime[title] </div> <div style='text-align:center'> User Score: $user_score </div> diff --git a/app/views/includes/header.php b/app/views/includes/header.php index 7cd6ef2..6651866 100644 --- a/app/views/includes/header.php +++ b/app/views/includes/header.php @@ -50,7 +50,7 @@ $c = new Client(); echo " <div class='navbar-buttons'> - <a href='/?admin' > + <a href='/?admin/client/page=1' > <button class='navbar-icon-btn'> <img src='../../public/img/admin_icon.png' alt='Admin Button' width='30' height='30'/> <div class='navbar-icon-desc'> Admin </div> -- GitLab