diff --git a/README.md b/README.md index 5614db31c485058c8277b93c72a82d02c6d04a21..60748c3fea6620713359daccd30f406f637809d9 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,141 @@ -## Panduan Pengerjaan -Berikut adalah hal yang harus diperhatikan untuk pengumpulan tugas ini: -1. Buatlah grup pada Gitlab dengan format "IF3110-2023-01-XX", dengan XX adalah nomor kelompok (untuk K1 dan K2) atau kode kelompok (untuk K3). -2. Tambahkan anggota tim pada grup anda. -3. **Fork** pada repository ini dengan organisasi yang telah dibuat. -4. Ubah hak akses repository hasil Fork anda menjadi **private**. -5. Hal-hal yang harus diperhatikan. - * Silakan commit pada repository anda (hasil fork) - * Lakukan beberapa commit dengan pesan yang bermakna, contoh: “add register formâ€, “fix logout bugâ€, jangan seperti “finalâ€, “benerin dikitâ€, “fix bugâ€. - * Disarankan untuk tidak melakukan commit dengan perubahan yang besar karena akan mempengaruhi penilaian (contoh: hanya melakukan satu commit kemudian dikumpulkan). - * Commit dari setiap anggota tim akan mempengaruhi penilaian. - * Jadi, setiap anggota tim harus melakukan commit yang berpengaruh terhadap proses pembuatan aplikasi. - * Sebagai panduan bisa mengikuti [semantic commit](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716). -6. Buatlah file README yang berisi: - * Deskripsi aplikasi web - * Daftar requirement - * Cara instalasi - * Cara menjalankan server - * Screenshot tampilan aplikasi (tidak perlu semua kasus, minimal 1 per halaman), dan - * Penjelasan mengenai pembagian tugas masing-masing anggota (lihat formatnya pada bagian pembagian tugas). +# IF3110 - Tugas Besar WBD 1 + +## TicketKu: Ticket Management System + +## Kelompok 18: + +- 13521075 - Muhammad Rifko Favian +- 13521111 - Tabitha Permalla +- 13521151 - Vanessa Rebecca Wiyono + +## Deskripsi Aplikasi web + +Aplikasi web yang dibangun merupakan sebuah sistem informasi yang digunakan untuk melakukan manajemen / pengelolaan stok tiket. Dengan spesifikasi sebagai berikut: + +1. Implementasi client-side menggunakan Javascript, HTML, dan CSS. +2. Implementasi server-side menggunakan PHP murni tanpa framework +3. Implementasi basis data menggunakan MySQL +4. Sistem dibuat dengan struktur MVC + +Fitur yang dimiliki aplikasi antara lain: + +1. Atentikasi pengguna agar dapat mengakses seluruh fitur lainnya. + Pengguna dibedakan menjadi 2 kategori: user dan admin. +2. Admin dapat melakukan penambahan event +3. Admin dapat melakukan edit event +5. User dapat melihat daftar event +6. User dapat melakukan pembelian tiket suatu event +7. User dapat melihat history pembelian tiket +8. User dapat melakukan edit profile + +Spesifikasi bonus yang tersedia yaitu: + +1. Responsive Design +2. Docker + +## Daftar Requirement +- PHP 8 + +Untuk menjalankan server secara lokal tanpa Docker: +- XAMPP + +Untuk menjalankan dengan Docker: +- OS Ubuntu / Windows dengan WSL2 +- Docker +- Docker Compose + +## Cara Instalasi + +### XAMPP + +**Aktivasi MySQL pada PHP** + +1. Buka php.ini in C:\xampp\php +2. Tambahkan / uncomment kode ini +```bash +extension=mysqli +``` +3. Pastikan libmysql.dll dapat diakses. + +**Aktivasi PDO MySQL pada PHP** +1. Buka file php.ini di C:\xampp\php. +2. Tambahkan / uncomment kode ini +```bash +extension=pdo_mysql +``` + +## Cara Menjalankan server + +### XAMPP + +1. Clone repository ini pada directory htdocs XAMPP anda. Contohnya: `C:\xampp\htdocs\` +2. Buka XAMPP Control Panel dan Start service Apache +3. Aplikasi akan dijalankan pada `localhost/tugas-besar-1` + +### Docker + +1. Clone repository ini +2. Masuk ke directory utama (root) dari repository +3. Untuk menjalankan aplikasi: + +```bash +docker-compose up --build +``` + +4. Container akan berjalan dengan nama `tubes-1` +5. Aplikasi akan berjalan pada `localhost:8008` +7. Untuk menghentikan aplikasi, jalankan: + +```bash +docker-compose stop +``` + + +## Screenshot Tampilan Aplikasi + + +## Pembagian Tugas + +### Bonus + +| Item | NIM | +| ------------------------- | ------------------ | +| Bonus: Responsif | 13521151, 13521111 | +| Bonus: Docker | 13521151 | + +#### Server-side + +| Item | NIM | +| ---------------------- | ------------------ | +| Login | 13521111 | +| Register | 13521111 | +| Dashboard | 13521111, 13521151 | +| Pencarian Event | 13521151 | +| Daftar Event | 13521151 | +| Tambah Event | 13521075, 13521151 | +| Edit Event | 13521075, 13521151 | +| Delete Event | 13521075, 13521151 | +| Pembelian tiket | 13521111 | +| Setup Basis Data | 13521151 | +| History | 13521151 | +| Lihat profile | 13521151 | +| Navbar | 13521111, 13521151 | +| Footer | 13521111, 13521151 | + +#### Client-side + +| Item | NIM | +| ------------------------ | ---------------------------- | +| Init Directories, Styles | 13521111, 13521151 | +| Login | 13521075, 13521111 | +| Register | 13521075, 13521111 | +| Dashboard | 13521111, 13521151 | +| Pencarian Event | 13521111, 13521151 | +| Daftar Event | 13521111, 13521151 | +| Pembelian Tiket | 13521111 | +| Tambah Event | 13521075, 13521151 | +| Edit Event | 13521075, 13521151 | +| Lihat profile | 13521111, 13521151 | +| Edit profile | 13521111, 13521151 | +| Navbar | 13521111, 13521151 | +| Footer | 13521111, 13521151 | diff --git a/app/Controllers/EventController.php b/app/Controllers/EventController.php index 9d10f24bf16f23a5edc31e4ae90b2bf3189a56d6..57c5df826c9ab63d64be8bb7612da33f2e4d354c 100644 --- a/app/Controllers/EventController.php +++ b/app/Controllers/EventController.php @@ -127,7 +127,7 @@ class EventController { ob_end_flush(); } } else { - // Handle other actions here, if needed + // other } if (isset($_GET['eventAction'])) { if ($_GET['eventAction'] === 'getEvent') { @@ -136,10 +136,10 @@ class EventController { unset($_GET['eventId']); echo json_encode($this->getEvent($eventId)); } else { - // Handle other actions here, if needed + // other } } } } -?> \ No newline at end of file +?> diff --git a/app/Models/Event.php b/app/Models/Event.php index c9636eb61f9e38f172e4ed1354cdd6577e410da9..94ec0d38200f8e5d4b30acc731426dd08ce58f3c 100644 --- a/app/Models/Event.php +++ b/app/Models/Event.php @@ -1,7 +1,7 @@ <?php require_once(__DIR__ . '/../../db/connect.php'); -require_once(__DIR__ . '/../../util.php'); +require_once(__DIR__ . '/../util.php'); class EventModel { diff --git a/app/Models/Pembelian.php b/app/Models/Pembelian.php index c0a9ddff9eebc225c4f729d18e5fd0dc3f2a61a9..0fcf741d91a4773be623aefe0029031038b12efb 100644 --- a/app/Models/Pembelian.php +++ b/app/Models/Pembelian.php @@ -2,7 +2,7 @@ // app/models/Pembelian.php require_once(__DIR__ . '/../../db/connect.php'); -require_once(__DIR__ . '/../../util.php'); +require_once(__DIR__ . '/../util.php'); class PembelianModel { public function createPembelian($ticketId, $userId, $createdTime) { diff --git a/app/Views/event/create.php b/app/Views/event/create.php index c3a9a1c3471fa73d2e9a87f47ea91028316746e5..476cc49acfd78c636c3375dea324a3eb342b412c 100644 --- a/app/Views/event/create.php +++ b/app/Views/event/create.php @@ -20,8 +20,8 @@ <div class="main-content"> <form method="post" class="event-form" action="../../router.php" enctype="multipart/form-data"> <input type="text" name="eventName" placeholder="Name" required> - <input type="text" name="eventStock" placeholder="Stock" required> - <input type="text" name="eventPrice" placeholder="Price" required> + <input type="number" name="eventStock" placeholder="Stock" required> + <input type="number" name="eventPrice" placeholder="Price" required> <input type="datetime-local" name="eventDate" required> <input type="text" name="eventLocation" placeholder="Location" required> @@ -31,7 +31,6 @@ <input type="file" id="file-input-create" name="gambar" accept="image/*" required> </div> - <!-- <input type="text" name="vid" placeholder="Video URL"> --> <div id="drop-area-create"> <p>Drag and drop an video file here or click to select one.</p> <input type="file" id="file-input-create" name="vid" accept="video/*" required> diff --git a/app/Views/event/update.php b/app/Views/event/update.php index 48c82a230cf1a4b34fef57b24044c8c7270236d3..60eaff84d79cbae435db05388900d99a4643acdf 100644 --- a/app/Views/event/update.php +++ b/app/Views/event/update.php @@ -21,7 +21,7 @@ <form method="post" class="event-form" action="../../router.php" enctype="multipart/form-data"> <input type="hidden" name="eventId" value="<?php echo $_GET['id']; ?>"> <input type="text" name="eventName" placeholder="Name" required> - <input type="text" name="eventPrice" placeholder="Price" required> + <input type="number" name="eventPrice" placeholder="Price" required> <input type="datetime-local" name="eventDate" required> <input type="text" name="eventLocation" placeholder="Location" required> @@ -50,18 +50,35 @@ const eventId = urlParams.get('id'); document.addEventListener("DOMContentLoaded", function(){ - // Fetch user data on page load - fetch('../../router.php?eventAction=getEvent&eventId=' + eventId) - .then(response => response.json()) - .then(data => { + var xhr = new XMLHttpRequest(); + + xhr.open('GET', '../../router.php?eventAction=getEvent&eventId=' + eventId, true); + + // Set up a function to run when the request is successfully completed + xhr.onload = function () { + if (xhr.status >= 200 && xhr.status < 300) { + // Parse the JSON + var data = JSON.parse(xhr.responseText); + + // Log and utilize data console.log(data); - // Populate the form fields with the data document.querySelector('input[name="eventName"]').value = data.event_name; document.querySelector('input[name="eventPrice"]').value = data.event_price; document.querySelector('input[name="eventDate"]').value = data.event_date; document.querySelector('input[name="eventLocation"]').value = data.event_location; - }) - .catch(error => console.error(error)); + } else { + // Handle error: log status text + console.log('Failed to fetch event:', xhr.statusText); + } + }; + + // Set up a function to handle any errors that may occur + xhr.onerror = function () { + console.error('Request failed:', xhr.statusText); + }; + + // Send the request + xhr.send(); }); const cancelButton = document.getElementById("cancelButton"); diff --git a/app/Views/history/.gitkeep b/app/Views/history/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/app/Views/profile/edit_profile.php b/app/Views/profile/edit_profile.php index 1756ea16be02bc47ced7eeb75aa4660f439ccaf5..da5e7c5b527cbb4b36b342d21f321fb7c80ea8a5 100644 --- a/app/Views/profile/edit_profile.php +++ b/app/Views/profile/edit_profile.php @@ -31,17 +31,33 @@ <?php include '../template/footer.php'; ?> <script> document.addEventListener("DOMContentLoaded", function(){ - // Fetch user data on page load - fetch('../../router.php?userAction=getUser') - .then(response => response.json()) - .then(data => { - console.log(data); - // Populate the form fields with the data + var xhr = new XMLHttpRequest(); + + xhr.open('GET', '../../router.php?userAction=getUser', true); + + // Set up a function to run when the request is successfully completed + xhr.onload = function () { + if (xhr.status >= 200 && xhr.status < 300) { + // Parse the JSON + var data = JSON.parse(xhr.responseText); + + // Log and utilize data document.querySelector('input[name="user_name"]').value = data.user_name; document.querySelector('input[name="user_username"]').value = data.username; document.querySelector('input[name="user_email"]').value = data.user_email; - }) - .catch(error => console.error(error)); + } else { + // Handle error: log status text + console.log('Failed to fetch user:', xhr.statusText); + } + }; + + // Set up a function to handle any errors that may occur + xhr.onerror = function () { + console.error('Request failed:', xhr.statusText); + }; + + // Send the request + xhr.send(); }); const cancelButton = document.getElementById("cancelButton"); diff --git a/util.php b/app/util.php similarity index 100% rename from util.php rename to app/util.php diff --git a/db/data.php b/db/data.php index 7fa10644a7733466d73752e7933bc84d87bb3084..d8b2b4b5948c735cdf00dfec6c214379f6d2b83e 100644 --- a/db/data.php +++ b/db/data.php @@ -53,10 +53,10 @@ $db->exec($sqlTicket); // echo "Successfully inserted dummy data to tickets table<br/>"; - $db->exec($sqlUser); + // $db->exec($sqlUser); // echo "Successfully inserted dummy data to users table<br/>"; - $db->exec($sqlPembelian); + // $db->exec($sqlPembelian); // echo "Successfully inserted dummy data to pembelian table<br/>"; $db->commit();