Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Showing
with 200 additions and 57 deletions
......@@ -7,7 +7,7 @@
<li><a href="/app/Views/history/history.php">History</a></li>
<!-- Logout Button -->
<li>
<form method="post" action="/app/router.php">
<form method="post" action="/logout">
<button type="submit" name="userAction" value="logout">Logout</button>
</form>
</li>
......
File moved
File moved
File moved
File moved
File moved
File moved
<?php
if (session_status() == PHP_SESSION_NONE) {
// If a session is not already started, start a new one
session_start();
}
ob_start();
if (!isset($_SESSION["user_id"])) {
echo "here";
// User is not authenticated; redirect to login page
header("Location: /app/Views/login/login.php");
ob_end_flush();
}
require_once '../../Controllers/UserController.php';
$userController = new UserController();
$isAdmin = $userController->getUser($_SESSION['user_id'])['isAdmin'];
// Allow only admin to access this page
if (!$isAdmin){
header("Location: /app/Views/home/home.php");
ob_end_flush();
}
?>
<!DOCTYPE html>
<html lang="en">
......
<?php
if (session_status() == PHP_SESSION_NONE) {
// If a session is not already started, start a new one
session_start();
}
ob_start();
if (!isset($_SESSION["user_id"])) {
echo "here";
// User is not authenticated; redirect to login page
header("Location: /app/Views/login/login.php");
ob_end_flush();
}
require_once '../../Controllers/UserController.php';
$userController = new UserController();
$isAdmin = $userController->getUser($_SESSION['user_id'])['isAdmin'];
// Allow only admin to access this page
if (!$isAdmin){
header("Location: /app/Views/home/home.php");
ob_end_flush();
}
?>
<!DOCTYPE html>
<html lang="en">
......
<?php
session_start();
if (session_status() == PHP_SESSION_NONE) {
// If a session is not already started, start a new one
session_start();
}
ob_start();
if (!isset($_SESSION["user_id"])) {
echo "here";
......@@ -25,7 +28,9 @@
} else {
$pembelians = $pembelianController->getAllPembelianWithDetails();
}
$paginationData = $pembelianController->paginateHistory($pembelians);
$pageSize = isset($_GET['pageSize']) ? $_GET['pageSize'] : 10;
$paginationData = $pembelianController->paginateHistory($pembelians,$_GET['page'],$pageSize);
$pembelians = $paginationData['pembelian'];
$totalEvents = $paginationData['total'];
$currentPage = $paginationData['page'];
......@@ -61,18 +66,30 @@
endforeach;?>
</div>
<div class="pagination">
<?php if ($currentPage > 1) : ?>
<a href="?page=<?= $currentPage - 1 ?>">Previous</a>
<?php endif; ?>
<?php for ($i = 1; $i <= $maxPage; $i++) : ?>
<a href="?page=<?= $i ?>" <?= ($i == $currentPage) ? 'class="active"' : '' ?>><?= $i ?></a>
<?php endfor; ?>
<?php if ($currentPage < $maxPage) : ?>
<a href="?page=<?= $currentPage + 1 ?>">Next</a>
<?php endif; ?>
</div>
<?php
$searchParams = [
'search' => $searchQuery,
'min_stock' => $minStock,
'sort' => $sortKey,
'pageSize' => $pageSize, // Include page size
];
$maxButtons = 5; // Maximum number of pagination buttons to display
$halfMaxButtons = floor($maxButtons / 2);
if ($currentPage > 1) : ?>
<a href="?page=<?= $currentPage - 1 ?>">Previous</a>
<?php endif; ?>
<?php
for ($i = max(1, $currentPage - $halfMaxButtons); $i <= min($maxPage, $currentPage + $halfMaxButtons); $i++) : ?>
<a href="?page=<?= $i ?>" <?= ($i == $currentPage) ? 'class="active"' : '' ?>><?= $i ?></a>
<?php endfor; ?>
<?php if ($currentPage < $maxPage) : ?>
<a href="?page=<?= $currentPage + 1 ?>">Next</a>
<?php endif; ?>
</div>
</div>
......
<?php
session_start();
if (session_status() == PHP_SESSION_NONE) {
// If a session is not already started, start a new one
session_start();
}
ob_start();
if (!isset($_SESSION["user_id"])) {
echo "here";
// User is not authenticated; redirect to login page
header("Location: /app/Views/login/login.php");
header("Location: login");
ob_end_flush();
}
require_once '../../Controllers/PembelianController.php';
require_once '../../Controllers/TicketController.php';
require_once '../../Controllers/UserController.php';
require_once '../../Controllers/EventController.php';
require_once (__DIR__.'/../../../Server/Controllers/PembelianController.php');
require_once (__DIR__.'/../../../Server/Controllers/TicketController.php');
require_once (__DIR__.'/../../../Server/Controllers/UserController.php');
require_once (__DIR__.'/../../../Server/Controllers/EventController.php');
$eventController = new EventController();
$pembelianController = new PembelianController();
$ticketController = new TicketController();
$userController = new UserController();
$userController = new \Server\Controllers\UserController();
// Handle search query
$searchQuery = isset($_GET['search']) ? $_GET['search'] : '';
......@@ -28,13 +31,15 @@
if (!isset($_GET['page'])) {
$_GET['page'] = 1;
}
$paginationData = $eventController->paginateEvents($searchResults,$_GET['page']);
$pageSize = isset($_GET['pageSize']) ? $_GET['pageSize'] : 10;
$paginationData = $eventController->paginateEvents($searchResults,$_GET['page'],$pageSize);
$events = $paginationData['events'];
$totalEvents = $paginationData['total'];
$currentPage = $paginationData['page'];
$maxPage = $paginationData['maxpage'];
$isAdmin = $userController->getUser($_SESSION['user_id'])['isAdmin'];
$isAdmin = $userController->getUser($_SESSION['user_id'])['isadmin'];
?>
<!DOCTYPE html>
......@@ -44,20 +49,20 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HOME • TICKET KU</title>
<link rel="stylesheet" type="text/css" href="/../../styles/global.css">
<link rel="stylesheet" type="text/css" href="/../../styles/form.css">
<link rel="stylesheet" type="text/css" href="/../../styles/footer.css">
<link rel="stylesheet" type="text/css" href="/../../styles/navbar.css">
<link rel="stylesheet" type="text/css" href="/../../styles/container.css">
<link rel="stylesheet" type="text/css" href="/../../styles/auth.css">
<link rel="stylesheet" type="text/css" href="/../../styles/dropdown.css">
<link rel="stylesheet" type="text/css" href="/../../styles/pagination.css">
<link rel="stylesheet" type="text/css" href="/../../styles/media.css">
<link rel="stylesheet" type="text/css" href="/../../global.css">
<link rel="stylesheet" type="text/css" href="/../../form.css">
<link rel="stylesheet" type="text/css" href="/../../footer.css">
<link rel="stylesheet" type="text/css" href="/../../navbar.css">
<link rel="stylesheet" type="text/css" href="/../../container.css">
<link rel="stylesheet" type="text/css" href="/../../auth.css">
<link rel="stylesheet" type="text/css" href="/../../dropdown.css">
<link rel="stylesheet" type="text/css" href="/../../pagination.css">
<link rel="stylesheet" type="text/css" href="/../../media.css">
</head>
<body>
<!-- Navbar -->
<?php include '../template/navbar.php';?>
<?php include (__DIR__.'/../../components/navbar.php');?>
<div class="main-content">
<div class="column">
......@@ -65,38 +70,53 @@
<button onclick="openCreateEventPage()" id="createEventBtn" class="admin">Create Event</button>
<?php endif; ?>
<div class="row">
<input type="text" id="searchInput" placeholder="Search.." value="<?= htmlspecialchars($searchQuery)?>" style="width:250%;">
<input type="text" id="searchInput" placeholder="Search.." value="<?= isset($searchQuery) ? htmlspecialchars($searchQuery) : '' ?>" style="width:250%;">
<select name="sort" id="sortSelect" class="styled-select">
<option value="" <?= empty($sortKey) ? 'selected' : '' ?>>No Sorting</option>
<option value="name" <?= $sortKey === 'name' ? 'selected' : '' ?>>Sort by Name</option>
<option value="location" <?= $sortKey === 'location' ? 'selected' : '' ?>>Sort by Location</option>
</select>
<!-- Change input type to "text" for minimum stock -->
<input type="text" id="minStockInput" name="min_stock" placeholder="Min Stock" value="<?= htmlspecialchars($minStock) ?>">
<input type="text" id="minStockInput" name="min_stock" placeholder="Min Stock" value="<?= isset($minStock) ? htmlspecialchars($minStock) : 0 ?>"
">
<button type="submit" id="search-button">Search</button>
</div>
<?php foreach ($events as $event) :
include '../template/event.php';
include (__DIR__.'/../../components/event.php');
endforeach;?>
<div class="pagination">
<?php if ($currentPage > 1) : ?>
<a href="?page=<?= $currentPage - 1 ?>">Previous</a>
<?php
$searchParams = [
'search' => $searchQuery,
'min_stock' => $minStock,
'sort' => $sortKey,
'pageSize' => $pageSize, // Include page size
];
$maxButtons = 5; // Maximum number of pagination buttons to display
$halfMaxButtons = floor($maxButtons / 2);
if ($currentPage > 1) : ?>
<a href="?page=<?= $currentPage - 1 . '&' . http_build_query($searchParams) ?>">Previous</a>
<?php endif; ?>
<?php for ($i = 1; $i <= $maxPage; $i++) : ?>
<a href="?page=<?= $i ?>" <?= ($i == $currentPage) ? 'class="active"' : '' ?>><?= $i ?></a>
<?php
for ($i = max(1, $currentPage - $halfMaxButtons); $i <= min($maxPage, $currentPage + $halfMaxButtons); $i++) : ?>
<a href="?page=<?= $i . '&' . http_build_query($searchParams) ?>" <?= ($i == $currentPage) ? 'class="active"' : '' ?>><?= $i ?></a>
<?php endfor; ?>
<?php if ($currentPage < $maxPage) : ?>
<a href="?page=<?= $currentPage + 1 ?>">Next</a>
<a href="?page=<?= $currentPage + 1 . '&' . http_build_query($searchParams) ?>">Next</a>
<?php endif; ?>
</div>
</div>
</div>
<?php include '../template/footer.php';?>
<?php include (__DIR__.'/../../components/footer.php');?>
<script defer>
function toggleMenu() {
......@@ -126,7 +146,7 @@
const sortKey = document.getElementById('sortSelect').value;
// Construct the URL with search, min_stock, and sort parameters
const url = `/app/Views/home/home.php?search=${encodeURIComponent(searchQuery)}&min_stock=${encodeURIComponent(minStock)}&sort=${encodeURIComponent(sortKey)}`;
const url = `/home?search=${encodeURIComponent(searchQuery)}&min_stock=${encodeURIComponent(minStock)}&sort=${encodeURIComponent(sortKey)}`;
// Redirect to the updated URL
window.location.href = url;
......
<?php
if (session_status() == PHP_SESSION_NONE) {
// If a session is not already started, start a new one
session_start();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Login • TICKET KU</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="../../auth.css">
</head>
<body>
<div class="login-container">
<h1>Login</h1>
<form id="loginForm" method="post" action="login">
<!-- Aslinya email atau username bisa(?) -->
<label for="email">Email or Username</label>
<input type="text" id="identifier" name="loginIdentifier" required>
<label for="password">Password</label>
<input type="password" id="password" name="loginPassword" required>
<?php
// Check if there is an error message in the session
if (isset($_SESSION['message'])) {
echo '<p>' . $_SESSION['message'] . '</p>';
unset($_SESSION['message']); // Remove the error message from the session
}
?>
<button type="submit" name="userAction" value="login">Login</button>
</form>
<p>Don't have an account? <a href="register">Register</a></p>
</div>
</body>
</html>
<?php
session_start();
if (session_status() == PHP_SESSION_NONE) {
// If a session is not already started, start a new one
session_start();
}
?>
<!DOCTYPE html>
<html lang="en">
......@@ -8,13 +11,13 @@
<title>Register • TICKET KU</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="../../../styles/auth.css">
<link rel="stylesheet" type="text/css" href="../../auth.css">
</head>
<body>
<div class="register-container">
<h1>Register</h1>
<form id="registerForm" method="post" action="../../router.php">
<form id="registerForm" method="post" action="register">
<label for="userName">Name</label>
<input type="text" id="userName" name="userName" required>
......@@ -41,7 +44,7 @@
<button type="submit" name="userAction" value="createUser">Register</button>
</form>
<p>Already have an account? <a href="login.php">Login</a></p>
<p>Already have an account? <a href="login">Login</a></p>
</div>
</body>
</html>
\ No newline at end of file
<?php
session_start();
if (session_status() == PHP_SESSION_NONE) {
// If a session is not already started, start a new one
session_start();
}
ob_start();
if (!isset($_SESSION["user_id"])) {
echo "here";
......
<?php
session_start();
if (session_status() == PHP_SESSION_NONE) {
// If a session is not already started, start a new one
session_start();
}
ob_start();
if (!isset($_SESSION["user_id"])) {
echo "here";
......
File moved
<?php
// app/Controllers/EventController.php
ob_start();
require_once(__DIR__ . '/../Models/Event.php');
include(__DIR__ . '../../Models/Event.php');
require_once(__DIR__ . '/TicketController.php');
......@@ -10,7 +9,7 @@ class EventController {
private $eventModel;
public function __construct() {
$this->eventModel = new EventModel();
$this->eventModel = new \Server\Models\EventModel();
}
public function createEvent($event_name, $stock, $event_price, $event_date, $event_location, $gambar, $vid){
......
<?php
namespace Server\Controllers;
class HomeController {
public function __construct(){}
public function home()
{
include (__DIR__.'/../../Client/pages/home/home.php');
}
}
\ No newline at end of file
......@@ -10,11 +10,10 @@ class PembelianController {
public function __construct() {
$this->pembelianModel = new PembelianModel();
$this->pembelianModel = new \Server\Models\PembelianModel();
}
public function createPembelian($ticketId, $userId, $createdTime) {
$pembelianModel = new PembelianModel();
return $this->pembelianModel->createPembelian($ticketId, $userId, $createdTime);
}
......